From dc792d4ec049fb05194b6f5e026ce554b0d9cb9b Mon Sep 17 00:00:00 2001 From: root Date: Tue, 24 Mar 2026 13:06:23 +0000 Subject: [PATCH 1/9] feat: update Node.js SDK to 22.1.3 * Updated `DocumentsDB` docs and `DatabasesIndexType` usage; bumped API version badge to 1.9.0 --- CHANGELOG.md | 11 +- README.md | 2 +- docs/examples/databases/create-index.md | 2 +- docs/examples/databases/upsert-documents.md | 2 +- .../examples/documentsdb/create-collection.md | 21 + docs/examples/documentsdb/create-document.md | 24 + docs/examples/documentsdb/create-documents.md | 16 + docs/examples/documentsdb/create-index.md | 20 + .../examples/documentsdb/create-operations.md | 25 + .../documentsdb/create-transaction.md | 14 + docs/examples/documentsdb/create.md | 16 + .../decrement-document-attribute.md | 20 + .../examples/documentsdb/delete-collection.md | 15 + docs/examples/documentsdb/delete-document.md | 17 + docs/examples/documentsdb/delete-documents.md | 17 + docs/examples/documentsdb/delete-index.md | 16 + .../documentsdb/delete-transaction.md | 14 + docs/examples/documentsdb/delete.md | 14 + docs/examples/documentsdb/get-collection.md | 15 + docs/examples/documentsdb/get-document.md | 18 + docs/examples/documentsdb/get-index.md | 16 + docs/examples/documentsdb/get-transaction.md | 14 + docs/examples/documentsdb/get.md | 14 + .../increment-document-attribute.md | 20 + docs/examples/documentsdb/list-collections.md | 17 + docs/examples/documentsdb/list-documents.md | 19 + docs/examples/documentsdb/list-indexes.md | 17 + .../examples/documentsdb/list-transactions.md | 14 + docs/examples/documentsdb/list.md | 16 + .../examples/documentsdb/update-collection.md | 19 + docs/examples/documentsdb/update-document.md | 19 + docs/examples/documentsdb/update-documents.md | 18 + .../documentsdb/update-transaction.md | 16 + docs/examples/documentsdb/update.md | 16 + docs/examples/documentsdb/upsert-document.md | 19 + docs/examples/documentsdb/upsert-documents.md | 17 + docs/examples/functions/create.md | 4 +- docs/examples/functions/update.md | 4 +- docs/examples/project/create-variable.md | 17 + docs/examples/project/delete-variable.md | 14 + docs/examples/project/get-variable.md | 14 + docs/examples/project/list-variables.md | 15 + docs/examples/project/update-variable.md | 17 + docs/examples/sites/create.md | 5 +- docs/examples/sites/update.md | 5 +- docs/examples/tablesdb/create-index.md | 2 +- docs/examples/users/update-impersonator.md | 15 + docs/examples/vectorsdb/create-collection.md | 20 + docs/examples/vectorsdb/create-document.md | 28 + docs/examples/vectorsdb/create-documents.md | 16 + docs/examples/vectorsdb/create-index.md | 20 + docs/examples/vectorsdb/create-operations.md | 25 + .../vectorsdb/create-text-embeddings.md | 15 + docs/examples/vectorsdb/create-transaction.md | 14 + docs/examples/vectorsdb/create.md | 16 + docs/examples/vectorsdb/delete-collection.md | 15 + docs/examples/vectorsdb/delete-document.md | 17 + docs/examples/vectorsdb/delete-documents.md | 17 + docs/examples/vectorsdb/delete-index.md | 16 + docs/examples/vectorsdb/delete-transaction.md | 14 + docs/examples/vectorsdb/delete.md | 14 + docs/examples/vectorsdb/get-collection.md | 15 + docs/examples/vectorsdb/get-document.md | 18 + docs/examples/vectorsdb/get-index.md | 16 + docs/examples/vectorsdb/get-transaction.md | 14 + docs/examples/vectorsdb/get.md | 14 + docs/examples/vectorsdb/list-collections.md | 17 + docs/examples/vectorsdb/list-documents.md | 19 + docs/examples/vectorsdb/list-indexes.md | 17 + docs/examples/vectorsdb/list-transactions.md | 14 + docs/examples/vectorsdb/list.md | 16 + docs/examples/vectorsdb/update-collection.md | 20 + docs/examples/vectorsdb/update-document.md | 19 + docs/examples/vectorsdb/update-documents.md | 18 + docs/examples/vectorsdb/update-transaction.md | 16 + docs/examples/vectorsdb/update.md | 16 + docs/examples/vectorsdb/upsert-document.md | 19 + docs/examples/vectorsdb/upsert-documents.md | 17 + docs/examples/webhooks/create.md | 21 + docs/examples/webhooks/delete.md | 14 + docs/examples/webhooks/get.md | 14 + docs/examples/webhooks/list.md | 15 + docs/examples/webhooks/update-signature.md | 14 + docs/examples/webhooks/update.md | 21 + package.json | 6 +- src/client.ts | 51 +- src/enums/backup-services.ts | 3 + src/enums/build-runtime.ts | 86 + src/enums/database-type.ts | 2 + src/enums/databases-index-type.ts | 6 + src/enums/documents-db-index-type.ts | 6 + src/enums/model.ts | 3 + src/enums/runtime.ts | 86 + src/enums/scopes.ts | 4 + ...{index-type.ts => tables-db-index-type.ts} | 2 +- src/enums/vectors-db-index-type.ts | 8 + src/index.ts | 10 +- src/models.ts | 306 ++- src/services/databases.ts | 20 +- src/services/documents-db.ts | 2349 +++++++++++++++++ src/services/functions.ts | 76 +- src/services/project.ts | 330 +++ src/services/sites.ts | 124 +- src/services/tables-db.ts | 20 +- src/services/users.ts | 69 +- src/services/vectors-db.ts | 2170 +++++++++++++++ src/services/webhooks.ts | 450 ++++ test/id.test.js | 6 + test/operator.test.js | 99 + test/permission.test.js | 10 + test/query.test.js | 155 ++ test/role.test.js | 14 + test/services/account.test.js | 1307 +++++++++ test/services/activities.test.js | 73 + test/services/avatars.test.js | 123 + test/services/backups.test.js | 256 ++ test/services/databases.test.js | 1574 +++++++++++ test/services/documents-d-b.test.js | 660 +++++ test/services/functions.test.js | 751 ++++++ test/services/graphql.test.js | 40 + test/services/health.test.js | 438 +++ test/services/locale.test.js | 137 + test/services/messaging.test.js | 1200 +++++++++ test/services/project.test.js | 109 + test/services/sites.test.js | 729 +++++ test/services/storage.test.js | 288 ++ test/services/tables-d-b.test.js | 1574 +++++++++++ test/services/teams.test.js | 278 ++ test/services/tokens.test.js | 107 + test/services/users.test.js | 1145 ++++++++ test/services/vectors-d-b.test.js | 632 +++++ test/services/webhooks.test.js | 155 ++ 132 files changed, 19243 insertions(+), 117 deletions(-) create mode 100644 docs/examples/documentsdb/create-collection.md create mode 100644 docs/examples/documentsdb/create-document.md create mode 100644 docs/examples/documentsdb/create-documents.md create mode 100644 docs/examples/documentsdb/create-index.md create mode 100644 docs/examples/documentsdb/create-operations.md create mode 100644 docs/examples/documentsdb/create-transaction.md create mode 100644 docs/examples/documentsdb/create.md create mode 100644 docs/examples/documentsdb/decrement-document-attribute.md create mode 100644 docs/examples/documentsdb/delete-collection.md create mode 100644 docs/examples/documentsdb/delete-document.md create mode 100644 docs/examples/documentsdb/delete-documents.md create mode 100644 docs/examples/documentsdb/delete-index.md create mode 100644 docs/examples/documentsdb/delete-transaction.md create mode 100644 docs/examples/documentsdb/delete.md create mode 100644 docs/examples/documentsdb/get-collection.md create mode 100644 docs/examples/documentsdb/get-document.md create mode 100644 docs/examples/documentsdb/get-index.md create mode 100644 docs/examples/documentsdb/get-transaction.md create mode 100644 docs/examples/documentsdb/get.md create mode 100644 docs/examples/documentsdb/increment-document-attribute.md create mode 100644 docs/examples/documentsdb/list-collections.md create mode 100644 docs/examples/documentsdb/list-documents.md create mode 100644 docs/examples/documentsdb/list-indexes.md create mode 100644 docs/examples/documentsdb/list-transactions.md create mode 100644 docs/examples/documentsdb/list.md create mode 100644 docs/examples/documentsdb/update-collection.md create mode 100644 docs/examples/documentsdb/update-document.md create mode 100644 docs/examples/documentsdb/update-documents.md create mode 100644 docs/examples/documentsdb/update-transaction.md create mode 100644 docs/examples/documentsdb/update.md create mode 100644 docs/examples/documentsdb/upsert-document.md create mode 100644 docs/examples/documentsdb/upsert-documents.md create mode 100644 docs/examples/project/create-variable.md create mode 100644 docs/examples/project/delete-variable.md create mode 100644 docs/examples/project/get-variable.md create mode 100644 docs/examples/project/list-variables.md create mode 100644 docs/examples/project/update-variable.md create mode 100644 docs/examples/users/update-impersonator.md create mode 100644 docs/examples/vectorsdb/create-collection.md create mode 100644 docs/examples/vectorsdb/create-document.md create mode 100644 docs/examples/vectorsdb/create-documents.md create mode 100644 docs/examples/vectorsdb/create-index.md create mode 100644 docs/examples/vectorsdb/create-operations.md create mode 100644 docs/examples/vectorsdb/create-text-embeddings.md create mode 100644 docs/examples/vectorsdb/create-transaction.md create mode 100644 docs/examples/vectorsdb/create.md create mode 100644 docs/examples/vectorsdb/delete-collection.md create mode 100644 docs/examples/vectorsdb/delete-document.md create mode 100644 docs/examples/vectorsdb/delete-documents.md create mode 100644 docs/examples/vectorsdb/delete-index.md create mode 100644 docs/examples/vectorsdb/delete-transaction.md create mode 100644 docs/examples/vectorsdb/delete.md create mode 100644 docs/examples/vectorsdb/get-collection.md create mode 100644 docs/examples/vectorsdb/get-document.md create mode 100644 docs/examples/vectorsdb/get-index.md create mode 100644 docs/examples/vectorsdb/get-transaction.md create mode 100644 docs/examples/vectorsdb/get.md create mode 100644 docs/examples/vectorsdb/list-collections.md create mode 100644 docs/examples/vectorsdb/list-documents.md create mode 100644 docs/examples/vectorsdb/list-indexes.md create mode 100644 docs/examples/vectorsdb/list-transactions.md create mode 100644 docs/examples/vectorsdb/list.md create mode 100644 docs/examples/vectorsdb/update-collection.md create mode 100644 docs/examples/vectorsdb/update-document.md create mode 100644 docs/examples/vectorsdb/update-documents.md create mode 100644 docs/examples/vectorsdb/update-transaction.md create mode 100644 docs/examples/vectorsdb/update.md create mode 100644 docs/examples/vectorsdb/upsert-document.md create mode 100644 docs/examples/vectorsdb/upsert-documents.md create mode 100644 docs/examples/webhooks/create.md create mode 100644 docs/examples/webhooks/delete.md create mode 100644 docs/examples/webhooks/get.md create mode 100644 docs/examples/webhooks/list.md create mode 100644 docs/examples/webhooks/update-signature.md create mode 100644 docs/examples/webhooks/update.md create mode 100644 src/enums/databases-index-type.ts create mode 100644 src/enums/documents-db-index-type.ts create mode 100644 src/enums/model.ts rename src/enums/{index-type.ts => tables-db-index-type.ts} (74%) create mode 100644 src/enums/vectors-db-index-type.ts create mode 100644 src/services/documents-db.ts create mode 100644 src/services/project.ts create mode 100644 src/services/vectors-db.ts create mode 100644 src/services/webhooks.ts create mode 100644 test/id.test.js create mode 100644 test/operator.test.js create mode 100644 test/permission.test.js create mode 100644 test/query.test.js create mode 100644 test/role.test.js create mode 100644 test/services/account.test.js create mode 100644 test/services/activities.test.js create mode 100644 test/services/avatars.test.js create mode 100644 test/services/backups.test.js create mode 100644 test/services/databases.test.js create mode 100644 test/services/documents-d-b.test.js create mode 100644 test/services/functions.test.js create mode 100644 test/services/graphql.test.js create mode 100644 test/services/health.test.js create mode 100644 test/services/locale.test.js create mode 100644 test/services/messaging.test.js create mode 100644 test/services/project.test.js create mode 100644 test/services/sites.test.js create mode 100644 test/services/storage.test.js create mode 100644 test/services/tables-d-b.test.js create mode 100644 test/services/teams.test.js create mode 100644 test/services/tokens.test.js create mode 100644 test/services/users.test.js create mode 100644 test/services/vectors-d-b.test.js create mode 100644 test/services/webhooks.test.js diff --git a/CHANGELOG.md b/CHANGELOG.md index 503400a8..3b6ec129 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,13 +1,8 @@ # Change Log -## 22.2.0 - -* Added ttl option to listDocuments for cached responses -* Added getConsolePausing health status endpoint in Health service -* Added Health.getConsolePausing overloads (object and positional) -* Added updateRelationshipAttribute for Databases to manage relationship attributes -* Added console pausing example to health docs -* Made activate optional in createDeployment object parameter +## 22.1.3 + +* Updated `DocumentsDB` docs and `DatabasesIndexType` usage; bumped API version badge to 1.9.0 ## 22.1.2 diff --git a/README.md b/README.md index 4be156d7..0a3903ad 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # Appwrite Node.js SDK ![License](https://img.shields.io/github/license/appwrite/sdk-for-node.svg?style=flat-square) -![Version](https://img.shields.io/badge/api%20version-1.8.1-blue.svg?style=flat-square) +![Version](https://img.shields.io/badge/api%20version-1.9.0-blue.svg?style=flat-square) [![Build Status](https://img.shields.io/travis/com/appwrite/sdk-generator?style=flat-square)](https://travis-ci.com/appwrite/sdk-generator) [![Twitter Account](https://img.shields.io/twitter/follow/appwrite?color=00acee&label=twitter&style=flat-square)](https://twitter.com/appwrite) [![Discord](https://img.shields.io/discord/564160730845151244?label=discord&style=flat-square)](https://appwrite.io/discord) diff --git a/docs/examples/databases/create-index.md b/docs/examples/databases/create-index.md index 1d0280d1..ba3bf3a6 100644 --- a/docs/examples/databases/create-index.md +++ b/docs/examples/databases/create-index.md @@ -12,7 +12,7 @@ const result = await databases.createIndex({ databaseId: '', collectionId: '', key: '', - type: sdk.IndexType.Key, + type: sdk.DatabasesIndexType.Key, attributes: [], orders: [sdk.OrderBy.Asc], // optional lengths: [] // optional diff --git a/docs/examples/databases/upsert-documents.md b/docs/examples/databases/upsert-documents.md index 2a304924..73caa593 100644 --- a/docs/examples/databases/upsert-documents.md +++ b/docs/examples/databases/upsert-documents.md @@ -4,7 +4,7 @@ const sdk = require('node-appwrite'); const client = new sdk.Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint .setProject('') // Your project ID - .setKey(''); // Your secret API key + .setSession(''); // The user session to authenticate with const databases = new sdk.Databases(client); diff --git a/docs/examples/documentsdb/create-collection.md b/docs/examples/documentsdb/create-collection.md new file mode 100644 index 00000000..6e25ad42 --- /dev/null +++ b/docs/examples/documentsdb/create-collection.md @@ -0,0 +1,21 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +const documentsDB = new sdk.DocumentsDB(client); + +const result = await documentsDB.createCollection({ + databaseId: '', + collectionId: '', + name: '', + permissions: [sdk.Permission.read(sdk.Role.any())], // optional + documentSecurity: false, // optional + enabled: false, // optional + attributes: [], // optional + indexes: [] // optional +}); +``` diff --git a/docs/examples/documentsdb/create-document.md b/docs/examples/documentsdb/create-document.md new file mode 100644 index 00000000..62daf212 --- /dev/null +++ b/docs/examples/documentsdb/create-document.md @@ -0,0 +1,24 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setSession(''); // The user session to authenticate with + +const documentsDB = new sdk.DocumentsDB(client); + +const result = await documentsDB.createDocument({ + databaseId: '', + collectionId: '', + documentId: '', + data: { + "username": "walter.obrien", + "email": "walter.obrien@example.com", + "fullName": "Walter O'Brien", + "age": 30, + "isAdmin": false + }, + permissions: [sdk.Permission.read(sdk.Role.any())] // optional +}); +``` diff --git a/docs/examples/documentsdb/create-documents.md b/docs/examples/documentsdb/create-documents.md new file mode 100644 index 00000000..c990675c --- /dev/null +++ b/docs/examples/documentsdb/create-documents.md @@ -0,0 +1,16 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setSession(''); // The user session to authenticate with + +const documentsDB = new sdk.DocumentsDB(client); + +const result = await documentsDB.createDocuments({ + databaseId: '', + collectionId: '', + documents: [] +}); +``` diff --git a/docs/examples/documentsdb/create-index.md b/docs/examples/documentsdb/create-index.md new file mode 100644 index 00000000..bece398c --- /dev/null +++ b/docs/examples/documentsdb/create-index.md @@ -0,0 +1,20 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +const documentsDB = new sdk.DocumentsDB(client); + +const result = await documentsDB.createIndex({ + databaseId: '', + collectionId: '', + key: '', + type: sdk.DocumentsDBIndexType.Key, + attributes: [], + orders: [sdk.OrderBy.Asc], // optional + lengths: [] // optional +}); +``` diff --git a/docs/examples/documentsdb/create-operations.md b/docs/examples/documentsdb/create-operations.md new file mode 100644 index 00000000..464cc672 --- /dev/null +++ b/docs/examples/documentsdb/create-operations.md @@ -0,0 +1,25 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +const documentsDB = new sdk.DocumentsDB(client); + +const result = await documentsDB.createOperations({ + transactionId: '', + operations: [ + { + "action": "create", + "databaseId": "", + "collectionId": "", + "documentId": "", + "data": { + "name": "Walter O'Brien" + } + } + ] // optional +}); +``` diff --git a/docs/examples/documentsdb/create-transaction.md b/docs/examples/documentsdb/create-transaction.md new file mode 100644 index 00000000..73bbb2fa --- /dev/null +++ b/docs/examples/documentsdb/create-transaction.md @@ -0,0 +1,14 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +const documentsDB = new sdk.DocumentsDB(client); + +const result = await documentsDB.createTransaction({ + ttl: 60 // optional +}); +``` diff --git a/docs/examples/documentsdb/create.md b/docs/examples/documentsdb/create.md new file mode 100644 index 00000000..d6eb4357 --- /dev/null +++ b/docs/examples/documentsdb/create.md @@ -0,0 +1,16 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +const documentsDB = new sdk.DocumentsDB(client); + +const result = await documentsDB.create({ + databaseId: '', + name: '', + enabled: false // optional +}); +``` diff --git a/docs/examples/documentsdb/decrement-document-attribute.md b/docs/examples/documentsdb/decrement-document-attribute.md new file mode 100644 index 00000000..1f3f8dc2 --- /dev/null +++ b/docs/examples/documentsdb/decrement-document-attribute.md @@ -0,0 +1,20 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setSession(''); // The user session to authenticate with + +const documentsDB = new sdk.DocumentsDB(client); + +const result = await documentsDB.decrementDocumentAttribute({ + databaseId: '', + collectionId: '', + documentId: '', + attribute: '', + value: null, // optional + min: null, // optional + transactionId: '' // optional +}); +``` diff --git a/docs/examples/documentsdb/delete-collection.md b/docs/examples/documentsdb/delete-collection.md new file mode 100644 index 00000000..44cb7cc2 --- /dev/null +++ b/docs/examples/documentsdb/delete-collection.md @@ -0,0 +1,15 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +const documentsDB = new sdk.DocumentsDB(client); + +const result = await documentsDB.deleteCollection({ + databaseId: '', + collectionId: '' +}); +``` diff --git a/docs/examples/documentsdb/delete-document.md b/docs/examples/documentsdb/delete-document.md new file mode 100644 index 00000000..05363fc7 --- /dev/null +++ b/docs/examples/documentsdb/delete-document.md @@ -0,0 +1,17 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setSession(''); // The user session to authenticate with + +const documentsDB = new sdk.DocumentsDB(client); + +const result = await documentsDB.deleteDocument({ + databaseId: '', + collectionId: '', + documentId: '', + transactionId: '' // optional +}); +``` diff --git a/docs/examples/documentsdb/delete-documents.md b/docs/examples/documentsdb/delete-documents.md new file mode 100644 index 00000000..9c9d0201 --- /dev/null +++ b/docs/examples/documentsdb/delete-documents.md @@ -0,0 +1,17 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +const documentsDB = new sdk.DocumentsDB(client); + +const result = await documentsDB.deleteDocuments({ + databaseId: '', + collectionId: '', + queries: [], // optional + transactionId: '' // optional +}); +``` diff --git a/docs/examples/documentsdb/delete-index.md b/docs/examples/documentsdb/delete-index.md new file mode 100644 index 00000000..cfdfd3e2 --- /dev/null +++ b/docs/examples/documentsdb/delete-index.md @@ -0,0 +1,16 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +const documentsDB = new sdk.DocumentsDB(client); + +const result = await documentsDB.deleteIndex({ + databaseId: '', + collectionId: '', + key: '' +}); +``` diff --git a/docs/examples/documentsdb/delete-transaction.md b/docs/examples/documentsdb/delete-transaction.md new file mode 100644 index 00000000..a8b1e9ec --- /dev/null +++ b/docs/examples/documentsdb/delete-transaction.md @@ -0,0 +1,14 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +const documentsDB = new sdk.DocumentsDB(client); + +const result = await documentsDB.deleteTransaction({ + transactionId: '' +}); +``` diff --git a/docs/examples/documentsdb/delete.md b/docs/examples/documentsdb/delete.md new file mode 100644 index 00000000..9f6d6c88 --- /dev/null +++ b/docs/examples/documentsdb/delete.md @@ -0,0 +1,14 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +const documentsDB = new sdk.DocumentsDB(client); + +const result = await documentsDB.delete({ + databaseId: '' +}); +``` diff --git a/docs/examples/documentsdb/get-collection.md b/docs/examples/documentsdb/get-collection.md new file mode 100644 index 00000000..49b419c1 --- /dev/null +++ b/docs/examples/documentsdb/get-collection.md @@ -0,0 +1,15 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +const documentsDB = new sdk.DocumentsDB(client); + +const result = await documentsDB.getCollection({ + databaseId: '', + collectionId: '' +}); +``` diff --git a/docs/examples/documentsdb/get-document.md b/docs/examples/documentsdb/get-document.md new file mode 100644 index 00000000..7ef838c8 --- /dev/null +++ b/docs/examples/documentsdb/get-document.md @@ -0,0 +1,18 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setSession(''); // The user session to authenticate with + +const documentsDB = new sdk.DocumentsDB(client); + +const result = await documentsDB.getDocument({ + databaseId: '', + collectionId: '', + documentId: '', + queries: [], // optional + transactionId: '' // optional +}); +``` diff --git a/docs/examples/documentsdb/get-index.md b/docs/examples/documentsdb/get-index.md new file mode 100644 index 00000000..a44b6d08 --- /dev/null +++ b/docs/examples/documentsdb/get-index.md @@ -0,0 +1,16 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +const documentsDB = new sdk.DocumentsDB(client); + +const result = await documentsDB.getIndex({ + databaseId: '', + collectionId: '', + key: '' +}); +``` diff --git a/docs/examples/documentsdb/get-transaction.md b/docs/examples/documentsdb/get-transaction.md new file mode 100644 index 00000000..74de2fc0 --- /dev/null +++ b/docs/examples/documentsdb/get-transaction.md @@ -0,0 +1,14 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +const documentsDB = new sdk.DocumentsDB(client); + +const result = await documentsDB.getTransaction({ + transactionId: '' +}); +``` diff --git a/docs/examples/documentsdb/get.md b/docs/examples/documentsdb/get.md new file mode 100644 index 00000000..5b867708 --- /dev/null +++ b/docs/examples/documentsdb/get.md @@ -0,0 +1,14 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +const documentsDB = new sdk.DocumentsDB(client); + +const result = await documentsDB.get({ + databaseId: '' +}); +``` diff --git a/docs/examples/documentsdb/increment-document-attribute.md b/docs/examples/documentsdb/increment-document-attribute.md new file mode 100644 index 00000000..931d73c0 --- /dev/null +++ b/docs/examples/documentsdb/increment-document-attribute.md @@ -0,0 +1,20 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setSession(''); // The user session to authenticate with + +const documentsDB = new sdk.DocumentsDB(client); + +const result = await documentsDB.incrementDocumentAttribute({ + databaseId: '', + collectionId: '', + documentId: '', + attribute: '', + value: null, // optional + max: null, // optional + transactionId: '' // optional +}); +``` diff --git a/docs/examples/documentsdb/list-collections.md b/docs/examples/documentsdb/list-collections.md new file mode 100644 index 00000000..d640873e --- /dev/null +++ b/docs/examples/documentsdb/list-collections.md @@ -0,0 +1,17 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +const documentsDB = new sdk.DocumentsDB(client); + +const result = await documentsDB.listCollections({ + databaseId: '', + queries: [], // optional + search: '', // optional + total: false // optional +}); +``` diff --git a/docs/examples/documentsdb/list-documents.md b/docs/examples/documentsdb/list-documents.md new file mode 100644 index 00000000..5d061737 --- /dev/null +++ b/docs/examples/documentsdb/list-documents.md @@ -0,0 +1,19 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setSession(''); // The user session to authenticate with + +const documentsDB = new sdk.DocumentsDB(client); + +const result = await documentsDB.listDocuments({ + databaseId: '', + collectionId: '', + queries: [], // optional + transactionId: '', // optional + total: false, // optional + ttl: 0 // optional +}); +``` diff --git a/docs/examples/documentsdb/list-indexes.md b/docs/examples/documentsdb/list-indexes.md new file mode 100644 index 00000000..35c48a84 --- /dev/null +++ b/docs/examples/documentsdb/list-indexes.md @@ -0,0 +1,17 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +const documentsDB = new sdk.DocumentsDB(client); + +const result = await documentsDB.listIndexes({ + databaseId: '', + collectionId: '', + queries: [], // optional + total: false // optional +}); +``` diff --git a/docs/examples/documentsdb/list-transactions.md b/docs/examples/documentsdb/list-transactions.md new file mode 100644 index 00000000..5caad1f5 --- /dev/null +++ b/docs/examples/documentsdb/list-transactions.md @@ -0,0 +1,14 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +const documentsDB = new sdk.DocumentsDB(client); + +const result = await documentsDB.listTransactions({ + queries: [] // optional +}); +``` diff --git a/docs/examples/documentsdb/list.md b/docs/examples/documentsdb/list.md new file mode 100644 index 00000000..70ce780c --- /dev/null +++ b/docs/examples/documentsdb/list.md @@ -0,0 +1,16 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +const documentsDB = new sdk.DocumentsDB(client); + +const result = await documentsDB.list({ + queries: [], // optional + search: '', // optional + total: false // optional +}); +``` diff --git a/docs/examples/documentsdb/update-collection.md b/docs/examples/documentsdb/update-collection.md new file mode 100644 index 00000000..48ba26f9 --- /dev/null +++ b/docs/examples/documentsdb/update-collection.md @@ -0,0 +1,19 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +const documentsDB = new sdk.DocumentsDB(client); + +const result = await documentsDB.updateCollection({ + databaseId: '', + collectionId: '', + name: '', + permissions: [sdk.Permission.read(sdk.Role.any())], // optional + documentSecurity: false, // optional + enabled: false // optional +}); +``` diff --git a/docs/examples/documentsdb/update-document.md b/docs/examples/documentsdb/update-document.md new file mode 100644 index 00000000..17e2d8ff --- /dev/null +++ b/docs/examples/documentsdb/update-document.md @@ -0,0 +1,19 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setSession(''); // The user session to authenticate with + +const documentsDB = new sdk.DocumentsDB(client); + +const result = await documentsDB.updateDocument({ + databaseId: '', + collectionId: '', + documentId: '', + data: {}, // optional + permissions: [sdk.Permission.read(sdk.Role.any())], // optional + transactionId: '' // optional +}); +``` diff --git a/docs/examples/documentsdb/update-documents.md b/docs/examples/documentsdb/update-documents.md new file mode 100644 index 00000000..bb5869e6 --- /dev/null +++ b/docs/examples/documentsdb/update-documents.md @@ -0,0 +1,18 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +const documentsDB = new sdk.DocumentsDB(client); + +const result = await documentsDB.updateDocuments({ + databaseId: '', + collectionId: '', + data: {}, // optional + queries: [], // optional + transactionId: '' // optional +}); +``` diff --git a/docs/examples/documentsdb/update-transaction.md b/docs/examples/documentsdb/update-transaction.md new file mode 100644 index 00000000..2d5c1d65 --- /dev/null +++ b/docs/examples/documentsdb/update-transaction.md @@ -0,0 +1,16 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +const documentsDB = new sdk.DocumentsDB(client); + +const result = await documentsDB.updateTransaction({ + transactionId: '', + commit: false, // optional + rollback: false // optional +}); +``` diff --git a/docs/examples/documentsdb/update.md b/docs/examples/documentsdb/update.md new file mode 100644 index 00000000..bc41f2e8 --- /dev/null +++ b/docs/examples/documentsdb/update.md @@ -0,0 +1,16 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +const documentsDB = new sdk.DocumentsDB(client); + +const result = await documentsDB.update({ + databaseId: '', + name: '', + enabled: false // optional +}); +``` diff --git a/docs/examples/documentsdb/upsert-document.md b/docs/examples/documentsdb/upsert-document.md new file mode 100644 index 00000000..27d66b3b --- /dev/null +++ b/docs/examples/documentsdb/upsert-document.md @@ -0,0 +1,19 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setSession(''); // The user session to authenticate with + +const documentsDB = new sdk.DocumentsDB(client); + +const result = await documentsDB.upsertDocument({ + databaseId: '', + collectionId: '', + documentId: '', + data: {}, // optional + permissions: [sdk.Permission.read(sdk.Role.any())], // optional + transactionId: '' // optional +}); +``` diff --git a/docs/examples/documentsdb/upsert-documents.md b/docs/examples/documentsdb/upsert-documents.md new file mode 100644 index 00000000..5efd848f --- /dev/null +++ b/docs/examples/documentsdb/upsert-documents.md @@ -0,0 +1,17 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +const documentsDB = new sdk.DocumentsDB(client); + +const result = await documentsDB.upsertDocuments({ + databaseId: '', + collectionId: '', + documents: [], + transactionId: '' // optional +}); +``` diff --git a/docs/examples/functions/create.md b/docs/examples/functions/create.md index 292a0e40..b0004d85 100644 --- a/docs/examples/functions/create.md +++ b/docs/examples/functions/create.md @@ -26,6 +26,8 @@ const result = await functions.create({ providerBranch: '', // optional providerSilentMode: false, // optional providerRootDirectory: '', // optional - specification: '' // optional + buildSpecification: '', // optional + runtimeSpecification: '', // optional + deploymentRetention: 0 // optional }); ``` diff --git a/docs/examples/functions/update.md b/docs/examples/functions/update.md index 459b5f37..915037ff 100644 --- a/docs/examples/functions/update.md +++ b/docs/examples/functions/update.md @@ -26,6 +26,8 @@ const result = await functions.update({ providerBranch: '', // optional providerSilentMode: false, // optional providerRootDirectory: '', // optional - specification: '' // optional + buildSpecification: '', // optional + runtimeSpecification: '', // optional + deploymentRetention: 0 // optional }); ``` diff --git a/docs/examples/project/create-variable.md b/docs/examples/project/create-variable.md new file mode 100644 index 00000000..6333b935 --- /dev/null +++ b/docs/examples/project/create-variable.md @@ -0,0 +1,17 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +const project = new sdk.Project(client); + +const result = await project.createVariable({ + variableId: '', + key: '', + value: '', + secret: false // optional +}); +``` diff --git a/docs/examples/project/delete-variable.md b/docs/examples/project/delete-variable.md new file mode 100644 index 00000000..c930811b --- /dev/null +++ b/docs/examples/project/delete-variable.md @@ -0,0 +1,14 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +const project = new sdk.Project(client); + +const result = await project.deleteVariable({ + variableId: '' +}); +``` diff --git a/docs/examples/project/get-variable.md b/docs/examples/project/get-variable.md new file mode 100644 index 00000000..5232de86 --- /dev/null +++ b/docs/examples/project/get-variable.md @@ -0,0 +1,14 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +const project = new sdk.Project(client); + +const result = await project.getVariable({ + variableId: '' +}); +``` diff --git a/docs/examples/project/list-variables.md b/docs/examples/project/list-variables.md new file mode 100644 index 00000000..3ffd1b95 --- /dev/null +++ b/docs/examples/project/list-variables.md @@ -0,0 +1,15 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +const project = new sdk.Project(client); + +const result = await project.listVariables({ + queries: [], // optional + total: false // optional +}); +``` diff --git a/docs/examples/project/update-variable.md b/docs/examples/project/update-variable.md new file mode 100644 index 00000000..58e738ed --- /dev/null +++ b/docs/examples/project/update-variable.md @@ -0,0 +1,17 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +const project = new sdk.Project(client); + +const result = await project.updateVariable({ + variableId: '', + key: '', // optional + value: '', // optional + secret: false // optional +}); +``` diff --git a/docs/examples/sites/create.md b/docs/examples/sites/create.md index fe5c2649..65e5c64c 100644 --- a/docs/examples/sites/create.md +++ b/docs/examples/sites/create.md @@ -18,6 +18,7 @@ const result = await sites.create({ timeout: 1, // optional installCommand: '', // optional buildCommand: '', // optional + startCommand: '', // optional outputDirectory: '', // optional adapter: sdk.Adapter.Static, // optional installationId: '', // optional @@ -26,6 +27,8 @@ const result = await sites.create({ providerBranch: '', // optional providerSilentMode: false, // optional providerRootDirectory: '', // optional - specification: '' // optional + buildSpecification: '', // optional + runtimeSpecification: '', // optional + deploymentRetention: 0 // optional }); ``` diff --git a/docs/examples/sites/update.md b/docs/examples/sites/update.md index 28f2e80f..0411752f 100644 --- a/docs/examples/sites/update.md +++ b/docs/examples/sites/update.md @@ -17,6 +17,7 @@ const result = await sites.update({ timeout: 1, // optional installCommand: '', // optional buildCommand: '', // optional + startCommand: '', // optional outputDirectory: '', // optional buildRuntime: sdk.BuildRuntime.Node145, // optional adapter: sdk.Adapter.Static, // optional @@ -26,6 +27,8 @@ const result = await sites.update({ providerBranch: '', // optional providerSilentMode: false, // optional providerRootDirectory: '', // optional - specification: '' // optional + buildSpecification: '', // optional + runtimeSpecification: '', // optional + deploymentRetention: 0 // optional }); ``` diff --git a/docs/examples/tablesdb/create-index.md b/docs/examples/tablesdb/create-index.md index 989110f2..6a7523ba 100644 --- a/docs/examples/tablesdb/create-index.md +++ b/docs/examples/tablesdb/create-index.md @@ -12,7 +12,7 @@ const result = await tablesDB.createIndex({ databaseId: '', tableId: '', key: '', - type: sdk.IndexType.Key, + type: sdk.TablesDBIndexType.Key, columns: [], orders: [sdk.OrderBy.Asc], // optional lengths: [] // optional diff --git a/docs/examples/users/update-impersonator.md b/docs/examples/users/update-impersonator.md new file mode 100644 index 00000000..a41d11dc --- /dev/null +++ b/docs/examples/users/update-impersonator.md @@ -0,0 +1,15 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +const users = new sdk.Users(client); + +const result = await users.updateImpersonator({ + userId: '', + impersonator: false +}); +``` diff --git a/docs/examples/vectorsdb/create-collection.md b/docs/examples/vectorsdb/create-collection.md new file mode 100644 index 00000000..8745693d --- /dev/null +++ b/docs/examples/vectorsdb/create-collection.md @@ -0,0 +1,20 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +const vectorsDB = new sdk.VectorsDB(client); + +const result = await vectorsDB.createCollection({ + databaseId: '', + collectionId: '', + name: '', + dimension: 1, + permissions: [sdk.Permission.read(sdk.Role.any())], // optional + documentSecurity: false, // optional + enabled: false // optional +}); +``` diff --git a/docs/examples/vectorsdb/create-document.md b/docs/examples/vectorsdb/create-document.md new file mode 100644 index 00000000..dc007a91 --- /dev/null +++ b/docs/examples/vectorsdb/create-document.md @@ -0,0 +1,28 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setSession(''); // The user session to authenticate with + +const vectorsDB = new sdk.VectorsDB(client); + +const result = await vectorsDB.createDocument({ + databaseId: '', + collectionId: '', + documentId: '', + data: { + "embeddings": [ + 0.12, + -0.55, + 0.88, + 1.02 + ], + "metadata": { + "key": "value" + } + }, + permissions: [sdk.Permission.read(sdk.Role.any())] // optional +}); +``` diff --git a/docs/examples/vectorsdb/create-documents.md b/docs/examples/vectorsdb/create-documents.md new file mode 100644 index 00000000..04cad8ca --- /dev/null +++ b/docs/examples/vectorsdb/create-documents.md @@ -0,0 +1,16 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +const vectorsDB = new sdk.VectorsDB(client); + +const result = await vectorsDB.createDocuments({ + databaseId: '', + collectionId: '', + documents: [] +}); +``` diff --git a/docs/examples/vectorsdb/create-index.md b/docs/examples/vectorsdb/create-index.md new file mode 100644 index 00000000..b865aa6f --- /dev/null +++ b/docs/examples/vectorsdb/create-index.md @@ -0,0 +1,20 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +const vectorsDB = new sdk.VectorsDB(client); + +const result = await vectorsDB.createIndex({ + databaseId: '', + collectionId: '', + key: '', + type: sdk.VectorsDBIndexType.HnswEuclidean, + attributes: [], + orders: [sdk.OrderBy.Asc], // optional + lengths: [] // optional +}); +``` diff --git a/docs/examples/vectorsdb/create-operations.md b/docs/examples/vectorsdb/create-operations.md new file mode 100644 index 00000000..f8858957 --- /dev/null +++ b/docs/examples/vectorsdb/create-operations.md @@ -0,0 +1,25 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +const vectorsDB = new sdk.VectorsDB(client); + +const result = await vectorsDB.createOperations({ + transactionId: '', + operations: [ + { + "action": "create", + "databaseId": "", + "collectionId": "", + "documentId": "", + "data": { + "name": "Walter O'Brien" + } + } + ] // optional +}); +``` diff --git a/docs/examples/vectorsdb/create-text-embeddings.md b/docs/examples/vectorsdb/create-text-embeddings.md new file mode 100644 index 00000000..1afac117 --- /dev/null +++ b/docs/examples/vectorsdb/create-text-embeddings.md @@ -0,0 +1,15 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +const vectorsDB = new sdk.VectorsDB(client); + +const result = await vectorsDB.createTextEmbeddings({ + texts: [], + model: sdk.Model.Embeddinggemma // optional +}); +``` diff --git a/docs/examples/vectorsdb/create-transaction.md b/docs/examples/vectorsdb/create-transaction.md new file mode 100644 index 00000000..ef39679c --- /dev/null +++ b/docs/examples/vectorsdb/create-transaction.md @@ -0,0 +1,14 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +const vectorsDB = new sdk.VectorsDB(client); + +const result = await vectorsDB.createTransaction({ + ttl: 60 // optional +}); +``` diff --git a/docs/examples/vectorsdb/create.md b/docs/examples/vectorsdb/create.md new file mode 100644 index 00000000..e7177fa5 --- /dev/null +++ b/docs/examples/vectorsdb/create.md @@ -0,0 +1,16 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +const vectorsDB = new sdk.VectorsDB(client); + +const result = await vectorsDB.create({ + databaseId: '', + name: '', + enabled: false // optional +}); +``` diff --git a/docs/examples/vectorsdb/delete-collection.md b/docs/examples/vectorsdb/delete-collection.md new file mode 100644 index 00000000..5e66e78d --- /dev/null +++ b/docs/examples/vectorsdb/delete-collection.md @@ -0,0 +1,15 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +const vectorsDB = new sdk.VectorsDB(client); + +const result = await vectorsDB.deleteCollection({ + databaseId: '', + collectionId: '' +}); +``` diff --git a/docs/examples/vectorsdb/delete-document.md b/docs/examples/vectorsdb/delete-document.md new file mode 100644 index 00000000..0e115e86 --- /dev/null +++ b/docs/examples/vectorsdb/delete-document.md @@ -0,0 +1,17 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setSession(''); // The user session to authenticate with + +const vectorsDB = new sdk.VectorsDB(client); + +const result = await vectorsDB.deleteDocument({ + databaseId: '', + collectionId: '', + documentId: '', + transactionId: '' // optional +}); +``` diff --git a/docs/examples/vectorsdb/delete-documents.md b/docs/examples/vectorsdb/delete-documents.md new file mode 100644 index 00000000..7c8d2eca --- /dev/null +++ b/docs/examples/vectorsdb/delete-documents.md @@ -0,0 +1,17 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +const vectorsDB = new sdk.VectorsDB(client); + +const result = await vectorsDB.deleteDocuments({ + databaseId: '', + collectionId: '', + queries: [], // optional + transactionId: '' // optional +}); +``` diff --git a/docs/examples/vectorsdb/delete-index.md b/docs/examples/vectorsdb/delete-index.md new file mode 100644 index 00000000..8c09bf5a --- /dev/null +++ b/docs/examples/vectorsdb/delete-index.md @@ -0,0 +1,16 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +const vectorsDB = new sdk.VectorsDB(client); + +const result = await vectorsDB.deleteIndex({ + databaseId: '', + collectionId: '', + key: '' +}); +``` diff --git a/docs/examples/vectorsdb/delete-transaction.md b/docs/examples/vectorsdb/delete-transaction.md new file mode 100644 index 00000000..7b361c61 --- /dev/null +++ b/docs/examples/vectorsdb/delete-transaction.md @@ -0,0 +1,14 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +const vectorsDB = new sdk.VectorsDB(client); + +const result = await vectorsDB.deleteTransaction({ + transactionId: '' +}); +``` diff --git a/docs/examples/vectorsdb/delete.md b/docs/examples/vectorsdb/delete.md new file mode 100644 index 00000000..3a2d160f --- /dev/null +++ b/docs/examples/vectorsdb/delete.md @@ -0,0 +1,14 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +const vectorsDB = new sdk.VectorsDB(client); + +const result = await vectorsDB.delete({ + databaseId: '' +}); +``` diff --git a/docs/examples/vectorsdb/get-collection.md b/docs/examples/vectorsdb/get-collection.md new file mode 100644 index 00000000..0f419ffb --- /dev/null +++ b/docs/examples/vectorsdb/get-collection.md @@ -0,0 +1,15 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +const vectorsDB = new sdk.VectorsDB(client); + +const result = await vectorsDB.getCollection({ + databaseId: '', + collectionId: '' +}); +``` diff --git a/docs/examples/vectorsdb/get-document.md b/docs/examples/vectorsdb/get-document.md new file mode 100644 index 00000000..568c4f53 --- /dev/null +++ b/docs/examples/vectorsdb/get-document.md @@ -0,0 +1,18 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setSession(''); // The user session to authenticate with + +const vectorsDB = new sdk.VectorsDB(client); + +const result = await vectorsDB.getDocument({ + databaseId: '', + collectionId: '', + documentId: '', + queries: [], // optional + transactionId: '' // optional +}); +``` diff --git a/docs/examples/vectorsdb/get-index.md b/docs/examples/vectorsdb/get-index.md new file mode 100644 index 00000000..34a337b1 --- /dev/null +++ b/docs/examples/vectorsdb/get-index.md @@ -0,0 +1,16 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +const vectorsDB = new sdk.VectorsDB(client); + +const result = await vectorsDB.getIndex({ + databaseId: '', + collectionId: '', + key: '' +}); +``` diff --git a/docs/examples/vectorsdb/get-transaction.md b/docs/examples/vectorsdb/get-transaction.md new file mode 100644 index 00000000..9240c005 --- /dev/null +++ b/docs/examples/vectorsdb/get-transaction.md @@ -0,0 +1,14 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +const vectorsDB = new sdk.VectorsDB(client); + +const result = await vectorsDB.getTransaction({ + transactionId: '' +}); +``` diff --git a/docs/examples/vectorsdb/get.md b/docs/examples/vectorsdb/get.md new file mode 100644 index 00000000..4660d56a --- /dev/null +++ b/docs/examples/vectorsdb/get.md @@ -0,0 +1,14 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +const vectorsDB = new sdk.VectorsDB(client); + +const result = await vectorsDB.get({ + databaseId: '' +}); +``` diff --git a/docs/examples/vectorsdb/list-collections.md b/docs/examples/vectorsdb/list-collections.md new file mode 100644 index 00000000..3e28a482 --- /dev/null +++ b/docs/examples/vectorsdb/list-collections.md @@ -0,0 +1,17 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +const vectorsDB = new sdk.VectorsDB(client); + +const result = await vectorsDB.listCollections({ + databaseId: '', + queries: [], // optional + search: '', // optional + total: false // optional +}); +``` diff --git a/docs/examples/vectorsdb/list-documents.md b/docs/examples/vectorsdb/list-documents.md new file mode 100644 index 00000000..34d00aa4 --- /dev/null +++ b/docs/examples/vectorsdb/list-documents.md @@ -0,0 +1,19 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setSession(''); // The user session to authenticate with + +const vectorsDB = new sdk.VectorsDB(client); + +const result = await vectorsDB.listDocuments({ + databaseId: '', + collectionId: '', + queries: [], // optional + transactionId: '', // optional + total: false, // optional + ttl: 0 // optional +}); +``` diff --git a/docs/examples/vectorsdb/list-indexes.md b/docs/examples/vectorsdb/list-indexes.md new file mode 100644 index 00000000..c7289253 --- /dev/null +++ b/docs/examples/vectorsdb/list-indexes.md @@ -0,0 +1,17 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +const vectorsDB = new sdk.VectorsDB(client); + +const result = await vectorsDB.listIndexes({ + databaseId: '', + collectionId: '', + queries: [], // optional + total: false // optional +}); +``` diff --git a/docs/examples/vectorsdb/list-transactions.md b/docs/examples/vectorsdb/list-transactions.md new file mode 100644 index 00000000..2a7ab778 --- /dev/null +++ b/docs/examples/vectorsdb/list-transactions.md @@ -0,0 +1,14 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +const vectorsDB = new sdk.VectorsDB(client); + +const result = await vectorsDB.listTransactions({ + queries: [] // optional +}); +``` diff --git a/docs/examples/vectorsdb/list.md b/docs/examples/vectorsdb/list.md new file mode 100644 index 00000000..b067d0a4 --- /dev/null +++ b/docs/examples/vectorsdb/list.md @@ -0,0 +1,16 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +const vectorsDB = new sdk.VectorsDB(client); + +const result = await vectorsDB.list({ + queries: [], // optional + search: '', // optional + total: false // optional +}); +``` diff --git a/docs/examples/vectorsdb/update-collection.md b/docs/examples/vectorsdb/update-collection.md new file mode 100644 index 00000000..ecfb1d53 --- /dev/null +++ b/docs/examples/vectorsdb/update-collection.md @@ -0,0 +1,20 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +const vectorsDB = new sdk.VectorsDB(client); + +const result = await vectorsDB.updateCollection({ + databaseId: '', + collectionId: '', + name: '', + dimension: 1, // optional + permissions: [sdk.Permission.read(sdk.Role.any())], // optional + documentSecurity: false, // optional + enabled: false // optional +}); +``` diff --git a/docs/examples/vectorsdb/update-document.md b/docs/examples/vectorsdb/update-document.md new file mode 100644 index 00000000..05091037 --- /dev/null +++ b/docs/examples/vectorsdb/update-document.md @@ -0,0 +1,19 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setSession(''); // The user session to authenticate with + +const vectorsDB = new sdk.VectorsDB(client); + +const result = await vectorsDB.updateDocument({ + databaseId: '', + collectionId: '', + documentId: '', + data: {}, // optional + permissions: [sdk.Permission.read(sdk.Role.any())], // optional + transactionId: '' // optional +}); +``` diff --git a/docs/examples/vectorsdb/update-documents.md b/docs/examples/vectorsdb/update-documents.md new file mode 100644 index 00000000..58733e79 --- /dev/null +++ b/docs/examples/vectorsdb/update-documents.md @@ -0,0 +1,18 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +const vectorsDB = new sdk.VectorsDB(client); + +const result = await vectorsDB.updateDocuments({ + databaseId: '', + collectionId: '', + data: {}, // optional + queries: [], // optional + transactionId: '' // optional +}); +``` diff --git a/docs/examples/vectorsdb/update-transaction.md b/docs/examples/vectorsdb/update-transaction.md new file mode 100644 index 00000000..37c14a1b --- /dev/null +++ b/docs/examples/vectorsdb/update-transaction.md @@ -0,0 +1,16 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +const vectorsDB = new sdk.VectorsDB(client); + +const result = await vectorsDB.updateTransaction({ + transactionId: '', + commit: false, // optional + rollback: false // optional +}); +``` diff --git a/docs/examples/vectorsdb/update.md b/docs/examples/vectorsdb/update.md new file mode 100644 index 00000000..ff7d737e --- /dev/null +++ b/docs/examples/vectorsdb/update.md @@ -0,0 +1,16 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +const vectorsDB = new sdk.VectorsDB(client); + +const result = await vectorsDB.update({ + databaseId: '', + name: '', + enabled: false // optional +}); +``` diff --git a/docs/examples/vectorsdb/upsert-document.md b/docs/examples/vectorsdb/upsert-document.md new file mode 100644 index 00000000..96c823aa --- /dev/null +++ b/docs/examples/vectorsdb/upsert-document.md @@ -0,0 +1,19 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setSession(''); // The user session to authenticate with + +const vectorsDB = new sdk.VectorsDB(client); + +const result = await vectorsDB.upsertDocument({ + databaseId: '', + collectionId: '', + documentId: '', + data: {}, // optional + permissions: [sdk.Permission.read(sdk.Role.any())], // optional + transactionId: '' // optional +}); +``` diff --git a/docs/examples/vectorsdb/upsert-documents.md b/docs/examples/vectorsdb/upsert-documents.md new file mode 100644 index 00000000..36e20ac7 --- /dev/null +++ b/docs/examples/vectorsdb/upsert-documents.md @@ -0,0 +1,17 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +const vectorsDB = new sdk.VectorsDB(client); + +const result = await vectorsDB.upsertDocuments({ + databaseId: '', + collectionId: '', + documents: [], + transactionId: '' // optional +}); +``` diff --git a/docs/examples/webhooks/create.md b/docs/examples/webhooks/create.md new file mode 100644 index 00000000..5641306f --- /dev/null +++ b/docs/examples/webhooks/create.md @@ -0,0 +1,21 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +const webhooks = new sdk.Webhooks(client); + +const result = await webhooks.create({ + webhookId: '', + url: '', + name: '', + events: [], + enabled: false, // optional + security: false, // optional + httpUser: '', // optional + httpPass: '' // optional +}); +``` diff --git a/docs/examples/webhooks/delete.md b/docs/examples/webhooks/delete.md new file mode 100644 index 00000000..51639e22 --- /dev/null +++ b/docs/examples/webhooks/delete.md @@ -0,0 +1,14 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +const webhooks = new sdk.Webhooks(client); + +const result = await webhooks.delete({ + webhookId: '' +}); +``` diff --git a/docs/examples/webhooks/get.md b/docs/examples/webhooks/get.md new file mode 100644 index 00000000..07d1ecda --- /dev/null +++ b/docs/examples/webhooks/get.md @@ -0,0 +1,14 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +const webhooks = new sdk.Webhooks(client); + +const result = await webhooks.get({ + webhookId: '' +}); +``` diff --git a/docs/examples/webhooks/list.md b/docs/examples/webhooks/list.md new file mode 100644 index 00000000..f509df71 --- /dev/null +++ b/docs/examples/webhooks/list.md @@ -0,0 +1,15 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +const webhooks = new sdk.Webhooks(client); + +const result = await webhooks.list({ + queries: [], // optional + total: false // optional +}); +``` diff --git a/docs/examples/webhooks/update-signature.md b/docs/examples/webhooks/update-signature.md new file mode 100644 index 00000000..6257ba58 --- /dev/null +++ b/docs/examples/webhooks/update-signature.md @@ -0,0 +1,14 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +const webhooks = new sdk.Webhooks(client); + +const result = await webhooks.updateSignature({ + webhookId: '' +}); +``` diff --git a/docs/examples/webhooks/update.md b/docs/examples/webhooks/update.md new file mode 100644 index 00000000..acd6c9a3 --- /dev/null +++ b/docs/examples/webhooks/update.md @@ -0,0 +1,21 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +const webhooks = new sdk.Webhooks(client); + +const result = await webhooks.update({ + webhookId: '', + name: '', + url: '', + events: [], + enabled: false, // optional + security: false, // optional + httpUser: '', // optional + httpPass: '' // optional +}); +``` diff --git a/package.json b/package.json index 940dbfd8..897b77ba 100644 --- a/package.json +++ b/package.json @@ -7,7 +7,8 @@ "main": "dist/index.js", "type": "commonjs", "scripts": { - "build": "tsup" + "build": "tsup", + "test": "jest" }, "exports": { ".": { @@ -46,7 +47,8 @@ "tsup": "7.2.0", "esbuild-plugin-file-path-extensions": "^2.0.0", "tslib": "2.6.2", - "typescript": "5.4.2" + "typescript": "5.4.2", + "jest": "^29.7.0" }, "dependencies": { "json-bigint": "1.0.0", diff --git a/src/client.ts b/src/client.ts index 885c8f33..d427cbc3 100644 --- a/src/client.ts +++ b/src/client.ts @@ -117,6 +117,9 @@ class Client { locale: '', session: '', forwardeduseragent: '', + impersonateuserid: '', + impersonateuseremail: '', + impersonateuserphone: '', }; headers: Headers = { 'x-sdk-name': 'Node.js', @@ -124,7 +127,7 @@ class Client { 'x-sdk-language': 'nodejs', 'x-sdk-version': '22.1.3', 'user-agent' : getUserAgent(), - 'X-Appwrite-Response-Format': '1.8.0', + 'X-Appwrite-Response-Format': '1.9.0', }; /** @@ -263,6 +266,48 @@ class Client { this.config.forwardeduseragent = value; return this; } + /** + * Set ImpersonateUserId + * + * Impersonate a user by ID on an already user-authenticated request. Requires the current request to be authenticated as a user with impersonator capability; X-Appwrite-Key alone is not sufficient. Impersonator users are intentionally granted users.read so they can discover a target before impersonation begins. Internal audit logs still attribute actions to the original impersonator and record the impersonated target only in internal audit payload data. + * + * @param value string + * + * @return {this} + */ + setImpersonateUserId(value: string): this { + this.headers['X-Appwrite-Impersonate-User-Id'] = value; + this.config.impersonateuserid = value; + return this; + } + /** + * Set ImpersonateUserEmail + * + * Impersonate a user by email on an already user-authenticated request. Requires the current request to be authenticated as a user with impersonator capability; X-Appwrite-Key alone is not sufficient. Impersonator users are intentionally granted users.read so they can discover a target before impersonation begins. Internal audit logs still attribute actions to the original impersonator and record the impersonated target only in internal audit payload data. + * + * @param value string + * + * @return {this} + */ + setImpersonateUserEmail(value: string): this { + this.headers['X-Appwrite-Impersonate-User-Email'] = value; + this.config.impersonateuseremail = value; + return this; + } + /** + * Set ImpersonateUserPhone + * + * Impersonate a user by phone on an already user-authenticated request. Requires the current request to be authenticated as a user with impersonator capability; X-Appwrite-Key alone is not sufficient. Impersonator users are intentionally granted users.read so they can discover a target before impersonation begins. Internal audit logs still attribute actions to the original impersonator and record the impersonated target only in internal audit payload data. + * + * @param value string + * + * @return {this} + */ + setImpersonateUserPhone(value: string): this { + this.headers['X-Appwrite-Impersonate-User-Phone'] = value; + this.config.impersonateuserphone = value; + return this; + } prepareRequest(method: string, url: URL, headers: Headers = {}, params: Payload = {}): { uri: string, options: RequestInit } { method = method.toUpperCase(); @@ -408,6 +453,10 @@ class Client { throw new AppwriteException(data?.message, response.status, data?.type, responseText); } + if (data && typeof data === 'object') { + data.toString = () => JSONbig.stringify(data); + } + return data; } diff --git a/src/enums/backup-services.ts b/src/enums/backup-services.ts index f0f829ab..bd0582ce 100644 --- a/src/enums/backup-services.ts +++ b/src/enums/backup-services.ts @@ -1,5 +1,8 @@ export enum BackupServices { Databases = 'databases', + Tablesdb = 'tablesdb', + Documentsdb = 'documentsdb', + Vectorsdb = 'vectorsdb', Functions = 'functions', Storage = 'storage', } \ No newline at end of file diff --git a/src/enums/build-runtime.ts b/src/enums/build-runtime.ts index 3f85913f..be56a9f4 100644 --- a/src/enums/build-runtime.ts +++ b/src/enums/build-runtime.ts @@ -85,4 +85,90 @@ export enum BuildRuntime { Flutter332 = 'flutter-3.32', Flutter335 = 'flutter-3.35', Flutter338 = 'flutter-3.38', + Node145rc = 'node-14.5-rc', + Node160rc = 'node-16.0-rc', + Node180rc = 'node-18.0-rc', + Node190rc = 'node-19.0-rc', + Node200rc = 'node-20.0-rc', + Node210rc = 'node-21.0-rc', + Node22rc = 'node-22-rc', + Node23rc = 'node-23-rc', + Node24rc = 'node-24-rc', + Node25rc = 'node-25-rc', + Php80rc = 'php-8.0-rc', + Php81rc = 'php-8.1-rc', + Php82rc = 'php-8.2-rc', + Php83rc = 'php-8.3-rc', + Php84rc = 'php-8.4-rc', + Ruby30rc = 'ruby-3.0-rc', + Ruby31rc = 'ruby-3.1-rc', + Ruby32rc = 'ruby-3.2-rc', + Ruby33rc = 'ruby-3.3-rc', + Ruby34rc = 'ruby-3.4-rc', + Ruby40rc = 'ruby-4.0-rc', + Python38rc = 'python-3.8-rc', + Python39rc = 'python-3.9-rc', + Python310rc = 'python-3.10-rc', + Python311rc = 'python-3.11-rc', + Python312rc = 'python-3.12-rc', + Python313rc = 'python-3.13-rc', + Python314rc = 'python-3.14-rc', + Pythonml311rc = 'python-ml-3.11-rc', + Pythonml312rc = 'python-ml-3.12-rc', + Pythonml313rc = 'python-ml-3.13-rc', + Deno140rc = 'deno-1.40-rc', + Deno146rc = 'deno-1.46-rc', + Deno20rc = 'deno-2.0-rc', + Deno25rc = 'deno-2.5-rc', + Deno26rc = 'deno-2.6-rc', + Dart215rc = 'dart-2.15-rc', + Dart216rc = 'dart-2.16-rc', + Dart217rc = 'dart-2.17-rc', + Dart218rc = 'dart-2.18-rc', + Dart219rc = 'dart-2.19-rc', + Dart30rc = 'dart-3.0-rc', + Dart31rc = 'dart-3.1-rc', + Dart33rc = 'dart-3.3-rc', + Dart35rc = 'dart-3.5-rc', + Dart38rc = 'dart-3.8-rc', + Dart39rc = 'dart-3.9-rc', + Dart310rc = 'dart-3.10-rc', + Dotnet60rc = 'dotnet-6.0-rc', + Dotnet70rc = 'dotnet-7.0-rc', + Dotnet80rc = 'dotnet-8.0-rc', + Dotnet10rc = 'dotnet-10-rc', + Java80rc = 'java-8.0-rc', + Java110rc = 'java-11.0-rc', + Java170rc = 'java-17.0-rc', + Java180rc = 'java-18.0-rc', + Java210rc = 'java-21.0-rc', + Java22rc = 'java-22-rc', + Java25rc = 'java-25-rc', + Swift55rc = 'swift-5.5-rc', + Swift58rc = 'swift-5.8-rc', + Swift59rc = 'swift-5.9-rc', + Swift510rc = 'swift-5.10-rc', + Swift62rc = 'swift-6.2-rc', + Kotlin16rc = 'kotlin-1.6-rc', + Kotlin18rc = 'kotlin-1.8-rc', + Kotlin19rc = 'kotlin-1.9-rc', + Kotlin20rc = 'kotlin-2.0-rc', + Kotlin23rc = 'kotlin-2.3-rc', + Cpp17rc = 'cpp-17-rc', + Cpp20rc = 'cpp-20-rc', + Bun10rc = 'bun-1.0-rc', + Bun11rc = 'bun-1.1-rc', + Bun12rc = 'bun-1.2-rc', + Bun13rc = 'bun-1.3-rc', + Go123rc = 'go-1.23-rc', + Go124rc = 'go-1.24-rc', + Go125rc = 'go-1.25-rc', + Go126rc = 'go-1.26-rc', + Static1rc = 'static-1-rc', + Flutter324rc = 'flutter-3.24-rc', + Flutter327rc = 'flutter-3.27-rc', + Flutter329rc = 'flutter-3.29-rc', + Flutter332rc = 'flutter-3.32-rc', + Flutter335rc = 'flutter-3.35-rc', + Flutter338rc = 'flutter-3.38-rc', } \ No newline at end of file diff --git a/src/enums/database-type.ts b/src/enums/database-type.ts index 71d1ed9d..8ccd9699 100644 --- a/src/enums/database-type.ts +++ b/src/enums/database-type.ts @@ -1,4 +1,6 @@ export enum DatabaseType { Legacy = 'legacy', Tablesdb = 'tablesdb', + Documentsdb = 'documentsdb', + Vectorsdb = 'vectorsdb', } \ No newline at end of file diff --git a/src/enums/databases-index-type.ts b/src/enums/databases-index-type.ts new file mode 100644 index 00000000..85ccf867 --- /dev/null +++ b/src/enums/databases-index-type.ts @@ -0,0 +1,6 @@ +export enum DatabasesIndexType { + Key = 'key', + Fulltext = 'fulltext', + Unique = 'unique', + Spatial = 'spatial', +} \ No newline at end of file diff --git a/src/enums/documents-db-index-type.ts b/src/enums/documents-db-index-type.ts new file mode 100644 index 00000000..8b65e173 --- /dev/null +++ b/src/enums/documents-db-index-type.ts @@ -0,0 +1,6 @@ +export enum DocumentsDBIndexType { + Key = 'key', + Fulltext = 'fulltext', + Unique = 'unique', + Spatial = 'spatial', +} \ No newline at end of file diff --git a/src/enums/model.ts b/src/enums/model.ts new file mode 100644 index 00000000..78e605e3 --- /dev/null +++ b/src/enums/model.ts @@ -0,0 +1,3 @@ +export enum Model { + Embeddinggemma = 'embeddinggemma', +} \ No newline at end of file diff --git a/src/enums/runtime.ts b/src/enums/runtime.ts index fda3bab3..cfd4a735 100644 --- a/src/enums/runtime.ts +++ b/src/enums/runtime.ts @@ -85,4 +85,90 @@ export enum Runtime { Flutter332 = 'flutter-3.32', Flutter335 = 'flutter-3.35', Flutter338 = 'flutter-3.38', + Node145rc = 'node-14.5-rc', + Node160rc = 'node-16.0-rc', + Node180rc = 'node-18.0-rc', + Node190rc = 'node-19.0-rc', + Node200rc = 'node-20.0-rc', + Node210rc = 'node-21.0-rc', + Node22rc = 'node-22-rc', + Node23rc = 'node-23-rc', + Node24rc = 'node-24-rc', + Node25rc = 'node-25-rc', + Php80rc = 'php-8.0-rc', + Php81rc = 'php-8.1-rc', + Php82rc = 'php-8.2-rc', + Php83rc = 'php-8.3-rc', + Php84rc = 'php-8.4-rc', + Ruby30rc = 'ruby-3.0-rc', + Ruby31rc = 'ruby-3.1-rc', + Ruby32rc = 'ruby-3.2-rc', + Ruby33rc = 'ruby-3.3-rc', + Ruby34rc = 'ruby-3.4-rc', + Ruby40rc = 'ruby-4.0-rc', + Python38rc = 'python-3.8-rc', + Python39rc = 'python-3.9-rc', + Python310rc = 'python-3.10-rc', + Python311rc = 'python-3.11-rc', + Python312rc = 'python-3.12-rc', + Python313rc = 'python-3.13-rc', + Python314rc = 'python-3.14-rc', + Pythonml311rc = 'python-ml-3.11-rc', + Pythonml312rc = 'python-ml-3.12-rc', + Pythonml313rc = 'python-ml-3.13-rc', + Deno140rc = 'deno-1.40-rc', + Deno146rc = 'deno-1.46-rc', + Deno20rc = 'deno-2.0-rc', + Deno25rc = 'deno-2.5-rc', + Deno26rc = 'deno-2.6-rc', + Dart215rc = 'dart-2.15-rc', + Dart216rc = 'dart-2.16-rc', + Dart217rc = 'dart-2.17-rc', + Dart218rc = 'dart-2.18-rc', + Dart219rc = 'dart-2.19-rc', + Dart30rc = 'dart-3.0-rc', + Dart31rc = 'dart-3.1-rc', + Dart33rc = 'dart-3.3-rc', + Dart35rc = 'dart-3.5-rc', + Dart38rc = 'dart-3.8-rc', + Dart39rc = 'dart-3.9-rc', + Dart310rc = 'dart-3.10-rc', + Dotnet60rc = 'dotnet-6.0-rc', + Dotnet70rc = 'dotnet-7.0-rc', + Dotnet80rc = 'dotnet-8.0-rc', + Dotnet10rc = 'dotnet-10-rc', + Java80rc = 'java-8.0-rc', + Java110rc = 'java-11.0-rc', + Java170rc = 'java-17.0-rc', + Java180rc = 'java-18.0-rc', + Java210rc = 'java-21.0-rc', + Java22rc = 'java-22-rc', + Java25rc = 'java-25-rc', + Swift55rc = 'swift-5.5-rc', + Swift58rc = 'swift-5.8-rc', + Swift59rc = 'swift-5.9-rc', + Swift510rc = 'swift-5.10-rc', + Swift62rc = 'swift-6.2-rc', + Kotlin16rc = 'kotlin-1.6-rc', + Kotlin18rc = 'kotlin-1.8-rc', + Kotlin19rc = 'kotlin-1.9-rc', + Kotlin20rc = 'kotlin-2.0-rc', + Kotlin23rc = 'kotlin-2.3-rc', + Cpp17rc = 'cpp-17-rc', + Cpp20rc = 'cpp-20-rc', + Bun10rc = 'bun-1.0-rc', + Bun11rc = 'bun-1.1-rc', + Bun12rc = 'bun-1.2-rc', + Bun13rc = 'bun-1.3-rc', + Go123rc = 'go-1.23-rc', + Go124rc = 'go-1.24-rc', + Go125rc = 'go-1.25-rc', + Go126rc = 'go-1.26-rc', + Static1rc = 'static-1-rc', + Flutter324rc = 'flutter-3.24-rc', + Flutter327rc = 'flutter-3.27-rc', + Flutter329rc = 'flutter-3.29-rc', + Flutter332rc = 'flutter-3.32-rc', + Flutter335rc = 'flutter-3.35-rc', + Flutter338rc = 'flutter-3.38-rc', } \ No newline at end of file diff --git a/src/enums/scopes.ts b/src/enums/scopes.ts index 083114b2..d85b2bb5 100644 --- a/src/enums/scopes.ts +++ b/src/enums/scopes.ts @@ -56,6 +56,10 @@ export enum Scopes { AssistantRead = 'assistant.read', TokensRead = 'tokens.read', TokensWrite = 'tokens.write', + WebhooksRead = 'webhooks.read', + WebhooksWrite = 'webhooks.write', + ProjectRead = 'project.read', + ProjectWrite = 'project.write', PoliciesWrite = 'policies.write', PoliciesRead = 'policies.read', ArchivesRead = 'archives.read', diff --git a/src/enums/index-type.ts b/src/enums/tables-db-index-type.ts similarity index 74% rename from src/enums/index-type.ts rename to src/enums/tables-db-index-type.ts index e5b5bbab..a199cd9c 100644 --- a/src/enums/index-type.ts +++ b/src/enums/tables-db-index-type.ts @@ -1,4 +1,4 @@ -export enum IndexType { +export enum TablesDBIndexType { Key = 'key', Fulltext = 'fulltext', Unique = 'unique', diff --git a/src/enums/vectors-db-index-type.ts b/src/enums/vectors-db-index-type.ts new file mode 100644 index 00000000..a38d5ea1 --- /dev/null +++ b/src/enums/vectors-db-index-type.ts @@ -0,0 +1,8 @@ +export enum VectorsDBIndexType { + HnswEuclidean = 'hnsw_euclidean', + HnswDot = 'hnsw_dot', + HnswCosine = 'hnsw_cosine', + Object = 'object', + Key = 'key', + Unique = 'unique', +} \ No newline at end of file diff --git a/src/index.ts b/src/index.ts index 2e7ab5fc..ac7e25aa 100644 --- a/src/index.ts +++ b/src/index.ts @@ -4,17 +4,21 @@ export { Activities } from './services/activities'; export { Avatars } from './services/avatars'; export { Backups } from './services/backups'; export { Databases } from './services/databases'; +export { DocumentsDB } from './services/documents-db'; export { Functions } from './services/functions'; export { Graphql } from './services/graphql'; export { Health } from './services/health'; export { Locale } from './services/locale'; export { Messaging } from './services/messaging'; +export { Project } from './services/project'; export { Sites } from './services/sites'; export { Storage } from './services/storage'; export { TablesDB } from './services/tables-db'; export { Teams } from './services/teams'; export { Tokens } from './services/tokens'; export { Users } from './services/users'; +export { VectorsDB } from './services/vectors-db'; +export { Webhooks } from './services/webhooks'; export type { Models, Payload, UploadProgress } from './client'; export type { QueryTypes, QueryTypesList } from './query'; export { Permission } from './permission'; @@ -34,8 +38,9 @@ export { ImageFormat } from './enums/image-format'; export { BackupServices } from './enums/backup-services'; export { RelationshipType } from './enums/relationship-type'; export { RelationMutate } from './enums/relation-mutate'; -export { IndexType } from './enums/index-type'; +export { DatabasesIndexType } from './enums/databases-index-type'; export { OrderBy } from './enums/order-by'; +export { DocumentsDBIndexType } from './enums/documents-db-index-type'; export { Runtime } from './enums/runtime'; export { Scopes } from './enums/scopes'; export { TemplateReferenceType } from './enums/template-reference-type'; @@ -50,8 +55,11 @@ export { BuildRuntime } from './enums/build-runtime'; export { Adapter } from './enums/adapter'; export { Compression } from './enums/compression'; export { ImageGravity } from './enums/image-gravity'; +export { TablesDBIndexType } from './enums/tables-db-index-type'; export { PasswordHash } from './enums/password-hash'; export { MessagingProviderType } from './enums/messaging-provider-type'; +export { Model } from './enums/model'; +export { VectorsDBIndexType } from './enums/vectors-db-index-type'; export { DatabaseType } from './enums/database-type'; export { AttributeStatus } from './enums/attribute-status'; export { ColumnStatus } from './enums/column-status'; diff --git a/src/models.ts b/src/models.ts index fea4da85..0958a926 100644 --- a/src/models.ts +++ b/src/models.ts @@ -324,6 +324,20 @@ export namespace Models { executions: Execution[]; } + /** + * Webhooks List + */ + export type WebhookList = { + /** + * Total number of webhooks that matched your query. + */ + total: number; + /** + * List of webhooks. + */ + webhooks: Webhook[]; + } + /** * Countries List */ @@ -534,6 +548,34 @@ export namespace Models { specifications: Specification[]; } + /** + * VectorsDB Collections List + */ + export type VectorsdbCollectionList = { + /** + * Total number of collections that matched your query. + */ + total: number; + /** + * List of collections. + */ + collections: VectorsdbCollection[]; + } + + /** + * Embedding list + */ + export type EmbeddingList = { + /** + * Total number of embeddings that matched your query. + */ + total: number; + /** + * List of embeddings. + */ + embeddings: Embedding[]; + } + /** * Database */ @@ -572,6 +614,28 @@ export namespace Models { archives: Collection[]; } + /** + * Embedding + */ + export type Embedding = { + /** + * Embedding model used to generate embeddings. + */ + model: string; + /** + * Number of dimensions for each embedding vector. + */ + dimension: number; + /** + * Embedding vector values. If an error occurs, this will be an empty array. + */ + embedding: number[]; + /** + * Error message if embedding generation fails. Empty string if no error. + */ + error: string; + } + /** * Collection */ @@ -1442,6 +1506,144 @@ export namespace Models { encrypt?: boolean; } + /** + * VectorsDB Collection + */ + export type VectorsdbCollection = { + /** + * Collection ID. + */ + $id: string; + /** + * Collection creation date in ISO 8601 format. + */ + $createdAt: string; + /** + * Collection update date in ISO 8601 format. + */ + $updatedAt: string; + /** + * Collection permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). + */ + $permissions: string[]; + /** + * Database ID. + */ + databaseId: string; + /** + * Collection name. + */ + name: string; + /** + * Collection enabled. Can be 'enabled' or 'disabled'. When disabled, the collection is inaccessible to users, but remains accessible to Server SDKs using API keys. + */ + enabled: boolean; + /** + * Whether document-level permissions are enabled. [Learn more about permissions](https://appwrite.io/docs/permissions). + */ + documentSecurity: boolean; + /** + * Collection attributes. + */ + attributes: (Models.AttributeObject | Models.AttributeVector)[]; + /** + * Collection indexes. + */ + indexes: Index[]; + /** + * Maximum document size in bytes. Returns 0 when no limit applies. + */ + bytesMax: number; + /** + * Currently used document size in bytes based on defined attributes. + */ + bytesUsed: number; + /** + * Embedding dimension. + */ + dimension: number; + } + + /** + * AttributeObject + */ + export type AttributeObject = { + /** + * Attribute Key. + */ + key: string; + /** + * Attribute type. + */ + type: string; + /** + * Attribute status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` + */ + status: AttributeStatus; + /** + * Error message. Displays error generated on failure of creating or deleting an attribute. + */ + error: string; + /** + * Is attribute required? + */ + required: boolean; + /** + * Is attribute an array? + */ + array?: boolean; + /** + * Attribute creation date in ISO 8601 format. + */ + $createdAt: string; + /** + * Attribute update date in ISO 8601 format. + */ + $updatedAt: string; + } + + /** + * AttributeVector + */ + export type AttributeVector = { + /** + * Attribute Key. + */ + key: string; + /** + * Attribute type. + */ + type: string; + /** + * Attribute status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` + */ + status: AttributeStatus; + /** + * Error message. Displays error generated on failure of creating or deleting an attribute. + */ + error: string; + /** + * Is attribute required? + */ + required: boolean; + /** + * Is attribute an array? + */ + array?: boolean; + /** + * Attribute creation date in ISO 8601 format. + */ + $createdAt: string; + /** + * Attribute update date in ISO 8601 format. + */ + $updatedAt: string; + /** + * Vector dimensions. + */ + size: number; + } + /** * Table */ @@ -2415,7 +2617,7 @@ export namespace Models { /** * Row sequence ID. */ - $sequence: number; + $sequence: string; /** * Table ID. */ @@ -2454,7 +2656,7 @@ export namespace Models { /** * Document sequence ID. */ - $sequence: number; + $sequence: string; /** * Collection ID. */ @@ -2491,15 +2693,15 @@ export namespace Models { */ event: string; /** - * User ID. + * User ID of the actor recorded for this log. During impersonation, this is the original impersonator, not the impersonated target user. */ userId: string; /** - * User Email. + * User email of the actor recorded for this log. During impersonation, this is the original impersonator. */ userEmail: string; /** - * User Name. + * User name of the actor recorded for this log. During impersonation, this is the original impersonator. */ userName: string; /** @@ -2652,6 +2854,14 @@ export namespace Models { * Most recent access date in ISO 8601 format. This attribute is only updated again after 24 hours. */ accessedAt: string; + /** + * Whether the user can impersonate other users. + */ + impersonator?: boolean; + /** + * ID of the original actor performing the impersonation. Present only when the current request is impersonating another user. Internal audit logs attribute the action to this user, while the impersonated target is recorded only in internal audit payload data. + */ + impersonatorUserId?: string; } /** @@ -3309,6 +3519,10 @@ export namespace Models { * Site framework. */ framework: string; + /** + * How many days to keep the non-active deployments before they will be automatically deleted. + */ + deploymentRetention: number; /** * Site's active deployment ID. */ @@ -3353,6 +3567,10 @@ export namespace Models { * The build command used to build the site. */ buildCommand: string; + /** + * Custom command to use when starting site runtime. + */ + startCommand: string; /** * The directory where the site build output is located. */ @@ -3378,9 +3596,13 @@ export namespace Models { */ providerSilentMode: boolean; /** - * Machine specification for builds and executions. + * Machine specification for deployment builds. + */ + buildSpecification: string; + /** + * Machine specification for SSR executions. */ - specification: string; + runtimeSpecification: string; /** * Site build runtime. */ @@ -3435,6 +3657,10 @@ export namespace Models { * Function execution and build runtime. */ runtime: string; + /** + * How many days to keep the non-active deployments before they will be automatically deleted. + */ + deploymentRetention: number; /** * Function's active deployment ID. */ @@ -3508,9 +3734,13 @@ export namespace Models { */ providerSilentMode: boolean; /** - * Machine specification for builds and executions. + * Machine specification for deployment builds. */ - specification: string; + buildSpecification: string; + /** + * Machine specification for executions. + */ + runtimeSpecification: string; } /** @@ -3795,6 +4025,64 @@ export namespace Models { scheduledAt?: string; } + /** + * Webhook + */ + export type Webhook = { + /** + * Webhook ID. + */ + $id: string; + /** + * Webhook creation date in ISO 8601 format. + */ + $createdAt: string; + /** + * Webhook update date in ISO 8601 format. + */ + $updatedAt: string; + /** + * Webhook name. + */ + name: string; + /** + * Webhook URL endpoint. + */ + url: string; + /** + * Webhook trigger events. + */ + events: string[]; + /** + * Indicated if SSL / TLS Certificate verification is enabled. + */ + security: boolean; + /** + * HTTP basic authentication username. + */ + httpUser: string; + /** + * HTTP basic authentication password. + */ + httpPass: string; + /** + * Signature key which can be used to validated incoming + */ + signatureKey: string; + /** + * Indicates if this webhook is enabled. + */ + enabled: boolean; + /** + * Webhook error logs from the most recent failure. + */ + logs: string; + /** + * Number of consecutive failed webhook attempts. + */ + attempts: number; + } + /** * Variable */ diff --git a/src/services/databases.ts b/src/services/databases.ts index b559e71e..54b2eb0f 100644 --- a/src/services/databases.ts +++ b/src/services/databases.ts @@ -3,7 +3,7 @@ import type { Models } from '../models'; import { RelationshipType } from '../enums/relationship-type'; import { RelationMutate } from '../enums/relation-mutate'; -import { IndexType } from '../enums/index-type'; +import { DatabasesIndexType } from '../enums/databases-index-type'; import { OrderBy } from '../enums/order-by'; export class Databases { @@ -5757,7 +5757,7 @@ export class Databases { * @param {string} params.databaseId - Database ID. * @param {string} params.collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). * @param {string} params.key - Index Key. - * @param {IndexType} params.type - Index type. + * @param {DatabasesIndexType} params.type - Index type. * @param {string[]} params.attributes - Array of attributes to index. Maximum of 100 attributes are allowed, each 32 characters long. * @param {OrderBy[]} params.orders - Array of index orders. Maximum of 100 orders are allowed. * @param {number[]} params.lengths - Length of index. Maximum of 100 @@ -5765,7 +5765,7 @@ export class Databases { * @returns {Promise} * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.createIndex` instead. */ - createIndex(params: { databaseId: string, collectionId: string, key: string, type: IndexType, attributes: string[], orders?: OrderBy[], lengths?: number[] }): Promise; + createIndex(params: { databaseId: string, collectionId: string, key: string, type: DatabasesIndexType, attributes: string[], orders?: OrderBy[], lengths?: number[] }): Promise; /** * Creates an index on the attributes listed. Your index should include all the attributes you will query in a single request. * Attributes can be `key`, `fulltext`, and `unique`. @@ -5773,7 +5773,7 @@ export class Databases { * @param {string} databaseId - Database ID. * @param {string} collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). * @param {string} key - Index Key. - * @param {IndexType} type - Index type. + * @param {DatabasesIndexType} type - Index type. * @param {string[]} attributes - Array of attributes to index. Maximum of 100 attributes are allowed, each 32 characters long. * @param {OrderBy[]} orders - Array of index orders. Maximum of 100 orders are allowed. * @param {number[]} lengths - Length of index. Maximum of 100 @@ -5781,21 +5781,21 @@ export class Databases { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createIndex(databaseId: string, collectionId: string, key: string, type: IndexType, attributes: string[], orders?: OrderBy[], lengths?: number[]): Promise; + createIndex(databaseId: string, collectionId: string, key: string, type: DatabasesIndexType, attributes: string[], orders?: OrderBy[], lengths?: number[]): Promise; createIndex( - paramsOrFirst: { databaseId: string, collectionId: string, key: string, type: IndexType, attributes: string[], orders?: OrderBy[], lengths?: number[] } | string, - ...rest: [(string)?, (string)?, (IndexType)?, (string[])?, (OrderBy[])?, (number[])?] + paramsOrFirst: { databaseId: string, collectionId: string, key: string, type: DatabasesIndexType, attributes: string[], orders?: OrderBy[], lengths?: number[] } | string, + ...rest: [(string)?, (string)?, (DatabasesIndexType)?, (string[])?, (OrderBy[])?, (number[])?] ): Promise { - let params: { databaseId: string, collectionId: string, key: string, type: IndexType, attributes: string[], orders?: OrderBy[], lengths?: number[] }; + let params: { databaseId: string, collectionId: string, key: string, type: DatabasesIndexType, attributes: string[], orders?: OrderBy[], lengths?: number[] }; if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, key: string, type: IndexType, attributes: string[], orders?: OrderBy[], lengths?: number[] }; + params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, key: string, type: DatabasesIndexType, attributes: string[], orders?: OrderBy[], lengths?: number[] }; } else { params = { databaseId: paramsOrFirst as string, collectionId: rest[0] as string, key: rest[1] as string, - type: rest[2] as IndexType, + type: rest[2] as DatabasesIndexType, attributes: rest[3] as string[], orders: rest[4] as OrderBy[], lengths: rest[5] as number[] diff --git a/src/services/documents-db.ts b/src/services/documents-db.ts new file mode 100644 index 00000000..71dd25d7 --- /dev/null +++ b/src/services/documents-db.ts @@ -0,0 +1,2349 @@ +import { AppwriteException, Client, type Payload, UploadProgress } from '../client'; +import type { Models } from '../models'; + +import { DocumentsDBIndexType } from '../enums/documents-db-index-type'; +import { OrderBy } from '../enums/order-by'; + +export class DocumentsDB { + client: Client; + + constructor(client: Client) { + this.client = client; + } + + /** + * Get a list of all databases from the current Appwrite project. You can use the search parameter to filter your results. + * + * @param {string[]} params.queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following columns: name + * @param {string} params.search - Search term to filter your list results. Max length: 256 chars. + * @param {boolean} params.total - When set to false, the total count returned will be 0 and will not be calculated. + * @throws {AppwriteException} + * @returns {Promise} + */ + list(params?: { queries?: string[], search?: string, total?: boolean }): Promise; + /** + * Get a list of all databases from the current Appwrite project. You can use the search parameter to filter your results. + * + * @param {string[]} queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following columns: name + * @param {string} search - Search term to filter your list results. Max length: 256 chars. + * @param {boolean} total - When set to false, the total count returned will be 0 and will not be calculated. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + list(queries?: string[], search?: string, total?: boolean): Promise; + list( + paramsOrFirst?: { queries?: string[], search?: string, total?: boolean } | string[], + ...rest: [(string)?, (boolean)?] + ): Promise { + let params: { queries?: string[], search?: string, total?: boolean }; + + if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { queries?: string[], search?: string, total?: boolean }; + } else { + params = { + queries: paramsOrFirst as string[], + search: rest[0] as string, + total: rest[1] as boolean + }; + } + + const queries = params.queries; + const search = params.search; + const total = params.total; + + + const apiPath = '/documentsdb'; + const payload: Payload = {}; + if (typeof queries !== 'undefined') { + payload['queries'] = queries; + } + if (typeof search !== 'undefined') { + payload['search'] = search; + } + if (typeof total !== 'undefined') { + payload['total'] = total; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + } + + return this.client.call( + 'get', + uri, + apiHeaders, + payload, + ); + } + + /** + * Create a new Database. + * + * + * @param {string} params.databaseId - Unique Id. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + * @param {string} params.name - Database name. Max length: 128 chars. + * @param {boolean} params.enabled - Is the database enabled? When set to 'disabled', users cannot access the database but Server SDKs with an API key can still read and write to the database. No data is lost when this is toggled. + * @throws {AppwriteException} + * @returns {Promise} + */ + create(params: { databaseId: string, name: string, enabled?: boolean }): Promise; + /** + * Create a new Database. + * + * + * @param {string} databaseId - Unique Id. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + * @param {string} name - Database name. Max length: 128 chars. + * @param {boolean} enabled - Is the database enabled? When set to 'disabled', users cannot access the database but Server SDKs with an API key can still read and write to the database. No data is lost when this is toggled. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + create(databaseId: string, name: string, enabled?: boolean): Promise; + create( + paramsOrFirst: { databaseId: string, name: string, enabled?: boolean } | string, + ...rest: [(string)?, (boolean)?] + ): Promise { + let params: { databaseId: string, name: string, enabled?: boolean }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { databaseId: string, name: string, enabled?: boolean }; + } else { + params = { + databaseId: paramsOrFirst as string, + name: rest[0] as string, + enabled: rest[1] as boolean + }; + } + + const databaseId = params.databaseId; + const name = params.name; + const enabled = params.enabled; + + if (typeof databaseId === 'undefined') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + if (typeof name === 'undefined') { + throw new AppwriteException('Missing required parameter: "name"'); + } + + const apiPath = '/documentsdb'; + const payload: Payload = {}; + if (typeof databaseId !== 'undefined') { + payload['databaseId'] = databaseId; + } + if (typeof name !== 'undefined') { + payload['name'] = name; + } + if (typeof enabled !== 'undefined') { + payload['enabled'] = enabled; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'post', + uri, + apiHeaders, + payload, + ); + } + + /** + * + * @param {string[]} params.queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). + * @throws {AppwriteException} + * @returns {Promise} + */ + listTransactions(params?: { queries?: string[] }): Promise; + /** + * + * @param {string[]} queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + listTransactions(queries?: string[]): Promise; + listTransactions( + paramsOrFirst?: { queries?: string[] } | string[] + ): Promise { + let params: { queries?: string[] }; + + if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { queries?: string[] }; + } else { + params = { + queries: paramsOrFirst as string[] + }; + } + + const queries = params.queries; + + + const apiPath = '/documentsdb/transactions'; + const payload: Payload = {}; + if (typeof queries !== 'undefined') { + payload['queries'] = queries; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + } + + return this.client.call( + 'get', + uri, + apiHeaders, + payload, + ); + } + + /** + * + * @param {number} params.ttl - Seconds before the transaction expires. + * @throws {AppwriteException} + * @returns {Promise} + */ + createTransaction(params?: { ttl?: number }): Promise; + /** + * + * @param {number} ttl - Seconds before the transaction expires. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createTransaction(ttl?: number): Promise; + createTransaction( + paramsOrFirst?: { ttl?: number } | number + ): Promise { + let params: { ttl?: number }; + + if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { ttl?: number }; + } else { + params = { + ttl: paramsOrFirst as number + }; + } + + const ttl = params.ttl; + + + const apiPath = '/documentsdb/transactions'; + const payload: Payload = {}; + if (typeof ttl !== 'undefined') { + payload['ttl'] = ttl; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'post', + uri, + apiHeaders, + payload, + ); + } + + /** + * + * @param {string} params.transactionId - Transaction ID. + * @throws {AppwriteException} + * @returns {Promise} + */ + getTransaction(params: { transactionId: string }): Promise; + /** + * + * @param {string} transactionId - Transaction ID. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + getTransaction(transactionId: string): Promise; + getTransaction( + paramsOrFirst: { transactionId: string } | string + ): Promise { + let params: { transactionId: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { transactionId: string }; + } else { + params = { + transactionId: paramsOrFirst as string + }; + } + + const transactionId = params.transactionId; + + if (typeof transactionId === 'undefined') { + throw new AppwriteException('Missing required parameter: "transactionId"'); + } + + const apiPath = '/documentsdb/transactions/{transactionId}'.replace('{transactionId}', transactionId); + const payload: Payload = {}; + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + } + + return this.client.call( + 'get', + uri, + apiHeaders, + payload, + ); + } + + /** + * + * @param {string} params.transactionId - Transaction ID. + * @param {boolean} params.commit - Commit transaction? + * @param {boolean} params.rollback - Rollback transaction? + * @throws {AppwriteException} + * @returns {Promise} + */ + updateTransaction(params: { transactionId: string, commit?: boolean, rollback?: boolean }): Promise; + /** + * + * @param {string} transactionId - Transaction ID. + * @param {boolean} commit - Commit transaction? + * @param {boolean} rollback - Rollback transaction? + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateTransaction(transactionId: string, commit?: boolean, rollback?: boolean): Promise; + updateTransaction( + paramsOrFirst: { transactionId: string, commit?: boolean, rollback?: boolean } | string, + ...rest: [(boolean)?, (boolean)?] + ): Promise { + let params: { transactionId: string, commit?: boolean, rollback?: boolean }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { transactionId: string, commit?: boolean, rollback?: boolean }; + } else { + params = { + transactionId: paramsOrFirst as string, + commit: rest[0] as boolean, + rollback: rest[1] as boolean + }; + } + + const transactionId = params.transactionId; + const commit = params.commit; + const rollback = params.rollback; + + if (typeof transactionId === 'undefined') { + throw new AppwriteException('Missing required parameter: "transactionId"'); + } + + const apiPath = '/documentsdb/transactions/{transactionId}'.replace('{transactionId}', transactionId); + const payload: Payload = {}; + if (typeof commit !== 'undefined') { + payload['commit'] = commit; + } + if (typeof rollback !== 'undefined') { + payload['rollback'] = rollback; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'patch', + uri, + apiHeaders, + payload, + ); + } + + /** + * + * @param {string} params.transactionId - Transaction ID. + * @throws {AppwriteException} + * @returns {Promise<{}>} + */ + deleteTransaction(params: { transactionId: string }): Promise<{}>; + /** + * + * @param {string} transactionId - Transaction ID. + * @throws {AppwriteException} + * @returns {Promise<{}>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + deleteTransaction(transactionId: string): Promise<{}>; + deleteTransaction( + paramsOrFirst: { transactionId: string } | string + ): Promise<{}> { + let params: { transactionId: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { transactionId: string }; + } else { + params = { + transactionId: paramsOrFirst as string + }; + } + + const transactionId = params.transactionId; + + if (typeof transactionId === 'undefined') { + throw new AppwriteException('Missing required parameter: "transactionId"'); + } + + const apiPath = '/documentsdb/transactions/{transactionId}'.replace('{transactionId}', transactionId); + const payload: Payload = {}; + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'delete', + uri, + apiHeaders, + payload, + ); + } + + /** + * + * @param {string} params.transactionId - Transaction ID. + * @param {object[]} params.operations - Array of staged operations. + * @throws {AppwriteException} + * @returns {Promise} + */ + createOperations(params: { transactionId: string, operations?: object[] }): Promise; + /** + * + * @param {string} transactionId - Transaction ID. + * @param {object[]} operations - Array of staged operations. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createOperations(transactionId: string, operations?: object[]): Promise; + createOperations( + paramsOrFirst: { transactionId: string, operations?: object[] } | string, + ...rest: [(object[])?] + ): Promise { + let params: { transactionId: string, operations?: object[] }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { transactionId: string, operations?: object[] }; + } else { + params = { + transactionId: paramsOrFirst as string, + operations: rest[0] as object[] + }; + } + + const transactionId = params.transactionId; + const operations = params.operations; + + if (typeof transactionId === 'undefined') { + throw new AppwriteException('Missing required parameter: "transactionId"'); + } + + const apiPath = '/documentsdb/transactions/{transactionId}/operations'.replace('{transactionId}', transactionId); + const payload: Payload = {}; + if (typeof operations !== 'undefined') { + payload['operations'] = operations; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'post', + uri, + apiHeaders, + payload, + ); + } + + /** + * Get a database by its unique ID. This endpoint response returns a JSON object with the database metadata. + * + * @param {string} params.databaseId - Database ID. + * @throws {AppwriteException} + * @returns {Promise} + */ + get(params: { databaseId: string }): Promise; + /** + * Get a database by its unique ID. This endpoint response returns a JSON object with the database metadata. + * + * @param {string} databaseId - Database ID. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + get(databaseId: string): Promise; + get( + paramsOrFirst: { databaseId: string } | string + ): Promise { + let params: { databaseId: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { databaseId: string }; + } else { + params = { + databaseId: paramsOrFirst as string + }; + } + + const databaseId = params.databaseId; + + if (typeof databaseId === 'undefined') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + const apiPath = '/documentsdb/{databaseId}'.replace('{databaseId}', databaseId); + const payload: Payload = {}; + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + } + + return this.client.call( + 'get', + uri, + apiHeaders, + payload, + ); + } + + /** + * Update a database by its unique ID. + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.name - Database name. Max length: 128 chars. + * @param {boolean} params.enabled - Is database enabled? When set to 'disabled', users cannot access the database but Server SDKs with an API key can still read and write to the database. No data is lost when this is toggled. + * @throws {AppwriteException} + * @returns {Promise} + */ + update(params: { databaseId: string, name: string, enabled?: boolean }): Promise; + /** + * Update a database by its unique ID. + * + * @param {string} databaseId - Database ID. + * @param {string} name - Database name. Max length: 128 chars. + * @param {boolean} enabled - Is database enabled? When set to 'disabled', users cannot access the database but Server SDKs with an API key can still read and write to the database. No data is lost when this is toggled. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + update(databaseId: string, name: string, enabled?: boolean): Promise; + update( + paramsOrFirst: { databaseId: string, name: string, enabled?: boolean } | string, + ...rest: [(string)?, (boolean)?] + ): Promise { + let params: { databaseId: string, name: string, enabled?: boolean }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { databaseId: string, name: string, enabled?: boolean }; + } else { + params = { + databaseId: paramsOrFirst as string, + name: rest[0] as string, + enabled: rest[1] as boolean + }; + } + + const databaseId = params.databaseId; + const name = params.name; + const enabled = params.enabled; + + if (typeof databaseId === 'undefined') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + if (typeof name === 'undefined') { + throw new AppwriteException('Missing required parameter: "name"'); + } + + const apiPath = '/documentsdb/{databaseId}'.replace('{databaseId}', databaseId); + const payload: Payload = {}; + if (typeof name !== 'undefined') { + payload['name'] = name; + } + if (typeof enabled !== 'undefined') { + payload['enabled'] = enabled; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'put', + uri, + apiHeaders, + payload, + ); + } + + /** + * Delete a database by its unique ID. Only API keys with with databases.write scope can delete a database. + * + * @param {string} params.databaseId - Database ID. + * @throws {AppwriteException} + * @returns {Promise<{}>} + */ + delete(params: { databaseId: string }): Promise<{}>; + /** + * Delete a database by its unique ID. Only API keys with with databases.write scope can delete a database. + * + * @param {string} databaseId - Database ID. + * @throws {AppwriteException} + * @returns {Promise<{}>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + delete(databaseId: string): Promise<{}>; + delete( + paramsOrFirst: { databaseId: string } | string + ): Promise<{}> { + let params: { databaseId: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { databaseId: string }; + } else { + params = { + databaseId: paramsOrFirst as string + }; + } + + const databaseId = params.databaseId; + + if (typeof databaseId === 'undefined') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + const apiPath = '/documentsdb/{databaseId}'.replace('{databaseId}', databaseId); + const payload: Payload = {}; + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'delete', + uri, + apiHeaders, + payload, + ); + } + + /** + * Get a list of all collections that belong to the provided databaseId. You can use the search parameter to filter your results. + * + * @param {string} params.databaseId - Database ID. + * @param {string[]} params.queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: name, enabled, documentSecurity + * @param {string} params.search - Search term to filter your list results. Max length: 256 chars. + * @param {boolean} params.total - When set to false, the total count returned will be 0 and will not be calculated. + * @throws {AppwriteException} + * @returns {Promise} + */ + listCollections(params: { databaseId: string, queries?: string[], search?: string, total?: boolean }): Promise; + /** + * Get a list of all collections that belong to the provided databaseId. You can use the search parameter to filter your results. + * + * @param {string} databaseId - Database ID. + * @param {string[]} queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: name, enabled, documentSecurity + * @param {string} search - Search term to filter your list results. Max length: 256 chars. + * @param {boolean} total - When set to false, the total count returned will be 0 and will not be calculated. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + listCollections(databaseId: string, queries?: string[], search?: string, total?: boolean): Promise; + listCollections( + paramsOrFirst: { databaseId: string, queries?: string[], search?: string, total?: boolean } | string, + ...rest: [(string[])?, (string)?, (boolean)?] + ): Promise { + let params: { databaseId: string, queries?: string[], search?: string, total?: boolean }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { databaseId: string, queries?: string[], search?: string, total?: boolean }; + } else { + params = { + databaseId: paramsOrFirst as string, + queries: rest[0] as string[], + search: rest[1] as string, + total: rest[2] as boolean + }; + } + + const databaseId = params.databaseId; + const queries = params.queries; + const search = params.search; + const total = params.total; + + if (typeof databaseId === 'undefined') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + const apiPath = '/documentsdb/{databaseId}/collections'.replace('{databaseId}', databaseId); + const payload: Payload = {}; + if (typeof queries !== 'undefined') { + payload['queries'] = queries; + } + if (typeof search !== 'undefined') { + payload['search'] = search; + } + if (typeof total !== 'undefined') { + payload['total'] = total; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + } + + return this.client.call( + 'get', + uri, + apiHeaders, + payload, + ); + } + + /** + * Create a new Collection. Before using this route, you should create a new database resource using either a [server integration](https://appwrite.io/docs/server/databases#documentsDBCreateCollection) API or directly from your database console. + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.collectionId - Unique Id. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + * @param {string} params.name - Collection name. Max length: 128 chars. + * @param {string[]} params.permissions - An array of permissions strings. By default, no user is granted with any permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). + * @param {boolean} params.documentSecurity - Enables configuring permissions for individual documents. A user needs one of document or collection level permissions to access a document. [Learn more about permissions](https://appwrite.io/docs/permissions). + * @param {boolean} params.enabled - Is collection enabled? When set to 'disabled', users cannot access the collection but Server SDKs with and API key can still read and write to the collection. No data is lost when this is toggled. + * @param {object[]} params.attributes - Array of attribute definitions to create. Each attribute should contain: key (string), type (string: string, integer, float, boolean, datetime, relationship), size (integer, required for string type), required (boolean, optional), default (mixed, optional), array (boolean, optional), and type-specific options. + * @param {object[]} params.indexes - Array of index definitions to create. Each index should contain: key (string), type (string: key, fulltext, unique, spatial), attributes (array of attribute keys), orders (array of ASC/DESC, optional), and lengths (array of integers, optional). + * @throws {AppwriteException} + * @returns {Promise} + */ + createCollection(params: { databaseId: string, collectionId: string, name: string, permissions?: string[], documentSecurity?: boolean, enabled?: boolean, attributes?: object[], indexes?: object[] }): Promise; + /** + * Create a new Collection. Before using this route, you should create a new database resource using either a [server integration](https://appwrite.io/docs/server/databases#documentsDBCreateCollection) API or directly from your database console. + * + * @param {string} databaseId - Database ID. + * @param {string} collectionId - Unique Id. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + * @param {string} name - Collection name. Max length: 128 chars. + * @param {string[]} permissions - An array of permissions strings. By default, no user is granted with any permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). + * @param {boolean} documentSecurity - Enables configuring permissions for individual documents. A user needs one of document or collection level permissions to access a document. [Learn more about permissions](https://appwrite.io/docs/permissions). + * @param {boolean} enabled - Is collection enabled? When set to 'disabled', users cannot access the collection but Server SDKs with and API key can still read and write to the collection. No data is lost when this is toggled. + * @param {object[]} attributes - Array of attribute definitions to create. Each attribute should contain: key (string), type (string: string, integer, float, boolean, datetime, relationship), size (integer, required for string type), required (boolean, optional), default (mixed, optional), array (boolean, optional), and type-specific options. + * @param {object[]} indexes - Array of index definitions to create. Each index should contain: key (string), type (string: key, fulltext, unique, spatial), attributes (array of attribute keys), orders (array of ASC/DESC, optional), and lengths (array of integers, optional). + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createCollection(databaseId: string, collectionId: string, name: string, permissions?: string[], documentSecurity?: boolean, enabled?: boolean, attributes?: object[], indexes?: object[]): Promise; + createCollection( + paramsOrFirst: { databaseId: string, collectionId: string, name: string, permissions?: string[], documentSecurity?: boolean, enabled?: boolean, attributes?: object[], indexes?: object[] } | string, + ...rest: [(string)?, (string)?, (string[])?, (boolean)?, (boolean)?, (object[])?, (object[])?] + ): Promise { + let params: { databaseId: string, collectionId: string, name: string, permissions?: string[], documentSecurity?: boolean, enabled?: boolean, attributes?: object[], indexes?: object[] }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, name: string, permissions?: string[], documentSecurity?: boolean, enabled?: boolean, attributes?: object[], indexes?: object[] }; + } else { + params = { + databaseId: paramsOrFirst as string, + collectionId: rest[0] as string, + name: rest[1] as string, + permissions: rest[2] as string[], + documentSecurity: rest[3] as boolean, + enabled: rest[4] as boolean, + attributes: rest[5] as object[], + indexes: rest[6] as object[] + }; + } + + const databaseId = params.databaseId; + const collectionId = params.collectionId; + const name = params.name; + const permissions = params.permissions; + const documentSecurity = params.documentSecurity; + const enabled = params.enabled; + const attributes = params.attributes; + const indexes = params.indexes; + + if (typeof databaseId === 'undefined') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + if (typeof collectionId === 'undefined') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + if (typeof name === 'undefined') { + throw new AppwriteException('Missing required parameter: "name"'); + } + + const apiPath = '/documentsdb/{databaseId}/collections'.replace('{databaseId}', databaseId); + const payload: Payload = {}; + if (typeof collectionId !== 'undefined') { + payload['collectionId'] = collectionId; + } + if (typeof name !== 'undefined') { + payload['name'] = name; + } + if (typeof permissions !== 'undefined') { + payload['permissions'] = permissions; + } + if (typeof documentSecurity !== 'undefined') { + payload['documentSecurity'] = documentSecurity; + } + if (typeof enabled !== 'undefined') { + payload['enabled'] = enabled; + } + if (typeof attributes !== 'undefined') { + payload['attributes'] = attributes; + } + if (typeof indexes !== 'undefined') { + payload['indexes'] = indexes; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'post', + uri, + apiHeaders, + payload, + ); + } + + /** + * Get a collection by its unique ID. This endpoint response returns a JSON object with the collection metadata. + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.collectionId - Collection ID. + * @throws {AppwriteException} + * @returns {Promise} + */ + getCollection(params: { databaseId: string, collectionId: string }): Promise; + /** + * Get a collection by its unique ID. This endpoint response returns a JSON object with the collection metadata. + * + * @param {string} databaseId - Database ID. + * @param {string} collectionId - Collection ID. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + getCollection(databaseId: string, collectionId: string): Promise; + getCollection( + paramsOrFirst: { databaseId: string, collectionId: string } | string, + ...rest: [(string)?] + ): Promise { + let params: { databaseId: string, collectionId: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string }; + } else { + params = { + databaseId: paramsOrFirst as string, + collectionId: rest[0] as string + }; + } + + const databaseId = params.databaseId; + const collectionId = params.collectionId; + + if (typeof databaseId === 'undefined') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + if (typeof collectionId === 'undefined') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + + const apiPath = '/documentsdb/{databaseId}/collections/{collectionId}'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId); + const payload: Payload = {}; + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + } + + return this.client.call( + 'get', + uri, + apiHeaders, + payload, + ); + } + + /** + * Update a collection by its unique ID. + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.collectionId - Collection ID. + * @param {string} params.name - Collection name. Max length: 128 chars. + * @param {string[]} params.permissions - An array of permission strings. By default, the current permissions are inherited. [Learn more about permissions](https://appwrite.io/docs/permissions). + * @param {boolean} params.documentSecurity - Enables configuring permissions for individual documents. A user needs one of document or collection level permissions to access a document. [Learn more about permissions](https://appwrite.io/docs/permissions). + * @param {boolean} params.enabled - Is collection enabled? When set to 'disabled', users cannot access the collection but Server SDKs with and API key can still read and write to the collection. No data is lost when this is toggled. + * @throws {AppwriteException} + * @returns {Promise} + */ + updateCollection(params: { databaseId: string, collectionId: string, name: string, permissions?: string[], documentSecurity?: boolean, enabled?: boolean }): Promise; + /** + * Update a collection by its unique ID. + * + * @param {string} databaseId - Database ID. + * @param {string} collectionId - Collection ID. + * @param {string} name - Collection name. Max length: 128 chars. + * @param {string[]} permissions - An array of permission strings. By default, the current permissions are inherited. [Learn more about permissions](https://appwrite.io/docs/permissions). + * @param {boolean} documentSecurity - Enables configuring permissions for individual documents. A user needs one of document or collection level permissions to access a document. [Learn more about permissions](https://appwrite.io/docs/permissions). + * @param {boolean} enabled - Is collection enabled? When set to 'disabled', users cannot access the collection but Server SDKs with and API key can still read and write to the collection. No data is lost when this is toggled. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateCollection(databaseId: string, collectionId: string, name: string, permissions?: string[], documentSecurity?: boolean, enabled?: boolean): Promise; + updateCollection( + paramsOrFirst: { databaseId: string, collectionId: string, name: string, permissions?: string[], documentSecurity?: boolean, enabled?: boolean } | string, + ...rest: [(string)?, (string)?, (string[])?, (boolean)?, (boolean)?] + ): Promise { + let params: { databaseId: string, collectionId: string, name: string, permissions?: string[], documentSecurity?: boolean, enabled?: boolean }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, name: string, permissions?: string[], documentSecurity?: boolean, enabled?: boolean }; + } else { + params = { + databaseId: paramsOrFirst as string, + collectionId: rest[0] as string, + name: rest[1] as string, + permissions: rest[2] as string[], + documentSecurity: rest[3] as boolean, + enabled: rest[4] as boolean + }; + } + + const databaseId = params.databaseId; + const collectionId = params.collectionId; + const name = params.name; + const permissions = params.permissions; + const documentSecurity = params.documentSecurity; + const enabled = params.enabled; + + if (typeof databaseId === 'undefined') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + if (typeof collectionId === 'undefined') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + if (typeof name === 'undefined') { + throw new AppwriteException('Missing required parameter: "name"'); + } + + const apiPath = '/documentsdb/{databaseId}/collections/{collectionId}'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId); + const payload: Payload = {}; + if (typeof name !== 'undefined') { + payload['name'] = name; + } + if (typeof permissions !== 'undefined') { + payload['permissions'] = permissions; + } + if (typeof documentSecurity !== 'undefined') { + payload['documentSecurity'] = documentSecurity; + } + if (typeof enabled !== 'undefined') { + payload['enabled'] = enabled; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'put', + uri, + apiHeaders, + payload, + ); + } + + /** + * Delete a collection by its unique ID. Only users with write permissions have access to delete this resource. + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.collectionId - Collection ID. + * @throws {AppwriteException} + * @returns {Promise<{}>} + */ + deleteCollection(params: { databaseId: string, collectionId: string }): Promise<{}>; + /** + * Delete a collection by its unique ID. Only users with write permissions have access to delete this resource. + * + * @param {string} databaseId - Database ID. + * @param {string} collectionId - Collection ID. + * @throws {AppwriteException} + * @returns {Promise<{}>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + deleteCollection(databaseId: string, collectionId: string): Promise<{}>; + deleteCollection( + paramsOrFirst: { databaseId: string, collectionId: string } | string, + ...rest: [(string)?] + ): Promise<{}> { + let params: { databaseId: string, collectionId: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string }; + } else { + params = { + databaseId: paramsOrFirst as string, + collectionId: rest[0] as string + }; + } + + const databaseId = params.databaseId; + const collectionId = params.collectionId; + + if (typeof databaseId === 'undefined') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + if (typeof collectionId === 'undefined') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + + const apiPath = '/documentsdb/{databaseId}/collections/{collectionId}'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId); + const payload: Payload = {}; + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'delete', + uri, + apiHeaders, + payload, + ); + } + + /** + * Get a list of all the user's documents in a given collection. You can use the query params to filter your results. + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). + * @param {string[]} params.queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. + * @param {string} params.transactionId - Transaction ID to read uncommitted changes within the transaction. + * @param {boolean} params.total - When set to false, the total count returned will be 0 and will not be calculated. + * @param {number} params.ttl - TTL (seconds) for cached responses when caching is enabled for select queries. Must be between 0 and 86400 (24 hours). + * @throws {AppwriteException} + * @returns {Promise>} + */ + listDocuments(params: { databaseId: string, collectionId: string, queries?: string[], transactionId?: string, total?: boolean, ttl?: number }): Promise>; + /** + * Get a list of all the user's documents in a given collection. You can use the query params to filter your results. + * + * @param {string} databaseId - Database ID. + * @param {string} collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). + * @param {string[]} queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. + * @param {string} transactionId - Transaction ID to read uncommitted changes within the transaction. + * @param {boolean} total - When set to false, the total count returned will be 0 and will not be calculated. + * @param {number} ttl - TTL (seconds) for cached responses when caching is enabled for select queries. Must be between 0 and 86400 (24 hours). + * @throws {AppwriteException} + * @returns {Promise>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + listDocuments(databaseId: string, collectionId: string, queries?: string[], transactionId?: string, total?: boolean, ttl?: number): Promise>; + listDocuments( + paramsOrFirst: { databaseId: string, collectionId: string, queries?: string[], transactionId?: string, total?: boolean, ttl?: number } | string, + ...rest: [(string)?, (string[])?, (string)?, (boolean)?, (number)?] + ): Promise> { + let params: { databaseId: string, collectionId: string, queries?: string[], transactionId?: string, total?: boolean, ttl?: number }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, queries?: string[], transactionId?: string, total?: boolean, ttl?: number }; + } else { + params = { + databaseId: paramsOrFirst as string, + collectionId: rest[0] as string, + queries: rest[1] as string[], + transactionId: rest[2] as string, + total: rest[3] as boolean, + ttl: rest[4] as number + }; + } + + const databaseId = params.databaseId; + const collectionId = params.collectionId; + const queries = params.queries; + const transactionId = params.transactionId; + const total = params.total; + const ttl = params.ttl; + + if (typeof databaseId === 'undefined') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + if (typeof collectionId === 'undefined') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + + const apiPath = '/documentsdb/{databaseId}/collections/{collectionId}/documents'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId); + const payload: Payload = {}; + if (typeof queries !== 'undefined') { + payload['queries'] = queries; + } + if (typeof transactionId !== 'undefined') { + payload['transactionId'] = transactionId; + } + if (typeof total !== 'undefined') { + payload['total'] = total; + } + if (typeof ttl !== 'undefined') { + payload['ttl'] = ttl; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + } + + return this.client.call( + 'get', + uri, + apiHeaders, + payload, + ); + } + + /** + * Create a new Document. Before using this route, you should create a new collection resource using either a [server integration](https://appwrite.io/docs/server/databases#documentsDBCreateCollection) API or directly from your database console. + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). Make sure to define attributes before creating documents. + * @param {string} params.documentId - Document ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + * @param {Document extends Models.DefaultDocument ? Partial & Record : Partial & Omit} params.data - Document data as JSON object. + * @param {string[]} params.permissions - An array of permissions strings. By default, only the current user is granted all permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). + * @throws {AppwriteException} + * @returns {Promise} + */ + createDocument(params: { databaseId: string, collectionId: string, documentId: string, data: Document extends Models.DefaultDocument ? Partial & Record : Partial & Omit, permissions?: string[] }): Promise; + /** + * Create a new Document. Before using this route, you should create a new collection resource using either a [server integration](https://appwrite.io/docs/server/databases#documentsDBCreateCollection) API or directly from your database console. + * + * @param {string} databaseId - Database ID. + * @param {string} collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). Make sure to define attributes before creating documents. + * @param {string} documentId - Document ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + * @param {Document extends Models.DefaultDocument ? Partial & Record : Partial & Omit} data - Document data as JSON object. + * @param {string[]} permissions - An array of permissions strings. By default, only the current user is granted all permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createDocument(databaseId: string, collectionId: string, documentId: string, data: Document extends Models.DefaultDocument ? Partial & Record : Partial & Omit, permissions?: string[]): Promise; + createDocument( + paramsOrFirst: { databaseId: string, collectionId: string, documentId: string, data: Document extends Models.DefaultDocument ? Partial & Record : Partial & Omit, permissions?: string[] } | string, + ...rest: [(string)?, (string)?, (Document extends Models.DefaultDocument ? Partial & Record : Partial & Omit)?, (string[])?] + ): Promise { + let params: { databaseId: string, collectionId: string, documentId: string, data: Document extends Models.DefaultDocument ? Partial & Record : Partial & Omit, permissions?: string[] }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, documentId: string, data: Document extends Models.DefaultDocument ? Partial & Record : Partial & Omit, permissions?: string[] }; + } else { + params = { + databaseId: paramsOrFirst as string, + collectionId: rest[0] as string, + documentId: rest[1] as string, + data: rest[2] as Document extends Models.DefaultDocument ? Partial & Record : Partial & Omit, + permissions: rest[3] as string[] + }; + } + + const databaseId = params.databaseId; + const collectionId = params.collectionId; + const documentId = params.documentId; + const data = params.data; + const permissions = params.permissions; + + if (typeof databaseId === 'undefined') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + if (typeof collectionId === 'undefined') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + if (typeof documentId === 'undefined') { + throw new AppwriteException('Missing required parameter: "documentId"'); + } + if (typeof data === 'undefined') { + throw new AppwriteException('Missing required parameter: "data"'); + } + + const apiPath = '/documentsdb/{databaseId}/collections/{collectionId}/documents'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId); + const payload: Payload = {}; + if (typeof documentId !== 'undefined') { + payload['documentId'] = documentId; + } + if (typeof data !== 'undefined') { + payload['data'] = data; + } + if (typeof permissions !== 'undefined') { + payload['permissions'] = permissions; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'post', + uri, + apiHeaders, + payload, + ); + } + + /** + * Create new Documents. Before using this route, you should create a new collection resource using either a [server integration](https://appwrite.io/docs/server/databases#documentsDBCreateCollection) API or directly from your database console. + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). Make sure to define attributes before creating documents. + * @param {object[]} params.documents - Array of documents data as JSON objects. + * @throws {AppwriteException} + * @returns {Promise>} + */ + createDocuments(params: { databaseId: string, collectionId: string, documents: object[] }): Promise>; + /** + * Create new Documents. Before using this route, you should create a new collection resource using either a [server integration](https://appwrite.io/docs/server/databases#documentsDBCreateCollection) API or directly from your database console. + * + * @param {string} databaseId - Database ID. + * @param {string} collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). Make sure to define attributes before creating documents. + * @param {object[]} documents - Array of documents data as JSON objects. + * @throws {AppwriteException} + * @returns {Promise>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createDocuments(databaseId: string, collectionId: string, documents: object[]): Promise>; + createDocuments( + paramsOrFirst: { databaseId: string, collectionId: string, documents: object[] } | string, + ...rest: [(string)?, (object[])?] + ): Promise> { + let params: { databaseId: string, collectionId: string, documents: object[] }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, documents: object[] }; + } else { + params = { + databaseId: paramsOrFirst as string, + collectionId: rest[0] as string, + documents: rest[1] as object[] + }; + } + + const databaseId = params.databaseId; + const collectionId = params.collectionId; + const documents = params.documents; + + if (typeof databaseId === 'undefined') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + if (typeof collectionId === 'undefined') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + if (typeof documents === 'undefined') { + throw new AppwriteException('Missing required parameter: "documents"'); + } + + const apiPath = '/documentsdb/{databaseId}/collections/{collectionId}/documents'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId); + const payload: Payload = {}; + if (typeof documents !== 'undefined') { + payload['documents'] = documents; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'post', + uri, + apiHeaders, + payload, + ); + } + + /** + * Create or update Documents. Before using this route, you should create a new collection resource using either a [server integration](https://appwrite.io/docs/server/databases#documentsDBCreateCollection) API or directly from your database console. + * + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.collectionId - Collection ID. + * @param {object[]} params.documents - Array of document data as JSON objects. May contain partial documents. + * @param {string} params.transactionId - Transaction ID for staging the operation. + * @throws {AppwriteException} + * @returns {Promise>} + */ + upsertDocuments(params: { databaseId: string, collectionId: string, documents: object[], transactionId?: string }): Promise>; + /** + * Create or update Documents. Before using this route, you should create a new collection resource using either a [server integration](https://appwrite.io/docs/server/databases#documentsDBCreateCollection) API or directly from your database console. + * + * + * @param {string} databaseId - Database ID. + * @param {string} collectionId - Collection ID. + * @param {object[]} documents - Array of document data as JSON objects. May contain partial documents. + * @param {string} transactionId - Transaction ID for staging the operation. + * @throws {AppwriteException} + * @returns {Promise>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + upsertDocuments(databaseId: string, collectionId: string, documents: object[], transactionId?: string): Promise>; + upsertDocuments( + paramsOrFirst: { databaseId: string, collectionId: string, documents: object[], transactionId?: string } | string, + ...rest: [(string)?, (object[])?, (string)?] + ): Promise> { + let params: { databaseId: string, collectionId: string, documents: object[], transactionId?: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, documents: object[], transactionId?: string }; + } else { + params = { + databaseId: paramsOrFirst as string, + collectionId: rest[0] as string, + documents: rest[1] as object[], + transactionId: rest[2] as string + }; + } + + const databaseId = params.databaseId; + const collectionId = params.collectionId; + const documents = params.documents; + const transactionId = params.transactionId; + + if (typeof databaseId === 'undefined') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + if (typeof collectionId === 'undefined') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + if (typeof documents === 'undefined') { + throw new AppwriteException('Missing required parameter: "documents"'); + } + + const apiPath = '/documentsdb/{databaseId}/collections/{collectionId}/documents'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId); + const payload: Payload = {}; + if (typeof documents !== 'undefined') { + payload['documents'] = documents; + } + if (typeof transactionId !== 'undefined') { + payload['transactionId'] = transactionId; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'put', + uri, + apiHeaders, + payload, + ); + } + + /** + * Update all documents that match your queries, if no queries are submitted then all documents are updated. You can pass only specific fields to be updated. + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.collectionId - Collection ID. + * @param {object} params.data - Document data as JSON object. Include only attribute and value pairs to be updated. + * @param {string[]} params.queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. + * @param {string} params.transactionId - Transaction ID for staging the operation. + * @throws {AppwriteException} + * @returns {Promise>} + */ + updateDocuments(params: { databaseId: string, collectionId: string, data?: object, queries?: string[], transactionId?: string }): Promise>; + /** + * Update all documents that match your queries, if no queries are submitted then all documents are updated. You can pass only specific fields to be updated. + * + * @param {string} databaseId - Database ID. + * @param {string} collectionId - Collection ID. + * @param {object} data - Document data as JSON object. Include only attribute and value pairs to be updated. + * @param {string[]} queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. + * @param {string} transactionId - Transaction ID for staging the operation. + * @throws {AppwriteException} + * @returns {Promise>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateDocuments(databaseId: string, collectionId: string, data?: object, queries?: string[], transactionId?: string): Promise>; + updateDocuments( + paramsOrFirst: { databaseId: string, collectionId: string, data?: object, queries?: string[], transactionId?: string } | string, + ...rest: [(string)?, (object)?, (string[])?, (string)?] + ): Promise> { + let params: { databaseId: string, collectionId: string, data?: object, queries?: string[], transactionId?: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, data?: object, queries?: string[], transactionId?: string }; + } else { + params = { + databaseId: paramsOrFirst as string, + collectionId: rest[0] as string, + data: rest[1] as object, + queries: rest[2] as string[], + transactionId: rest[3] as string + }; + } + + const databaseId = params.databaseId; + const collectionId = params.collectionId; + const data = params.data; + const queries = params.queries; + const transactionId = params.transactionId; + + if (typeof databaseId === 'undefined') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + if (typeof collectionId === 'undefined') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + + const apiPath = '/documentsdb/{databaseId}/collections/{collectionId}/documents'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId); + const payload: Payload = {}; + if (typeof data !== 'undefined') { + payload['data'] = data; + } + if (typeof queries !== 'undefined') { + payload['queries'] = queries; + } + if (typeof transactionId !== 'undefined') { + payload['transactionId'] = transactionId; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'patch', + uri, + apiHeaders, + payload, + ); + } + + /** + * Bulk delete documents using queries, if no queries are passed then all documents are deleted. + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). + * @param {string[]} params.queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. + * @param {string} params.transactionId - Transaction ID for staging the operation. + * @throws {AppwriteException} + * @returns {Promise>} + */ + deleteDocuments(params: { databaseId: string, collectionId: string, queries?: string[], transactionId?: string }): Promise>; + /** + * Bulk delete documents using queries, if no queries are passed then all documents are deleted. + * + * @param {string} databaseId - Database ID. + * @param {string} collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). + * @param {string[]} queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. + * @param {string} transactionId - Transaction ID for staging the operation. + * @throws {AppwriteException} + * @returns {Promise>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + deleteDocuments(databaseId: string, collectionId: string, queries?: string[], transactionId?: string): Promise>; + deleteDocuments( + paramsOrFirst: { databaseId: string, collectionId: string, queries?: string[], transactionId?: string } | string, + ...rest: [(string)?, (string[])?, (string)?] + ): Promise> { + let params: { databaseId: string, collectionId: string, queries?: string[], transactionId?: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, queries?: string[], transactionId?: string }; + } else { + params = { + databaseId: paramsOrFirst as string, + collectionId: rest[0] as string, + queries: rest[1] as string[], + transactionId: rest[2] as string + }; + } + + const databaseId = params.databaseId; + const collectionId = params.collectionId; + const queries = params.queries; + const transactionId = params.transactionId; + + if (typeof databaseId === 'undefined') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + if (typeof collectionId === 'undefined') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + + const apiPath = '/documentsdb/{databaseId}/collections/{collectionId}/documents'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId); + const payload: Payload = {}; + if (typeof queries !== 'undefined') { + payload['queries'] = queries; + } + if (typeof transactionId !== 'undefined') { + payload['transactionId'] = transactionId; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'delete', + uri, + apiHeaders, + payload, + ); + } + + /** + * Get a document by its unique ID. This endpoint response returns a JSON object with the document data. + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). + * @param {string} params.documentId - Document ID. + * @param {string[]} params.queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. + * @param {string} params.transactionId - Transaction ID to read uncommitted changes within the transaction. + * @throws {AppwriteException} + * @returns {Promise} + */ + getDocument(params: { databaseId: string, collectionId: string, documentId: string, queries?: string[], transactionId?: string }): Promise; + /** + * Get a document by its unique ID. This endpoint response returns a JSON object with the document data. + * + * @param {string} databaseId - Database ID. + * @param {string} collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). + * @param {string} documentId - Document ID. + * @param {string[]} queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. + * @param {string} transactionId - Transaction ID to read uncommitted changes within the transaction. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + getDocument(databaseId: string, collectionId: string, documentId: string, queries?: string[], transactionId?: string): Promise; + getDocument( + paramsOrFirst: { databaseId: string, collectionId: string, documentId: string, queries?: string[], transactionId?: string } | string, + ...rest: [(string)?, (string)?, (string[])?, (string)?] + ): Promise { + let params: { databaseId: string, collectionId: string, documentId: string, queries?: string[], transactionId?: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, documentId: string, queries?: string[], transactionId?: string }; + } else { + params = { + databaseId: paramsOrFirst as string, + collectionId: rest[0] as string, + documentId: rest[1] as string, + queries: rest[2] as string[], + transactionId: rest[3] as string + }; + } + + const databaseId = params.databaseId; + const collectionId = params.collectionId; + const documentId = params.documentId; + const queries = params.queries; + const transactionId = params.transactionId; + + if (typeof databaseId === 'undefined') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + if (typeof collectionId === 'undefined') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + if (typeof documentId === 'undefined') { + throw new AppwriteException('Missing required parameter: "documentId"'); + } + + const apiPath = '/documentsdb/{databaseId}/collections/{collectionId}/documents/{documentId}'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId).replace('{documentId}', documentId); + const payload: Payload = {}; + if (typeof queries !== 'undefined') { + payload['queries'] = queries; + } + if (typeof transactionId !== 'undefined') { + payload['transactionId'] = transactionId; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + } + + return this.client.call( + 'get', + uri, + apiHeaders, + payload, + ); + } + + /** + * Create or update a Document. Before using this route, you should create a new collection resource using either a [server integration](https://appwrite.io/docs/server/databases#documentsDBCreateCollection) API or directly from your database console. + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.collectionId - Collection ID. + * @param {string} params.documentId - Document ID. + * @param {Document extends Models.DefaultDocument ? Partial & Record : Partial & Partial>} params.data - Document data as JSON object. Include all required fields of the document to be created or updated. + * @param {string[]} params.permissions - An array of permissions strings. By default, the current permissions are inherited. [Learn more about permissions](https://appwrite.io/docs/permissions). + * @param {string} params.transactionId - Transaction ID for staging the operation. + * @throws {AppwriteException} + * @returns {Promise} + */ + upsertDocument(params: { databaseId: string, collectionId: string, documentId: string, data?: Document extends Models.DefaultDocument ? Partial & Record : Partial & Partial>, permissions?: string[], transactionId?: string }): Promise; + /** + * Create or update a Document. Before using this route, you should create a new collection resource using either a [server integration](https://appwrite.io/docs/server/databases#documentsDBCreateCollection) API or directly from your database console. + * + * @param {string} databaseId - Database ID. + * @param {string} collectionId - Collection ID. + * @param {string} documentId - Document ID. + * @param {Document extends Models.DefaultDocument ? Partial & Record : Partial & Partial>} data - Document data as JSON object. Include all required fields of the document to be created or updated. + * @param {string[]} permissions - An array of permissions strings. By default, the current permissions are inherited. [Learn more about permissions](https://appwrite.io/docs/permissions). + * @param {string} transactionId - Transaction ID for staging the operation. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + upsertDocument(databaseId: string, collectionId: string, documentId: string, data?: Document extends Models.DefaultDocument ? Partial & Record : Partial & Partial>, permissions?: string[], transactionId?: string): Promise; + upsertDocument( + paramsOrFirst: { databaseId: string, collectionId: string, documentId: string, data?: Document extends Models.DefaultDocument ? Partial & Record : Partial & Partial>, permissions?: string[], transactionId?: string } | string, + ...rest: [(string)?, (string)?, (Document extends Models.DefaultDocument ? Partial & Record : Partial & Partial>)?, (string[])?, (string)?] + ): Promise { + let params: { databaseId: string, collectionId: string, documentId: string, data?: Document extends Models.DefaultDocument ? Partial & Record : Partial & Partial>, permissions?: string[], transactionId?: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, documentId: string, data?: Document extends Models.DefaultDocument ? Partial & Record : Partial & Partial>, permissions?: string[], transactionId?: string }; + } else { + params = { + databaseId: paramsOrFirst as string, + collectionId: rest[0] as string, + documentId: rest[1] as string, + data: rest[2] as Document extends Models.DefaultDocument ? Partial & Record : Partial & Partial>, + permissions: rest[3] as string[], + transactionId: rest[4] as string + }; + } + + const databaseId = params.databaseId; + const collectionId = params.collectionId; + const documentId = params.documentId; + const data = params.data; + const permissions = params.permissions; + const transactionId = params.transactionId; + + if (typeof databaseId === 'undefined') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + if (typeof collectionId === 'undefined') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + if (typeof documentId === 'undefined') { + throw new AppwriteException('Missing required parameter: "documentId"'); + } + + const apiPath = '/documentsdb/{databaseId}/collections/{collectionId}/documents/{documentId}'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId).replace('{documentId}', documentId); + const payload: Payload = {}; + if (typeof data !== 'undefined') { + payload['data'] = data; + } + if (typeof permissions !== 'undefined') { + payload['permissions'] = permissions; + } + if (typeof transactionId !== 'undefined') { + payload['transactionId'] = transactionId; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'put', + uri, + apiHeaders, + payload, + ); + } + + /** + * Update a document by its unique ID. Using the patch method you can pass only specific fields that will get updated. + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.collectionId - Collection ID. + * @param {string} params.documentId - Document ID. + * @param {Document extends Models.DefaultDocument ? Partial & Record : Partial & Partial>} params.data - Document data as JSON object. Include only fields and value pairs to be updated. + * @param {string[]} params.permissions - An array of permissions strings. By default, the current permissions are inherited. [Learn more about permissions](https://appwrite.io/docs/permissions). + * @param {string} params.transactionId - Transaction ID for staging the operation. + * @throws {AppwriteException} + * @returns {Promise} + */ + updateDocument(params: { databaseId: string, collectionId: string, documentId: string, data?: Document extends Models.DefaultDocument ? Partial & Record : Partial & Partial>, permissions?: string[], transactionId?: string }): Promise; + /** + * Update a document by its unique ID. Using the patch method you can pass only specific fields that will get updated. + * + * @param {string} databaseId - Database ID. + * @param {string} collectionId - Collection ID. + * @param {string} documentId - Document ID. + * @param {Document extends Models.DefaultDocument ? Partial & Record : Partial & Partial>} data - Document data as JSON object. Include only fields and value pairs to be updated. + * @param {string[]} permissions - An array of permissions strings. By default, the current permissions are inherited. [Learn more about permissions](https://appwrite.io/docs/permissions). + * @param {string} transactionId - Transaction ID for staging the operation. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateDocument(databaseId: string, collectionId: string, documentId: string, data?: Document extends Models.DefaultDocument ? Partial & Record : Partial & Partial>, permissions?: string[], transactionId?: string): Promise; + updateDocument( + paramsOrFirst: { databaseId: string, collectionId: string, documentId: string, data?: Document extends Models.DefaultDocument ? Partial & Record : Partial & Partial>, permissions?: string[], transactionId?: string } | string, + ...rest: [(string)?, (string)?, (Document extends Models.DefaultDocument ? Partial & Record : Partial & Partial>)?, (string[])?, (string)?] + ): Promise { + let params: { databaseId: string, collectionId: string, documentId: string, data?: Document extends Models.DefaultDocument ? Partial & Record : Partial & Partial>, permissions?: string[], transactionId?: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, documentId: string, data?: Document extends Models.DefaultDocument ? Partial & Record : Partial & Partial>, permissions?: string[], transactionId?: string }; + } else { + params = { + databaseId: paramsOrFirst as string, + collectionId: rest[0] as string, + documentId: rest[1] as string, + data: rest[2] as Document extends Models.DefaultDocument ? Partial & Record : Partial & Partial>, + permissions: rest[3] as string[], + transactionId: rest[4] as string + }; + } + + const databaseId = params.databaseId; + const collectionId = params.collectionId; + const documentId = params.documentId; + const data = params.data; + const permissions = params.permissions; + const transactionId = params.transactionId; + + if (typeof databaseId === 'undefined') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + if (typeof collectionId === 'undefined') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + if (typeof documentId === 'undefined') { + throw new AppwriteException('Missing required parameter: "documentId"'); + } + + const apiPath = '/documentsdb/{databaseId}/collections/{collectionId}/documents/{documentId}'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId).replace('{documentId}', documentId); + const payload: Payload = {}; + if (typeof data !== 'undefined') { + payload['data'] = data; + } + if (typeof permissions !== 'undefined') { + payload['permissions'] = permissions; + } + if (typeof transactionId !== 'undefined') { + payload['transactionId'] = transactionId; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'patch', + uri, + apiHeaders, + payload, + ); + } + + /** + * Delete a document by its unique ID. + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). + * @param {string} params.documentId - Document ID. + * @param {string} params.transactionId - Transaction ID for staging the operation. + * @throws {AppwriteException} + * @returns {Promise<{}>} + */ + deleteDocument(params: { databaseId: string, collectionId: string, documentId: string, transactionId?: string }): Promise<{}>; + /** + * Delete a document by its unique ID. + * + * @param {string} databaseId - Database ID. + * @param {string} collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). + * @param {string} documentId - Document ID. + * @param {string} transactionId - Transaction ID for staging the operation. + * @throws {AppwriteException} + * @returns {Promise<{}>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + deleteDocument(databaseId: string, collectionId: string, documentId: string, transactionId?: string): Promise<{}>; + deleteDocument( + paramsOrFirst: { databaseId: string, collectionId: string, documentId: string, transactionId?: string } | string, + ...rest: [(string)?, (string)?, (string)?] + ): Promise<{}> { + let params: { databaseId: string, collectionId: string, documentId: string, transactionId?: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, documentId: string, transactionId?: string }; + } else { + params = { + databaseId: paramsOrFirst as string, + collectionId: rest[0] as string, + documentId: rest[1] as string, + transactionId: rest[2] as string + }; + } + + const databaseId = params.databaseId; + const collectionId = params.collectionId; + const documentId = params.documentId; + const transactionId = params.transactionId; + + if (typeof databaseId === 'undefined') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + if (typeof collectionId === 'undefined') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + if (typeof documentId === 'undefined') { + throw new AppwriteException('Missing required parameter: "documentId"'); + } + + const apiPath = '/documentsdb/{databaseId}/collections/{collectionId}/documents/{documentId}'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId).replace('{documentId}', documentId); + const payload: Payload = {}; + if (typeof transactionId !== 'undefined') { + payload['transactionId'] = transactionId; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'delete', + uri, + apiHeaders, + payload, + ); + } + + /** + * Decrement a specific column of a row by a given value. + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.collectionId - Collection ID. + * @param {string} params.documentId - Document ID. + * @param {string} params.attribute - Attribute key. + * @param {number} params.value - Value to decrement the attribute by. The value must be a number. + * @param {number} params.min - Minimum value for the attribute. If the current value is lesser than this value, an exception will be thrown. + * @param {string} params.transactionId - Transaction ID for staging the operation. + * @throws {AppwriteException} + * @returns {Promise} + */ + decrementDocumentAttribute(params: { databaseId: string, collectionId: string, documentId: string, attribute: string, value?: number, min?: number, transactionId?: string }): Promise; + /** + * Decrement a specific column of a row by a given value. + * + * @param {string} databaseId - Database ID. + * @param {string} collectionId - Collection ID. + * @param {string} documentId - Document ID. + * @param {string} attribute - Attribute key. + * @param {number} value - Value to decrement the attribute by. The value must be a number. + * @param {number} min - Minimum value for the attribute. If the current value is lesser than this value, an exception will be thrown. + * @param {string} transactionId - Transaction ID for staging the operation. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + decrementDocumentAttribute(databaseId: string, collectionId: string, documentId: string, attribute: string, value?: number, min?: number, transactionId?: string): Promise; + decrementDocumentAttribute( + paramsOrFirst: { databaseId: string, collectionId: string, documentId: string, attribute: string, value?: number, min?: number, transactionId?: string } | string, + ...rest: [(string)?, (string)?, (string)?, (number)?, (number)?, (string)?] + ): Promise { + let params: { databaseId: string, collectionId: string, documentId: string, attribute: string, value?: number, min?: number, transactionId?: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, documentId: string, attribute: string, value?: number, min?: number, transactionId?: string }; + } else { + params = { + databaseId: paramsOrFirst as string, + collectionId: rest[0] as string, + documentId: rest[1] as string, + attribute: rest[2] as string, + value: rest[3] as number, + min: rest[4] as number, + transactionId: rest[5] as string + }; + } + + const databaseId = params.databaseId; + const collectionId = params.collectionId; + const documentId = params.documentId; + const attribute = params.attribute; + const value = params.value; + const min = params.min; + const transactionId = params.transactionId; + + if (typeof databaseId === 'undefined') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + if (typeof collectionId === 'undefined') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + if (typeof documentId === 'undefined') { + throw new AppwriteException('Missing required parameter: "documentId"'); + } + if (typeof attribute === 'undefined') { + throw new AppwriteException('Missing required parameter: "attribute"'); + } + + const apiPath = '/documentsdb/{databaseId}/collections/{collectionId}/documents/{documentId}/{attribute}/decrement'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId).replace('{documentId}', documentId).replace('{attribute}', attribute); + const payload: Payload = {}; + if (typeof value !== 'undefined') { + payload['value'] = value; + } + if (typeof min !== 'undefined') { + payload['min'] = min; + } + if (typeof transactionId !== 'undefined') { + payload['transactionId'] = transactionId; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'patch', + uri, + apiHeaders, + payload, + ); + } + + /** + * Increment a specific column of a row by a given value. + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.collectionId - Collection ID. + * @param {string} params.documentId - Document ID. + * @param {string} params.attribute - Attribute key. + * @param {number} params.value - Value to increment the attribute by. The value must be a number. + * @param {number} params.max - Maximum value for the attribute. If the current value is greater than this value, an error will be thrown. + * @param {string} params.transactionId - Transaction ID for staging the operation. + * @throws {AppwriteException} + * @returns {Promise} + */ + incrementDocumentAttribute(params: { databaseId: string, collectionId: string, documentId: string, attribute: string, value?: number, max?: number, transactionId?: string }): Promise; + /** + * Increment a specific column of a row by a given value. + * + * @param {string} databaseId - Database ID. + * @param {string} collectionId - Collection ID. + * @param {string} documentId - Document ID. + * @param {string} attribute - Attribute key. + * @param {number} value - Value to increment the attribute by. The value must be a number. + * @param {number} max - Maximum value for the attribute. If the current value is greater than this value, an error will be thrown. + * @param {string} transactionId - Transaction ID for staging the operation. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + incrementDocumentAttribute(databaseId: string, collectionId: string, documentId: string, attribute: string, value?: number, max?: number, transactionId?: string): Promise; + incrementDocumentAttribute( + paramsOrFirst: { databaseId: string, collectionId: string, documentId: string, attribute: string, value?: number, max?: number, transactionId?: string } | string, + ...rest: [(string)?, (string)?, (string)?, (number)?, (number)?, (string)?] + ): Promise { + let params: { databaseId: string, collectionId: string, documentId: string, attribute: string, value?: number, max?: number, transactionId?: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, documentId: string, attribute: string, value?: number, max?: number, transactionId?: string }; + } else { + params = { + databaseId: paramsOrFirst as string, + collectionId: rest[0] as string, + documentId: rest[1] as string, + attribute: rest[2] as string, + value: rest[3] as number, + max: rest[4] as number, + transactionId: rest[5] as string + }; + } + + const databaseId = params.databaseId; + const collectionId = params.collectionId; + const documentId = params.documentId; + const attribute = params.attribute; + const value = params.value; + const max = params.max; + const transactionId = params.transactionId; + + if (typeof databaseId === 'undefined') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + if (typeof collectionId === 'undefined') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + if (typeof documentId === 'undefined') { + throw new AppwriteException('Missing required parameter: "documentId"'); + } + if (typeof attribute === 'undefined') { + throw new AppwriteException('Missing required parameter: "attribute"'); + } + + const apiPath = '/documentsdb/{databaseId}/collections/{collectionId}/documents/{documentId}/{attribute}/increment'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId).replace('{documentId}', documentId).replace('{attribute}', attribute); + const payload: Payload = {}; + if (typeof value !== 'undefined') { + payload['value'] = value; + } + if (typeof max !== 'undefined') { + payload['max'] = max; + } + if (typeof transactionId !== 'undefined') { + payload['transactionId'] = transactionId; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'patch', + uri, + apiHeaders, + payload, + ); + } + + /** + * List indexes in the collection. + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). + * @param {string[]} params.queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: key, type, status, attributes, error + * @param {boolean} params.total - When set to false, the total count returned will be 0 and will not be calculated. + * @throws {AppwriteException} + * @returns {Promise} + */ + listIndexes(params: { databaseId: string, collectionId: string, queries?: string[], total?: boolean }): Promise; + /** + * List indexes in the collection. + * + * @param {string} databaseId - Database ID. + * @param {string} collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). + * @param {string[]} queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: key, type, status, attributes, error + * @param {boolean} total - When set to false, the total count returned will be 0 and will not be calculated. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + listIndexes(databaseId: string, collectionId: string, queries?: string[], total?: boolean): Promise; + listIndexes( + paramsOrFirst: { databaseId: string, collectionId: string, queries?: string[], total?: boolean } | string, + ...rest: [(string)?, (string[])?, (boolean)?] + ): Promise { + let params: { databaseId: string, collectionId: string, queries?: string[], total?: boolean }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, queries?: string[], total?: boolean }; + } else { + params = { + databaseId: paramsOrFirst as string, + collectionId: rest[0] as string, + queries: rest[1] as string[], + total: rest[2] as boolean + }; + } + + const databaseId = params.databaseId; + const collectionId = params.collectionId; + const queries = params.queries; + const total = params.total; + + if (typeof databaseId === 'undefined') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + if (typeof collectionId === 'undefined') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + + const apiPath = '/documentsdb/{databaseId}/collections/{collectionId}/indexes'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId); + const payload: Payload = {}; + if (typeof queries !== 'undefined') { + payload['queries'] = queries; + } + if (typeof total !== 'undefined') { + payload['total'] = total; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + } + + return this.client.call( + 'get', + uri, + apiHeaders, + payload, + ); + } + + /** + * Creates an index on the attributes listed. Your index should include all the attributes you will query in a single request. + * Attributes can be `key`, `fulltext`, and `unique`. + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). + * @param {string} params.key - Index Key. + * @param {DocumentsDBIndexType} params.type - Index type. + * @param {string[]} params.attributes - Array of attributes to index. Maximum of 100 attributes are allowed, each 32 characters long. + * @param {OrderBy[]} params.orders - Array of index orders. Maximum of 100 orders are allowed. + * @param {number[]} params.lengths - Length of index. Maximum of 100 + * @throws {AppwriteException} + * @returns {Promise} + */ + createIndex(params: { databaseId: string, collectionId: string, key: string, type: DocumentsDBIndexType, attributes: string[], orders?: OrderBy[], lengths?: number[] }): Promise; + /** + * Creates an index on the attributes listed. Your index should include all the attributes you will query in a single request. + * Attributes can be `key`, `fulltext`, and `unique`. + * + * @param {string} databaseId - Database ID. + * @param {string} collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). + * @param {string} key - Index Key. + * @param {DocumentsDBIndexType} type - Index type. + * @param {string[]} attributes - Array of attributes to index. Maximum of 100 attributes are allowed, each 32 characters long. + * @param {OrderBy[]} orders - Array of index orders. Maximum of 100 orders are allowed. + * @param {number[]} lengths - Length of index. Maximum of 100 + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createIndex(databaseId: string, collectionId: string, key: string, type: DocumentsDBIndexType, attributes: string[], orders?: OrderBy[], lengths?: number[]): Promise; + createIndex( + paramsOrFirst: { databaseId: string, collectionId: string, key: string, type: DocumentsDBIndexType, attributes: string[], orders?: OrderBy[], lengths?: number[] } | string, + ...rest: [(string)?, (string)?, (DocumentsDBIndexType)?, (string[])?, (OrderBy[])?, (number[])?] + ): Promise { + let params: { databaseId: string, collectionId: string, key: string, type: DocumentsDBIndexType, attributes: string[], orders?: OrderBy[], lengths?: number[] }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, key: string, type: DocumentsDBIndexType, attributes: string[], orders?: OrderBy[], lengths?: number[] }; + } else { + params = { + databaseId: paramsOrFirst as string, + collectionId: rest[0] as string, + key: rest[1] as string, + type: rest[2] as DocumentsDBIndexType, + attributes: rest[3] as string[], + orders: rest[4] as OrderBy[], + lengths: rest[5] as number[] + }; + } + + const databaseId = params.databaseId; + const collectionId = params.collectionId; + const key = params.key; + const type = params.type; + const attributes = params.attributes; + const orders = params.orders; + const lengths = params.lengths; + + if (typeof databaseId === 'undefined') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + if (typeof collectionId === 'undefined') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + if (typeof key === 'undefined') { + throw new AppwriteException('Missing required parameter: "key"'); + } + if (typeof type === 'undefined') { + throw new AppwriteException('Missing required parameter: "type"'); + } + if (typeof attributes === 'undefined') { + throw new AppwriteException('Missing required parameter: "attributes"'); + } + + const apiPath = '/documentsdb/{databaseId}/collections/{collectionId}/indexes'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId); + const payload: Payload = {}; + if (typeof key !== 'undefined') { + payload['key'] = key; + } + if (typeof type !== 'undefined') { + payload['type'] = type; + } + if (typeof attributes !== 'undefined') { + payload['attributes'] = attributes; + } + if (typeof orders !== 'undefined') { + payload['orders'] = orders; + } + if (typeof lengths !== 'undefined') { + payload['lengths'] = lengths; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'post', + uri, + apiHeaders, + payload, + ); + } + + /** + * Get index by ID. + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). + * @param {string} params.key - Index Key. + * @throws {AppwriteException} + * @returns {Promise} + */ + getIndex(params: { databaseId: string, collectionId: string, key: string }): Promise; + /** + * Get index by ID. + * + * @param {string} databaseId - Database ID. + * @param {string} collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). + * @param {string} key - Index Key. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + getIndex(databaseId: string, collectionId: string, key: string): Promise; + getIndex( + paramsOrFirst: { databaseId: string, collectionId: string, key: string } | string, + ...rest: [(string)?, (string)?] + ): Promise { + let params: { databaseId: string, collectionId: string, key: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, key: string }; + } else { + params = { + databaseId: paramsOrFirst as string, + collectionId: rest[0] as string, + key: rest[1] as string + }; + } + + const databaseId = params.databaseId; + const collectionId = params.collectionId; + const key = params.key; + + if (typeof databaseId === 'undefined') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + if (typeof collectionId === 'undefined') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + if (typeof key === 'undefined') { + throw new AppwriteException('Missing required parameter: "key"'); + } + + const apiPath = '/documentsdb/{databaseId}/collections/{collectionId}/indexes/{key}'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId).replace('{key}', key); + const payload: Payload = {}; + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + } + + return this.client.call( + 'get', + uri, + apiHeaders, + payload, + ); + } + + /** + * Delete an index. + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). + * @param {string} params.key - Index Key. + * @throws {AppwriteException} + * @returns {Promise<{}>} + */ + deleteIndex(params: { databaseId: string, collectionId: string, key: string }): Promise<{}>; + /** + * Delete an index. + * + * @param {string} databaseId - Database ID. + * @param {string} collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). + * @param {string} key - Index Key. + * @throws {AppwriteException} + * @returns {Promise<{}>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + deleteIndex(databaseId: string, collectionId: string, key: string): Promise<{}>; + deleteIndex( + paramsOrFirst: { databaseId: string, collectionId: string, key: string } | string, + ...rest: [(string)?, (string)?] + ): Promise<{}> { + let params: { databaseId: string, collectionId: string, key: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, key: string }; + } else { + params = { + databaseId: paramsOrFirst as string, + collectionId: rest[0] as string, + key: rest[1] as string + }; + } + + const databaseId = params.databaseId; + const collectionId = params.collectionId; + const key = params.key; + + if (typeof databaseId === 'undefined') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + if (typeof collectionId === 'undefined') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + if (typeof key === 'undefined') { + throw new AppwriteException('Missing required parameter: "key"'); + } + + const apiPath = '/documentsdb/{databaseId}/collections/{collectionId}/indexes/{key}'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId).replace('{key}', key); + const payload: Payload = {}; + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'delete', + uri, + apiHeaders, + payload, + ); + } +} diff --git a/src/services/functions.ts b/src/services/functions.ts index 1daf8ba3..743acc04 100644 --- a/src/services/functions.ts +++ b/src/services/functions.ts @@ -101,11 +101,13 @@ export class Functions { * @param {string} params.providerBranch - Production branch for the repo linked to the function. * @param {boolean} params.providerSilentMode - Is the VCS (Version Control System) connection in silent mode for the repo linked to the function? In silent mode, comments will not be made on commits and pull requests. * @param {string} params.providerRootDirectory - Path to function code in the linked repo. - * @param {string} params.specification - Runtime specification for the function and builds. + * @param {string} params.buildSpecification - Build specification for the function deployments. + * @param {string} params.runtimeSpecification - Runtime specification for the function executions. + * @param {number} params.deploymentRetention - Days to keep non-active deployments before deletion. Value 0 means all deployments will be kept. * @throws {AppwriteException} * @returns {Promise} */ - create(params: { functionId: string, name: string, runtime: Runtime, execute?: string[], events?: string[], schedule?: string, timeout?: number, enabled?: boolean, logging?: boolean, entrypoint?: string, commands?: string, scopes?: Scopes[], installationId?: string, providerRepositoryId?: string, providerBranch?: string, providerSilentMode?: boolean, providerRootDirectory?: string, specification?: string }): Promise; + create(params: { functionId: string, name: string, runtime: Runtime, execute?: string[], events?: string[], schedule?: string, timeout?: number, enabled?: boolean, logging?: boolean, entrypoint?: string, commands?: string, scopes?: Scopes[], installationId?: string, providerRepositoryId?: string, providerBranch?: string, providerSilentMode?: boolean, providerRootDirectory?: string, buildSpecification?: string, runtimeSpecification?: string, deploymentRetention?: number }): Promise; /** * Create a new function. You can pass a list of [permissions](https://appwrite.io/docs/permissions) to allow different project users or team with access to execute the function using the client API. * @@ -126,20 +128,22 @@ export class Functions { * @param {string} providerBranch - Production branch for the repo linked to the function. * @param {boolean} providerSilentMode - Is the VCS (Version Control System) connection in silent mode for the repo linked to the function? In silent mode, comments will not be made on commits and pull requests. * @param {string} providerRootDirectory - Path to function code in the linked repo. - * @param {string} specification - Runtime specification for the function and builds. + * @param {string} buildSpecification - Build specification for the function deployments. + * @param {string} runtimeSpecification - Runtime specification for the function executions. + * @param {number} deploymentRetention - Days to keep non-active deployments before deletion. Value 0 means all deployments will be kept. * @throws {AppwriteException} * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - create(functionId: string, name: string, runtime: Runtime, execute?: string[], events?: string[], schedule?: string, timeout?: number, enabled?: boolean, logging?: boolean, entrypoint?: string, commands?: string, scopes?: Scopes[], installationId?: string, providerRepositoryId?: string, providerBranch?: string, providerSilentMode?: boolean, providerRootDirectory?: string, specification?: string): Promise; + create(functionId: string, name: string, runtime: Runtime, execute?: string[], events?: string[], schedule?: string, timeout?: number, enabled?: boolean, logging?: boolean, entrypoint?: string, commands?: string, scopes?: Scopes[], installationId?: string, providerRepositoryId?: string, providerBranch?: string, providerSilentMode?: boolean, providerRootDirectory?: string, buildSpecification?: string, runtimeSpecification?: string, deploymentRetention?: number): Promise; create( - paramsOrFirst: { functionId: string, name: string, runtime: Runtime, execute?: string[], events?: string[], schedule?: string, timeout?: number, enabled?: boolean, logging?: boolean, entrypoint?: string, commands?: string, scopes?: Scopes[], installationId?: string, providerRepositoryId?: string, providerBranch?: string, providerSilentMode?: boolean, providerRootDirectory?: string, specification?: string } | string, - ...rest: [(string)?, (Runtime)?, (string[])?, (string[])?, (string)?, (number)?, (boolean)?, (boolean)?, (string)?, (string)?, (Scopes[])?, (string)?, (string)?, (string)?, (boolean)?, (string)?, (string)?] + paramsOrFirst: { functionId: string, name: string, runtime: Runtime, execute?: string[], events?: string[], schedule?: string, timeout?: number, enabled?: boolean, logging?: boolean, entrypoint?: string, commands?: string, scopes?: Scopes[], installationId?: string, providerRepositoryId?: string, providerBranch?: string, providerSilentMode?: boolean, providerRootDirectory?: string, buildSpecification?: string, runtimeSpecification?: string, deploymentRetention?: number } | string, + ...rest: [(string)?, (Runtime)?, (string[])?, (string[])?, (string)?, (number)?, (boolean)?, (boolean)?, (string)?, (string)?, (Scopes[])?, (string)?, (string)?, (string)?, (boolean)?, (string)?, (string)?, (string)?, (number)?] ): Promise { - let params: { functionId: string, name: string, runtime: Runtime, execute?: string[], events?: string[], schedule?: string, timeout?: number, enabled?: boolean, logging?: boolean, entrypoint?: string, commands?: string, scopes?: Scopes[], installationId?: string, providerRepositoryId?: string, providerBranch?: string, providerSilentMode?: boolean, providerRootDirectory?: string, specification?: string }; + let params: { functionId: string, name: string, runtime: Runtime, execute?: string[], events?: string[], schedule?: string, timeout?: number, enabled?: boolean, logging?: boolean, entrypoint?: string, commands?: string, scopes?: Scopes[], installationId?: string, providerRepositoryId?: string, providerBranch?: string, providerSilentMode?: boolean, providerRootDirectory?: string, buildSpecification?: string, runtimeSpecification?: string, deploymentRetention?: number }; if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { functionId: string, name: string, runtime: Runtime, execute?: string[], events?: string[], schedule?: string, timeout?: number, enabled?: boolean, logging?: boolean, entrypoint?: string, commands?: string, scopes?: Scopes[], installationId?: string, providerRepositoryId?: string, providerBranch?: string, providerSilentMode?: boolean, providerRootDirectory?: string, specification?: string }; + params = (paramsOrFirst || {}) as { functionId: string, name: string, runtime: Runtime, execute?: string[], events?: string[], schedule?: string, timeout?: number, enabled?: boolean, logging?: boolean, entrypoint?: string, commands?: string, scopes?: Scopes[], installationId?: string, providerRepositoryId?: string, providerBranch?: string, providerSilentMode?: boolean, providerRootDirectory?: string, buildSpecification?: string, runtimeSpecification?: string, deploymentRetention?: number }; } else { params = { functionId: paramsOrFirst as string, @@ -159,7 +163,9 @@ export class Functions { providerBranch: rest[13] as string, providerSilentMode: rest[14] as boolean, providerRootDirectory: rest[15] as string, - specification: rest[16] as string + buildSpecification: rest[16] as string, + runtimeSpecification: rest[17] as string, + deploymentRetention: rest[18] as number }; } @@ -180,7 +186,9 @@ export class Functions { const providerBranch = params.providerBranch; const providerSilentMode = params.providerSilentMode; const providerRootDirectory = params.providerRootDirectory; - const specification = params.specification; + const buildSpecification = params.buildSpecification; + const runtimeSpecification = params.runtimeSpecification; + const deploymentRetention = params.deploymentRetention; if (typeof functionId === 'undefined') { throw new AppwriteException('Missing required parameter: "functionId"'); @@ -245,8 +253,14 @@ export class Functions { if (typeof providerRootDirectory !== 'undefined') { payload['providerRootDirectory'] = providerRootDirectory; } - if (typeof specification !== 'undefined') { - payload['specification'] = specification; + if (typeof buildSpecification !== 'undefined') { + payload['buildSpecification'] = buildSpecification; + } + if (typeof runtimeSpecification !== 'undefined') { + payload['runtimeSpecification'] = runtimeSpecification; + } + if (typeof deploymentRetention !== 'undefined') { + payload['deploymentRetention'] = deploymentRetention; } const uri = new URL(this.client.config.endpoint + apiPath); @@ -379,11 +393,13 @@ export class Functions { * @param {string} params.providerBranch - Production branch for the repo linked to the function * @param {boolean} params.providerSilentMode - Is the VCS (Version Control System) connection in silent mode for the repo linked to the function? In silent mode, comments will not be made on commits and pull requests. * @param {string} params.providerRootDirectory - Path to function code in the linked repo. - * @param {string} params.specification - Runtime specification for the function and builds. + * @param {string} params.buildSpecification - Build specification for the function deployments. + * @param {string} params.runtimeSpecification - Runtime specification for the function executions. + * @param {number} params.deploymentRetention - Days to keep non-active deployments before deletion. Value 0 means all deployments will be kept. * @throws {AppwriteException} * @returns {Promise} */ - update(params: { functionId: string, name: string, runtime?: Runtime, execute?: string[], events?: string[], schedule?: string, timeout?: number, enabled?: boolean, logging?: boolean, entrypoint?: string, commands?: string, scopes?: Scopes[], installationId?: string, providerRepositoryId?: string, providerBranch?: string, providerSilentMode?: boolean, providerRootDirectory?: string, specification?: string }): Promise; + update(params: { functionId: string, name: string, runtime?: Runtime, execute?: string[], events?: string[], schedule?: string, timeout?: number, enabled?: boolean, logging?: boolean, entrypoint?: string, commands?: string, scopes?: Scopes[], installationId?: string, providerRepositoryId?: string, providerBranch?: string, providerSilentMode?: boolean, providerRootDirectory?: string, buildSpecification?: string, runtimeSpecification?: string, deploymentRetention?: number }): Promise; /** * Update function by its unique ID. * @@ -404,20 +420,22 @@ export class Functions { * @param {string} providerBranch - Production branch for the repo linked to the function * @param {boolean} providerSilentMode - Is the VCS (Version Control System) connection in silent mode for the repo linked to the function? In silent mode, comments will not be made on commits and pull requests. * @param {string} providerRootDirectory - Path to function code in the linked repo. - * @param {string} specification - Runtime specification for the function and builds. + * @param {string} buildSpecification - Build specification for the function deployments. + * @param {string} runtimeSpecification - Runtime specification for the function executions. + * @param {number} deploymentRetention - Days to keep non-active deployments before deletion. Value 0 means all deployments will be kept. * @throws {AppwriteException} * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - update(functionId: string, name: string, runtime?: Runtime, execute?: string[], events?: string[], schedule?: string, timeout?: number, enabled?: boolean, logging?: boolean, entrypoint?: string, commands?: string, scopes?: Scopes[], installationId?: string, providerRepositoryId?: string, providerBranch?: string, providerSilentMode?: boolean, providerRootDirectory?: string, specification?: string): Promise; + update(functionId: string, name: string, runtime?: Runtime, execute?: string[], events?: string[], schedule?: string, timeout?: number, enabled?: boolean, logging?: boolean, entrypoint?: string, commands?: string, scopes?: Scopes[], installationId?: string, providerRepositoryId?: string, providerBranch?: string, providerSilentMode?: boolean, providerRootDirectory?: string, buildSpecification?: string, runtimeSpecification?: string, deploymentRetention?: number): Promise; update( - paramsOrFirst: { functionId: string, name: string, runtime?: Runtime, execute?: string[], events?: string[], schedule?: string, timeout?: number, enabled?: boolean, logging?: boolean, entrypoint?: string, commands?: string, scopes?: Scopes[], installationId?: string, providerRepositoryId?: string, providerBranch?: string, providerSilentMode?: boolean, providerRootDirectory?: string, specification?: string } | string, - ...rest: [(string)?, (Runtime)?, (string[])?, (string[])?, (string)?, (number)?, (boolean)?, (boolean)?, (string)?, (string)?, (Scopes[])?, (string)?, (string)?, (string)?, (boolean)?, (string)?, (string)?] + paramsOrFirst: { functionId: string, name: string, runtime?: Runtime, execute?: string[], events?: string[], schedule?: string, timeout?: number, enabled?: boolean, logging?: boolean, entrypoint?: string, commands?: string, scopes?: Scopes[], installationId?: string, providerRepositoryId?: string, providerBranch?: string, providerSilentMode?: boolean, providerRootDirectory?: string, buildSpecification?: string, runtimeSpecification?: string, deploymentRetention?: number } | string, + ...rest: [(string)?, (Runtime)?, (string[])?, (string[])?, (string)?, (number)?, (boolean)?, (boolean)?, (string)?, (string)?, (Scopes[])?, (string)?, (string)?, (string)?, (boolean)?, (string)?, (string)?, (string)?, (number)?] ): Promise { - let params: { functionId: string, name: string, runtime?: Runtime, execute?: string[], events?: string[], schedule?: string, timeout?: number, enabled?: boolean, logging?: boolean, entrypoint?: string, commands?: string, scopes?: Scopes[], installationId?: string, providerRepositoryId?: string, providerBranch?: string, providerSilentMode?: boolean, providerRootDirectory?: string, specification?: string }; + let params: { functionId: string, name: string, runtime?: Runtime, execute?: string[], events?: string[], schedule?: string, timeout?: number, enabled?: boolean, logging?: boolean, entrypoint?: string, commands?: string, scopes?: Scopes[], installationId?: string, providerRepositoryId?: string, providerBranch?: string, providerSilentMode?: boolean, providerRootDirectory?: string, buildSpecification?: string, runtimeSpecification?: string, deploymentRetention?: number }; if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { functionId: string, name: string, runtime?: Runtime, execute?: string[], events?: string[], schedule?: string, timeout?: number, enabled?: boolean, logging?: boolean, entrypoint?: string, commands?: string, scopes?: Scopes[], installationId?: string, providerRepositoryId?: string, providerBranch?: string, providerSilentMode?: boolean, providerRootDirectory?: string, specification?: string }; + params = (paramsOrFirst || {}) as { functionId: string, name: string, runtime?: Runtime, execute?: string[], events?: string[], schedule?: string, timeout?: number, enabled?: boolean, logging?: boolean, entrypoint?: string, commands?: string, scopes?: Scopes[], installationId?: string, providerRepositoryId?: string, providerBranch?: string, providerSilentMode?: boolean, providerRootDirectory?: string, buildSpecification?: string, runtimeSpecification?: string, deploymentRetention?: number }; } else { params = { functionId: paramsOrFirst as string, @@ -437,7 +455,9 @@ export class Functions { providerBranch: rest[13] as string, providerSilentMode: rest[14] as boolean, providerRootDirectory: rest[15] as string, - specification: rest[16] as string + buildSpecification: rest[16] as string, + runtimeSpecification: rest[17] as string, + deploymentRetention: rest[18] as number }; } @@ -458,7 +478,9 @@ export class Functions { const providerBranch = params.providerBranch; const providerSilentMode = params.providerSilentMode; const providerRootDirectory = params.providerRootDirectory; - const specification = params.specification; + const buildSpecification = params.buildSpecification; + const runtimeSpecification = params.runtimeSpecification; + const deploymentRetention = params.deploymentRetention; if (typeof functionId === 'undefined') { throw new AppwriteException('Missing required parameter: "functionId"'); @@ -517,8 +539,14 @@ export class Functions { if (typeof providerRootDirectory !== 'undefined') { payload['providerRootDirectory'] = providerRootDirectory; } - if (typeof specification !== 'undefined') { - payload['specification'] = specification; + if (typeof buildSpecification !== 'undefined') { + payload['buildSpecification'] = buildSpecification; + } + if (typeof runtimeSpecification !== 'undefined') { + payload['runtimeSpecification'] = runtimeSpecification; + } + if (typeof deploymentRetention !== 'undefined') { + payload['deploymentRetention'] = deploymentRetention; } const uri = new URL(this.client.config.endpoint + apiPath); diff --git a/src/services/project.ts b/src/services/project.ts new file mode 100644 index 00000000..ed6fcb19 --- /dev/null +++ b/src/services/project.ts @@ -0,0 +1,330 @@ +import { AppwriteException, Client, type Payload, UploadProgress } from '../client'; +import type { Models } from '../models'; + + +export class Project { + client: Client; + + constructor(client: Client) { + this.client = client; + } + + /** + * Get a list of all project environment variables. + * + * @param {string[]} params.queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: key, resourceType, resourceId, secret + * @param {boolean} params.total - When set to false, the total count returned will be 0 and will not be calculated. + * @throws {AppwriteException} + * @returns {Promise} + */ + listVariables(params?: { queries?: string[], total?: boolean }): Promise; + /** + * Get a list of all project environment variables. + * + * @param {string[]} queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: key, resourceType, resourceId, secret + * @param {boolean} total - When set to false, the total count returned will be 0 and will not be calculated. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + listVariables(queries?: string[], total?: boolean): Promise; + listVariables( + paramsOrFirst?: { queries?: string[], total?: boolean } | string[], + ...rest: [(boolean)?] + ): Promise { + let params: { queries?: string[], total?: boolean }; + + if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { queries?: string[], total?: boolean }; + } else { + params = { + queries: paramsOrFirst as string[], + total: rest[0] as boolean + }; + } + + const queries = params.queries; + const total = params.total; + + + const apiPath = '/project/variables'; + const payload: Payload = {}; + if (typeof queries !== 'undefined') { + payload['queries'] = queries; + } + if (typeof total !== 'undefined') { + payload['total'] = total; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + } + + return this.client.call( + 'get', + uri, + apiHeaders, + payload, + ); + } + + /** + * Create a new project environment variable. These variables can be accessed by all functions and sites in the project. + * + * @param {string} params.variableId - Variable ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + * @param {string} params.key - Variable key. Max length: 255 chars. + * @param {string} params.value - Variable value. Max length: 8192 chars. + * @param {boolean} params.secret - Secret variables can be updated or deleted, but only projects can read them during build and runtime. + * @throws {AppwriteException} + * @returns {Promise} + */ + createVariable(params: { variableId: string, key: string, value: string, secret?: boolean }): Promise; + /** + * Create a new project environment variable. These variables can be accessed by all functions and sites in the project. + * + * @param {string} variableId - Variable ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + * @param {string} key - Variable key. Max length: 255 chars. + * @param {string} value - Variable value. Max length: 8192 chars. + * @param {boolean} secret - Secret variables can be updated or deleted, but only projects can read them during build and runtime. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createVariable(variableId: string, key: string, value: string, secret?: boolean): Promise; + createVariable( + paramsOrFirst: { variableId: string, key: string, value: string, secret?: boolean } | string, + ...rest: [(string)?, (string)?, (boolean)?] + ): Promise { + let params: { variableId: string, key: string, value: string, secret?: boolean }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { variableId: string, key: string, value: string, secret?: boolean }; + } else { + params = { + variableId: paramsOrFirst as string, + key: rest[0] as string, + value: rest[1] as string, + secret: rest[2] as boolean + }; + } + + const variableId = params.variableId; + const key = params.key; + const value = params.value; + const secret = params.secret; + + if (typeof variableId === 'undefined') { + throw new AppwriteException('Missing required parameter: "variableId"'); + } + if (typeof key === 'undefined') { + throw new AppwriteException('Missing required parameter: "key"'); + } + if (typeof value === 'undefined') { + throw new AppwriteException('Missing required parameter: "value"'); + } + + const apiPath = '/project/variables'; + const payload: Payload = {}; + if (typeof variableId !== 'undefined') { + payload['variableId'] = variableId; + } + if (typeof key !== 'undefined') { + payload['key'] = key; + } + if (typeof value !== 'undefined') { + payload['value'] = value; + } + if (typeof secret !== 'undefined') { + payload['secret'] = secret; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'post', + uri, + apiHeaders, + payload, + ); + } + + /** + * Get a variable by its unique ID. + * + * @param {string} params.variableId - Variable ID. + * @throws {AppwriteException} + * @returns {Promise} + */ + getVariable(params: { variableId: string }): Promise; + /** + * Get a variable by its unique ID. + * + * @param {string} variableId - Variable ID. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + getVariable(variableId: string): Promise; + getVariable( + paramsOrFirst: { variableId: string } | string + ): Promise { + let params: { variableId: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { variableId: string }; + } else { + params = { + variableId: paramsOrFirst as string + }; + } + + const variableId = params.variableId; + + if (typeof variableId === 'undefined') { + throw new AppwriteException('Missing required parameter: "variableId"'); + } + + const apiPath = '/project/variables/{variableId}'.replace('{variableId}', variableId); + const payload: Payload = {}; + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + } + + return this.client.call( + 'get', + uri, + apiHeaders, + payload, + ); + } + + /** + * Update variable by its unique ID. + * + * @param {string} params.variableId - Variable ID. + * @param {string} params.key - Variable key. Max length: 255 chars. + * @param {string} params.value - Variable value. Max length: 8192 chars. + * @param {boolean} params.secret - Secret variables can be updated or deleted, but only projects can read them during build and runtime. + * @throws {AppwriteException} + * @returns {Promise} + */ + updateVariable(params: { variableId: string, key?: string, value?: string, secret?: boolean }): Promise; + /** + * Update variable by its unique ID. + * + * @param {string} variableId - Variable ID. + * @param {string} key - Variable key. Max length: 255 chars. + * @param {string} value - Variable value. Max length: 8192 chars. + * @param {boolean} secret - Secret variables can be updated or deleted, but only projects can read them during build and runtime. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateVariable(variableId: string, key?: string, value?: string, secret?: boolean): Promise; + updateVariable( + paramsOrFirst: { variableId: string, key?: string, value?: string, secret?: boolean } | string, + ...rest: [(string)?, (string)?, (boolean)?] + ): Promise { + let params: { variableId: string, key?: string, value?: string, secret?: boolean }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { variableId: string, key?: string, value?: string, secret?: boolean }; + } else { + params = { + variableId: paramsOrFirst as string, + key: rest[0] as string, + value: rest[1] as string, + secret: rest[2] as boolean + }; + } + + const variableId = params.variableId; + const key = params.key; + const value = params.value; + const secret = params.secret; + + if (typeof variableId === 'undefined') { + throw new AppwriteException('Missing required parameter: "variableId"'); + } + + const apiPath = '/project/variables/{variableId}'.replace('{variableId}', variableId); + const payload: Payload = {}; + if (typeof key !== 'undefined') { + payload['key'] = key; + } + if (typeof value !== 'undefined') { + payload['value'] = value; + } + if (typeof secret !== 'undefined') { + payload['secret'] = secret; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'put', + uri, + apiHeaders, + payload, + ); + } + + /** + * Delete a variable by its unique ID. + * + * @param {string} params.variableId - Variable ID. + * @throws {AppwriteException} + * @returns {Promise<{}>} + */ + deleteVariable(params: { variableId: string }): Promise<{}>; + /** + * Delete a variable by its unique ID. + * + * @param {string} variableId - Variable ID. + * @throws {AppwriteException} + * @returns {Promise<{}>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + deleteVariable(variableId: string): Promise<{}>; + deleteVariable( + paramsOrFirst: { variableId: string } | string + ): Promise<{}> { + let params: { variableId: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { variableId: string }; + } else { + params = { + variableId: paramsOrFirst as string + }; + } + + const variableId = params.variableId; + + if (typeof variableId === 'undefined') { + throw new AppwriteException('Missing required parameter: "variableId"'); + } + + const apiPath = '/project/variables/{variableId}'.replace('{variableId}', variableId); + const payload: Payload = {}; + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'delete', + uri, + apiHeaders, + payload, + ); + } +} diff --git a/src/services/sites.ts b/src/services/sites.ts index 5018382a..4ae79aaf 100644 --- a/src/services/sites.ts +++ b/src/services/sites.ts @@ -93,6 +93,7 @@ export class Sites { * @param {number} params.timeout - Maximum request time in seconds. * @param {string} params.installCommand - Install Command. * @param {string} params.buildCommand - Build Command. + * @param {string} params.startCommand - Custom start command. Leave empty to use default. * @param {string} params.outputDirectory - Output Directory for site. * @param {Adapter} params.adapter - Framework adapter defining rendering strategy. Allowed values are: static, ssr * @param {string} params.installationId - Appwrite Installation ID for VCS (Version Control System) deployment. @@ -101,11 +102,13 @@ export class Sites { * @param {string} params.providerBranch - Production branch for the repo linked to the site. * @param {boolean} params.providerSilentMode - Is the VCS (Version Control System) connection in silent mode for the repo linked to the site? In silent mode, comments will not be made on commits and pull requests. * @param {string} params.providerRootDirectory - Path to site code in the linked repo. - * @param {string} params.specification - Framework specification for the site and builds. + * @param {string} params.buildSpecification - Build specification for the site deployments. + * @param {string} params.runtimeSpecification - Runtime specification for the SSR executions. + * @param {number} params.deploymentRetention - Days to keep non-active deployments before deletion. Value 0 means all deployments will be kept. * @throws {AppwriteException} * @returns {Promise} */ - create(params: { siteId: string, name: string, framework: Framework, buildRuntime: BuildRuntime, enabled?: boolean, logging?: boolean, timeout?: number, installCommand?: string, buildCommand?: string, outputDirectory?: string, adapter?: Adapter, installationId?: string, fallbackFile?: string, providerRepositoryId?: string, providerBranch?: string, providerSilentMode?: boolean, providerRootDirectory?: string, specification?: string }): Promise; + create(params: { siteId: string, name: string, framework: Framework, buildRuntime: BuildRuntime, enabled?: boolean, logging?: boolean, timeout?: number, installCommand?: string, buildCommand?: string, startCommand?: string, outputDirectory?: string, adapter?: Adapter, installationId?: string, fallbackFile?: string, providerRepositoryId?: string, providerBranch?: string, providerSilentMode?: boolean, providerRootDirectory?: string, buildSpecification?: string, runtimeSpecification?: string, deploymentRetention?: number }): Promise; /** * Create a new site. * @@ -118,6 +121,7 @@ export class Sites { * @param {number} timeout - Maximum request time in seconds. * @param {string} installCommand - Install Command. * @param {string} buildCommand - Build Command. + * @param {string} startCommand - Custom start command. Leave empty to use default. * @param {string} outputDirectory - Output Directory for site. * @param {Adapter} adapter - Framework adapter defining rendering strategy. Allowed values are: static, ssr * @param {string} installationId - Appwrite Installation ID for VCS (Version Control System) deployment. @@ -126,20 +130,22 @@ export class Sites { * @param {string} providerBranch - Production branch for the repo linked to the site. * @param {boolean} providerSilentMode - Is the VCS (Version Control System) connection in silent mode for the repo linked to the site? In silent mode, comments will not be made on commits and pull requests. * @param {string} providerRootDirectory - Path to site code in the linked repo. - * @param {string} specification - Framework specification for the site and builds. + * @param {string} buildSpecification - Build specification for the site deployments. + * @param {string} runtimeSpecification - Runtime specification for the SSR executions. + * @param {number} deploymentRetention - Days to keep non-active deployments before deletion. Value 0 means all deployments will be kept. * @throws {AppwriteException} * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - create(siteId: string, name: string, framework: Framework, buildRuntime: BuildRuntime, enabled?: boolean, logging?: boolean, timeout?: number, installCommand?: string, buildCommand?: string, outputDirectory?: string, adapter?: Adapter, installationId?: string, fallbackFile?: string, providerRepositoryId?: string, providerBranch?: string, providerSilentMode?: boolean, providerRootDirectory?: string, specification?: string): Promise; + create(siteId: string, name: string, framework: Framework, buildRuntime: BuildRuntime, enabled?: boolean, logging?: boolean, timeout?: number, installCommand?: string, buildCommand?: string, startCommand?: string, outputDirectory?: string, adapter?: Adapter, installationId?: string, fallbackFile?: string, providerRepositoryId?: string, providerBranch?: string, providerSilentMode?: boolean, providerRootDirectory?: string, buildSpecification?: string, runtimeSpecification?: string, deploymentRetention?: number): Promise; create( - paramsOrFirst: { siteId: string, name: string, framework: Framework, buildRuntime: BuildRuntime, enabled?: boolean, logging?: boolean, timeout?: number, installCommand?: string, buildCommand?: string, outputDirectory?: string, adapter?: Adapter, installationId?: string, fallbackFile?: string, providerRepositoryId?: string, providerBranch?: string, providerSilentMode?: boolean, providerRootDirectory?: string, specification?: string } | string, - ...rest: [(string)?, (Framework)?, (BuildRuntime)?, (boolean)?, (boolean)?, (number)?, (string)?, (string)?, (string)?, (Adapter)?, (string)?, (string)?, (string)?, (string)?, (boolean)?, (string)?, (string)?] + paramsOrFirst: { siteId: string, name: string, framework: Framework, buildRuntime: BuildRuntime, enabled?: boolean, logging?: boolean, timeout?: number, installCommand?: string, buildCommand?: string, startCommand?: string, outputDirectory?: string, adapter?: Adapter, installationId?: string, fallbackFile?: string, providerRepositoryId?: string, providerBranch?: string, providerSilentMode?: boolean, providerRootDirectory?: string, buildSpecification?: string, runtimeSpecification?: string, deploymentRetention?: number } | string, + ...rest: [(string)?, (Framework)?, (BuildRuntime)?, (boolean)?, (boolean)?, (number)?, (string)?, (string)?, (string)?, (string)?, (Adapter)?, (string)?, (string)?, (string)?, (string)?, (boolean)?, (string)?, (string)?, (string)?, (number)?] ): Promise { - let params: { siteId: string, name: string, framework: Framework, buildRuntime: BuildRuntime, enabled?: boolean, logging?: boolean, timeout?: number, installCommand?: string, buildCommand?: string, outputDirectory?: string, adapter?: Adapter, installationId?: string, fallbackFile?: string, providerRepositoryId?: string, providerBranch?: string, providerSilentMode?: boolean, providerRootDirectory?: string, specification?: string }; + let params: { siteId: string, name: string, framework: Framework, buildRuntime: BuildRuntime, enabled?: boolean, logging?: boolean, timeout?: number, installCommand?: string, buildCommand?: string, startCommand?: string, outputDirectory?: string, adapter?: Adapter, installationId?: string, fallbackFile?: string, providerRepositoryId?: string, providerBranch?: string, providerSilentMode?: boolean, providerRootDirectory?: string, buildSpecification?: string, runtimeSpecification?: string, deploymentRetention?: number }; if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { siteId: string, name: string, framework: Framework, buildRuntime: BuildRuntime, enabled?: boolean, logging?: boolean, timeout?: number, installCommand?: string, buildCommand?: string, outputDirectory?: string, adapter?: Adapter, installationId?: string, fallbackFile?: string, providerRepositoryId?: string, providerBranch?: string, providerSilentMode?: boolean, providerRootDirectory?: string, specification?: string }; + params = (paramsOrFirst || {}) as { siteId: string, name: string, framework: Framework, buildRuntime: BuildRuntime, enabled?: boolean, logging?: boolean, timeout?: number, installCommand?: string, buildCommand?: string, startCommand?: string, outputDirectory?: string, adapter?: Adapter, installationId?: string, fallbackFile?: string, providerRepositoryId?: string, providerBranch?: string, providerSilentMode?: boolean, providerRootDirectory?: string, buildSpecification?: string, runtimeSpecification?: string, deploymentRetention?: number }; } else { params = { siteId: paramsOrFirst as string, @@ -151,15 +157,18 @@ export class Sites { timeout: rest[5] as number, installCommand: rest[6] as string, buildCommand: rest[7] as string, - outputDirectory: rest[8] as string, - adapter: rest[9] as Adapter, - installationId: rest[10] as string, - fallbackFile: rest[11] as string, - providerRepositoryId: rest[12] as string, - providerBranch: rest[13] as string, - providerSilentMode: rest[14] as boolean, - providerRootDirectory: rest[15] as string, - specification: rest[16] as string + startCommand: rest[8] as string, + outputDirectory: rest[9] as string, + adapter: rest[10] as Adapter, + installationId: rest[11] as string, + fallbackFile: rest[12] as string, + providerRepositoryId: rest[13] as string, + providerBranch: rest[14] as string, + providerSilentMode: rest[15] as boolean, + providerRootDirectory: rest[16] as string, + buildSpecification: rest[17] as string, + runtimeSpecification: rest[18] as string, + deploymentRetention: rest[19] as number }; } @@ -172,6 +181,7 @@ export class Sites { const timeout = params.timeout; const installCommand = params.installCommand; const buildCommand = params.buildCommand; + const startCommand = params.startCommand; const outputDirectory = params.outputDirectory; const adapter = params.adapter; const installationId = params.installationId; @@ -180,7 +190,9 @@ export class Sites { const providerBranch = params.providerBranch; const providerSilentMode = params.providerSilentMode; const providerRootDirectory = params.providerRootDirectory; - const specification = params.specification; + const buildSpecification = params.buildSpecification; + const runtimeSpecification = params.runtimeSpecification; + const deploymentRetention = params.deploymentRetention; if (typeof siteId === 'undefined') { throw new AppwriteException('Missing required parameter: "siteId"'); @@ -221,6 +233,9 @@ export class Sites { if (typeof buildCommand !== 'undefined') { payload['buildCommand'] = buildCommand; } + if (typeof startCommand !== 'undefined') { + payload['startCommand'] = startCommand; + } if (typeof outputDirectory !== 'undefined') { payload['outputDirectory'] = outputDirectory; } @@ -248,8 +263,14 @@ export class Sites { if (typeof providerRootDirectory !== 'undefined') { payload['providerRootDirectory'] = providerRootDirectory; } - if (typeof specification !== 'undefined') { - payload['specification'] = specification; + if (typeof buildSpecification !== 'undefined') { + payload['buildSpecification'] = buildSpecification; + } + if (typeof runtimeSpecification !== 'undefined') { + payload['runtimeSpecification'] = runtimeSpecification; + } + if (typeof deploymentRetention !== 'undefined') { + payload['deploymentRetention'] = deploymentRetention; } const uri = new URL(this.client.config.endpoint + apiPath); @@ -373,6 +394,7 @@ export class Sites { * @param {number} params.timeout - Maximum request time in seconds. * @param {string} params.installCommand - Install Command. * @param {string} params.buildCommand - Build Command. + * @param {string} params.startCommand - Custom start command. Leave empty to use default. * @param {string} params.outputDirectory - Output Directory for site. * @param {BuildRuntime} params.buildRuntime - Runtime to use during build step. * @param {Adapter} params.adapter - Framework adapter defining rendering strategy. Allowed values are: static, ssr @@ -382,11 +404,13 @@ export class Sites { * @param {string} params.providerBranch - Production branch for the repo linked to the site. * @param {boolean} params.providerSilentMode - Is the VCS (Version Control System) connection in silent mode for the repo linked to the site? In silent mode, comments will not be made on commits and pull requests. * @param {string} params.providerRootDirectory - Path to site code in the linked repo. - * @param {string} params.specification - Framework specification for the site and builds. + * @param {string} params.buildSpecification - Build specification for the site deployments. + * @param {string} params.runtimeSpecification - Runtime specification for the SSR executions. + * @param {number} params.deploymentRetention - Days to keep non-active deployments before deletion. Value 0 means all deployments will be kept. * @throws {AppwriteException} * @returns {Promise} */ - update(params: { siteId: string, name: string, framework: Framework, enabled?: boolean, logging?: boolean, timeout?: number, installCommand?: string, buildCommand?: string, outputDirectory?: string, buildRuntime?: BuildRuntime, adapter?: Adapter, fallbackFile?: string, installationId?: string, providerRepositoryId?: string, providerBranch?: string, providerSilentMode?: boolean, providerRootDirectory?: string, specification?: string }): Promise; + update(params: { siteId: string, name: string, framework: Framework, enabled?: boolean, logging?: boolean, timeout?: number, installCommand?: string, buildCommand?: string, startCommand?: string, outputDirectory?: string, buildRuntime?: BuildRuntime, adapter?: Adapter, fallbackFile?: string, installationId?: string, providerRepositoryId?: string, providerBranch?: string, providerSilentMode?: boolean, providerRootDirectory?: string, buildSpecification?: string, runtimeSpecification?: string, deploymentRetention?: number }): Promise; /** * Update site by its unique ID. * @@ -398,6 +422,7 @@ export class Sites { * @param {number} timeout - Maximum request time in seconds. * @param {string} installCommand - Install Command. * @param {string} buildCommand - Build Command. + * @param {string} startCommand - Custom start command. Leave empty to use default. * @param {string} outputDirectory - Output Directory for site. * @param {BuildRuntime} buildRuntime - Runtime to use during build step. * @param {Adapter} adapter - Framework adapter defining rendering strategy. Allowed values are: static, ssr @@ -407,20 +432,22 @@ export class Sites { * @param {string} providerBranch - Production branch for the repo linked to the site. * @param {boolean} providerSilentMode - Is the VCS (Version Control System) connection in silent mode for the repo linked to the site? In silent mode, comments will not be made on commits and pull requests. * @param {string} providerRootDirectory - Path to site code in the linked repo. - * @param {string} specification - Framework specification for the site and builds. + * @param {string} buildSpecification - Build specification for the site deployments. + * @param {string} runtimeSpecification - Runtime specification for the SSR executions. + * @param {number} deploymentRetention - Days to keep non-active deployments before deletion. Value 0 means all deployments will be kept. * @throws {AppwriteException} * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - update(siteId: string, name: string, framework: Framework, enabled?: boolean, logging?: boolean, timeout?: number, installCommand?: string, buildCommand?: string, outputDirectory?: string, buildRuntime?: BuildRuntime, adapter?: Adapter, fallbackFile?: string, installationId?: string, providerRepositoryId?: string, providerBranch?: string, providerSilentMode?: boolean, providerRootDirectory?: string, specification?: string): Promise; + update(siteId: string, name: string, framework: Framework, enabled?: boolean, logging?: boolean, timeout?: number, installCommand?: string, buildCommand?: string, startCommand?: string, outputDirectory?: string, buildRuntime?: BuildRuntime, adapter?: Adapter, fallbackFile?: string, installationId?: string, providerRepositoryId?: string, providerBranch?: string, providerSilentMode?: boolean, providerRootDirectory?: string, buildSpecification?: string, runtimeSpecification?: string, deploymentRetention?: number): Promise; update( - paramsOrFirst: { siteId: string, name: string, framework: Framework, enabled?: boolean, logging?: boolean, timeout?: number, installCommand?: string, buildCommand?: string, outputDirectory?: string, buildRuntime?: BuildRuntime, adapter?: Adapter, fallbackFile?: string, installationId?: string, providerRepositoryId?: string, providerBranch?: string, providerSilentMode?: boolean, providerRootDirectory?: string, specification?: string } | string, - ...rest: [(string)?, (Framework)?, (boolean)?, (boolean)?, (number)?, (string)?, (string)?, (string)?, (BuildRuntime)?, (Adapter)?, (string)?, (string)?, (string)?, (string)?, (boolean)?, (string)?, (string)?] + paramsOrFirst: { siteId: string, name: string, framework: Framework, enabled?: boolean, logging?: boolean, timeout?: number, installCommand?: string, buildCommand?: string, startCommand?: string, outputDirectory?: string, buildRuntime?: BuildRuntime, adapter?: Adapter, fallbackFile?: string, installationId?: string, providerRepositoryId?: string, providerBranch?: string, providerSilentMode?: boolean, providerRootDirectory?: string, buildSpecification?: string, runtimeSpecification?: string, deploymentRetention?: number } | string, + ...rest: [(string)?, (Framework)?, (boolean)?, (boolean)?, (number)?, (string)?, (string)?, (string)?, (string)?, (BuildRuntime)?, (Adapter)?, (string)?, (string)?, (string)?, (string)?, (boolean)?, (string)?, (string)?, (string)?, (number)?] ): Promise { - let params: { siteId: string, name: string, framework: Framework, enabled?: boolean, logging?: boolean, timeout?: number, installCommand?: string, buildCommand?: string, outputDirectory?: string, buildRuntime?: BuildRuntime, adapter?: Adapter, fallbackFile?: string, installationId?: string, providerRepositoryId?: string, providerBranch?: string, providerSilentMode?: boolean, providerRootDirectory?: string, specification?: string }; + let params: { siteId: string, name: string, framework: Framework, enabled?: boolean, logging?: boolean, timeout?: number, installCommand?: string, buildCommand?: string, startCommand?: string, outputDirectory?: string, buildRuntime?: BuildRuntime, adapter?: Adapter, fallbackFile?: string, installationId?: string, providerRepositoryId?: string, providerBranch?: string, providerSilentMode?: boolean, providerRootDirectory?: string, buildSpecification?: string, runtimeSpecification?: string, deploymentRetention?: number }; if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { siteId: string, name: string, framework: Framework, enabled?: boolean, logging?: boolean, timeout?: number, installCommand?: string, buildCommand?: string, outputDirectory?: string, buildRuntime?: BuildRuntime, adapter?: Adapter, fallbackFile?: string, installationId?: string, providerRepositoryId?: string, providerBranch?: string, providerSilentMode?: boolean, providerRootDirectory?: string, specification?: string }; + params = (paramsOrFirst || {}) as { siteId: string, name: string, framework: Framework, enabled?: boolean, logging?: boolean, timeout?: number, installCommand?: string, buildCommand?: string, startCommand?: string, outputDirectory?: string, buildRuntime?: BuildRuntime, adapter?: Adapter, fallbackFile?: string, installationId?: string, providerRepositoryId?: string, providerBranch?: string, providerSilentMode?: boolean, providerRootDirectory?: string, buildSpecification?: string, runtimeSpecification?: string, deploymentRetention?: number }; } else { params = { siteId: paramsOrFirst as string, @@ -431,16 +458,19 @@ export class Sites { timeout: rest[4] as number, installCommand: rest[5] as string, buildCommand: rest[6] as string, - outputDirectory: rest[7] as string, - buildRuntime: rest[8] as BuildRuntime, - adapter: rest[9] as Adapter, - fallbackFile: rest[10] as string, - installationId: rest[11] as string, - providerRepositoryId: rest[12] as string, - providerBranch: rest[13] as string, - providerSilentMode: rest[14] as boolean, - providerRootDirectory: rest[15] as string, - specification: rest[16] as string + startCommand: rest[7] as string, + outputDirectory: rest[8] as string, + buildRuntime: rest[9] as BuildRuntime, + adapter: rest[10] as Adapter, + fallbackFile: rest[11] as string, + installationId: rest[12] as string, + providerRepositoryId: rest[13] as string, + providerBranch: rest[14] as string, + providerSilentMode: rest[15] as boolean, + providerRootDirectory: rest[16] as string, + buildSpecification: rest[17] as string, + runtimeSpecification: rest[18] as string, + deploymentRetention: rest[19] as number }; } @@ -452,6 +482,7 @@ export class Sites { const timeout = params.timeout; const installCommand = params.installCommand; const buildCommand = params.buildCommand; + const startCommand = params.startCommand; const outputDirectory = params.outputDirectory; const buildRuntime = params.buildRuntime; const adapter = params.adapter; @@ -461,7 +492,9 @@ export class Sites { const providerBranch = params.providerBranch; const providerSilentMode = params.providerSilentMode; const providerRootDirectory = params.providerRootDirectory; - const specification = params.specification; + const buildSpecification = params.buildSpecification; + const runtimeSpecification = params.runtimeSpecification; + const deploymentRetention = params.deploymentRetention; if (typeof siteId === 'undefined') { throw new AppwriteException('Missing required parameter: "siteId"'); @@ -496,6 +529,9 @@ export class Sites { if (typeof buildCommand !== 'undefined') { payload['buildCommand'] = buildCommand; } + if (typeof startCommand !== 'undefined') { + payload['startCommand'] = startCommand; + } if (typeof outputDirectory !== 'undefined') { payload['outputDirectory'] = outputDirectory; } @@ -523,8 +559,14 @@ export class Sites { if (typeof providerRootDirectory !== 'undefined') { payload['providerRootDirectory'] = providerRootDirectory; } - if (typeof specification !== 'undefined') { - payload['specification'] = specification; + if (typeof buildSpecification !== 'undefined') { + payload['buildSpecification'] = buildSpecification; + } + if (typeof runtimeSpecification !== 'undefined') { + payload['runtimeSpecification'] = runtimeSpecification; + } + if (typeof deploymentRetention !== 'undefined') { + payload['deploymentRetention'] = deploymentRetention; } const uri = new URL(this.client.config.endpoint + apiPath); diff --git a/src/services/tables-db.ts b/src/services/tables-db.ts index af1fa996..509e7554 100644 --- a/src/services/tables-db.ts +++ b/src/services/tables-db.ts @@ -3,7 +3,7 @@ import type { Models } from '../models'; import { RelationshipType } from '../enums/relationship-type'; import { RelationMutate } from '../enums/relation-mutate'; -import { IndexType } from '../enums/index-type'; +import { TablesDBIndexType } from '../enums/tables-db-index-type'; import { OrderBy } from '../enums/order-by'; export class TablesDB { @@ -4693,14 +4693,14 @@ export class TablesDB { * @param {string} params.databaseId - Database ID. * @param {string} params.tableId - Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable). * @param {string} params.key - Index Key. - * @param {IndexType} params.type - Index type. + * @param {TablesDBIndexType} params.type - Index type. * @param {string[]} params.columns - Array of columns to index. Maximum of 100 columns are allowed, each 32 characters long. * @param {OrderBy[]} params.orders - Array of index orders. Maximum of 100 orders are allowed. * @param {number[]} params.lengths - Length of index. Maximum of 100 * @throws {AppwriteException} * @returns {Promise} */ - createIndex(params: { databaseId: string, tableId: string, key: string, type: IndexType, columns: string[], orders?: OrderBy[], lengths?: number[] }): Promise; + createIndex(params: { databaseId: string, tableId: string, key: string, type: TablesDBIndexType, columns: string[], orders?: OrderBy[], lengths?: number[] }): Promise; /** * Creates an index on the columns listed. Your index should include all the columns you will query in a single request. * Type can be `key`, `fulltext`, or `unique`. @@ -4708,7 +4708,7 @@ export class TablesDB { * @param {string} databaseId - Database ID. * @param {string} tableId - Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable). * @param {string} key - Index Key. - * @param {IndexType} type - Index type. + * @param {TablesDBIndexType} type - Index type. * @param {string[]} columns - Array of columns to index. Maximum of 100 columns are allowed, each 32 characters long. * @param {OrderBy[]} orders - Array of index orders. Maximum of 100 orders are allowed. * @param {number[]} lengths - Length of index. Maximum of 100 @@ -4716,21 +4716,21 @@ export class TablesDB { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createIndex(databaseId: string, tableId: string, key: string, type: IndexType, columns: string[], orders?: OrderBy[], lengths?: number[]): Promise; + createIndex(databaseId: string, tableId: string, key: string, type: TablesDBIndexType, columns: string[], orders?: OrderBy[], lengths?: number[]): Promise; createIndex( - paramsOrFirst: { databaseId: string, tableId: string, key: string, type: IndexType, columns: string[], orders?: OrderBy[], lengths?: number[] } | string, - ...rest: [(string)?, (string)?, (IndexType)?, (string[])?, (OrderBy[])?, (number[])?] + paramsOrFirst: { databaseId: string, tableId: string, key: string, type: TablesDBIndexType, columns: string[], orders?: OrderBy[], lengths?: number[] } | string, + ...rest: [(string)?, (string)?, (TablesDBIndexType)?, (string[])?, (OrderBy[])?, (number[])?] ): Promise { - let params: { databaseId: string, tableId: string, key: string, type: IndexType, columns: string[], orders?: OrderBy[], lengths?: number[] }; + let params: { databaseId: string, tableId: string, key: string, type: TablesDBIndexType, columns: string[], orders?: OrderBy[], lengths?: number[] }; if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, tableId: string, key: string, type: IndexType, columns: string[], orders?: OrderBy[], lengths?: number[] }; + params = (paramsOrFirst || {}) as { databaseId: string, tableId: string, key: string, type: TablesDBIndexType, columns: string[], orders?: OrderBy[], lengths?: number[] }; } else { params = { databaseId: paramsOrFirst as string, tableId: rest[0] as string, key: rest[1] as string, - type: rest[2] as IndexType, + type: rest[2] as TablesDBIndexType, columns: rest[3] as string[], orders: rest[4] as OrderBy[], lengths: rest[5] as number[] diff --git a/src/services/users.ts b/src/services/users.ts index a837dcb9..7bef1693 100644 --- a/src/services/users.ts +++ b/src/services/users.ts @@ -15,7 +15,7 @@ export class Users { /** * Get a list of all the project's users. You can use the query params to filter your results. * - * @param {string[]} params.queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: name, email, phone, status, passwordUpdate, registration, emailVerification, phoneVerification, labels + * @param {string[]} params.queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: name, email, phone, status, passwordUpdate, registration, emailVerification, phoneVerification, labels, impersonator * @param {string} params.search - Search term to filter your list results. Max length: 256 chars. * @param {boolean} params.total - When set to false, the total count returned will be 0 and will not be calculated. * @throws {AppwriteException} @@ -25,7 +25,7 @@ export class Users { /** * Get a list of all the project's users. You can use the query params to filter your results. * - * @param {string[]} queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: name, email, phone, status, passwordUpdate, registration, emailVerification, phoneVerification, labels + * @param {string[]} queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: name, email, phone, status, passwordUpdate, registration, emailVerification, phoneVerification, labels, impersonator * @param {string} search - Search term to filter your list results. Max length: 256 chars. * @param {boolean} total - When set to false, the total count returned will be 0 and will not be calculated. * @throws {AppwriteException} @@ -1114,6 +1114,71 @@ export class Users { ); } + /** + * Enable or disable whether a user can impersonate other users. When impersonation headers are used, the request runs as the target user for API behavior, while internal audit logs still attribute the action to the original impersonator and store the impersonated target details only in internal audit payload data. + * + * + * @param {string} params.userId - User ID. + * @param {boolean} params.impersonator - Whether the user can impersonate other users. When true, the user can browse project users to choose a target and can pass impersonation headers to act as that user. Internal audit logs still attribute impersonated actions to the original impersonator and store the target user details only in internal audit payload data. + * @throws {AppwriteException} + * @returns {Promise>} + */ + updateImpersonator(params: { userId: string, impersonator: boolean }): Promise>; + /** + * Enable or disable whether a user can impersonate other users. When impersonation headers are used, the request runs as the target user for API behavior, while internal audit logs still attribute the action to the original impersonator and store the impersonated target details only in internal audit payload data. + * + * + * @param {string} userId - User ID. + * @param {boolean} impersonator - Whether the user can impersonate other users. When true, the user can browse project users to choose a target and can pass impersonation headers to act as that user. Internal audit logs still attribute impersonated actions to the original impersonator and store the target user details only in internal audit payload data. + * @throws {AppwriteException} + * @returns {Promise>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateImpersonator(userId: string, impersonator: boolean): Promise>; + updateImpersonator( + paramsOrFirst: { userId: string, impersonator: boolean } | string, + ...rest: [(boolean)?] + ): Promise> { + let params: { userId: string, impersonator: boolean }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { userId: string, impersonator: boolean }; + } else { + params = { + userId: paramsOrFirst as string, + impersonator: rest[0] as boolean + }; + } + + const userId = params.userId; + const impersonator = params.impersonator; + + if (typeof userId === 'undefined') { + throw new AppwriteException('Missing required parameter: "userId"'); + } + if (typeof impersonator === 'undefined') { + throw new AppwriteException('Missing required parameter: "impersonator"'); + } + + const apiPath = '/users/{userId}/impersonator'.replace('{userId}', userId); + const payload: Payload = {}; + if (typeof impersonator !== 'undefined') { + payload['impersonator'] = impersonator; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'patch', + uri, + apiHeaders, + payload, + ); + } + /** * Use this endpoint to create a JSON Web Token for user by its unique ID. You can use the resulting JWT to authenticate on behalf of the user. The JWT secret will become invalid if the session it uses gets deleted. * diff --git a/src/services/vectors-db.ts b/src/services/vectors-db.ts new file mode 100644 index 00000000..5a9dca25 --- /dev/null +++ b/src/services/vectors-db.ts @@ -0,0 +1,2170 @@ +import { AppwriteException, Client, type Payload, UploadProgress } from '../client'; +import type { Models } from '../models'; + +import { Model } from '../enums/model'; +import { VectorsDBIndexType } from '../enums/vectors-db-index-type'; +import { OrderBy } from '../enums/order-by'; + +export class VectorsDB { + client: Client; + + constructor(client: Client) { + this.client = client; + } + + /** + * + * @param {string[]} params.queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following columns: name + * @param {string} params.search - Search term to filter your list results. Max length: 256 chars. + * @param {boolean} params.total - When set to false, the total count returned will be 0 and will not be calculated. + * @throws {AppwriteException} + * @returns {Promise} + */ + list(params?: { queries?: string[], search?: string, total?: boolean }): Promise; + /** + * + * @param {string[]} queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following columns: name + * @param {string} search - Search term to filter your list results. Max length: 256 chars. + * @param {boolean} total - When set to false, the total count returned will be 0 and will not be calculated. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + list(queries?: string[], search?: string, total?: boolean): Promise; + list( + paramsOrFirst?: { queries?: string[], search?: string, total?: boolean } | string[], + ...rest: [(string)?, (boolean)?] + ): Promise { + let params: { queries?: string[], search?: string, total?: boolean }; + + if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { queries?: string[], search?: string, total?: boolean }; + } else { + params = { + queries: paramsOrFirst as string[], + search: rest[0] as string, + total: rest[1] as boolean + }; + } + + const queries = params.queries; + const search = params.search; + const total = params.total; + + + const apiPath = '/vectorsdb'; + const payload: Payload = {}; + if (typeof queries !== 'undefined') { + payload['queries'] = queries; + } + if (typeof search !== 'undefined') { + payload['search'] = search; + } + if (typeof total !== 'undefined') { + payload['total'] = total; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + } + + return this.client.call( + 'get', + uri, + apiHeaders, + payload, + ); + } + + /** + * + * @param {string} params.databaseId - Unique Id. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + * @param {string} params.name - Database name. Max length: 128 chars. + * @param {boolean} params.enabled - Is the database enabled? When set to 'disabled', users cannot access the database but Server SDKs with an API key can still read and write to the database. No data is lost when this is toggled. + * @throws {AppwriteException} + * @returns {Promise} + */ + create(params: { databaseId: string, name: string, enabled?: boolean }): Promise; + /** + * + * @param {string} databaseId - Unique Id. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + * @param {string} name - Database name. Max length: 128 chars. + * @param {boolean} enabled - Is the database enabled? When set to 'disabled', users cannot access the database but Server SDKs with an API key can still read and write to the database. No data is lost when this is toggled. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + create(databaseId: string, name: string, enabled?: boolean): Promise; + create( + paramsOrFirst: { databaseId: string, name: string, enabled?: boolean } | string, + ...rest: [(string)?, (boolean)?] + ): Promise { + let params: { databaseId: string, name: string, enabled?: boolean }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { databaseId: string, name: string, enabled?: boolean }; + } else { + params = { + databaseId: paramsOrFirst as string, + name: rest[0] as string, + enabled: rest[1] as boolean + }; + } + + const databaseId = params.databaseId; + const name = params.name; + const enabled = params.enabled; + + if (typeof databaseId === 'undefined') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + if (typeof name === 'undefined') { + throw new AppwriteException('Missing required parameter: "name"'); + } + + const apiPath = '/vectorsdb'; + const payload: Payload = {}; + if (typeof databaseId !== 'undefined') { + payload['databaseId'] = databaseId; + } + if (typeof name !== 'undefined') { + payload['name'] = name; + } + if (typeof enabled !== 'undefined') { + payload['enabled'] = enabled; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'post', + uri, + apiHeaders, + payload, + ); + } + + /** + * + * @param {string[]} params.texts - Array of text to generate embeddings. + * @param {Model} params.model - The embedding model to use for generating vector embeddings. + * @throws {AppwriteException} + * @returns {Promise} + */ + createTextEmbeddings(params: { texts: string[], model?: Model }): Promise; + /** + * + * @param {string[]} texts - Array of text to generate embeddings. + * @param {Model} model - The embedding model to use for generating vector embeddings. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createTextEmbeddings(texts: string[], model?: Model): Promise; + createTextEmbeddings( + paramsOrFirst: { texts: string[], model?: Model } | string[], + ...rest: [(Model)?] + ): Promise { + let params: { texts: string[], model?: Model }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { texts: string[], model?: Model }; + } else { + params = { + texts: paramsOrFirst as string[], + model: rest[0] as Model + }; + } + + const texts = params.texts; + const model = params.model; + + if (typeof texts === 'undefined') { + throw new AppwriteException('Missing required parameter: "texts"'); + } + + const apiPath = '/vectorsdb/embeddings/text'; + const payload: Payload = {}; + if (typeof texts !== 'undefined') { + payload['texts'] = texts; + } + if (typeof model !== 'undefined') { + payload['model'] = model; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'post', + uri, + apiHeaders, + payload, + ); + } + + /** + * + * @param {string[]} params.queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). + * @throws {AppwriteException} + * @returns {Promise} + */ + listTransactions(params?: { queries?: string[] }): Promise; + /** + * + * @param {string[]} queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + listTransactions(queries?: string[]): Promise; + listTransactions( + paramsOrFirst?: { queries?: string[] } | string[] + ): Promise { + let params: { queries?: string[] }; + + if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { queries?: string[] }; + } else { + params = { + queries: paramsOrFirst as string[] + }; + } + + const queries = params.queries; + + + const apiPath = '/vectorsdb/transactions'; + const payload: Payload = {}; + if (typeof queries !== 'undefined') { + payload['queries'] = queries; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + } + + return this.client.call( + 'get', + uri, + apiHeaders, + payload, + ); + } + + /** + * + * @param {number} params.ttl - Seconds before the transaction expires. + * @throws {AppwriteException} + * @returns {Promise} + */ + createTransaction(params?: { ttl?: number }): Promise; + /** + * + * @param {number} ttl - Seconds before the transaction expires. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createTransaction(ttl?: number): Promise; + createTransaction( + paramsOrFirst?: { ttl?: number } | number + ): Promise { + let params: { ttl?: number }; + + if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { ttl?: number }; + } else { + params = { + ttl: paramsOrFirst as number + }; + } + + const ttl = params.ttl; + + + const apiPath = '/vectorsdb/transactions'; + const payload: Payload = {}; + if (typeof ttl !== 'undefined') { + payload['ttl'] = ttl; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'post', + uri, + apiHeaders, + payload, + ); + } + + /** + * + * @param {string} params.transactionId - Transaction ID. + * @throws {AppwriteException} + * @returns {Promise} + */ + getTransaction(params: { transactionId: string }): Promise; + /** + * + * @param {string} transactionId - Transaction ID. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + getTransaction(transactionId: string): Promise; + getTransaction( + paramsOrFirst: { transactionId: string } | string + ): Promise { + let params: { transactionId: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { transactionId: string }; + } else { + params = { + transactionId: paramsOrFirst as string + }; + } + + const transactionId = params.transactionId; + + if (typeof transactionId === 'undefined') { + throw new AppwriteException('Missing required parameter: "transactionId"'); + } + + const apiPath = '/vectorsdb/transactions/{transactionId}'.replace('{transactionId}', transactionId); + const payload: Payload = {}; + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + } + + return this.client.call( + 'get', + uri, + apiHeaders, + payload, + ); + } + + /** + * + * @param {string} params.transactionId - Transaction ID. + * @param {boolean} params.commit - Commit transaction? + * @param {boolean} params.rollback - Rollback transaction? + * @throws {AppwriteException} + * @returns {Promise} + */ + updateTransaction(params: { transactionId: string, commit?: boolean, rollback?: boolean }): Promise; + /** + * + * @param {string} transactionId - Transaction ID. + * @param {boolean} commit - Commit transaction? + * @param {boolean} rollback - Rollback transaction? + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateTransaction(transactionId: string, commit?: boolean, rollback?: boolean): Promise; + updateTransaction( + paramsOrFirst: { transactionId: string, commit?: boolean, rollback?: boolean } | string, + ...rest: [(boolean)?, (boolean)?] + ): Promise { + let params: { transactionId: string, commit?: boolean, rollback?: boolean }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { transactionId: string, commit?: boolean, rollback?: boolean }; + } else { + params = { + transactionId: paramsOrFirst as string, + commit: rest[0] as boolean, + rollback: rest[1] as boolean + }; + } + + const transactionId = params.transactionId; + const commit = params.commit; + const rollback = params.rollback; + + if (typeof transactionId === 'undefined') { + throw new AppwriteException('Missing required parameter: "transactionId"'); + } + + const apiPath = '/vectorsdb/transactions/{transactionId}'.replace('{transactionId}', transactionId); + const payload: Payload = {}; + if (typeof commit !== 'undefined') { + payload['commit'] = commit; + } + if (typeof rollback !== 'undefined') { + payload['rollback'] = rollback; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'patch', + uri, + apiHeaders, + payload, + ); + } + + /** + * + * @param {string} params.transactionId - Transaction ID. + * @throws {AppwriteException} + * @returns {Promise<{}>} + */ + deleteTransaction(params: { transactionId: string }): Promise<{}>; + /** + * + * @param {string} transactionId - Transaction ID. + * @throws {AppwriteException} + * @returns {Promise<{}>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + deleteTransaction(transactionId: string): Promise<{}>; + deleteTransaction( + paramsOrFirst: { transactionId: string } | string + ): Promise<{}> { + let params: { transactionId: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { transactionId: string }; + } else { + params = { + transactionId: paramsOrFirst as string + }; + } + + const transactionId = params.transactionId; + + if (typeof transactionId === 'undefined') { + throw new AppwriteException('Missing required parameter: "transactionId"'); + } + + const apiPath = '/vectorsdb/transactions/{transactionId}'.replace('{transactionId}', transactionId); + const payload: Payload = {}; + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'delete', + uri, + apiHeaders, + payload, + ); + } + + /** + * + * @param {string} params.transactionId - Transaction ID. + * @param {object[]} params.operations - Array of staged operations. + * @throws {AppwriteException} + * @returns {Promise} + */ + createOperations(params: { transactionId: string, operations?: object[] }): Promise; + /** + * + * @param {string} transactionId - Transaction ID. + * @param {object[]} operations - Array of staged operations. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createOperations(transactionId: string, operations?: object[]): Promise; + createOperations( + paramsOrFirst: { transactionId: string, operations?: object[] } | string, + ...rest: [(object[])?] + ): Promise { + let params: { transactionId: string, operations?: object[] }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { transactionId: string, operations?: object[] }; + } else { + params = { + transactionId: paramsOrFirst as string, + operations: rest[0] as object[] + }; + } + + const transactionId = params.transactionId; + const operations = params.operations; + + if (typeof transactionId === 'undefined') { + throw new AppwriteException('Missing required parameter: "transactionId"'); + } + + const apiPath = '/vectorsdb/transactions/{transactionId}/operations'.replace('{transactionId}', transactionId); + const payload: Payload = {}; + if (typeof operations !== 'undefined') { + payload['operations'] = operations; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'post', + uri, + apiHeaders, + payload, + ); + } + + /** + * + * @param {string} params.databaseId - Database ID. + * @throws {AppwriteException} + * @returns {Promise} + */ + get(params: { databaseId: string }): Promise; + /** + * + * @param {string} databaseId - Database ID. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + get(databaseId: string): Promise; + get( + paramsOrFirst: { databaseId: string } | string + ): Promise { + let params: { databaseId: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { databaseId: string }; + } else { + params = { + databaseId: paramsOrFirst as string + }; + } + + const databaseId = params.databaseId; + + if (typeof databaseId === 'undefined') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + const apiPath = '/vectorsdb/{databaseId}'.replace('{databaseId}', databaseId); + const payload: Payload = {}; + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + } + + return this.client.call( + 'get', + uri, + apiHeaders, + payload, + ); + } + + /** + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.name - Database name. Max length: 128 chars. + * @param {boolean} params.enabled - Is database enabled? When set to 'disabled', users cannot access the database but Server SDKs with an API key can still read and write to the database. No data is lost when this is toggled. + * @throws {AppwriteException} + * @returns {Promise} + */ + update(params: { databaseId: string, name: string, enabled?: boolean }): Promise; + /** + * + * @param {string} databaseId - Database ID. + * @param {string} name - Database name. Max length: 128 chars. + * @param {boolean} enabled - Is database enabled? When set to 'disabled', users cannot access the database but Server SDKs with an API key can still read and write to the database. No data is lost when this is toggled. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + update(databaseId: string, name: string, enabled?: boolean): Promise; + update( + paramsOrFirst: { databaseId: string, name: string, enabled?: boolean } | string, + ...rest: [(string)?, (boolean)?] + ): Promise { + let params: { databaseId: string, name: string, enabled?: boolean }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { databaseId: string, name: string, enabled?: boolean }; + } else { + params = { + databaseId: paramsOrFirst as string, + name: rest[0] as string, + enabled: rest[1] as boolean + }; + } + + const databaseId = params.databaseId; + const name = params.name; + const enabled = params.enabled; + + if (typeof databaseId === 'undefined') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + if (typeof name === 'undefined') { + throw new AppwriteException('Missing required parameter: "name"'); + } + + const apiPath = '/vectorsdb/{databaseId}'.replace('{databaseId}', databaseId); + const payload: Payload = {}; + if (typeof name !== 'undefined') { + payload['name'] = name; + } + if (typeof enabled !== 'undefined') { + payload['enabled'] = enabled; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'put', + uri, + apiHeaders, + payload, + ); + } + + /** + * + * @param {string} params.databaseId - Database ID. + * @throws {AppwriteException} + * @returns {Promise<{}>} + */ + delete(params: { databaseId: string }): Promise<{}>; + /** + * + * @param {string} databaseId - Database ID. + * @throws {AppwriteException} + * @returns {Promise<{}>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + delete(databaseId: string): Promise<{}>; + delete( + paramsOrFirst: { databaseId: string } | string + ): Promise<{}> { + let params: { databaseId: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { databaseId: string }; + } else { + params = { + databaseId: paramsOrFirst as string + }; + } + + const databaseId = params.databaseId; + + if (typeof databaseId === 'undefined') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + const apiPath = '/vectorsdb/{databaseId}'.replace('{databaseId}', databaseId); + const payload: Payload = {}; + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'delete', + uri, + apiHeaders, + payload, + ); + } + + /** + * + * @param {string} params.databaseId - Database ID. + * @param {string[]} params.queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: name, enabled, documentSecurity + * @param {string} params.search - Search term to filter your list results. Max length: 256 chars. + * @param {boolean} params.total - When set to false, the total count returned will be 0 and will not be calculated. + * @throws {AppwriteException} + * @returns {Promise} + */ + listCollections(params: { databaseId: string, queries?: string[], search?: string, total?: boolean }): Promise; + /** + * + * @param {string} databaseId - Database ID. + * @param {string[]} queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: name, enabled, documentSecurity + * @param {string} search - Search term to filter your list results. Max length: 256 chars. + * @param {boolean} total - When set to false, the total count returned will be 0 and will not be calculated. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + listCollections(databaseId: string, queries?: string[], search?: string, total?: boolean): Promise; + listCollections( + paramsOrFirst: { databaseId: string, queries?: string[], search?: string, total?: boolean } | string, + ...rest: [(string[])?, (string)?, (boolean)?] + ): Promise { + let params: { databaseId: string, queries?: string[], search?: string, total?: boolean }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { databaseId: string, queries?: string[], search?: string, total?: boolean }; + } else { + params = { + databaseId: paramsOrFirst as string, + queries: rest[0] as string[], + search: rest[1] as string, + total: rest[2] as boolean + }; + } + + const databaseId = params.databaseId; + const queries = params.queries; + const search = params.search; + const total = params.total; + + if (typeof databaseId === 'undefined') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + const apiPath = '/vectorsdb/{databaseId}/collections'.replace('{databaseId}', databaseId); + const payload: Payload = {}; + if (typeof queries !== 'undefined') { + payload['queries'] = queries; + } + if (typeof search !== 'undefined') { + payload['search'] = search; + } + if (typeof total !== 'undefined') { + payload['total'] = total; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + } + + return this.client.call( + 'get', + uri, + apiHeaders, + payload, + ); + } + + /** + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.collectionId - Unique Id. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + * @param {string} params.name - Collection name. Max length: 128 chars. + * @param {number} params.dimension - Embedding dimension. + * @param {string[]} params.permissions - An array of permissions strings. By default, no user is granted with any permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). + * @param {boolean} params.documentSecurity - Enables configuring permissions for individual documents. A user needs one of document or collection level permissions to access a document. [Learn more about permissions](https://appwrite.io/docs/permissions). + * @param {boolean} params.enabled - Is collection enabled? When set to 'disabled', users cannot access the collection but Server SDKs with and API key can still read and write to the collection. No data is lost when this is toggled. + * @throws {AppwriteException} + * @returns {Promise} + */ + createCollection(params: { databaseId: string, collectionId: string, name: string, dimension: number, permissions?: string[], documentSecurity?: boolean, enabled?: boolean }): Promise; + /** + * + * @param {string} databaseId - Database ID. + * @param {string} collectionId - Unique Id. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + * @param {string} name - Collection name. Max length: 128 chars. + * @param {number} dimension - Embedding dimension. + * @param {string[]} permissions - An array of permissions strings. By default, no user is granted with any permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). + * @param {boolean} documentSecurity - Enables configuring permissions for individual documents. A user needs one of document or collection level permissions to access a document. [Learn more about permissions](https://appwrite.io/docs/permissions). + * @param {boolean} enabled - Is collection enabled? When set to 'disabled', users cannot access the collection but Server SDKs with and API key can still read and write to the collection. No data is lost when this is toggled. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createCollection(databaseId: string, collectionId: string, name: string, dimension: number, permissions?: string[], documentSecurity?: boolean, enabled?: boolean): Promise; + createCollection( + paramsOrFirst: { databaseId: string, collectionId: string, name: string, dimension: number, permissions?: string[], documentSecurity?: boolean, enabled?: boolean } | string, + ...rest: [(string)?, (string)?, (number)?, (string[])?, (boolean)?, (boolean)?] + ): Promise { + let params: { databaseId: string, collectionId: string, name: string, dimension: number, permissions?: string[], documentSecurity?: boolean, enabled?: boolean }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, name: string, dimension: number, permissions?: string[], documentSecurity?: boolean, enabled?: boolean }; + } else { + params = { + databaseId: paramsOrFirst as string, + collectionId: rest[0] as string, + name: rest[1] as string, + dimension: rest[2] as number, + permissions: rest[3] as string[], + documentSecurity: rest[4] as boolean, + enabled: rest[5] as boolean + }; + } + + const databaseId = params.databaseId; + const collectionId = params.collectionId; + const name = params.name; + const dimension = params.dimension; + const permissions = params.permissions; + const documentSecurity = params.documentSecurity; + const enabled = params.enabled; + + if (typeof databaseId === 'undefined') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + if (typeof collectionId === 'undefined') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + if (typeof name === 'undefined') { + throw new AppwriteException('Missing required parameter: "name"'); + } + if (typeof dimension === 'undefined') { + throw new AppwriteException('Missing required parameter: "dimension"'); + } + + const apiPath = '/vectorsdb/{databaseId}/collections'.replace('{databaseId}', databaseId); + const payload: Payload = {}; + if (typeof collectionId !== 'undefined') { + payload['collectionId'] = collectionId; + } + if (typeof name !== 'undefined') { + payload['name'] = name; + } + if (typeof dimension !== 'undefined') { + payload['dimension'] = dimension; + } + if (typeof permissions !== 'undefined') { + payload['permissions'] = permissions; + } + if (typeof documentSecurity !== 'undefined') { + payload['documentSecurity'] = documentSecurity; + } + if (typeof enabled !== 'undefined') { + payload['enabled'] = enabled; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'post', + uri, + apiHeaders, + payload, + ); + } + + /** + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.collectionId - Collection ID. + * @throws {AppwriteException} + * @returns {Promise} + */ + getCollection(params: { databaseId: string, collectionId: string }): Promise; + /** + * + * @param {string} databaseId - Database ID. + * @param {string} collectionId - Collection ID. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + getCollection(databaseId: string, collectionId: string): Promise; + getCollection( + paramsOrFirst: { databaseId: string, collectionId: string } | string, + ...rest: [(string)?] + ): Promise { + let params: { databaseId: string, collectionId: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string }; + } else { + params = { + databaseId: paramsOrFirst as string, + collectionId: rest[0] as string + }; + } + + const databaseId = params.databaseId; + const collectionId = params.collectionId; + + if (typeof databaseId === 'undefined') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + if (typeof collectionId === 'undefined') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + + const apiPath = '/vectorsdb/{databaseId}/collections/{collectionId}'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId); + const payload: Payload = {}; + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + } + + return this.client.call( + 'get', + uri, + apiHeaders, + payload, + ); + } + + /** + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.collectionId - Collection ID. + * @param {string} params.name - Collection name. Max length: 128 chars. + * @param {number} params.dimension - Embedding dimensions. + * @param {string[]} params.permissions - An array of permission strings. By default, the current permissions are inherited. [Learn more about permissions](https://appwrite.io/docs/permissions). + * @param {boolean} params.documentSecurity - Enables configuring permissions for individual documents. A user needs one of document or collection level permissions to access a document. [Learn more about permissions](https://appwrite.io/docs/permissions). + * @param {boolean} params.enabled - Is collection enabled? When set to 'disabled', users cannot access the collection but Server SDKs with and API key can still read and write to the collection. No data is lost when this is toggled. + * @throws {AppwriteException} + * @returns {Promise} + */ + updateCollection(params: { databaseId: string, collectionId: string, name: string, dimension?: number, permissions?: string[], documentSecurity?: boolean, enabled?: boolean }): Promise; + /** + * + * @param {string} databaseId - Database ID. + * @param {string} collectionId - Collection ID. + * @param {string} name - Collection name. Max length: 128 chars. + * @param {number} dimension - Embedding dimensions. + * @param {string[]} permissions - An array of permission strings. By default, the current permissions are inherited. [Learn more about permissions](https://appwrite.io/docs/permissions). + * @param {boolean} documentSecurity - Enables configuring permissions for individual documents. A user needs one of document or collection level permissions to access a document. [Learn more about permissions](https://appwrite.io/docs/permissions). + * @param {boolean} enabled - Is collection enabled? When set to 'disabled', users cannot access the collection but Server SDKs with and API key can still read and write to the collection. No data is lost when this is toggled. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateCollection(databaseId: string, collectionId: string, name: string, dimension?: number, permissions?: string[], documentSecurity?: boolean, enabled?: boolean): Promise; + updateCollection( + paramsOrFirst: { databaseId: string, collectionId: string, name: string, dimension?: number, permissions?: string[], documentSecurity?: boolean, enabled?: boolean } | string, + ...rest: [(string)?, (string)?, (number)?, (string[])?, (boolean)?, (boolean)?] + ): Promise { + let params: { databaseId: string, collectionId: string, name: string, dimension?: number, permissions?: string[], documentSecurity?: boolean, enabled?: boolean }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, name: string, dimension?: number, permissions?: string[], documentSecurity?: boolean, enabled?: boolean }; + } else { + params = { + databaseId: paramsOrFirst as string, + collectionId: rest[0] as string, + name: rest[1] as string, + dimension: rest[2] as number, + permissions: rest[3] as string[], + documentSecurity: rest[4] as boolean, + enabled: rest[5] as boolean + }; + } + + const databaseId = params.databaseId; + const collectionId = params.collectionId; + const name = params.name; + const dimension = params.dimension; + const permissions = params.permissions; + const documentSecurity = params.documentSecurity; + const enabled = params.enabled; + + if (typeof databaseId === 'undefined') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + if (typeof collectionId === 'undefined') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + if (typeof name === 'undefined') { + throw new AppwriteException('Missing required parameter: "name"'); + } + + const apiPath = '/vectorsdb/{databaseId}/collections/{collectionId}'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId); + const payload: Payload = {}; + if (typeof name !== 'undefined') { + payload['name'] = name; + } + if (typeof dimension !== 'undefined') { + payload['dimension'] = dimension; + } + if (typeof permissions !== 'undefined') { + payload['permissions'] = permissions; + } + if (typeof documentSecurity !== 'undefined') { + payload['documentSecurity'] = documentSecurity; + } + if (typeof enabled !== 'undefined') { + payload['enabled'] = enabled; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'put', + uri, + apiHeaders, + payload, + ); + } + + /** + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.collectionId - Collection ID. + * @throws {AppwriteException} + * @returns {Promise<{}>} + */ + deleteCollection(params: { databaseId: string, collectionId: string }): Promise<{}>; + /** + * + * @param {string} databaseId - Database ID. + * @param {string} collectionId - Collection ID. + * @throws {AppwriteException} + * @returns {Promise<{}>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + deleteCollection(databaseId: string, collectionId: string): Promise<{}>; + deleteCollection( + paramsOrFirst: { databaseId: string, collectionId: string } | string, + ...rest: [(string)?] + ): Promise<{}> { + let params: { databaseId: string, collectionId: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string }; + } else { + params = { + databaseId: paramsOrFirst as string, + collectionId: rest[0] as string + }; + } + + const databaseId = params.databaseId; + const collectionId = params.collectionId; + + if (typeof databaseId === 'undefined') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + if (typeof collectionId === 'undefined') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + + const apiPath = '/vectorsdb/{databaseId}/collections/{collectionId}'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId); + const payload: Payload = {}; + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'delete', + uri, + apiHeaders, + payload, + ); + } + + /** + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). + * @param {string[]} params.queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. + * @param {string} params.transactionId - Transaction ID to read uncommitted changes within the transaction. + * @param {boolean} params.total - When set to false, the total count returned will be 0 and will not be calculated. + * @param {number} params.ttl - TTL (seconds) for cached responses when caching is enabled for select queries. Must be between 0 and 86400 (24 hours). + * @throws {AppwriteException} + * @returns {Promise>} + */ + listDocuments(params: { databaseId: string, collectionId: string, queries?: string[], transactionId?: string, total?: boolean, ttl?: number }): Promise>; + /** + * + * @param {string} databaseId - Database ID. + * @param {string} collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). + * @param {string[]} queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. + * @param {string} transactionId - Transaction ID to read uncommitted changes within the transaction. + * @param {boolean} total - When set to false, the total count returned will be 0 and will not be calculated. + * @param {number} ttl - TTL (seconds) for cached responses when caching is enabled for select queries. Must be between 0 and 86400 (24 hours). + * @throws {AppwriteException} + * @returns {Promise>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + listDocuments(databaseId: string, collectionId: string, queries?: string[], transactionId?: string, total?: boolean, ttl?: number): Promise>; + listDocuments( + paramsOrFirst: { databaseId: string, collectionId: string, queries?: string[], transactionId?: string, total?: boolean, ttl?: number } | string, + ...rest: [(string)?, (string[])?, (string)?, (boolean)?, (number)?] + ): Promise> { + let params: { databaseId: string, collectionId: string, queries?: string[], transactionId?: string, total?: boolean, ttl?: number }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, queries?: string[], transactionId?: string, total?: boolean, ttl?: number }; + } else { + params = { + databaseId: paramsOrFirst as string, + collectionId: rest[0] as string, + queries: rest[1] as string[], + transactionId: rest[2] as string, + total: rest[3] as boolean, + ttl: rest[4] as number + }; + } + + const databaseId = params.databaseId; + const collectionId = params.collectionId; + const queries = params.queries; + const transactionId = params.transactionId; + const total = params.total; + const ttl = params.ttl; + + if (typeof databaseId === 'undefined') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + if (typeof collectionId === 'undefined') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + + const apiPath = '/vectorsdb/{databaseId}/collections/{collectionId}/documents'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId); + const payload: Payload = {}; + if (typeof queries !== 'undefined') { + payload['queries'] = queries; + } + if (typeof transactionId !== 'undefined') { + payload['transactionId'] = transactionId; + } + if (typeof total !== 'undefined') { + payload['total'] = total; + } + if (typeof ttl !== 'undefined') { + payload['ttl'] = ttl; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + } + + return this.client.call( + 'get', + uri, + apiHeaders, + payload, + ); + } + + /** + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). Make sure to define attributes before creating documents. + * @param {string} params.documentId - Document ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + * @param {Document extends Models.DefaultDocument ? Partial & Record : Partial & Omit} params.data - Document data as JSON object. + * @param {string[]} params.permissions - An array of permissions strings. By default, only the current user is granted all permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). + * @throws {AppwriteException} + * @returns {Promise} + */ + createDocument(params: { databaseId: string, collectionId: string, documentId: string, data: Document extends Models.DefaultDocument ? Partial & Record : Partial & Omit, permissions?: string[] }): Promise; + /** + * + * @param {string} databaseId - Database ID. + * @param {string} collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). Make sure to define attributes before creating documents. + * @param {string} documentId - Document ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + * @param {Document extends Models.DefaultDocument ? Partial & Record : Partial & Omit} data - Document data as JSON object. + * @param {string[]} permissions - An array of permissions strings. By default, only the current user is granted all permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createDocument(databaseId: string, collectionId: string, documentId: string, data: Document extends Models.DefaultDocument ? Partial & Record : Partial & Omit, permissions?: string[]): Promise; + createDocument( + paramsOrFirst: { databaseId: string, collectionId: string, documentId: string, data: Document extends Models.DefaultDocument ? Partial & Record : Partial & Omit, permissions?: string[] } | string, + ...rest: [(string)?, (string)?, (Document extends Models.DefaultDocument ? Partial & Record : Partial & Omit)?, (string[])?] + ): Promise { + let params: { databaseId: string, collectionId: string, documentId: string, data: Document extends Models.DefaultDocument ? Partial & Record : Partial & Omit, permissions?: string[] }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, documentId: string, data: Document extends Models.DefaultDocument ? Partial & Record : Partial & Omit, permissions?: string[] }; + } else { + params = { + databaseId: paramsOrFirst as string, + collectionId: rest[0] as string, + documentId: rest[1] as string, + data: rest[2] as Document extends Models.DefaultDocument ? Partial & Record : Partial & Omit, + permissions: rest[3] as string[] + }; + } + + const databaseId = params.databaseId; + const collectionId = params.collectionId; + const documentId = params.documentId; + const data = params.data; + const permissions = params.permissions; + + if (typeof databaseId === 'undefined') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + if (typeof collectionId === 'undefined') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + if (typeof documentId === 'undefined') { + throw new AppwriteException('Missing required parameter: "documentId"'); + } + if (typeof data === 'undefined') { + throw new AppwriteException('Missing required parameter: "data"'); + } + + const apiPath = '/vectorsdb/{databaseId}/collections/{collectionId}/documents'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId); + const payload: Payload = {}; + if (typeof documentId !== 'undefined') { + payload['documentId'] = documentId; + } + if (typeof data !== 'undefined') { + payload['data'] = data; + } + if (typeof permissions !== 'undefined') { + payload['permissions'] = permissions; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'post', + uri, + apiHeaders, + payload, + ); + } + + /** + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). Make sure to define attributes before creating documents. + * @param {object[]} params.documents - Array of documents data as JSON objects. + * @throws {AppwriteException} + * @returns {Promise>} + */ + createDocuments(params: { databaseId: string, collectionId: string, documents: object[] }): Promise>; + /** + * + * @param {string} databaseId - Database ID. + * @param {string} collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). Make sure to define attributes before creating documents. + * @param {object[]} documents - Array of documents data as JSON objects. + * @throws {AppwriteException} + * @returns {Promise>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createDocuments(databaseId: string, collectionId: string, documents: object[]): Promise>; + createDocuments( + paramsOrFirst: { databaseId: string, collectionId: string, documents: object[] } | string, + ...rest: [(string)?, (object[])?] + ): Promise> { + let params: { databaseId: string, collectionId: string, documents: object[] }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, documents: object[] }; + } else { + params = { + databaseId: paramsOrFirst as string, + collectionId: rest[0] as string, + documents: rest[1] as object[] + }; + } + + const databaseId = params.databaseId; + const collectionId = params.collectionId; + const documents = params.documents; + + if (typeof databaseId === 'undefined') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + if (typeof collectionId === 'undefined') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + if (typeof documents === 'undefined') { + throw new AppwriteException('Missing required parameter: "documents"'); + } + + const apiPath = '/vectorsdb/{databaseId}/collections/{collectionId}/documents'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId); + const payload: Payload = {}; + if (typeof documents !== 'undefined') { + payload['documents'] = documents; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'post', + uri, + apiHeaders, + payload, + ); + } + + /** + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.collectionId - Collection ID. + * @param {object[]} params.documents - Array of document data as JSON objects. May contain partial documents. + * @param {string} params.transactionId - Transaction ID for staging the operation. + * @throws {AppwriteException} + * @returns {Promise>} + */ + upsertDocuments(params: { databaseId: string, collectionId: string, documents: object[], transactionId?: string }): Promise>; + /** + * + * @param {string} databaseId - Database ID. + * @param {string} collectionId - Collection ID. + * @param {object[]} documents - Array of document data as JSON objects. May contain partial documents. + * @param {string} transactionId - Transaction ID for staging the operation. + * @throws {AppwriteException} + * @returns {Promise>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + upsertDocuments(databaseId: string, collectionId: string, documents: object[], transactionId?: string): Promise>; + upsertDocuments( + paramsOrFirst: { databaseId: string, collectionId: string, documents: object[], transactionId?: string } | string, + ...rest: [(string)?, (object[])?, (string)?] + ): Promise> { + let params: { databaseId: string, collectionId: string, documents: object[], transactionId?: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, documents: object[], transactionId?: string }; + } else { + params = { + databaseId: paramsOrFirst as string, + collectionId: rest[0] as string, + documents: rest[1] as object[], + transactionId: rest[2] as string + }; + } + + const databaseId = params.databaseId; + const collectionId = params.collectionId; + const documents = params.documents; + const transactionId = params.transactionId; + + if (typeof databaseId === 'undefined') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + if (typeof collectionId === 'undefined') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + if (typeof documents === 'undefined') { + throw new AppwriteException('Missing required parameter: "documents"'); + } + + const apiPath = '/vectorsdb/{databaseId}/collections/{collectionId}/documents'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId); + const payload: Payload = {}; + if (typeof documents !== 'undefined') { + payload['documents'] = documents; + } + if (typeof transactionId !== 'undefined') { + payload['transactionId'] = transactionId; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'put', + uri, + apiHeaders, + payload, + ); + } + + /** + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.collectionId - Collection ID. + * @param {object} params.data - Document data as JSON object. Include only attribute and value pairs to be updated. + * @param {string[]} params.queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. + * @param {string} params.transactionId - Transaction ID for staging the operation. + * @throws {AppwriteException} + * @returns {Promise>} + */ + updateDocuments(params: { databaseId: string, collectionId: string, data?: object, queries?: string[], transactionId?: string }): Promise>; + /** + * + * @param {string} databaseId - Database ID. + * @param {string} collectionId - Collection ID. + * @param {object} data - Document data as JSON object. Include only attribute and value pairs to be updated. + * @param {string[]} queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. + * @param {string} transactionId - Transaction ID for staging the operation. + * @throws {AppwriteException} + * @returns {Promise>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateDocuments(databaseId: string, collectionId: string, data?: object, queries?: string[], transactionId?: string): Promise>; + updateDocuments( + paramsOrFirst: { databaseId: string, collectionId: string, data?: object, queries?: string[], transactionId?: string } | string, + ...rest: [(string)?, (object)?, (string[])?, (string)?] + ): Promise> { + let params: { databaseId: string, collectionId: string, data?: object, queries?: string[], transactionId?: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, data?: object, queries?: string[], transactionId?: string }; + } else { + params = { + databaseId: paramsOrFirst as string, + collectionId: rest[0] as string, + data: rest[1] as object, + queries: rest[2] as string[], + transactionId: rest[3] as string + }; + } + + const databaseId = params.databaseId; + const collectionId = params.collectionId; + const data = params.data; + const queries = params.queries; + const transactionId = params.transactionId; + + if (typeof databaseId === 'undefined') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + if (typeof collectionId === 'undefined') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + + const apiPath = '/vectorsdb/{databaseId}/collections/{collectionId}/documents'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId); + const payload: Payload = {}; + if (typeof data !== 'undefined') { + payload['data'] = data; + } + if (typeof queries !== 'undefined') { + payload['queries'] = queries; + } + if (typeof transactionId !== 'undefined') { + payload['transactionId'] = transactionId; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'patch', + uri, + apiHeaders, + payload, + ); + } + + /** + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). + * @param {string[]} params.queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. + * @param {string} params.transactionId - Transaction ID for staging the operation. + * @throws {AppwriteException} + * @returns {Promise>} + */ + deleteDocuments(params: { databaseId: string, collectionId: string, queries?: string[], transactionId?: string }): Promise>; + /** + * + * @param {string} databaseId - Database ID. + * @param {string} collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). + * @param {string[]} queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. + * @param {string} transactionId - Transaction ID for staging the operation. + * @throws {AppwriteException} + * @returns {Promise>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + deleteDocuments(databaseId: string, collectionId: string, queries?: string[], transactionId?: string): Promise>; + deleteDocuments( + paramsOrFirst: { databaseId: string, collectionId: string, queries?: string[], transactionId?: string } | string, + ...rest: [(string)?, (string[])?, (string)?] + ): Promise> { + let params: { databaseId: string, collectionId: string, queries?: string[], transactionId?: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, queries?: string[], transactionId?: string }; + } else { + params = { + databaseId: paramsOrFirst as string, + collectionId: rest[0] as string, + queries: rest[1] as string[], + transactionId: rest[2] as string + }; + } + + const databaseId = params.databaseId; + const collectionId = params.collectionId; + const queries = params.queries; + const transactionId = params.transactionId; + + if (typeof databaseId === 'undefined') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + if (typeof collectionId === 'undefined') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + + const apiPath = '/vectorsdb/{databaseId}/collections/{collectionId}/documents'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId); + const payload: Payload = {}; + if (typeof queries !== 'undefined') { + payload['queries'] = queries; + } + if (typeof transactionId !== 'undefined') { + payload['transactionId'] = transactionId; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'delete', + uri, + apiHeaders, + payload, + ); + } + + /** + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). + * @param {string} params.documentId - Document ID. + * @param {string[]} params.queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. + * @param {string} params.transactionId - Transaction ID to read uncommitted changes within the transaction. + * @throws {AppwriteException} + * @returns {Promise} + */ + getDocument(params: { databaseId: string, collectionId: string, documentId: string, queries?: string[], transactionId?: string }): Promise; + /** + * + * @param {string} databaseId - Database ID. + * @param {string} collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). + * @param {string} documentId - Document ID. + * @param {string[]} queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. + * @param {string} transactionId - Transaction ID to read uncommitted changes within the transaction. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + getDocument(databaseId: string, collectionId: string, documentId: string, queries?: string[], transactionId?: string): Promise; + getDocument( + paramsOrFirst: { databaseId: string, collectionId: string, documentId: string, queries?: string[], transactionId?: string } | string, + ...rest: [(string)?, (string)?, (string[])?, (string)?] + ): Promise { + let params: { databaseId: string, collectionId: string, documentId: string, queries?: string[], transactionId?: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, documentId: string, queries?: string[], transactionId?: string }; + } else { + params = { + databaseId: paramsOrFirst as string, + collectionId: rest[0] as string, + documentId: rest[1] as string, + queries: rest[2] as string[], + transactionId: rest[3] as string + }; + } + + const databaseId = params.databaseId; + const collectionId = params.collectionId; + const documentId = params.documentId; + const queries = params.queries; + const transactionId = params.transactionId; + + if (typeof databaseId === 'undefined') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + if (typeof collectionId === 'undefined') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + if (typeof documentId === 'undefined') { + throw new AppwriteException('Missing required parameter: "documentId"'); + } + + const apiPath = '/vectorsdb/{databaseId}/collections/{collectionId}/documents/{documentId}'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId).replace('{documentId}', documentId); + const payload: Payload = {}; + if (typeof queries !== 'undefined') { + payload['queries'] = queries; + } + if (typeof transactionId !== 'undefined') { + payload['transactionId'] = transactionId; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + } + + return this.client.call( + 'get', + uri, + apiHeaders, + payload, + ); + } + + /** + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.collectionId - Collection ID. + * @param {string} params.documentId - Document ID. + * @param {Document extends Models.DefaultDocument ? Partial & Record : Partial & Partial>} params.data - Document data as JSON object. Include all required fields of the document to be created or updated. + * @param {string[]} params.permissions - An array of permissions strings. By default, the current permissions are inherited. [Learn more about permissions](https://appwrite.io/docs/permissions). + * @param {string} params.transactionId - Transaction ID for staging the operation. + * @throws {AppwriteException} + * @returns {Promise} + */ + upsertDocument(params: { databaseId: string, collectionId: string, documentId: string, data?: Document extends Models.DefaultDocument ? Partial & Record : Partial & Partial>, permissions?: string[], transactionId?: string }): Promise; + /** + * + * @param {string} databaseId - Database ID. + * @param {string} collectionId - Collection ID. + * @param {string} documentId - Document ID. + * @param {Document extends Models.DefaultDocument ? Partial & Record : Partial & Partial>} data - Document data as JSON object. Include all required fields of the document to be created or updated. + * @param {string[]} permissions - An array of permissions strings. By default, the current permissions are inherited. [Learn more about permissions](https://appwrite.io/docs/permissions). + * @param {string} transactionId - Transaction ID for staging the operation. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + upsertDocument(databaseId: string, collectionId: string, documentId: string, data?: Document extends Models.DefaultDocument ? Partial & Record : Partial & Partial>, permissions?: string[], transactionId?: string): Promise; + upsertDocument( + paramsOrFirst: { databaseId: string, collectionId: string, documentId: string, data?: Document extends Models.DefaultDocument ? Partial & Record : Partial & Partial>, permissions?: string[], transactionId?: string } | string, + ...rest: [(string)?, (string)?, (Document extends Models.DefaultDocument ? Partial & Record : Partial & Partial>)?, (string[])?, (string)?] + ): Promise { + let params: { databaseId: string, collectionId: string, documentId: string, data?: Document extends Models.DefaultDocument ? Partial & Record : Partial & Partial>, permissions?: string[], transactionId?: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, documentId: string, data?: Document extends Models.DefaultDocument ? Partial & Record : Partial & Partial>, permissions?: string[], transactionId?: string }; + } else { + params = { + databaseId: paramsOrFirst as string, + collectionId: rest[0] as string, + documentId: rest[1] as string, + data: rest[2] as Document extends Models.DefaultDocument ? Partial & Record : Partial & Partial>, + permissions: rest[3] as string[], + transactionId: rest[4] as string + }; + } + + const databaseId = params.databaseId; + const collectionId = params.collectionId; + const documentId = params.documentId; + const data = params.data; + const permissions = params.permissions; + const transactionId = params.transactionId; + + if (typeof databaseId === 'undefined') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + if (typeof collectionId === 'undefined') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + if (typeof documentId === 'undefined') { + throw new AppwriteException('Missing required parameter: "documentId"'); + } + + const apiPath = '/vectorsdb/{databaseId}/collections/{collectionId}/documents/{documentId}'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId).replace('{documentId}', documentId); + const payload: Payload = {}; + if (typeof data !== 'undefined') { + payload['data'] = data; + } + if (typeof permissions !== 'undefined') { + payload['permissions'] = permissions; + } + if (typeof transactionId !== 'undefined') { + payload['transactionId'] = transactionId; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'put', + uri, + apiHeaders, + payload, + ); + } + + /** + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.collectionId - Collection ID. + * @param {string} params.documentId - Document ID. + * @param {Document extends Models.DefaultDocument ? Partial & Record : Partial & Partial>} params.data - Document data as JSON object. Include only fields and value pairs to be updated. + * @param {string[]} params.permissions - An array of permissions strings. By default, the current permissions are inherited. [Learn more about permissions](https://appwrite.io/docs/permissions). + * @param {string} params.transactionId - Transaction ID for staging the operation. + * @throws {AppwriteException} + * @returns {Promise} + */ + updateDocument(params: { databaseId: string, collectionId: string, documentId: string, data?: Document extends Models.DefaultDocument ? Partial & Record : Partial & Partial>, permissions?: string[], transactionId?: string }): Promise; + /** + * + * @param {string} databaseId - Database ID. + * @param {string} collectionId - Collection ID. + * @param {string} documentId - Document ID. + * @param {Document extends Models.DefaultDocument ? Partial & Record : Partial & Partial>} data - Document data as JSON object. Include only fields and value pairs to be updated. + * @param {string[]} permissions - An array of permissions strings. By default, the current permissions are inherited. [Learn more about permissions](https://appwrite.io/docs/permissions). + * @param {string} transactionId - Transaction ID for staging the operation. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateDocument(databaseId: string, collectionId: string, documentId: string, data?: Document extends Models.DefaultDocument ? Partial & Record : Partial & Partial>, permissions?: string[], transactionId?: string): Promise; + updateDocument( + paramsOrFirst: { databaseId: string, collectionId: string, documentId: string, data?: Document extends Models.DefaultDocument ? Partial & Record : Partial & Partial>, permissions?: string[], transactionId?: string } | string, + ...rest: [(string)?, (string)?, (Document extends Models.DefaultDocument ? Partial & Record : Partial & Partial>)?, (string[])?, (string)?] + ): Promise { + let params: { databaseId: string, collectionId: string, documentId: string, data?: Document extends Models.DefaultDocument ? Partial & Record : Partial & Partial>, permissions?: string[], transactionId?: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, documentId: string, data?: Document extends Models.DefaultDocument ? Partial & Record : Partial & Partial>, permissions?: string[], transactionId?: string }; + } else { + params = { + databaseId: paramsOrFirst as string, + collectionId: rest[0] as string, + documentId: rest[1] as string, + data: rest[2] as Document extends Models.DefaultDocument ? Partial & Record : Partial & Partial>, + permissions: rest[3] as string[], + transactionId: rest[4] as string + }; + } + + const databaseId = params.databaseId; + const collectionId = params.collectionId; + const documentId = params.documentId; + const data = params.data; + const permissions = params.permissions; + const transactionId = params.transactionId; + + if (typeof databaseId === 'undefined') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + if (typeof collectionId === 'undefined') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + if (typeof documentId === 'undefined') { + throw new AppwriteException('Missing required parameter: "documentId"'); + } + + const apiPath = '/vectorsdb/{databaseId}/collections/{collectionId}/documents/{documentId}'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId).replace('{documentId}', documentId); + const payload: Payload = {}; + if (typeof data !== 'undefined') { + payload['data'] = data; + } + if (typeof permissions !== 'undefined') { + payload['permissions'] = permissions; + } + if (typeof transactionId !== 'undefined') { + payload['transactionId'] = transactionId; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'patch', + uri, + apiHeaders, + payload, + ); + } + + /** + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). + * @param {string} params.documentId - Document ID. + * @param {string} params.transactionId - Transaction ID for staging the operation. + * @throws {AppwriteException} + * @returns {Promise<{}>} + */ + deleteDocument(params: { databaseId: string, collectionId: string, documentId: string, transactionId?: string }): Promise<{}>; + /** + * + * @param {string} databaseId - Database ID. + * @param {string} collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). + * @param {string} documentId - Document ID. + * @param {string} transactionId - Transaction ID for staging the operation. + * @throws {AppwriteException} + * @returns {Promise<{}>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + deleteDocument(databaseId: string, collectionId: string, documentId: string, transactionId?: string): Promise<{}>; + deleteDocument( + paramsOrFirst: { databaseId: string, collectionId: string, documentId: string, transactionId?: string } | string, + ...rest: [(string)?, (string)?, (string)?] + ): Promise<{}> { + let params: { databaseId: string, collectionId: string, documentId: string, transactionId?: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, documentId: string, transactionId?: string }; + } else { + params = { + databaseId: paramsOrFirst as string, + collectionId: rest[0] as string, + documentId: rest[1] as string, + transactionId: rest[2] as string + }; + } + + const databaseId = params.databaseId; + const collectionId = params.collectionId; + const documentId = params.documentId; + const transactionId = params.transactionId; + + if (typeof databaseId === 'undefined') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + if (typeof collectionId === 'undefined') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + if (typeof documentId === 'undefined') { + throw new AppwriteException('Missing required parameter: "documentId"'); + } + + const apiPath = '/vectorsdb/{databaseId}/collections/{collectionId}/documents/{documentId}'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId).replace('{documentId}', documentId); + const payload: Payload = {}; + if (typeof transactionId !== 'undefined') { + payload['transactionId'] = transactionId; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'delete', + uri, + apiHeaders, + payload, + ); + } + + /** + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). + * @param {string[]} params.queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: key, type, status, attributes, error + * @param {boolean} params.total - When set to false, the total count returned will be 0 and will not be calculated. + * @throws {AppwriteException} + * @returns {Promise} + */ + listIndexes(params: { databaseId: string, collectionId: string, queries?: string[], total?: boolean }): Promise; + /** + * + * @param {string} databaseId - Database ID. + * @param {string} collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). + * @param {string[]} queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: key, type, status, attributes, error + * @param {boolean} total - When set to false, the total count returned will be 0 and will not be calculated. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + listIndexes(databaseId: string, collectionId: string, queries?: string[], total?: boolean): Promise; + listIndexes( + paramsOrFirst: { databaseId: string, collectionId: string, queries?: string[], total?: boolean } | string, + ...rest: [(string)?, (string[])?, (boolean)?] + ): Promise { + let params: { databaseId: string, collectionId: string, queries?: string[], total?: boolean }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, queries?: string[], total?: boolean }; + } else { + params = { + databaseId: paramsOrFirst as string, + collectionId: rest[0] as string, + queries: rest[1] as string[], + total: rest[2] as boolean + }; + } + + const databaseId = params.databaseId; + const collectionId = params.collectionId; + const queries = params.queries; + const total = params.total; + + if (typeof databaseId === 'undefined') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + if (typeof collectionId === 'undefined') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + + const apiPath = '/vectorsdb/{databaseId}/collections/{collectionId}/indexes'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId); + const payload: Payload = {}; + if (typeof queries !== 'undefined') { + payload['queries'] = queries; + } + if (typeof total !== 'undefined') { + payload['total'] = total; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + } + + return this.client.call( + 'get', + uri, + apiHeaders, + payload, + ); + } + + /** + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). + * @param {string} params.key - Index Key. + * @param {VectorsDBIndexType} params.type - Index type. + * @param {string[]} params.attributes - Array of attributes to index. Maximum of 100 attributes are allowed, each 32 characters long. + * @param {OrderBy[]} params.orders - Array of index orders. Maximum of 100 orders are allowed. + * @param {number[]} params.lengths - Length of index. Maximum of 100 + * @throws {AppwriteException} + * @returns {Promise} + */ + createIndex(params: { databaseId: string, collectionId: string, key: string, type: VectorsDBIndexType, attributes: string[], orders?: OrderBy[], lengths?: number[] }): Promise; + /** + * + * @param {string} databaseId - Database ID. + * @param {string} collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). + * @param {string} key - Index Key. + * @param {VectorsDBIndexType} type - Index type. + * @param {string[]} attributes - Array of attributes to index. Maximum of 100 attributes are allowed, each 32 characters long. + * @param {OrderBy[]} orders - Array of index orders. Maximum of 100 orders are allowed. + * @param {number[]} lengths - Length of index. Maximum of 100 + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createIndex(databaseId: string, collectionId: string, key: string, type: VectorsDBIndexType, attributes: string[], orders?: OrderBy[], lengths?: number[]): Promise; + createIndex( + paramsOrFirst: { databaseId: string, collectionId: string, key: string, type: VectorsDBIndexType, attributes: string[], orders?: OrderBy[], lengths?: number[] } | string, + ...rest: [(string)?, (string)?, (VectorsDBIndexType)?, (string[])?, (OrderBy[])?, (number[])?] + ): Promise { + let params: { databaseId: string, collectionId: string, key: string, type: VectorsDBIndexType, attributes: string[], orders?: OrderBy[], lengths?: number[] }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, key: string, type: VectorsDBIndexType, attributes: string[], orders?: OrderBy[], lengths?: number[] }; + } else { + params = { + databaseId: paramsOrFirst as string, + collectionId: rest[0] as string, + key: rest[1] as string, + type: rest[2] as VectorsDBIndexType, + attributes: rest[3] as string[], + orders: rest[4] as OrderBy[], + lengths: rest[5] as number[] + }; + } + + const databaseId = params.databaseId; + const collectionId = params.collectionId; + const key = params.key; + const type = params.type; + const attributes = params.attributes; + const orders = params.orders; + const lengths = params.lengths; + + if (typeof databaseId === 'undefined') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + if (typeof collectionId === 'undefined') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + if (typeof key === 'undefined') { + throw new AppwriteException('Missing required parameter: "key"'); + } + if (typeof type === 'undefined') { + throw new AppwriteException('Missing required parameter: "type"'); + } + if (typeof attributes === 'undefined') { + throw new AppwriteException('Missing required parameter: "attributes"'); + } + + const apiPath = '/vectorsdb/{databaseId}/collections/{collectionId}/indexes'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId); + const payload: Payload = {}; + if (typeof key !== 'undefined') { + payload['key'] = key; + } + if (typeof type !== 'undefined') { + payload['type'] = type; + } + if (typeof attributes !== 'undefined') { + payload['attributes'] = attributes; + } + if (typeof orders !== 'undefined') { + payload['orders'] = orders; + } + if (typeof lengths !== 'undefined') { + payload['lengths'] = lengths; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'post', + uri, + apiHeaders, + payload, + ); + } + + /** + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). + * @param {string} params.key - Index Key. + * @throws {AppwriteException} + * @returns {Promise} + */ + getIndex(params: { databaseId: string, collectionId: string, key: string }): Promise; + /** + * + * @param {string} databaseId - Database ID. + * @param {string} collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). + * @param {string} key - Index Key. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + getIndex(databaseId: string, collectionId: string, key: string): Promise; + getIndex( + paramsOrFirst: { databaseId: string, collectionId: string, key: string } | string, + ...rest: [(string)?, (string)?] + ): Promise { + let params: { databaseId: string, collectionId: string, key: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, key: string }; + } else { + params = { + databaseId: paramsOrFirst as string, + collectionId: rest[0] as string, + key: rest[1] as string + }; + } + + const databaseId = params.databaseId; + const collectionId = params.collectionId; + const key = params.key; + + if (typeof databaseId === 'undefined') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + if (typeof collectionId === 'undefined') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + if (typeof key === 'undefined') { + throw new AppwriteException('Missing required parameter: "key"'); + } + + const apiPath = '/vectorsdb/{databaseId}/collections/{collectionId}/indexes/{key}'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId).replace('{key}', key); + const payload: Payload = {}; + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + } + + return this.client.call( + 'get', + uri, + apiHeaders, + payload, + ); + } + + /** + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). + * @param {string} params.key - Index Key. + * @throws {AppwriteException} + * @returns {Promise<{}>} + */ + deleteIndex(params: { databaseId: string, collectionId: string, key: string }): Promise<{}>; + /** + * + * @param {string} databaseId - Database ID. + * @param {string} collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). + * @param {string} key - Index Key. + * @throws {AppwriteException} + * @returns {Promise<{}>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + deleteIndex(databaseId: string, collectionId: string, key: string): Promise<{}>; + deleteIndex( + paramsOrFirst: { databaseId: string, collectionId: string, key: string } | string, + ...rest: [(string)?, (string)?] + ): Promise<{}> { + let params: { databaseId: string, collectionId: string, key: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, key: string }; + } else { + params = { + databaseId: paramsOrFirst as string, + collectionId: rest[0] as string, + key: rest[1] as string + }; + } + + const databaseId = params.databaseId; + const collectionId = params.collectionId; + const key = params.key; + + if (typeof databaseId === 'undefined') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + if (typeof collectionId === 'undefined') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + if (typeof key === 'undefined') { + throw new AppwriteException('Missing required parameter: "key"'); + } + + const apiPath = '/vectorsdb/{databaseId}/collections/{collectionId}/indexes/{key}'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId).replace('{key}', key); + const payload: Payload = {}; + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'delete', + uri, + apiHeaders, + payload, + ); + } +} diff --git a/src/services/webhooks.ts b/src/services/webhooks.ts new file mode 100644 index 00000000..daa78ce0 --- /dev/null +++ b/src/services/webhooks.ts @@ -0,0 +1,450 @@ +import { AppwriteException, Client, type Payload, UploadProgress } from '../client'; +import type { Models } from '../models'; + + +export class Webhooks { + client: Client; + + constructor(client: Client) { + this.client = client; + } + + /** + * Get a list of all webhooks belonging to the project. You can use the query params to filter your results. + * + * @param {string[]} params.queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: name, url, httpUser, security, events, enabled, logs, attempts + * @param {boolean} params.total - When set to false, the total count returned will be 0 and will not be calculated. + * @throws {AppwriteException} + * @returns {Promise} + */ + list(params?: { queries?: string[], total?: boolean }): Promise; + /** + * Get a list of all webhooks belonging to the project. You can use the query params to filter your results. + * + * @param {string[]} queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: name, url, httpUser, security, events, enabled, logs, attempts + * @param {boolean} total - When set to false, the total count returned will be 0 and will not be calculated. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + list(queries?: string[], total?: boolean): Promise; + list( + paramsOrFirst?: { queries?: string[], total?: boolean } | string[], + ...rest: [(boolean)?] + ): Promise { + let params: { queries?: string[], total?: boolean }; + + if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { queries?: string[], total?: boolean }; + } else { + params = { + queries: paramsOrFirst as string[], + total: rest[0] as boolean + }; + } + + const queries = params.queries; + const total = params.total; + + + const apiPath = '/webhooks'; + const payload: Payload = {}; + if (typeof queries !== 'undefined') { + payload['queries'] = queries; + } + if (typeof total !== 'undefined') { + payload['total'] = total; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + } + + return this.client.call( + 'get', + uri, + apiHeaders, + payload, + ); + } + + /** + * Create a new webhook. Use this endpoint to configure a URL that will receive events from Appwrite when specific events occur. + * + * @param {string} params.webhookId - Webhook ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + * @param {string} params.url - Webhook URL. + * @param {string} params.name - Webhook name. Max length: 128 chars. + * @param {string[]} params.events - Events list. Maximum of 100 events are allowed. + * @param {boolean} params.enabled - Enable or disable a webhook. + * @param {boolean} params.security - Certificate verification, false for disabled or true for enabled. + * @param {string} params.httpUser - Webhook HTTP user. Max length: 256 chars. + * @param {string} params.httpPass - Webhook HTTP password. Max length: 256 chars. + * @throws {AppwriteException} + * @returns {Promise} + */ + create(params: { webhookId: string, url: string, name: string, events: string[], enabled?: boolean, security?: boolean, httpUser?: string, httpPass?: string }): Promise; + /** + * Create a new webhook. Use this endpoint to configure a URL that will receive events from Appwrite when specific events occur. + * + * @param {string} webhookId - Webhook ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + * @param {string} url - Webhook URL. + * @param {string} name - Webhook name. Max length: 128 chars. + * @param {string[]} events - Events list. Maximum of 100 events are allowed. + * @param {boolean} enabled - Enable or disable a webhook. + * @param {boolean} security - Certificate verification, false for disabled or true for enabled. + * @param {string} httpUser - Webhook HTTP user. Max length: 256 chars. + * @param {string} httpPass - Webhook HTTP password. Max length: 256 chars. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + create(webhookId: string, url: string, name: string, events: string[], enabled?: boolean, security?: boolean, httpUser?: string, httpPass?: string): Promise; + create( + paramsOrFirst: { webhookId: string, url: string, name: string, events: string[], enabled?: boolean, security?: boolean, httpUser?: string, httpPass?: string } | string, + ...rest: [(string)?, (string)?, (string[])?, (boolean)?, (boolean)?, (string)?, (string)?] + ): Promise { + let params: { webhookId: string, url: string, name: string, events: string[], enabled?: boolean, security?: boolean, httpUser?: string, httpPass?: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { webhookId: string, url: string, name: string, events: string[], enabled?: boolean, security?: boolean, httpUser?: string, httpPass?: string }; + } else { + params = { + webhookId: paramsOrFirst as string, + url: rest[0] as string, + name: rest[1] as string, + events: rest[2] as string[], + enabled: rest[3] as boolean, + security: rest[4] as boolean, + httpUser: rest[5] as string, + httpPass: rest[6] as string + }; + } + + const webhookId = params.webhookId; + const url = params.url; + const name = params.name; + const events = params.events; + const enabled = params.enabled; + const security = params.security; + const httpUser = params.httpUser; + const httpPass = params.httpPass; + + if (typeof webhookId === 'undefined') { + throw new AppwriteException('Missing required parameter: "webhookId"'); + } + if (typeof url === 'undefined') { + throw new AppwriteException('Missing required parameter: "url"'); + } + if (typeof name === 'undefined') { + throw new AppwriteException('Missing required parameter: "name"'); + } + if (typeof events === 'undefined') { + throw new AppwriteException('Missing required parameter: "events"'); + } + + const apiPath = '/webhooks'; + const payload: Payload = {}; + if (typeof webhookId !== 'undefined') { + payload['webhookId'] = webhookId; + } + if (typeof url !== 'undefined') { + payload['url'] = url; + } + if (typeof name !== 'undefined') { + payload['name'] = name; + } + if (typeof events !== 'undefined') { + payload['events'] = events; + } + if (typeof enabled !== 'undefined') { + payload['enabled'] = enabled; + } + if (typeof security !== 'undefined') { + payload['security'] = security; + } + if (typeof httpUser !== 'undefined') { + payload['httpUser'] = httpUser; + } + if (typeof httpPass !== 'undefined') { + payload['httpPass'] = httpPass; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'post', + uri, + apiHeaders, + payload, + ); + } + + /** + * Get a webhook by its unique ID. This endpoint returns details about a specific webhook configured for a project. + * + * @param {string} params.webhookId - Webhook ID. + * @throws {AppwriteException} + * @returns {Promise} + */ + get(params: { webhookId: string }): Promise; + /** + * Get a webhook by its unique ID. This endpoint returns details about a specific webhook configured for a project. + * + * @param {string} webhookId - Webhook ID. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + get(webhookId: string): Promise; + get( + paramsOrFirst: { webhookId: string } | string + ): Promise { + let params: { webhookId: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { webhookId: string }; + } else { + params = { + webhookId: paramsOrFirst as string + }; + } + + const webhookId = params.webhookId; + + if (typeof webhookId === 'undefined') { + throw new AppwriteException('Missing required parameter: "webhookId"'); + } + + const apiPath = '/webhooks/{webhookId}'.replace('{webhookId}', webhookId); + const payload: Payload = {}; + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + } + + return this.client.call( + 'get', + uri, + apiHeaders, + payload, + ); + } + + /** + * Update a webhook by its unique ID. Use this endpoint to update the URL, events, or status of an existing webhook. + * + * @param {string} params.webhookId - Webhook ID. + * @param {string} params.name - Webhook name. Max length: 128 chars. + * @param {string} params.url - Webhook URL. + * @param {string[]} params.events - Events list. Maximum of 100 events are allowed. + * @param {boolean} params.enabled - Enable or disable a webhook. + * @param {boolean} params.security - Certificate verification, false for disabled or true for enabled. + * @param {string} params.httpUser - Webhook HTTP user. Max length: 256 chars. + * @param {string} params.httpPass - Webhook HTTP password. Max length: 256 chars. + * @throws {AppwriteException} + * @returns {Promise} + */ + update(params: { webhookId: string, name: string, url: string, events: string[], enabled?: boolean, security?: boolean, httpUser?: string, httpPass?: string }): Promise; + /** + * Update a webhook by its unique ID. Use this endpoint to update the URL, events, or status of an existing webhook. + * + * @param {string} webhookId - Webhook ID. + * @param {string} name - Webhook name. Max length: 128 chars. + * @param {string} url - Webhook URL. + * @param {string[]} events - Events list. Maximum of 100 events are allowed. + * @param {boolean} enabled - Enable or disable a webhook. + * @param {boolean} security - Certificate verification, false for disabled or true for enabled. + * @param {string} httpUser - Webhook HTTP user. Max length: 256 chars. + * @param {string} httpPass - Webhook HTTP password. Max length: 256 chars. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + update(webhookId: string, name: string, url: string, events: string[], enabled?: boolean, security?: boolean, httpUser?: string, httpPass?: string): Promise; + update( + paramsOrFirst: { webhookId: string, name: string, url: string, events: string[], enabled?: boolean, security?: boolean, httpUser?: string, httpPass?: string } | string, + ...rest: [(string)?, (string)?, (string[])?, (boolean)?, (boolean)?, (string)?, (string)?] + ): Promise { + let params: { webhookId: string, name: string, url: string, events: string[], enabled?: boolean, security?: boolean, httpUser?: string, httpPass?: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { webhookId: string, name: string, url: string, events: string[], enabled?: boolean, security?: boolean, httpUser?: string, httpPass?: string }; + } else { + params = { + webhookId: paramsOrFirst as string, + name: rest[0] as string, + url: rest[1] as string, + events: rest[2] as string[], + enabled: rest[3] as boolean, + security: rest[4] as boolean, + httpUser: rest[5] as string, + httpPass: rest[6] as string + }; + } + + const webhookId = params.webhookId; + const name = params.name; + const url = params.url; + const events = params.events; + const enabled = params.enabled; + const security = params.security; + const httpUser = params.httpUser; + const httpPass = params.httpPass; + + if (typeof webhookId === 'undefined') { + throw new AppwriteException('Missing required parameter: "webhookId"'); + } + if (typeof name === 'undefined') { + throw new AppwriteException('Missing required parameter: "name"'); + } + if (typeof url === 'undefined') { + throw new AppwriteException('Missing required parameter: "url"'); + } + if (typeof events === 'undefined') { + throw new AppwriteException('Missing required parameter: "events"'); + } + + const apiPath = '/webhooks/{webhookId}'.replace('{webhookId}', webhookId); + const payload: Payload = {}; + if (typeof name !== 'undefined') { + payload['name'] = name; + } + if (typeof url !== 'undefined') { + payload['url'] = url; + } + if (typeof events !== 'undefined') { + payload['events'] = events; + } + if (typeof enabled !== 'undefined') { + payload['enabled'] = enabled; + } + if (typeof security !== 'undefined') { + payload['security'] = security; + } + if (typeof httpUser !== 'undefined') { + payload['httpUser'] = httpUser; + } + if (typeof httpPass !== 'undefined') { + payload['httpPass'] = httpPass; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'put', + uri, + apiHeaders, + payload, + ); + } + + /** + * Delete a webhook by its unique ID. Once deleted, the webhook will no longer receive project events. + * + * @param {string} params.webhookId - Webhook ID. + * @throws {AppwriteException} + * @returns {Promise<{}>} + */ + delete(params: { webhookId: string }): Promise<{}>; + /** + * Delete a webhook by its unique ID. Once deleted, the webhook will no longer receive project events. + * + * @param {string} webhookId - Webhook ID. + * @throws {AppwriteException} + * @returns {Promise<{}>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + delete(webhookId: string): Promise<{}>; + delete( + paramsOrFirst: { webhookId: string } | string + ): Promise<{}> { + let params: { webhookId: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { webhookId: string }; + } else { + params = { + webhookId: paramsOrFirst as string + }; + } + + const webhookId = params.webhookId; + + if (typeof webhookId === 'undefined') { + throw new AppwriteException('Missing required parameter: "webhookId"'); + } + + const apiPath = '/webhooks/{webhookId}'.replace('{webhookId}', webhookId); + const payload: Payload = {}; + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'delete', + uri, + apiHeaders, + payload, + ); + } + + /** + * Update the webhook signature key. This endpoint can be used to regenerate the signature key used to sign and validate payload deliveries for a specific webhook. + * + * @param {string} params.webhookId - Webhook ID. + * @throws {AppwriteException} + * @returns {Promise} + */ + updateSignature(params: { webhookId: string }): Promise; + /** + * Update the webhook signature key. This endpoint can be used to regenerate the signature key used to sign and validate payload deliveries for a specific webhook. + * + * @param {string} webhookId - Webhook ID. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateSignature(webhookId: string): Promise; + updateSignature( + paramsOrFirst: { webhookId: string } | string + ): Promise { + let params: { webhookId: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { webhookId: string }; + } else { + params = { + webhookId: paramsOrFirst as string + }; + } + + const webhookId = params.webhookId; + + if (typeof webhookId === 'undefined') { + throw new AppwriteException('Missing required parameter: "webhookId"'); + } + + const apiPath = '/webhooks/{webhookId}/signature'.replace('{webhookId}', webhookId); + const payload: Payload = {}; + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'patch', + uri, + apiHeaders, + payload, + ); + } +} diff --git a/test/id.test.js b/test/id.test.js new file mode 100644 index 00000000..0a648bc1 --- /dev/null +++ b/test/id.test.js @@ -0,0 +1,6 @@ +const { ID } = require("../dist/id"); + +describe("ID", () => { + test('unique', () => expect(ID.unique()).toHaveLength(20)); + test('custom', () => expect(ID.custom('custom')).toEqual('custom')); +}); diff --git a/test/operator.test.js b/test/operator.test.js new file mode 100644 index 00000000..a14910cd --- /dev/null +++ b/test/operator.test.js @@ -0,0 +1,99 @@ +const { Condition, Operator } = require("../dist/operator"); + +describe('Operator', () => { + test('returns increment', () => { + expect(Operator.increment(1)).toEqual(`{"method":"increment","values":[1]}`); + }); + + test('returns increment with max', () => { + expect(Operator.increment(5, 100)).toEqual(`{"method":"increment","values":[5,100]}`); + }); + + test('returns decrement', () => { + expect(Operator.decrement(1)).toEqual(`{"method":"decrement","values":[1]}`); + }); + + test('returns decrement with min', () => { + expect(Operator.decrement(3, 0)).toEqual(`{"method":"decrement","values":[3,0]}`); + }); + + test('returns multiply', () => { + expect(Operator.multiply(2)).toEqual(`{"method":"multiply","values":[2]}`); + }); + + test('returns multiply with max', () => { + expect(Operator.multiply(3, 1000)).toEqual(`{"method":"multiply","values":[3,1000]}`); + }); + + test('returns divide', () => { + expect(Operator.divide(2)).toEqual(`{"method":"divide","values":[2]}`); + }); + + test('returns divide with min', () => { + expect(Operator.divide(4, 1)).toEqual(`{"method":"divide","values":[4,1]}`); + }); + + test('returns modulo', () => { + expect(Operator.modulo(5)).toEqual(`{"method":"modulo","values":[5]}`); + }); + + test('returns power', () => { + expect(Operator.power(2)).toEqual(`{"method":"power","values":[2]}`); + }); + + test('returns arrayAppend', () => { + expect(Operator.arrayAppend(['item1', 'item2'])).toEqual('{"method":"arrayAppend","values":["item1","item2"]}'); + }); + + test('returns arrayPrepend', () => { + expect(Operator.arrayPrepend(['first', 'second'])).toEqual('{"method":"arrayPrepend","values":["first","second"]}'); + }); + + test('returns arrayInsert', () => { + expect(Operator.arrayInsert(0, 'newItem')).toEqual('{"method":"arrayInsert","values":[0,"newItem"]}'); + }); + + test('returns arrayRemove', () => { + expect(Operator.arrayRemove('oldItem')).toEqual('{"method":"arrayRemove","values":["oldItem"]}'); + }); + + test('returns arrayUnique', () => { + expect(Operator.arrayUnique()).toEqual('{"method":"arrayUnique","values":[]}'); + }); + + test('returns arrayIntersect', () => { + expect(Operator.arrayIntersect(['a', 'b', 'c'])).toEqual('{"method":"arrayIntersect","values":["a","b","c"]}'); + }); + + test('returns arrayDiff', () => { + expect(Operator.arrayDiff(['x', 'y'])).toEqual('{"method":"arrayDiff","values":["x","y"]}'); + }); + + test('returns arrayFilter', () => { + expect(Operator.arrayFilter(Condition.Equal, 'test')).toEqual('{"method":"arrayFilter","values":["equal","test"]}'); + }); + + test('returns stringConcat', () => { + expect(Operator.stringConcat('suffix')).toEqual('{"method":"stringConcat","values":["suffix"]}'); + }); + + test('returns stringReplace', () => { + expect(Operator.stringReplace('old', 'new')).toEqual('{"method":"stringReplace","values":["old","new"]}'); + }); + + test('returns toggle', () => { + expect(Operator.toggle()).toEqual('{"method":"toggle","values":[]}'); + }); + + test('returns dateAddDays', () => { + expect(Operator.dateAddDays(7)).toEqual('{"method":"dateAddDays","values":[7]}'); + }); + + test('returns dateSubDays', () => { + expect(Operator.dateSubDays(7)).toEqual('{"method":"dateSubDays","values":[7]}'); + }); + + test('returns dateSetNow', () => { + expect(Operator.dateSetNow()).toEqual('{"method":"dateSetNow","values":[]}'); + }); +}); diff --git a/test/permission.test.js b/test/permission.test.js new file mode 100644 index 00000000..7f972d3b --- /dev/null +++ b/test/permission.test.js @@ -0,0 +1,10 @@ +const { Permission } = require("../dist/permission"); +const { Role } = require("../dist/role"); + +describe('Permission', () => { + test('read', () => expect(Permission.read(Role.any())).toEqual('read("any")')); + test('write', () => expect(Permission.write(Role.any())).toEqual('write("any")')); + test('create', () => expect(Permission.create(Role.any())).toEqual('create("any")')); + test('update', () => expect(Permission.update(Role.any())).toEqual('update("any")')); + test('delete', () => expect(Permission.delete(Role.any())).toEqual('delete("any")')); +}) diff --git a/test/query.test.js b/test/query.test.js new file mode 100644 index 00000000..e539a1f6 --- /dev/null +++ b/test/query.test.js @@ -0,0 +1,155 @@ +const { Query } = require("../dist/query"); + +const tests = [ + { + description: 'with a string', + value: 's', + expectedValues: '["s"]' + }, + { + description: 'with a integer', + value: 1, + expectedValues: '[1]' + }, + { + description: 'with a double', + value: 1.2, + expectedValues: '[1.2]' + }, + { + description: 'with a whole number double', + value: 1.0, + expectedValues: '[1]' + }, + { + description: 'with a bool', + value: false, + expectedValues: '[false]' + }, + { + description: 'with a list', + value: ['a', 'b', 'c'], + expectedValues: '["a","b","c"]' + } +]; + +describe('Query', () => { + describe('basic filter equal', () => { + for (const t of tests) { + test(t.description, () => + expect(Query.equal("attr", t.value)) + .toEqual(`{"method":"equal","attribute":"attr","values":${t.expectedValues}}`) + ) + } + }) + + describe('basic filter notEqual', () => { + for (const t of tests) { + test(t.description, () => + expect(Query.notEqual("attr", t.value)) + .toEqual(`{"method":"notEqual","attribute":"attr","values":${t.expectedValues}}`) + ) + } + }); + + describe('basic filter lessThan', () => { + for (const t of tests) { + test(t.description, () => + expect(Query.lessThan("attr", t.value)) + .toEqual(`{"method":"lessThan","attribute":"attr","values":${t.expectedValues}}`) + ) + } + }); + + describe('basic filter lessThanEqual', () => { + for (const t of tests) { + test(t.description, () => + expect(Query.lessThanEqual("attr", t.value)) + .toEqual(`{"method":"lessThanEqual","attribute":"attr","values":${t.expectedValues}}`) + ) + } + }); + + describe('basic filter greaterThan', () => { + for (const t of tests) { + test(t.description, () => + expect(Query.greaterThan("attr", t.value)) + .toEqual(`{"method":"greaterThan","attribute":"attr","values":${t.expectedValues}}`) + ) + } + }); + + describe('basic filter greaterThanEqual', () => { + for (const t of tests) { + test(t.description, () => + expect(Query.greaterThanEqual("attr", t.value)) + .toEqual(`{"method":"greaterThanEqual","attribute":"attr","values":${t.expectedValues}}`) + ) + } + }); + + test('search', () => + expect(Query.search('attr', 'keyword1 keyword2')) + .toEqual(`{"method":"search","attribute":"attr","values":["keyword1 keyword2"]}`) + ); + + test('isNull', () => + expect(Query.isNull('attr')) + .toEqual(`{"method":"isNull","attribute":"attr"}`) + ); + + test('isNotNull', () => + expect(Query.isNotNull('attr')) + .toEqual(`{"method":"isNotNull","attribute":"attr"}`) + ); + + describe('between', () => { + test('with integers', () => + expect(Query.between('attr', 1, 2)) + .toEqual(`{"method":"between","attribute":"attr","values":[1,2]}`) + ); + test('with doubles', () => + expect(Query.between('attr', 1.2, 2.2)) + .toEqual(`{"method":"between","attribute":"attr","values":[1.2,2.2]}`) + ); + test('with strings', () => + expect(Query.between('attr',"a","z")) + .toEqual(`{"method":"between","attribute":"attr","values":["a","z"]}`) + ); + }); + + test('select', () => + expect(Query.select(['attr1', 'attr2'])) + .toEqual(`{"method":"select","values":["attr1","attr2"]}`) + ); + + test('orderAsc', () => + expect(Query.orderAsc('attr')) + .toEqual(`{"method":"orderAsc","attribute":"attr"}`) + ); + + test('orderDesc', () => + expect(Query.orderDesc('attr')) + .toEqual(`{"method":"orderDesc","attribute":"attr"}`) + ); + + test('cursorBefore', () => + expect(Query.cursorBefore('attr')) + .toEqual('{"method":"cursorBefore","values":["attr"]}') + ); + + test('cursorAfter', () => + expect(Query.cursorAfter('attr')) + .toEqual('{"method":"cursorAfter","values":["attr"]}') + ); + + test('limit', () => + expect(Query.limit(1)) + .toEqual('{"method":"limit","values":[1]}') + ); + + test('offset', () => + expect(Query.offset(1)) + .toEqual('{"method":"offset","values":[1]}') + ); +}) diff --git a/test/role.test.js b/test/role.test.js new file mode 100644 index 00000000..8f7420bd --- /dev/null +++ b/test/role.test.js @@ -0,0 +1,14 @@ +const { Role } = require("../dist/role"); + +describe('Role', () => { + test('any', () => expect(Role.any()).toEqual('any')); + test('user without status', () => expect(Role.user('custom')).toEqual('user:custom')); + test('user with status', () => expect(Role.user('custom', 'verified')).toEqual('user:custom/verified')); + test('users without status', () => expect(Role.users()).toEqual('users')); + test('users with status', () => expect(Role.users('verified')).toEqual('users/verified')); + test('guests', () => expect(Role.guests()).toEqual('guests')); + test('team without role', () => expect(Role.team('custom')).toEqual('team:custom')) + test('team with role', () => expect(Role.team('custom', 'owner')).toEqual('team:custom/owner')) + test('member', () => expect(Role.member('custom')).toEqual('member:custom')) + test('label', () => expect(Role.label('admin')).toEqual('label:admin')) +}) diff --git a/test/services/account.test.js b/test/services/account.test.js new file mode 100644 index 00000000..ec447a86 --- /dev/null +++ b/test/services/account.test.js @@ -0,0 +1,1307 @@ +const { Client } = require("../../dist/client"); +const { InputFile } = require("../../dist/inputFile"); +const { Account } = require("../../dist/services/account"); + +const { fetch: mockedFetch, Response } = require("node-fetch-native-with-agent"); +jest.mock('node-fetch-native-with-agent', () => ({ ...jest.requireActual('node-fetch-native-with-agent'), fetch: jest.fn() })); + +describe('Account', () => { + const client = new Client(); + const account = new Account(client); + + + test('test method get()', async () => { + const data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'name': 'John Doe', + 'registration': '2020-10-15T06:38:00.000+00:00', + 'status': true, + 'labels': [], + 'passwordUpdate': '2020-10-15T06:38:00.000+00:00', + 'email': 'john@appwrite.io', + 'phone': '+4930901820', + 'emailVerification': true, + 'phoneVerification': true, + 'mfa': true, + 'prefs': {}, + 'targets': [], + 'accessedAt': '2020-10-15T06:38:00.000+00:00',}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await account.get( + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method create()', async () => { + const data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'name': 'John Doe', + 'registration': '2020-10-15T06:38:00.000+00:00', + 'status': true, + 'labels': [], + 'passwordUpdate': '2020-10-15T06:38:00.000+00:00', + 'email': 'john@appwrite.io', + 'phone': '+4930901820', + 'emailVerification': true, + 'phoneVerification': true, + 'mfa': true, + 'prefs': {}, + 'targets': [], + 'accessedAt': '2020-10-15T06:38:00.000+00:00',}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await account.create( + '', + 'email@example.com', + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method updateEmail()', async () => { + const data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'name': 'John Doe', + 'registration': '2020-10-15T06:38:00.000+00:00', + 'status': true, + 'labels': [], + 'passwordUpdate': '2020-10-15T06:38:00.000+00:00', + 'email': 'john@appwrite.io', + 'phone': '+4930901820', + 'emailVerification': true, + 'phoneVerification': true, + 'mfa': true, + 'prefs': {}, + 'targets': [], + 'accessedAt': '2020-10-15T06:38:00.000+00:00',}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await account.updateEmail( + 'email@example.com', + 'password', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method listIdentities()', async () => { + const data = { + 'total': 5, + 'identities': [],}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await account.listIdentities( + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method deleteIdentity()', async () => { + const data = {message: ""}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await account.deleteIdentity( + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method createJWT()', async () => { + const data = { + 'jwt': 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c',}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await account.createJWT( + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method listLogs()', async () => { + const data = { + 'total': 5, + 'logs': [],}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await account.listLogs( + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method updateMFA()', async () => { + const data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'name': 'John Doe', + 'registration': '2020-10-15T06:38:00.000+00:00', + 'status': true, + 'labels': [], + 'passwordUpdate': '2020-10-15T06:38:00.000+00:00', + 'email': 'john@appwrite.io', + 'phone': '+4930901820', + 'emailVerification': true, + 'phoneVerification': true, + 'mfa': true, + 'prefs': {}, + 'targets': [], + 'accessedAt': '2020-10-15T06:38:00.000+00:00',}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await account.updateMFA( + true, + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method createMfaAuthenticator()', async () => { + const data = { + 'secret': '1', + 'uri': '1',}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await account.createMfaAuthenticator( + 'totp', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method createMFAAuthenticator()', async () => { + const data = { + 'secret': '1', + 'uri': '1',}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await account.createMFAAuthenticator( + 'totp', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method updateMfaAuthenticator()', async () => { + const data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'name': 'John Doe', + 'registration': '2020-10-15T06:38:00.000+00:00', + 'status': true, + 'labels': [], + 'passwordUpdate': '2020-10-15T06:38:00.000+00:00', + 'email': 'john@appwrite.io', + 'phone': '+4930901820', + 'emailVerification': true, + 'phoneVerification': true, + 'mfa': true, + 'prefs': {}, + 'targets': [], + 'accessedAt': '2020-10-15T06:38:00.000+00:00',}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await account.updateMfaAuthenticator( + 'totp', + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method updateMFAAuthenticator()', async () => { + const data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'name': 'John Doe', + 'registration': '2020-10-15T06:38:00.000+00:00', + 'status': true, + 'labels': [], + 'passwordUpdate': '2020-10-15T06:38:00.000+00:00', + 'email': 'john@appwrite.io', + 'phone': '+4930901820', + 'emailVerification': true, + 'phoneVerification': true, + 'mfa': true, + 'prefs': {}, + 'targets': [], + 'accessedAt': '2020-10-15T06:38:00.000+00:00',}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await account.updateMFAAuthenticator( + 'totp', + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method deleteMfaAuthenticator()', async () => { + const data = {message: ""}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await account.deleteMfaAuthenticator( + 'totp', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method deleteMFAAuthenticator()', async () => { + const data = {message: ""}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await account.deleteMFAAuthenticator( + 'totp', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method createMfaChallenge()', async () => { + const data = { + '\$id': 'bb8ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + 'userId': '5e5ea5c168bb8', + 'expire': '2020-10-15T06:38:00.000+00:00',}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await account.createMfaChallenge( + 'email', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method createMFAChallenge()', async () => { + const data = { + '\$id': 'bb8ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + 'userId': '5e5ea5c168bb8', + 'expire': '2020-10-15T06:38:00.000+00:00',}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await account.createMFAChallenge( + 'email', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method updateMfaChallenge()', async () => { + const data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'userId': '5e5bb8c16897e', + 'expire': '2020-10-15T06:38:00.000+00:00', + 'provider': 'email', + 'providerUid': 'user@example.com', + 'providerAccessToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', + 'providerAccessTokenExpiry': '2020-10-15T06:38:00.000+00:00', + 'providerRefreshToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', + 'ip': '127.0.0.1', + 'osCode': 'Mac', + 'osName': 'Mac', + 'osVersion': 'Mac', + 'clientType': 'browser', + 'clientCode': 'CM', + 'clientName': 'Chrome Mobile iOS', + 'clientVersion': '84.0', + 'clientEngine': 'WebKit', + 'clientEngineVersion': '605.1.15', + 'deviceName': 'smartphone', + 'deviceBrand': 'Google', + 'deviceModel': 'Nexus 5', + 'countryCode': 'US', + 'countryName': 'United States', + 'current': true, + 'factors': [], + 'secret': '5e5bb8c16897e', + 'mfaUpdatedAt': '2020-10-15T06:38:00.000+00:00',}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await account.updateMfaChallenge( + '', + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method updateMFAChallenge()', async () => { + const data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'userId': '5e5bb8c16897e', + 'expire': '2020-10-15T06:38:00.000+00:00', + 'provider': 'email', + 'providerUid': 'user@example.com', + 'providerAccessToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', + 'providerAccessTokenExpiry': '2020-10-15T06:38:00.000+00:00', + 'providerRefreshToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', + 'ip': '127.0.0.1', + 'osCode': 'Mac', + 'osName': 'Mac', + 'osVersion': 'Mac', + 'clientType': 'browser', + 'clientCode': 'CM', + 'clientName': 'Chrome Mobile iOS', + 'clientVersion': '84.0', + 'clientEngine': 'WebKit', + 'clientEngineVersion': '605.1.15', + 'deviceName': 'smartphone', + 'deviceBrand': 'Google', + 'deviceModel': 'Nexus 5', + 'countryCode': 'US', + 'countryName': 'United States', + 'current': true, + 'factors': [], + 'secret': '5e5bb8c16897e', + 'mfaUpdatedAt': '2020-10-15T06:38:00.000+00:00',}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await account.updateMFAChallenge( + '', + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method listMfaFactors()', async () => { + const data = { + 'totp': true, + 'phone': true, + 'email': true, + 'recoveryCode': true,}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await account.listMfaFactors( + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method listMFAFactors()', async () => { + const data = { + 'totp': true, + 'phone': true, + 'email': true, + 'recoveryCode': true,}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await account.listMFAFactors( + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method getMfaRecoveryCodes()', async () => { + const data = { + 'recoveryCodes': [],}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await account.getMfaRecoveryCodes( + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method getMFARecoveryCodes()', async () => { + const data = { + 'recoveryCodes': [],}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await account.getMFARecoveryCodes( + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method createMfaRecoveryCodes()', async () => { + const data = { + 'recoveryCodes': [],}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await account.createMfaRecoveryCodes( + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method createMFARecoveryCodes()', async () => { + const data = { + 'recoveryCodes': [],}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await account.createMFARecoveryCodes( + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method updateMfaRecoveryCodes()', async () => { + const data = { + 'recoveryCodes': [],}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await account.updateMfaRecoveryCodes( + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method updateMFARecoveryCodes()', async () => { + const data = { + 'recoveryCodes': [],}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await account.updateMFARecoveryCodes( + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method updateName()', async () => { + const data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'name': 'John Doe', + 'registration': '2020-10-15T06:38:00.000+00:00', + 'status': true, + 'labels': [], + 'passwordUpdate': '2020-10-15T06:38:00.000+00:00', + 'email': 'john@appwrite.io', + 'phone': '+4930901820', + 'emailVerification': true, + 'phoneVerification': true, + 'mfa': true, + 'prefs': {}, + 'targets': [], + 'accessedAt': '2020-10-15T06:38:00.000+00:00',}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await account.updateName( + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method updatePassword()', async () => { + const data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'name': 'John Doe', + 'registration': '2020-10-15T06:38:00.000+00:00', + 'status': true, + 'labels': [], + 'passwordUpdate': '2020-10-15T06:38:00.000+00:00', + 'email': 'john@appwrite.io', + 'phone': '+4930901820', + 'emailVerification': true, + 'phoneVerification': true, + 'mfa': true, + 'prefs': {}, + 'targets': [], + 'accessedAt': '2020-10-15T06:38:00.000+00:00',}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await account.updatePassword( + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method updatePhone()', async () => { + const data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'name': 'John Doe', + 'registration': '2020-10-15T06:38:00.000+00:00', + 'status': true, + 'labels': [], + 'passwordUpdate': '2020-10-15T06:38:00.000+00:00', + 'email': 'john@appwrite.io', + 'phone': '+4930901820', + 'emailVerification': true, + 'phoneVerification': true, + 'mfa': true, + 'prefs': {}, + 'targets': [], + 'accessedAt': '2020-10-15T06:38:00.000+00:00',}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await account.updatePhone( + '+12065550100', + 'password', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method getPrefs()', async () => { + const data = {}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await account.getPrefs( + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method updatePrefs()', async () => { + const data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'name': 'John Doe', + 'registration': '2020-10-15T06:38:00.000+00:00', + 'status': true, + 'labels': [], + 'passwordUpdate': '2020-10-15T06:38:00.000+00:00', + 'email': 'john@appwrite.io', + 'phone': '+4930901820', + 'emailVerification': true, + 'phoneVerification': true, + 'mfa': true, + 'prefs': {}, + 'targets': [], + 'accessedAt': '2020-10-15T06:38:00.000+00:00',}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await account.updatePrefs( + {}, + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method createRecovery()', async () => { + const data = { + '\$id': 'bb8ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + 'userId': '5e5ea5c168bb8', + 'secret': '', + 'expire': '2020-10-15T06:38:00.000+00:00', + 'phrase': 'Golden Fox',}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await account.createRecovery( + 'email@example.com', + 'https://example.com', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method updateRecovery()', async () => { + const data = { + '\$id': 'bb8ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + 'userId': '5e5ea5c168bb8', + 'secret': '', + 'expire': '2020-10-15T06:38:00.000+00:00', + 'phrase': 'Golden Fox',}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await account.updateRecovery( + '', + '', + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method listSessions()', async () => { + const data = { + 'total': 5, + 'sessions': [],}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await account.listSessions( + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method deleteSessions()', async () => { + const data = {message: ""}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await account.deleteSessions( + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method createAnonymousSession()', async () => { + const data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'userId': '5e5bb8c16897e', + 'expire': '2020-10-15T06:38:00.000+00:00', + 'provider': 'email', + 'providerUid': 'user@example.com', + 'providerAccessToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', + 'providerAccessTokenExpiry': '2020-10-15T06:38:00.000+00:00', + 'providerRefreshToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', + 'ip': '127.0.0.1', + 'osCode': 'Mac', + 'osName': 'Mac', + 'osVersion': 'Mac', + 'clientType': 'browser', + 'clientCode': 'CM', + 'clientName': 'Chrome Mobile iOS', + 'clientVersion': '84.0', + 'clientEngine': 'WebKit', + 'clientEngineVersion': '605.1.15', + 'deviceName': 'smartphone', + 'deviceBrand': 'Google', + 'deviceModel': 'Nexus 5', + 'countryCode': 'US', + 'countryName': 'United States', + 'current': true, + 'factors': [], + 'secret': '5e5bb8c16897e', + 'mfaUpdatedAt': '2020-10-15T06:38:00.000+00:00',}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await account.createAnonymousSession( + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method createEmailPasswordSession()', async () => { + const data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'userId': '5e5bb8c16897e', + 'expire': '2020-10-15T06:38:00.000+00:00', + 'provider': 'email', + 'providerUid': 'user@example.com', + 'providerAccessToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', + 'providerAccessTokenExpiry': '2020-10-15T06:38:00.000+00:00', + 'providerRefreshToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', + 'ip': '127.0.0.1', + 'osCode': 'Mac', + 'osName': 'Mac', + 'osVersion': 'Mac', + 'clientType': 'browser', + 'clientCode': 'CM', + 'clientName': 'Chrome Mobile iOS', + 'clientVersion': '84.0', + 'clientEngine': 'WebKit', + 'clientEngineVersion': '605.1.15', + 'deviceName': 'smartphone', + 'deviceBrand': 'Google', + 'deviceModel': 'Nexus 5', + 'countryCode': 'US', + 'countryName': 'United States', + 'current': true, + 'factors': [], + 'secret': '5e5bb8c16897e', + 'mfaUpdatedAt': '2020-10-15T06:38:00.000+00:00',}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await account.createEmailPasswordSession( + 'email@example.com', + 'password', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method updateMagicURLSession()', async () => { + const data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'userId': '5e5bb8c16897e', + 'expire': '2020-10-15T06:38:00.000+00:00', + 'provider': 'email', + 'providerUid': 'user@example.com', + 'providerAccessToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', + 'providerAccessTokenExpiry': '2020-10-15T06:38:00.000+00:00', + 'providerRefreshToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', + 'ip': '127.0.0.1', + 'osCode': 'Mac', + 'osName': 'Mac', + 'osVersion': 'Mac', + 'clientType': 'browser', + 'clientCode': 'CM', + 'clientName': 'Chrome Mobile iOS', + 'clientVersion': '84.0', + 'clientEngine': 'WebKit', + 'clientEngineVersion': '605.1.15', + 'deviceName': 'smartphone', + 'deviceBrand': 'Google', + 'deviceModel': 'Nexus 5', + 'countryCode': 'US', + 'countryName': 'United States', + 'current': true, + 'factors': [], + 'secret': '5e5bb8c16897e', + 'mfaUpdatedAt': '2020-10-15T06:38:00.000+00:00',}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await account.updateMagicURLSession( + '', + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method updatePhoneSession()', async () => { + const data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'userId': '5e5bb8c16897e', + 'expire': '2020-10-15T06:38:00.000+00:00', + 'provider': 'email', + 'providerUid': 'user@example.com', + 'providerAccessToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', + 'providerAccessTokenExpiry': '2020-10-15T06:38:00.000+00:00', + 'providerRefreshToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', + 'ip': '127.0.0.1', + 'osCode': 'Mac', + 'osName': 'Mac', + 'osVersion': 'Mac', + 'clientType': 'browser', + 'clientCode': 'CM', + 'clientName': 'Chrome Mobile iOS', + 'clientVersion': '84.0', + 'clientEngine': 'WebKit', + 'clientEngineVersion': '605.1.15', + 'deviceName': 'smartphone', + 'deviceBrand': 'Google', + 'deviceModel': 'Nexus 5', + 'countryCode': 'US', + 'countryName': 'United States', + 'current': true, + 'factors': [], + 'secret': '5e5bb8c16897e', + 'mfaUpdatedAt': '2020-10-15T06:38:00.000+00:00',}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await account.updatePhoneSession( + '', + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method createSession()', async () => { + const data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'userId': '5e5bb8c16897e', + 'expire': '2020-10-15T06:38:00.000+00:00', + 'provider': 'email', + 'providerUid': 'user@example.com', + 'providerAccessToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', + 'providerAccessTokenExpiry': '2020-10-15T06:38:00.000+00:00', + 'providerRefreshToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', + 'ip': '127.0.0.1', + 'osCode': 'Mac', + 'osName': 'Mac', + 'osVersion': 'Mac', + 'clientType': 'browser', + 'clientCode': 'CM', + 'clientName': 'Chrome Mobile iOS', + 'clientVersion': '84.0', + 'clientEngine': 'WebKit', + 'clientEngineVersion': '605.1.15', + 'deviceName': 'smartphone', + 'deviceBrand': 'Google', + 'deviceModel': 'Nexus 5', + 'countryCode': 'US', + 'countryName': 'United States', + 'current': true, + 'factors': [], + 'secret': '5e5bb8c16897e', + 'mfaUpdatedAt': '2020-10-15T06:38:00.000+00:00',}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await account.createSession( + '', + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method getSession()', async () => { + const data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'userId': '5e5bb8c16897e', + 'expire': '2020-10-15T06:38:00.000+00:00', + 'provider': 'email', + 'providerUid': 'user@example.com', + 'providerAccessToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', + 'providerAccessTokenExpiry': '2020-10-15T06:38:00.000+00:00', + 'providerRefreshToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', + 'ip': '127.0.0.1', + 'osCode': 'Mac', + 'osName': 'Mac', + 'osVersion': 'Mac', + 'clientType': 'browser', + 'clientCode': 'CM', + 'clientName': 'Chrome Mobile iOS', + 'clientVersion': '84.0', + 'clientEngine': 'WebKit', + 'clientEngineVersion': '605.1.15', + 'deviceName': 'smartphone', + 'deviceBrand': 'Google', + 'deviceModel': 'Nexus 5', + 'countryCode': 'US', + 'countryName': 'United States', + 'current': true, + 'factors': [], + 'secret': '5e5bb8c16897e', + 'mfaUpdatedAt': '2020-10-15T06:38:00.000+00:00',}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await account.getSession( + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method updateSession()', async () => { + const data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'userId': '5e5bb8c16897e', + 'expire': '2020-10-15T06:38:00.000+00:00', + 'provider': 'email', + 'providerUid': 'user@example.com', + 'providerAccessToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', + 'providerAccessTokenExpiry': '2020-10-15T06:38:00.000+00:00', + 'providerRefreshToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', + 'ip': '127.0.0.1', + 'osCode': 'Mac', + 'osName': 'Mac', + 'osVersion': 'Mac', + 'clientType': 'browser', + 'clientCode': 'CM', + 'clientName': 'Chrome Mobile iOS', + 'clientVersion': '84.0', + 'clientEngine': 'WebKit', + 'clientEngineVersion': '605.1.15', + 'deviceName': 'smartphone', + 'deviceBrand': 'Google', + 'deviceModel': 'Nexus 5', + 'countryCode': 'US', + 'countryName': 'United States', + 'current': true, + 'factors': [], + 'secret': '5e5bb8c16897e', + 'mfaUpdatedAt': '2020-10-15T06:38:00.000+00:00',}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await account.updateSession( + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method deleteSession()', async () => { + const data = {message: ""}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await account.deleteSession( + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method updateStatus()', async () => { + const data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'name': 'John Doe', + 'registration': '2020-10-15T06:38:00.000+00:00', + 'status': true, + 'labels': [], + 'passwordUpdate': '2020-10-15T06:38:00.000+00:00', + 'email': 'john@appwrite.io', + 'phone': '+4930901820', + 'emailVerification': true, + 'phoneVerification': true, + 'mfa': true, + 'prefs': {}, + 'targets': [], + 'accessedAt': '2020-10-15T06:38:00.000+00:00',}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await account.updateStatus( + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method createEmailToken()', async () => { + const data = { + '\$id': 'bb8ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + 'userId': '5e5ea5c168bb8', + 'secret': '', + 'expire': '2020-10-15T06:38:00.000+00:00', + 'phrase': 'Golden Fox',}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await account.createEmailToken( + '', + 'email@example.com', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method createMagicURLToken()', async () => { + const data = { + '\$id': 'bb8ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + 'userId': '5e5ea5c168bb8', + 'secret': '', + 'expire': '2020-10-15T06:38:00.000+00:00', + 'phrase': 'Golden Fox',}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await account.createMagicURLToken( + '', + 'email@example.com', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method createOAuth2Token()', async () => { + const data = 'https://example.com/'; + mockedFetch.mockImplementation(() => Response.redirect(data)); + + const response = await account.createOAuth2Token( + 'amazon', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method createPhoneToken()', async () => { + const data = { + '\$id': 'bb8ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + 'userId': '5e5ea5c168bb8', + 'secret': '', + 'expire': '2020-10-15T06:38:00.000+00:00', + 'phrase': 'Golden Fox',}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await account.createPhoneToken( + '', + '+12065550100', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method createEmailVerification()', async () => { + const data = { + '\$id': 'bb8ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + 'userId': '5e5ea5c168bb8', + 'secret': '', + 'expire': '2020-10-15T06:38:00.000+00:00', + 'phrase': 'Golden Fox',}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await account.createEmailVerification( + 'https://example.com', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method createVerification()', async () => { + const data = { + '\$id': 'bb8ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + 'userId': '5e5ea5c168bb8', + 'secret': '', + 'expire': '2020-10-15T06:38:00.000+00:00', + 'phrase': 'Golden Fox',}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await account.createVerification( + 'https://example.com', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method updateEmailVerification()', async () => { + const data = { + '\$id': 'bb8ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + 'userId': '5e5ea5c168bb8', + 'secret': '', + 'expire': '2020-10-15T06:38:00.000+00:00', + 'phrase': 'Golden Fox',}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await account.updateEmailVerification( + '', + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method updateVerification()', async () => { + const data = { + '\$id': 'bb8ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + 'userId': '5e5ea5c168bb8', + 'secret': '', + 'expire': '2020-10-15T06:38:00.000+00:00', + 'phrase': 'Golden Fox',}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await account.updateVerification( + '', + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method createPhoneVerification()', async () => { + const data = { + '\$id': 'bb8ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + 'userId': '5e5ea5c168bb8', + 'secret': '', + 'expire': '2020-10-15T06:38:00.000+00:00', + 'phrase': 'Golden Fox',}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await account.createPhoneVerification( + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method updatePhoneVerification()', async () => { + const data = { + '\$id': 'bb8ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + 'userId': '5e5ea5c168bb8', + 'secret': '', + 'expire': '2020-10-15T06:38:00.000+00:00', + 'phrase': 'Golden Fox',}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await account.updatePhoneVerification( + '', + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + }) diff --git a/test/services/activities.test.js b/test/services/activities.test.js new file mode 100644 index 00000000..fcf8e46e --- /dev/null +++ b/test/services/activities.test.js @@ -0,0 +1,73 @@ +const { Client } = require("../../dist/client"); +const { InputFile } = require("../../dist/inputFile"); +const { Activities } = require("../../dist/services/activities"); + +const { fetch: mockedFetch, Response } = require("node-fetch-native-with-agent"); +jest.mock('node-fetch-native-with-agent', () => ({ ...jest.requireActual('node-fetch-native-with-agent'), fetch: jest.fn() })); + +describe('Activities', () => { + const client = new Client(); + const activities = new Activities(client); + + + test('test method listEvents()', async () => { + const data = { + 'total': 5, + 'events': [],}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await activities.listEvents( + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method getEvent()', async () => { + const data = { + '\$id': '5e5ea5c16897e', + 'userType': 'user', + 'userId': '610fc2f985ee0', + 'userEmail': 'john@appwrite.io', + 'userName': 'John Doe', + 'resourceParent': 'database/ID', + 'resourceType': 'collection', + 'resourceId': '610fc2f985ee0', + 'resource': 'collections/610fc2f985ee0', + 'event': 'account.sessions.create', + 'userAgent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.198 Safari/537.36', + 'ip': '127.0.0.1', + 'mode': 'admin', + 'country': 'US', + 'time': '2020-10-15T06:38:00.000+00:00', + 'projectId': '610fc2f985ee0', + 'teamId': '610fc2f985ee0', + 'hostname': 'appwrite.io', + 'osCode': 'Mac', + 'osName': 'Mac', + 'osVersion': 'Mac', + 'clientType': 'browser', + 'clientCode': 'CM', + 'clientName': 'Chrome Mobile iOS', + 'clientVersion': '84.0', + 'clientEngine': 'WebKit', + 'clientEngineVersion': '605.1.15', + 'deviceName': 'smartphone', + 'deviceBrand': 'Google', + 'deviceModel': 'Nexus 5', + 'countryCode': 'US', + 'countryName': 'United States',}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await activities.getEvent( + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + }) diff --git a/test/services/avatars.test.js b/test/services/avatars.test.js new file mode 100644 index 00000000..ea4f3798 --- /dev/null +++ b/test/services/avatars.test.js @@ -0,0 +1,123 @@ +const { Client } = require("../../dist/client"); +const { InputFile } = require("../../dist/inputFile"); +const { Avatars } = require("../../dist/services/avatars"); + +const { fetch: mockedFetch, Response } = require("node-fetch-native-with-agent"); +jest.mock('node-fetch-native-with-agent', () => ({ ...jest.requireActual('node-fetch-native-with-agent'), fetch: jest.fn() })); + +describe('Avatars', () => { + const client = new Client(); + const avatars = new Avatars(client); + + + test('test method getBrowser()', async () => { + const data = new ArrayBuffer(0); + mockedFetch.mockImplementation(() => new Response(data)); + + const response = await avatars.getBrowser( + 'aa', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method getCreditCard()', async () => { + const data = new ArrayBuffer(0); + mockedFetch.mockImplementation(() => new Response(data)); + + const response = await avatars.getCreditCard( + 'amex', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method getFavicon()', async () => { + const data = new ArrayBuffer(0); + mockedFetch.mockImplementation(() => new Response(data)); + + const response = await avatars.getFavicon( + 'https://example.com', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method getFlag()', async () => { + const data = new ArrayBuffer(0); + mockedFetch.mockImplementation(() => new Response(data)); + + const response = await avatars.getFlag( + 'af', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method getImage()', async () => { + const data = new ArrayBuffer(0); + mockedFetch.mockImplementation(() => new Response(data)); + + const response = await avatars.getImage( + 'https://example.com', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method getInitials()', async () => { + const data = new ArrayBuffer(0); + mockedFetch.mockImplementation(() => new Response(data)); + + const response = await avatars.getInitials( + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method getQR()', async () => { + const data = new ArrayBuffer(0); + mockedFetch.mockImplementation(() => new Response(data)); + + const response = await avatars.getQR( + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method getScreenshot()', async () => { + const data = new ArrayBuffer(0); + mockedFetch.mockImplementation(() => new Response(data)); + + const response = await avatars.getScreenshot( + 'https://example.com', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + }) diff --git a/test/services/backups.test.js b/test/services/backups.test.js new file mode 100644 index 00000000..b87b1c08 --- /dev/null +++ b/test/services/backups.test.js @@ -0,0 +1,256 @@ +const { Client } = require("../../dist/client"); +const { InputFile } = require("../../dist/inputFile"); +const { Backups } = require("../../dist/services/backups"); + +const { fetch: mockedFetch, Response } = require("node-fetch-native-with-agent"); +jest.mock('node-fetch-native-with-agent', () => ({ ...jest.requireActual('node-fetch-native-with-agent'), fetch: jest.fn() })); + +describe('Backups', () => { + const client = new Client(); + const backups = new Backups(client); + + + test('test method listArchives()', async () => { + const data = { + 'total': 5, + 'archives': [],}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await backups.listArchives( + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method createArchive()', async () => { + const data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'policyId': 'did8jx6ws45jana098ab7', + 'size': 100000, + 'status': 'completed', + 'startedAt': '2020-10-15T06:38:00.000+00:00', + 'migrationId': 'did8jx6ws45jana098ab7', + 'services': [], + 'resources': [],}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await backups.createArchive( + [], + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method getArchive()', async () => { + const data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'policyId': 'did8jx6ws45jana098ab7', + 'size': 100000, + 'status': 'completed', + 'startedAt': '2020-10-15T06:38:00.000+00:00', + 'migrationId': 'did8jx6ws45jana098ab7', + 'services': [], + 'resources': [],}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await backups.getArchive( + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method deleteArchive()', async () => { + const data = {message: ""}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await backups.deleteArchive( + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method listPolicies()', async () => { + const data = { + 'total': 5, + 'policies': [],}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await backups.listPolicies( + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method createPolicy()', async () => { + const data = { + '\$id': '5e5ea5c16897e', + 'name': 'Hourly backups', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'services': [], + 'resources': [], + 'retention': 7, + 'schedule': '0 * * * *', + 'enabled': true,}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await backups.createPolicy( + '', + [], + 1, + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method getPolicy()', async () => { + const data = { + '\$id': '5e5ea5c16897e', + 'name': 'Hourly backups', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'services': [], + 'resources': [], + 'retention': 7, + 'schedule': '0 * * * *', + 'enabled': true,}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await backups.getPolicy( + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method updatePolicy()', async () => { + const data = { + '\$id': '5e5ea5c16897e', + 'name': 'Hourly backups', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'services': [], + 'resources': [], + 'retention': 7, + 'schedule': '0 * * * *', + 'enabled': true,}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await backups.updatePolicy( + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method deletePolicy()', async () => { + const data = {message: ""}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await backups.deletePolicy( + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method createRestoration()', async () => { + const data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'archiveId': 'did8jx6ws45jana098ab7', + 'policyId': 'did8jx6ws45jana098ab7', + 'status': 'completed', + 'startedAt': '2020-10-15T06:38:00.000+00:00', + 'migrationId': 'did8jx6ws45jana098ab7', + 'services': [], + 'resources': [], + 'options': '{databases.database[{oldId, newId, newName}]}',}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await backups.createRestoration( + '', + [], + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method listRestorations()', async () => { + const data = { + 'total': 5, + 'restorations': [],}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await backups.listRestorations( + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method getRestoration()', async () => { + const data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'archiveId': 'did8jx6ws45jana098ab7', + 'policyId': 'did8jx6ws45jana098ab7', + 'status': 'completed', + 'startedAt': '2020-10-15T06:38:00.000+00:00', + 'migrationId': 'did8jx6ws45jana098ab7', + 'services': [], + 'resources': [], + 'options': '{databases.database[{oldId, newId, newName}]}',}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await backups.getRestoration( + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + }) diff --git a/test/services/databases.test.js b/test/services/databases.test.js new file mode 100644 index 00000000..ff809d28 --- /dev/null +++ b/test/services/databases.test.js @@ -0,0 +1,1574 @@ +const { Client } = require("../../dist/client"); +const { InputFile } = require("../../dist/inputFile"); +const { Databases } = require("../../dist/services/databases"); + +const { fetch: mockedFetch, Response } = require("node-fetch-native-with-agent"); +jest.mock('node-fetch-native-with-agent', () => ({ ...jest.requireActual('node-fetch-native-with-agent'), fetch: jest.fn() })); + +describe('Databases', () => { + const client = new Client(); + const databases = new Databases(client); + + + test('test method list()', async () => { + const data = { + 'total': 5, + 'databases': [],}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await databases.list( + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method create()', async () => { + const data = { + '\$id': '5e5ea5c16897e', + 'name': 'My Database', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'enabled': true, + 'type': 'legacy', + 'policies': [], + 'archives': [],}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await databases.create( + '', + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method listTransactions()', async () => { + const data = { + 'total': 5, + 'transactions': [],}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await databases.listTransactions( + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method createTransaction()', async () => { + const data = { + '\$id': '259125845563242502', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'status': 'pending', + 'operations': 5, + 'expiresAt': '2020-10-15T06:38:00.000+00:00',}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await databases.createTransaction( + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method getTransaction()', async () => { + const data = { + '\$id': '259125845563242502', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'status': 'pending', + 'operations': 5, + 'expiresAt': '2020-10-15T06:38:00.000+00:00',}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await databases.getTransaction( + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method updateTransaction()', async () => { + const data = { + '\$id': '259125845563242502', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'status': 'pending', + 'operations': 5, + 'expiresAt': '2020-10-15T06:38:00.000+00:00',}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await databases.updateTransaction( + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method deleteTransaction()', async () => { + const data = {message: ""}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await databases.deleteTransaction( + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method createOperations()', async () => { + const data = { + '\$id': '259125845563242502', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'status': 'pending', + 'operations': 5, + 'expiresAt': '2020-10-15T06:38:00.000+00:00',}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await databases.createOperations( + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method get()', async () => { + const data = { + '\$id': '5e5ea5c16897e', + 'name': 'My Database', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'enabled': true, + 'type': 'legacy', + 'policies': [], + 'archives': [],}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await databases.get( + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method update()', async () => { + const data = { + '\$id': '5e5ea5c16897e', + 'name': 'My Database', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'enabled': true, + 'type': 'legacy', + 'policies': [], + 'archives': [],}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await databases.update( + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method delete()', async () => { + const data = {message: ""}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await databases.delete( + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method listCollections()', async () => { + const data = { + 'total': 5, + 'collections': [],}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await databases.listCollections( + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method createCollection()', async () => { + const data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\$permissions': [], + 'databaseId': '5e5ea5c16897e', + 'name': 'My Collection', + 'enabled': true, + 'documentSecurity': true, + 'attributes': [], + 'indexes': [], + 'bytesMax': 65535, + 'bytesUsed': 1500,}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await databases.createCollection( + '', + '', + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method getCollection()', async () => { + const data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\$permissions': [], + 'databaseId': '5e5ea5c16897e', + 'name': 'My Collection', + 'enabled': true, + 'documentSecurity': true, + 'attributes': [], + 'indexes': [], + 'bytesMax': 65535, + 'bytesUsed': 1500,}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await databases.getCollection( + '', + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method updateCollection()', async () => { + const data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\$permissions': [], + 'databaseId': '5e5ea5c16897e', + 'name': 'My Collection', + 'enabled': true, + 'documentSecurity': true, + 'attributes': [], + 'indexes': [], + 'bytesMax': 65535, + 'bytesUsed': 1500,}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await databases.updateCollection( + '', + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method deleteCollection()', async () => { + const data = {message: ""}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await databases.deleteCollection( + '', + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method listAttributes()', async () => { + const data = { + 'total': 5, + 'attributes': [],}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await databases.listAttributes( + '', + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method createBooleanAttribute()', async () => { + const data = { + 'key': 'isEnabled', + 'type': 'boolean', + 'status': 'available', + 'error': 'string', + 'required': true, + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00',}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await databases.createBooleanAttribute( + '', + '', + '', + true, + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method updateBooleanAttribute()', async () => { + const data = { + 'key': 'isEnabled', + 'type': 'boolean', + 'status': 'available', + 'error': 'string', + 'required': true, + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00',}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await databases.updateBooleanAttribute( + '', + '', + '', + true, + true, + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method createDatetimeAttribute()', async () => { + const data = { + 'key': 'birthDay', + 'type': 'datetime', + 'status': 'available', + 'error': 'string', + 'required': true, + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'format': 'datetime',}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await databases.createDatetimeAttribute( + '', + '', + '', + true, + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method updateDatetimeAttribute()', async () => { + const data = { + 'key': 'birthDay', + 'type': 'datetime', + 'status': 'available', + 'error': 'string', + 'required': true, + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'format': 'datetime',}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await databases.updateDatetimeAttribute( + '', + '', + '', + true, + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method createEmailAttribute()', async () => { + const data = { + 'key': 'userEmail', + 'type': 'string', + 'status': 'available', + 'error': 'string', + 'required': true, + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'format': 'email',}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await databases.createEmailAttribute( + '', + '', + '', + true, + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method updateEmailAttribute()', async () => { + const data = { + 'key': 'userEmail', + 'type': 'string', + 'status': 'available', + 'error': 'string', + 'required': true, + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'format': 'email',}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await databases.updateEmailAttribute( + '', + '', + '', + true, + 'email@example.com', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method createEnumAttribute()', async () => { + const data = { + 'key': 'status', + 'type': 'string', + 'status': 'available', + 'error': 'string', + 'required': true, + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'elements': [], + 'format': 'enum',}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await databases.createEnumAttribute( + '', + '', + '', + [], + true, + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method updateEnumAttribute()', async () => { + const data = { + 'key': 'status', + 'type': 'string', + 'status': 'available', + 'error': 'string', + 'required': true, + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'elements': [], + 'format': 'enum',}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await databases.updateEnumAttribute( + '', + '', + '', + [], + true, + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method createFloatAttribute()', async () => { + const data = { + 'key': 'percentageCompleted', + 'type': 'double', + 'status': 'available', + 'error': 'string', + 'required': true, + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00',}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await databases.createFloatAttribute( + '', + '', + '', + true, + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method updateFloatAttribute()', async () => { + const data = { + 'key': 'percentageCompleted', + 'type': 'double', + 'status': 'available', + 'error': 'string', + 'required': true, + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00',}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await databases.updateFloatAttribute( + '', + '', + '', + true, + 1.0, + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method createIntegerAttribute()', async () => { + const data = { + 'key': 'count', + 'type': 'integer', + 'status': 'available', + 'error': 'string', + 'required': true, + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00',}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await databases.createIntegerAttribute( + '', + '', + '', + true, + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method updateIntegerAttribute()', async () => { + const data = { + 'key': 'count', + 'type': 'integer', + 'status': 'available', + 'error': 'string', + 'required': true, + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00',}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await databases.updateIntegerAttribute( + '', + '', + '', + true, + 1, + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method createIpAttribute()', async () => { + const data = { + 'key': 'ipAddress', + 'type': 'string', + 'status': 'available', + 'error': 'string', + 'required': true, + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'format': 'ip',}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await databases.createIpAttribute( + '', + '', + '', + true, + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method updateIpAttribute()', async () => { + const data = { + 'key': 'ipAddress', + 'type': 'string', + 'status': 'available', + 'error': 'string', + 'required': true, + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'format': 'ip',}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await databases.updateIpAttribute( + '', + '', + '', + true, + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method createLineAttribute()', async () => { + const data = { + 'key': 'fullName', + 'type': 'string', + 'status': 'available', + 'error': 'string', + 'required': true, + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00',}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await databases.createLineAttribute( + '', + '', + '', + true, + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method updateLineAttribute()', async () => { + const data = { + 'key': 'fullName', + 'type': 'string', + 'status': 'available', + 'error': 'string', + 'required': true, + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00',}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await databases.updateLineAttribute( + '', + '', + '', + true, + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method createLongtextAttribute()', async () => { + const data = { + 'key': 'fullName', + 'type': 'string', + 'status': 'available', + 'error': 'string', + 'required': true, + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00',}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await databases.createLongtextAttribute( + '', + '', + '', + true, + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method updateLongtextAttribute()', async () => { + const data = { + 'key': 'fullName', + 'type': 'string', + 'status': 'available', + 'error': 'string', + 'required': true, + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00',}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await databases.updateLongtextAttribute( + '', + '', + '', + true, + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method createMediumtextAttribute()', async () => { + const data = { + 'key': 'fullName', + 'type': 'string', + 'status': 'available', + 'error': 'string', + 'required': true, + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00',}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await databases.createMediumtextAttribute( + '', + '', + '', + true, + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method updateMediumtextAttribute()', async () => { + const data = { + 'key': 'fullName', + 'type': 'string', + 'status': 'available', + 'error': 'string', + 'required': true, + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00',}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await databases.updateMediumtextAttribute( + '', + '', + '', + true, + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method createPointAttribute()', async () => { + const data = { + 'key': 'fullName', + 'type': 'string', + 'status': 'available', + 'error': 'string', + 'required': true, + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00',}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await databases.createPointAttribute( + '', + '', + '', + true, + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method updatePointAttribute()', async () => { + const data = { + 'key': 'fullName', + 'type': 'string', + 'status': 'available', + 'error': 'string', + 'required': true, + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00',}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await databases.updatePointAttribute( + '', + '', + '', + true, + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method createPolygonAttribute()', async () => { + const data = { + 'key': 'fullName', + 'type': 'string', + 'status': 'available', + 'error': 'string', + 'required': true, + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00',}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await databases.createPolygonAttribute( + '', + '', + '', + true, + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method updatePolygonAttribute()', async () => { + const data = { + 'key': 'fullName', + 'type': 'string', + 'status': 'available', + 'error': 'string', + 'required': true, + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00',}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await databases.updatePolygonAttribute( + '', + '', + '', + true, + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method createRelationshipAttribute()', async () => { + const data = { + 'key': 'fullName', + 'type': 'string', + 'status': 'available', + 'error': 'string', + 'required': true, + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'relatedCollection': 'collection', + 'relationType': 'oneToOne|oneToMany|manyToOne|manyToMany', + 'twoWay': true, + 'twoWayKey': 'string', + 'onDelete': 'restrict|cascade|setNull', + 'side': 'parent|child',}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await databases.createRelationshipAttribute( + '', + '', + '', + 'oneToOne', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method updateRelationshipAttribute()', async () => { + const data = { + 'key': 'fullName', + 'type': 'string', + 'status': 'available', + 'error': 'string', + 'required': true, + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'relatedCollection': 'collection', + 'relationType': 'oneToOne|oneToMany|manyToOne|manyToMany', + 'twoWay': true, + 'twoWayKey': 'string', + 'onDelete': 'restrict|cascade|setNull', + 'side': 'parent|child',}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await databases.updateRelationshipAttribute( + '', + '', + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method createStringAttribute()', async () => { + const data = { + 'key': 'fullName', + 'type': 'string', + 'status': 'available', + 'error': 'string', + 'required': true, + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'size': 128,}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await databases.createStringAttribute( + '', + '', + '', + 1, + true, + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method updateStringAttribute()', async () => { + const data = { + 'key': 'fullName', + 'type': 'string', + 'status': 'available', + 'error': 'string', + 'required': true, + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'size': 128,}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await databases.updateStringAttribute( + '', + '', + '', + true, + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method createTextAttribute()', async () => { + const data = { + 'key': 'fullName', + 'type': 'string', + 'status': 'available', + 'error': 'string', + 'required': true, + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00',}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await databases.createTextAttribute( + '', + '', + '', + true, + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method updateTextAttribute()', async () => { + const data = { + 'key': 'fullName', + 'type': 'string', + 'status': 'available', + 'error': 'string', + 'required': true, + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00',}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await databases.updateTextAttribute( + '', + '', + '', + true, + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method createUrlAttribute()', async () => { + const data = { + 'key': 'githubUrl', + 'type': 'string', + 'status': 'available', + 'error': 'string', + 'required': true, + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'format': 'url',}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await databases.createUrlAttribute( + '', + '', + '', + true, + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method updateUrlAttribute()', async () => { + const data = { + 'key': 'githubUrl', + 'type': 'string', + 'status': 'available', + 'error': 'string', + 'required': true, + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'format': 'url',}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await databases.updateUrlAttribute( + '', + '', + '', + true, + 'https://example.com', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method createVarcharAttribute()', async () => { + const data = { + 'key': 'fullName', + 'type': 'string', + 'status': 'available', + 'error': 'string', + 'required': true, + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'size': 128,}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await databases.createVarcharAttribute( + '', + '', + '', + 1, + true, + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method updateVarcharAttribute()', async () => { + const data = { + 'key': 'fullName', + 'type': 'string', + 'status': 'available', + 'error': 'string', + 'required': true, + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'size': 128,}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await databases.updateVarcharAttribute( + '', + '', + '', + true, + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method getAttribute()', async () => { + const data = { + 'key': 'isEnabled', + 'type': 'boolean', + 'status': 'available', + 'error': 'string', + 'required': true, + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00',}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await databases.getAttribute( + '', + '', + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method deleteAttribute()', async () => { + const data = {message: ""}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await databases.deleteAttribute( + '', + '', + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method listDocuments()', async () => { + const data = { + 'total': 5, + 'documents': [],}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await databases.listDocuments( + '', + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method createDocument()', async () => { + const data = { + '\$id': '5e5ea5c16897e', + '\$sequence': '1', + '\$collectionId': '5e5ea5c15117e', + '\$databaseId': '5e5ea5c15117e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\$permissions': [],}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await databases.createDocument( + '', + '', + '', + {}, + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method createDocuments()', async () => { + const data = { + 'total': 5, + 'documents': [],}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await databases.createDocuments( + '', + '', + [], + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method upsertDocuments()', async () => { + const data = { + 'total': 5, + 'documents': [],}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await databases.upsertDocuments( + '', + '', + [], + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method updateDocuments()', async () => { + const data = { + 'total': 5, + 'documents': [],}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await databases.updateDocuments( + '', + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method deleteDocuments()', async () => { + const data = { + 'total': 5, + 'documents': [],}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await databases.deleteDocuments( + '', + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method getDocument()', async () => { + const data = { + '\$id': '5e5ea5c16897e', + '\$sequence': '1', + '\$collectionId': '5e5ea5c15117e', + '\$databaseId': '5e5ea5c15117e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\$permissions': [],}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await databases.getDocument( + '', + '', + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method upsertDocument()', async () => { + const data = { + '\$id': '5e5ea5c16897e', + '\$sequence': '1', + '\$collectionId': '5e5ea5c15117e', + '\$databaseId': '5e5ea5c15117e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\$permissions': [],}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await databases.upsertDocument( + '', + '', + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method updateDocument()', async () => { + const data = { + '\$id': '5e5ea5c16897e', + '\$sequence': '1', + '\$collectionId': '5e5ea5c15117e', + '\$databaseId': '5e5ea5c15117e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\$permissions': [],}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await databases.updateDocument( + '', + '', + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method deleteDocument()', async () => { + const data = {message: ""}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await databases.deleteDocument( + '', + '', + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method decrementDocumentAttribute()', async () => { + const data = { + '\$id': '5e5ea5c16897e', + '\$sequence': '1', + '\$collectionId': '5e5ea5c15117e', + '\$databaseId': '5e5ea5c15117e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\$permissions': [],}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await databases.decrementDocumentAttribute( + '', + '', + '', + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method incrementDocumentAttribute()', async () => { + const data = { + '\$id': '5e5ea5c16897e', + '\$sequence': '1', + '\$collectionId': '5e5ea5c15117e', + '\$databaseId': '5e5ea5c15117e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\$permissions': [],}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await databases.incrementDocumentAttribute( + '', + '', + '', + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method listIndexes()', async () => { + const data = { + 'total': 5, + 'indexes': [],}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await databases.listIndexes( + '', + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method createIndex()', async () => { + const data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'key': 'index1', + 'type': 'primary', + 'status': 'available', + 'error': 'string', + 'attributes': [], + 'lengths': [],}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await databases.createIndex( + '', + '', + '', + 'key', + [], + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method getIndex()', async () => { + const data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'key': 'index1', + 'type': 'primary', + 'status': 'available', + 'error': 'string', + 'attributes': [], + 'lengths': [],}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await databases.getIndex( + '', + '', + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method deleteIndex()', async () => { + const data = {message: ""}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await databases.deleteIndex( + '', + '', + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + }) diff --git a/test/services/documents-d-b.test.js b/test/services/documents-d-b.test.js new file mode 100644 index 00000000..7df9ef7d --- /dev/null +++ b/test/services/documents-d-b.test.js @@ -0,0 +1,660 @@ +const { Client } = require("../../dist/client"); +const { InputFile } = require("../../dist/inputFile"); +const { DocumentsDB } = require("../../dist/services/documents-db"); + +const { fetch: mockedFetch, Response } = require("node-fetch-native-with-agent"); +jest.mock('node-fetch-native-with-agent', () => ({ ...jest.requireActual('node-fetch-native-with-agent'), fetch: jest.fn() })); + +describe('DocumentsDB', () => { + const client = new Client(); + const documentsDB = new DocumentsDB(client); + + + test('test method list()', async () => { + const data = { + 'total': 5, + 'databases': [],}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await documentsDB.list( + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method create()', async () => { + const data = { + '\$id': '5e5ea5c16897e', + 'name': 'My Database', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'enabled': true, + 'type': 'legacy', + 'policies': [], + 'archives': [],}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await documentsDB.create( + '', + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method listTransactions()', async () => { + const data = { + 'total': 5, + 'transactions': [],}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await documentsDB.listTransactions( + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method createTransaction()', async () => { + const data = { + '\$id': '259125845563242502', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'status': 'pending', + 'operations': 5, + 'expiresAt': '2020-10-15T06:38:00.000+00:00',}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await documentsDB.createTransaction( + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method getTransaction()', async () => { + const data = { + '\$id': '259125845563242502', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'status': 'pending', + 'operations': 5, + 'expiresAt': '2020-10-15T06:38:00.000+00:00',}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await documentsDB.getTransaction( + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method updateTransaction()', async () => { + const data = { + '\$id': '259125845563242502', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'status': 'pending', + 'operations': 5, + 'expiresAt': '2020-10-15T06:38:00.000+00:00',}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await documentsDB.updateTransaction( + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method deleteTransaction()', async () => { + const data = {message: ""}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await documentsDB.deleteTransaction( + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method createOperations()', async () => { + const data = { + '\$id': '259125845563242502', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'status': 'pending', + 'operations': 5, + 'expiresAt': '2020-10-15T06:38:00.000+00:00',}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await documentsDB.createOperations( + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method get()', async () => { + const data = { + '\$id': '5e5ea5c16897e', + 'name': 'My Database', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'enabled': true, + 'type': 'legacy', + 'policies': [], + 'archives': [],}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await documentsDB.get( + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method update()', async () => { + const data = { + '\$id': '5e5ea5c16897e', + 'name': 'My Database', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'enabled': true, + 'type': 'legacy', + 'policies': [], + 'archives': [],}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await documentsDB.update( + '', + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method delete()', async () => { + const data = {message: ""}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await documentsDB.delete( + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method listCollections()', async () => { + const data = { + 'total': 5, + 'collections': [],}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await documentsDB.listCollections( + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method createCollection()', async () => { + const data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\$permissions': [], + 'databaseId': '5e5ea5c16897e', + 'name': 'My Collection', + 'enabled': true, + 'documentSecurity': true, + 'attributes': [], + 'indexes': [], + 'bytesMax': 65535, + 'bytesUsed': 1500,}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await documentsDB.createCollection( + '', + '', + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method getCollection()', async () => { + const data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\$permissions': [], + 'databaseId': '5e5ea5c16897e', + 'name': 'My Collection', + 'enabled': true, + 'documentSecurity': true, + 'attributes': [], + 'indexes': [], + 'bytesMax': 65535, + 'bytesUsed': 1500,}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await documentsDB.getCollection( + '', + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method updateCollection()', async () => { + const data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\$permissions': [], + 'databaseId': '5e5ea5c16897e', + 'name': 'My Collection', + 'enabled': true, + 'documentSecurity': true, + 'attributes': [], + 'indexes': [], + 'bytesMax': 65535, + 'bytesUsed': 1500,}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await documentsDB.updateCollection( + '', + '', + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method deleteCollection()', async () => { + const data = {message: ""}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await documentsDB.deleteCollection( + '', + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method listDocuments()', async () => { + const data = { + 'total': 5, + 'documents': [],}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await documentsDB.listDocuments( + '', + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method createDocument()', async () => { + const data = { + '\$id': '5e5ea5c16897e', + '\$sequence': '1', + '\$collectionId': '5e5ea5c15117e', + '\$databaseId': '5e5ea5c15117e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\$permissions': [],}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await documentsDB.createDocument( + '', + '', + '', + {}, + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method createDocuments()', async () => { + const data = { + 'total': 5, + 'documents': [],}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await documentsDB.createDocuments( + '', + '', + [], + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method upsertDocuments()', async () => { + const data = { + 'total': 5, + 'documents': [],}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await documentsDB.upsertDocuments( + '', + '', + [], + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method updateDocuments()', async () => { + const data = { + 'total': 5, + 'documents': [],}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await documentsDB.updateDocuments( + '', + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method deleteDocuments()', async () => { + const data = { + 'total': 5, + 'documents': [],}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await documentsDB.deleteDocuments( + '', + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method getDocument()', async () => { + const data = { + '\$id': '5e5ea5c16897e', + '\$sequence': '1', + '\$collectionId': '5e5ea5c15117e', + '\$databaseId': '5e5ea5c15117e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\$permissions': [],}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await documentsDB.getDocument( + '', + '', + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method upsertDocument()', async () => { + const data = { + '\$id': '5e5ea5c16897e', + '\$sequence': '1', + '\$collectionId': '5e5ea5c15117e', + '\$databaseId': '5e5ea5c15117e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\$permissions': [],}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await documentsDB.upsertDocument( + '', + '', + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method updateDocument()', async () => { + const data = { + '\$id': '5e5ea5c16897e', + '\$sequence': '1', + '\$collectionId': '5e5ea5c15117e', + '\$databaseId': '5e5ea5c15117e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\$permissions': [],}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await documentsDB.updateDocument( + '', + '', + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method deleteDocument()', async () => { + const data = {message: ""}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await documentsDB.deleteDocument( + '', + '', + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method decrementDocumentAttribute()', async () => { + const data = { + '\$id': '5e5ea5c16897e', + '\$sequence': '1', + '\$collectionId': '5e5ea5c15117e', + '\$databaseId': '5e5ea5c15117e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\$permissions': [],}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await documentsDB.decrementDocumentAttribute( + '', + '', + '', + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method incrementDocumentAttribute()', async () => { + const data = { + '\$id': '5e5ea5c16897e', + '\$sequence': '1', + '\$collectionId': '5e5ea5c15117e', + '\$databaseId': '5e5ea5c15117e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\$permissions': [],}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await documentsDB.incrementDocumentAttribute( + '', + '', + '', + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method listIndexes()', async () => { + const data = { + 'total': 5, + 'indexes': [],}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await documentsDB.listIndexes( + '', + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method createIndex()', async () => { + const data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'key': 'index1', + 'type': 'primary', + 'status': 'available', + 'error': 'string', + 'attributes': [], + 'lengths': [],}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await documentsDB.createIndex( + '', + '', + '', + 'key', + [], + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method getIndex()', async () => { + const data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'key': 'index1', + 'type': 'primary', + 'status': 'available', + 'error': 'string', + 'attributes': [], + 'lengths': [],}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await documentsDB.getIndex( + '', + '', + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method deleteIndex()', async () => { + const data = {message: ""}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await documentsDB.deleteIndex( + '', + '', + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + }) diff --git a/test/services/functions.test.js b/test/services/functions.test.js new file mode 100644 index 00000000..b057cd62 --- /dev/null +++ b/test/services/functions.test.js @@ -0,0 +1,751 @@ +const { Client } = require("../../dist/client"); +const { InputFile } = require("../../dist/inputFile"); +const { Functions } = require("../../dist/services/functions"); + +const { fetch: mockedFetch, Response } = require("node-fetch-native-with-agent"); +jest.mock('node-fetch-native-with-agent', () => ({ ...jest.requireActual('node-fetch-native-with-agent'), fetch: jest.fn() })); + +describe('Functions', () => { + const client = new Client(); + const functions = new Functions(client); + + + test('test method list()', async () => { + const data = { + 'total': 5, + 'functions': [],}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await functions.list( + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method create()', async () => { + const data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'execute': [], + 'name': 'My Function', + 'enabled': true, + 'live': true, + 'logging': true, + 'runtime': 'python-3.8', + 'deploymentRetention': 7, + 'deploymentId': '5e5ea5c16897e', + 'deploymentCreatedAt': '2020-10-15T06:38:00.000+00:00', + 'latestDeploymentId': '5e5ea5c16897e', + 'latestDeploymentCreatedAt': '2020-10-15T06:38:00.000+00:00', + 'latestDeploymentStatus': 'ready', + 'scopes': [], + 'vars': [], + 'events': [], + 'schedule': '5 4 * * *', + 'timeout': 300, + 'entrypoint': 'index.js', + 'commands': 'npm install', + 'version': 'v2', + 'installationId': '6m40at4ejk5h2u9s1hboo', + 'providerRepositoryId': 'appwrite', + 'providerBranch': 'main', + 'providerRootDirectory': 'functions/helloWorld', + 'providerSilentMode': true, + 'buildSpecification': 's-1vcpu-512mb', + 'runtimeSpecification': 's-1vcpu-512mb',}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await functions.create( + '', + '', + 'node-14.5', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method listRuntimes()', async () => { + const data = { + 'total': 5, + 'runtimes': [],}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await functions.listRuntimes( + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method listSpecifications()', async () => { + const data = { + 'total': 5, + 'specifications': [],}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await functions.listSpecifications( + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method get()', async () => { + const data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'execute': [], + 'name': 'My Function', + 'enabled': true, + 'live': true, + 'logging': true, + 'runtime': 'python-3.8', + 'deploymentRetention': 7, + 'deploymentId': '5e5ea5c16897e', + 'deploymentCreatedAt': '2020-10-15T06:38:00.000+00:00', + 'latestDeploymentId': '5e5ea5c16897e', + 'latestDeploymentCreatedAt': '2020-10-15T06:38:00.000+00:00', + 'latestDeploymentStatus': 'ready', + 'scopes': [], + 'vars': [], + 'events': [], + 'schedule': '5 4 * * *', + 'timeout': 300, + 'entrypoint': 'index.js', + 'commands': 'npm install', + 'version': 'v2', + 'installationId': '6m40at4ejk5h2u9s1hboo', + 'providerRepositoryId': 'appwrite', + 'providerBranch': 'main', + 'providerRootDirectory': 'functions/helloWorld', + 'providerSilentMode': true, + 'buildSpecification': 's-1vcpu-512mb', + 'runtimeSpecification': 's-1vcpu-512mb',}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await functions.get( + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method update()', async () => { + const data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'execute': [], + 'name': 'My Function', + 'enabled': true, + 'live': true, + 'logging': true, + 'runtime': 'python-3.8', + 'deploymentRetention': 7, + 'deploymentId': '5e5ea5c16897e', + 'deploymentCreatedAt': '2020-10-15T06:38:00.000+00:00', + 'latestDeploymentId': '5e5ea5c16897e', + 'latestDeploymentCreatedAt': '2020-10-15T06:38:00.000+00:00', + 'latestDeploymentStatus': 'ready', + 'scopes': [], + 'vars': [], + 'events': [], + 'schedule': '5 4 * * *', + 'timeout': 300, + 'entrypoint': 'index.js', + 'commands': 'npm install', + 'version': 'v2', + 'installationId': '6m40at4ejk5h2u9s1hboo', + 'providerRepositoryId': 'appwrite', + 'providerBranch': 'main', + 'providerRootDirectory': 'functions/helloWorld', + 'providerSilentMode': true, + 'buildSpecification': 's-1vcpu-512mb', + 'runtimeSpecification': 's-1vcpu-512mb',}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await functions.update( + '', + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method delete()', async () => { + const data = {message: ""}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await functions.delete( + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method updateFunctionDeployment()', async () => { + const data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'execute': [], + 'name': 'My Function', + 'enabled': true, + 'live': true, + 'logging': true, + 'runtime': 'python-3.8', + 'deploymentRetention': 7, + 'deploymentId': '5e5ea5c16897e', + 'deploymentCreatedAt': '2020-10-15T06:38:00.000+00:00', + 'latestDeploymentId': '5e5ea5c16897e', + 'latestDeploymentCreatedAt': '2020-10-15T06:38:00.000+00:00', + 'latestDeploymentStatus': 'ready', + 'scopes': [], + 'vars': [], + 'events': [], + 'schedule': '5 4 * * *', + 'timeout': 300, + 'entrypoint': 'index.js', + 'commands': 'npm install', + 'version': 'v2', + 'installationId': '6m40at4ejk5h2u9s1hboo', + 'providerRepositoryId': 'appwrite', + 'providerBranch': 'main', + 'providerRootDirectory': 'functions/helloWorld', + 'providerSilentMode': true, + 'buildSpecification': 's-1vcpu-512mb', + 'runtimeSpecification': 's-1vcpu-512mb',}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await functions.updateFunctionDeployment( + '', + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method listDeployments()', async () => { + const data = { + 'total': 5, + 'deployments': [],}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await functions.listDeployments( + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method createDeployment()', async () => { + const data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'type': 'vcs', + 'resourceId': '5e5ea6g16897e', + 'resourceType': 'functions', + 'entrypoint': 'index.js', + 'sourceSize': 128, + 'buildSize': 128, + 'totalSize': 128, + 'buildId': '5e5ea5c16897e', + 'activate': true, + 'screenshotLight': '5e5ea5c16897e', + 'screenshotDark': '5e5ea5c16897e', + 'status': 'ready', + 'buildLogs': 'Compiling source files...', + 'buildDuration': 128, + 'providerRepositoryName': 'database', + 'providerRepositoryOwner': 'utopia', + 'providerRepositoryUrl': 'https://github.com/vermakhushboo/g4-node-function', + 'providerCommitHash': '7c3f25d', + 'providerCommitAuthorUrl': 'https://github.com/vermakhushboo', + 'providerCommitAuthor': 'Khushboo Verma', + 'providerCommitMessage': 'Update index.js', + 'providerCommitUrl': 'https://github.com/vermakhushboo/g4-node-function/commit/60c0416257a9cbcdd96b2d370c38d8f8d150ccfb', + 'providerBranch': '0.7.x', + 'providerBranchUrl': 'https://github.com/vermakhushboo/appwrite/tree/0.7.x',}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await functions.createDeployment( + '', + InputFile.fromBuffer(new Uint8Array(0), 'image.png'), + true, + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method createDuplicateDeployment()', async () => { + const data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'type': 'vcs', + 'resourceId': '5e5ea6g16897e', + 'resourceType': 'functions', + 'entrypoint': 'index.js', + 'sourceSize': 128, + 'buildSize': 128, + 'totalSize': 128, + 'buildId': '5e5ea5c16897e', + 'activate': true, + 'screenshotLight': '5e5ea5c16897e', + 'screenshotDark': '5e5ea5c16897e', + 'status': 'ready', + 'buildLogs': 'Compiling source files...', + 'buildDuration': 128, + 'providerRepositoryName': 'database', + 'providerRepositoryOwner': 'utopia', + 'providerRepositoryUrl': 'https://github.com/vermakhushboo/g4-node-function', + 'providerCommitHash': '7c3f25d', + 'providerCommitAuthorUrl': 'https://github.com/vermakhushboo', + 'providerCommitAuthor': 'Khushboo Verma', + 'providerCommitMessage': 'Update index.js', + 'providerCommitUrl': 'https://github.com/vermakhushboo/g4-node-function/commit/60c0416257a9cbcdd96b2d370c38d8f8d150ccfb', + 'providerBranch': '0.7.x', + 'providerBranchUrl': 'https://github.com/vermakhushboo/appwrite/tree/0.7.x',}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await functions.createDuplicateDeployment( + '', + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method createTemplateDeployment()', async () => { + const data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'type': 'vcs', + 'resourceId': '5e5ea6g16897e', + 'resourceType': 'functions', + 'entrypoint': 'index.js', + 'sourceSize': 128, + 'buildSize': 128, + 'totalSize': 128, + 'buildId': '5e5ea5c16897e', + 'activate': true, + 'screenshotLight': '5e5ea5c16897e', + 'screenshotDark': '5e5ea5c16897e', + 'status': 'ready', + 'buildLogs': 'Compiling source files...', + 'buildDuration': 128, + 'providerRepositoryName': 'database', + 'providerRepositoryOwner': 'utopia', + 'providerRepositoryUrl': 'https://github.com/vermakhushboo/g4-node-function', + 'providerCommitHash': '7c3f25d', + 'providerCommitAuthorUrl': 'https://github.com/vermakhushboo', + 'providerCommitAuthor': 'Khushboo Verma', + 'providerCommitMessage': 'Update index.js', + 'providerCommitUrl': 'https://github.com/vermakhushboo/g4-node-function/commit/60c0416257a9cbcdd96b2d370c38d8f8d150ccfb', + 'providerBranch': '0.7.x', + 'providerBranchUrl': 'https://github.com/vermakhushboo/appwrite/tree/0.7.x',}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await functions.createTemplateDeployment( + '', + '', + '', + '', + 'commit', + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method createVcsDeployment()', async () => { + const data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'type': 'vcs', + 'resourceId': '5e5ea6g16897e', + 'resourceType': 'functions', + 'entrypoint': 'index.js', + 'sourceSize': 128, + 'buildSize': 128, + 'totalSize': 128, + 'buildId': '5e5ea5c16897e', + 'activate': true, + 'screenshotLight': '5e5ea5c16897e', + 'screenshotDark': '5e5ea5c16897e', + 'status': 'ready', + 'buildLogs': 'Compiling source files...', + 'buildDuration': 128, + 'providerRepositoryName': 'database', + 'providerRepositoryOwner': 'utopia', + 'providerRepositoryUrl': 'https://github.com/vermakhushboo/g4-node-function', + 'providerCommitHash': '7c3f25d', + 'providerCommitAuthorUrl': 'https://github.com/vermakhushboo', + 'providerCommitAuthor': 'Khushboo Verma', + 'providerCommitMessage': 'Update index.js', + 'providerCommitUrl': 'https://github.com/vermakhushboo/g4-node-function/commit/60c0416257a9cbcdd96b2d370c38d8f8d150ccfb', + 'providerBranch': '0.7.x', + 'providerBranchUrl': 'https://github.com/vermakhushboo/appwrite/tree/0.7.x',}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await functions.createVcsDeployment( + '', + 'branch', + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method getDeployment()', async () => { + const data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'type': 'vcs', + 'resourceId': '5e5ea6g16897e', + 'resourceType': 'functions', + 'entrypoint': 'index.js', + 'sourceSize': 128, + 'buildSize': 128, + 'totalSize': 128, + 'buildId': '5e5ea5c16897e', + 'activate': true, + 'screenshotLight': '5e5ea5c16897e', + 'screenshotDark': '5e5ea5c16897e', + 'status': 'ready', + 'buildLogs': 'Compiling source files...', + 'buildDuration': 128, + 'providerRepositoryName': 'database', + 'providerRepositoryOwner': 'utopia', + 'providerRepositoryUrl': 'https://github.com/vermakhushboo/g4-node-function', + 'providerCommitHash': '7c3f25d', + 'providerCommitAuthorUrl': 'https://github.com/vermakhushboo', + 'providerCommitAuthor': 'Khushboo Verma', + 'providerCommitMessage': 'Update index.js', + 'providerCommitUrl': 'https://github.com/vermakhushboo/g4-node-function/commit/60c0416257a9cbcdd96b2d370c38d8f8d150ccfb', + 'providerBranch': '0.7.x', + 'providerBranchUrl': 'https://github.com/vermakhushboo/appwrite/tree/0.7.x',}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await functions.getDeployment( + '', + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method deleteDeployment()', async () => { + const data = {message: ""}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await functions.deleteDeployment( + '', + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method getDeploymentDownload()', async () => { + const data = new ArrayBuffer(0); + mockedFetch.mockImplementation(() => new Response(data)); + + const response = await functions.getDeploymentDownload( + '', + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method updateDeploymentStatus()', async () => { + const data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'type': 'vcs', + 'resourceId': '5e5ea6g16897e', + 'resourceType': 'functions', + 'entrypoint': 'index.js', + 'sourceSize': 128, + 'buildSize': 128, + 'totalSize': 128, + 'buildId': '5e5ea5c16897e', + 'activate': true, + 'screenshotLight': '5e5ea5c16897e', + 'screenshotDark': '5e5ea5c16897e', + 'status': 'ready', + 'buildLogs': 'Compiling source files...', + 'buildDuration': 128, + 'providerRepositoryName': 'database', + 'providerRepositoryOwner': 'utopia', + 'providerRepositoryUrl': 'https://github.com/vermakhushboo/g4-node-function', + 'providerCommitHash': '7c3f25d', + 'providerCommitAuthorUrl': 'https://github.com/vermakhushboo', + 'providerCommitAuthor': 'Khushboo Verma', + 'providerCommitMessage': 'Update index.js', + 'providerCommitUrl': 'https://github.com/vermakhushboo/g4-node-function/commit/60c0416257a9cbcdd96b2d370c38d8f8d150ccfb', + 'providerBranch': '0.7.x', + 'providerBranchUrl': 'https://github.com/vermakhushboo/appwrite/tree/0.7.x',}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await functions.updateDeploymentStatus( + '', + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method listExecutions()', async () => { + const data = { + 'total': 5, + 'executions': [],}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await functions.listExecutions( + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method createExecution()', async () => { + const data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\$permissions': [], + 'functionId': '5e5ea6g16897e', + 'deploymentId': '5e5ea5c16897e', + 'trigger': 'http', + 'status': 'processing', + 'requestMethod': 'GET', + 'requestPath': '/articles?id=5', + 'requestHeaders': [], + 'responseStatusCode': 200, + 'responseBody': '', + 'responseHeaders': [], + 'logs': '', + 'errors': '', + 'duration': 0.4,}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await functions.createExecution( + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method getExecution()', async () => { + const data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\$permissions': [], + 'functionId': '5e5ea6g16897e', + 'deploymentId': '5e5ea5c16897e', + 'trigger': 'http', + 'status': 'processing', + 'requestMethod': 'GET', + 'requestPath': '/articles?id=5', + 'requestHeaders': [], + 'responseStatusCode': 200, + 'responseBody': '', + 'responseHeaders': [], + 'logs': '', + 'errors': '', + 'duration': 0.4,}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await functions.getExecution( + '', + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method deleteExecution()', async () => { + const data = {message: ""}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await functions.deleteExecution( + '', + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method listVariables()', async () => { + const data = { + 'total': 5, + 'variables': [],}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await functions.listVariables( + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method createVariable()', async () => { + const data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'key': 'API_KEY', + 'value': 'myPa\$\$word1', + 'secret': true, + 'resourceType': 'function', + 'resourceId': 'myAwesomeFunction',}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await functions.createVariable( + '', + '', + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method getVariable()', async () => { + const data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'key': 'API_KEY', + 'value': 'myPa\$\$word1', + 'secret': true, + 'resourceType': 'function', + 'resourceId': 'myAwesomeFunction',}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await functions.getVariable( + '', + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method updateVariable()', async () => { + const data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'key': 'API_KEY', + 'value': 'myPa\$\$word1', + 'secret': true, + 'resourceType': 'function', + 'resourceId': 'myAwesomeFunction',}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await functions.updateVariable( + '', + '', + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method deleteVariable()', async () => { + const data = {message: ""}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await functions.deleteVariable( + '', + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + }) diff --git a/test/services/graphql.test.js b/test/services/graphql.test.js new file mode 100644 index 00000000..3ff83bbd --- /dev/null +++ b/test/services/graphql.test.js @@ -0,0 +1,40 @@ +const { Client } = require("../../dist/client"); +const { InputFile } = require("../../dist/inputFile"); +const { Graphql } = require("../../dist/services/graphql"); + +const { fetch: mockedFetch, Response } = require("node-fetch-native-with-agent"); +jest.mock('node-fetch-native-with-agent', () => ({ ...jest.requireActual('node-fetch-native-with-agent'), fetch: jest.fn() })); + +describe('Graphql', () => { + const client = new Client(); + const graphql = new Graphql(client); + + + test('test method query()', async () => { + const data = {message: ""}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await graphql.query( + {}, + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method mutation()', async () => { + const data = {message: ""}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await graphql.mutation( + {}, + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + }) diff --git a/test/services/health.test.js b/test/services/health.test.js new file mode 100644 index 00000000..3c1bfddb --- /dev/null +++ b/test/services/health.test.js @@ -0,0 +1,438 @@ +const { Client } = require("../../dist/client"); +const { InputFile } = require("../../dist/inputFile"); +const { Health } = require("../../dist/services/health"); + +const { fetch: mockedFetch, Response } = require("node-fetch-native-with-agent"); +jest.mock('node-fetch-native-with-agent', () => ({ ...jest.requireActual('node-fetch-native-with-agent'), fetch: jest.fn() })); + +describe('Health', () => { + const client = new Client(); + const health = new Health(client); + + + test('test method get()', async () => { + const data = { + 'name': 'database', + 'ping': 128, + 'status': 'pass',}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await health.get( + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method getAntivirus()', async () => { + const data = { + 'version': '1.0.0', + 'status': 'online',}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await health.getAntivirus( + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method getCache()', async () => { + const data = { + 'total': 5, + 'statuses': [],}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await health.getCache( + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method getCertificate()', async () => { + const data = { + 'name': '/CN=www.google.com', + 'subjectSN': '', + 'issuerOrganisation': '', + 'validFrom': '1704200998', + 'validTo': '1711458597', + 'signatureTypeSN': 'RSA-SHA256',}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await health.getCertificate( + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method getConsolePausing()', async () => { + const data = { + 'name': 'database', + 'ping': 128, + 'status': 'pass',}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await health.getConsolePausing( + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method getDB()', async () => { + const data = { + 'total': 5, + 'statuses': [],}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await health.getDB( + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method getPubSub()', async () => { + const data = { + 'total': 5, + 'statuses': [],}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await health.getPubSub( + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method getQueueAudits()', async () => { + const data = { + 'size': 8,}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await health.getQueueAudits( + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method getQueueBillingProjectAggregation()', async () => { + const data = { + 'size': 8,}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await health.getQueueBillingProjectAggregation( + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method getQueueBillingTeamAggregation()', async () => { + const data = { + 'size': 8,}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await health.getQueueBillingTeamAggregation( + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method getQueueBuilds()', async () => { + const data = { + 'size': 8,}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await health.getQueueBuilds( + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method getQueuePriorityBuilds()', async () => { + const data = { + 'size': 8,}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await health.getQueuePriorityBuilds( + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method getQueueCertificates()', async () => { + const data = { + 'size': 8,}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await health.getQueueCertificates( + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method getQueueDatabases()', async () => { + const data = { + 'size': 8,}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await health.getQueueDatabases( + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method getQueueDeletes()', async () => { + const data = { + 'size': 8,}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await health.getQueueDeletes( + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method getFailedJobs()', async () => { + const data = { + 'size': 8,}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await health.getFailedJobs( + 'v1-database', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method getQueueFunctions()', async () => { + const data = { + 'size': 8,}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await health.getQueueFunctions( + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method getQueueLogs()', async () => { + const data = { + 'size': 8,}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await health.getQueueLogs( + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method getQueueMails()', async () => { + const data = { + 'size': 8,}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await health.getQueueMails( + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method getQueueMessaging()', async () => { + const data = { + 'size': 8,}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await health.getQueueMessaging( + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method getQueueMigrations()', async () => { + const data = { + 'size': 8,}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await health.getQueueMigrations( + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method getQueueRegionManager()', async () => { + const data = { + 'size': 8,}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await health.getQueueRegionManager( + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method getQueueStatsResources()', async () => { + const data = { + 'size': 8,}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await health.getQueueStatsResources( + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method getQueueUsage()', async () => { + const data = { + 'size': 8,}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await health.getQueueUsage( + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method getQueueThreats()', async () => { + const data = { + 'size': 8,}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await health.getQueueThreats( + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method getQueueWebhooks()', async () => { + const data = { + 'size': 8,}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await health.getQueueWebhooks( + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method getStorage()', async () => { + const data = { + 'name': 'database', + 'ping': 128, + 'status': 'pass',}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await health.getStorage( + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method getStorageLocal()', async () => { + const data = { + 'name': 'database', + 'ping': 128, + 'status': 'pass',}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await health.getStorageLocal( + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method getTime()', async () => { + const data = { + 'remoteTime': 1639490751, + 'localTime': 1639490844, + 'diff': 93,}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await health.getTime( + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + }) diff --git a/test/services/locale.test.js b/test/services/locale.test.js new file mode 100644 index 00000000..4667641d --- /dev/null +++ b/test/services/locale.test.js @@ -0,0 +1,137 @@ +const { Client } = require("../../dist/client"); +const { InputFile } = require("../../dist/inputFile"); +const { Locale } = require("../../dist/services/locale"); + +const { fetch: mockedFetch, Response } = require("node-fetch-native-with-agent"); +jest.mock('node-fetch-native-with-agent', () => ({ ...jest.requireActual('node-fetch-native-with-agent'), fetch: jest.fn() })); + +describe('Locale', () => { + const client = new Client(); + const locale = new Locale(client); + + + test('test method get()', async () => { + const data = { + 'ip': '127.0.0.1', + 'countryCode': 'US', + 'country': 'United States', + 'continentCode': 'NA', + 'continent': 'North America', + 'eu': true, + 'currency': 'USD',}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await locale.get( + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method listCodes()', async () => { + const data = { + 'total': 5, + 'localeCodes': [],}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await locale.listCodes( + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method listContinents()', async () => { + const data = { + 'total': 5, + 'continents': [],}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await locale.listContinents( + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method listCountries()', async () => { + const data = { + 'total': 5, + 'countries': [],}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await locale.listCountries( + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method listCountriesEU()', async () => { + const data = { + 'total': 5, + 'countries': [],}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await locale.listCountriesEU( + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method listCountriesPhones()', async () => { + const data = { + 'total': 5, + 'phones': [],}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await locale.listCountriesPhones( + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method listCurrencies()', async () => { + const data = { + 'total': 5, + 'currencies': [],}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await locale.listCurrencies( + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method listLanguages()', async () => { + const data = { + 'total': 5, + 'languages': [],}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await locale.listLanguages( + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + }) diff --git a/test/services/messaging.test.js b/test/services/messaging.test.js new file mode 100644 index 00000000..40931583 --- /dev/null +++ b/test/services/messaging.test.js @@ -0,0 +1,1200 @@ +const { Client } = require("../../dist/client"); +const { InputFile } = require("../../dist/inputFile"); +const { Messaging } = require("../../dist/services/messaging"); + +const { fetch: mockedFetch, Response } = require("node-fetch-native-with-agent"); +jest.mock('node-fetch-native-with-agent', () => ({ ...jest.requireActual('node-fetch-native-with-agent'), fetch: jest.fn() })); + +describe('Messaging', () => { + const client = new Client(); + const messaging = new Messaging(client); + + + test('test method listMessages()', async () => { + const data = { + 'total': 5, + 'messages': [],}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await messaging.listMessages( + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method createEmail()', async () => { + const data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'providerType': 'email', + 'topics': [], + 'users': [], + 'targets': [], + 'deliveredTotal': 1, + 'data': {}, + 'status': 'processing',}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await messaging.createEmail( + '', + '', + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method updateEmail()', async () => { + const data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'providerType': 'email', + 'topics': [], + 'users': [], + 'targets': [], + 'deliveredTotal': 1, + 'data': {}, + 'status': 'processing',}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await messaging.updateEmail( + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method createPush()', async () => { + const data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'providerType': 'email', + 'topics': [], + 'users': [], + 'targets': [], + 'deliveredTotal': 1, + 'data': {}, + 'status': 'processing',}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await messaging.createPush( + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method updatePush()', async () => { + const data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'providerType': 'email', + 'topics': [], + 'users': [], + 'targets': [], + 'deliveredTotal': 1, + 'data': {}, + 'status': 'processing',}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await messaging.updatePush( + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method createSms()', async () => { + const data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'providerType': 'email', + 'topics': [], + 'users': [], + 'targets': [], + 'deliveredTotal': 1, + 'data': {}, + 'status': 'processing',}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await messaging.createSms( + '', + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method createSMS()', async () => { + const data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'providerType': 'email', + 'topics': [], + 'users': [], + 'targets': [], + 'deliveredTotal': 1, + 'data': {}, + 'status': 'processing',}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await messaging.createSMS( + '', + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method updateSms()', async () => { + const data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'providerType': 'email', + 'topics': [], + 'users': [], + 'targets': [], + 'deliveredTotal': 1, + 'data': {}, + 'status': 'processing',}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await messaging.updateSms( + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method updateSMS()', async () => { + const data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'providerType': 'email', + 'topics': [], + 'users': [], + 'targets': [], + 'deliveredTotal': 1, + 'data': {}, + 'status': 'processing',}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await messaging.updateSMS( + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method getMessage()', async () => { + const data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'providerType': 'email', + 'topics': [], + 'users': [], + 'targets': [], + 'deliveredTotal': 1, + 'data': {}, + 'status': 'processing',}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await messaging.getMessage( + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method delete()', async () => { + const data = {message: ""}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await messaging.delete( + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method listMessageLogs()', async () => { + const data = { + 'total': 5, + 'logs': [],}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await messaging.listMessageLogs( + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method listTargets()', async () => { + const data = { + 'total': 5, + 'targets': [],}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await messaging.listTargets( + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method listProviders()', async () => { + const data = { + 'total': 5, + 'providers': [],}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await messaging.listProviders( + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method createApnsProvider()', async () => { + const data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'name': 'Mailgun', + 'provider': 'mailgun', + 'enabled': true, + 'type': 'sms', + 'credentials': {},}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await messaging.createApnsProvider( + '', + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method createAPNSProvider()', async () => { + const data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'name': 'Mailgun', + 'provider': 'mailgun', + 'enabled': true, + 'type': 'sms', + 'credentials': {},}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await messaging.createAPNSProvider( + '', + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method updateApnsProvider()', async () => { + const data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'name': 'Mailgun', + 'provider': 'mailgun', + 'enabled': true, + 'type': 'sms', + 'credentials': {},}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await messaging.updateApnsProvider( + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method updateAPNSProvider()', async () => { + const data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'name': 'Mailgun', + 'provider': 'mailgun', + 'enabled': true, + 'type': 'sms', + 'credentials': {},}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await messaging.updateAPNSProvider( + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method createFcmProvider()', async () => { + const data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'name': 'Mailgun', + 'provider': 'mailgun', + 'enabled': true, + 'type': 'sms', + 'credentials': {},}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await messaging.createFcmProvider( + '', + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method createFCMProvider()', async () => { + const data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'name': 'Mailgun', + 'provider': 'mailgun', + 'enabled': true, + 'type': 'sms', + 'credentials': {},}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await messaging.createFCMProvider( + '', + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method updateFcmProvider()', async () => { + const data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'name': 'Mailgun', + 'provider': 'mailgun', + 'enabled': true, + 'type': 'sms', + 'credentials': {},}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await messaging.updateFcmProvider( + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method updateFCMProvider()', async () => { + const data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'name': 'Mailgun', + 'provider': 'mailgun', + 'enabled': true, + 'type': 'sms', + 'credentials': {},}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await messaging.updateFCMProvider( + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method createMailgunProvider()', async () => { + const data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'name': 'Mailgun', + 'provider': 'mailgun', + 'enabled': true, + 'type': 'sms', + 'credentials': {},}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await messaging.createMailgunProvider( + '', + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method updateMailgunProvider()', async () => { + const data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'name': 'Mailgun', + 'provider': 'mailgun', + 'enabled': true, + 'type': 'sms', + 'credentials': {},}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await messaging.updateMailgunProvider( + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method createMsg91Provider()', async () => { + const data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'name': 'Mailgun', + 'provider': 'mailgun', + 'enabled': true, + 'type': 'sms', + 'credentials': {},}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await messaging.createMsg91Provider( + '', + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method updateMsg91Provider()', async () => { + const data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'name': 'Mailgun', + 'provider': 'mailgun', + 'enabled': true, + 'type': 'sms', + 'credentials': {},}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await messaging.updateMsg91Provider( + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method createResendProvider()', async () => { + const data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'name': 'Mailgun', + 'provider': 'mailgun', + 'enabled': true, + 'type': 'sms', + 'credentials': {},}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await messaging.createResendProvider( + '', + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method updateResendProvider()', async () => { + const data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'name': 'Mailgun', + 'provider': 'mailgun', + 'enabled': true, + 'type': 'sms', + 'credentials': {},}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await messaging.updateResendProvider( + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method createSendgridProvider()', async () => { + const data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'name': 'Mailgun', + 'provider': 'mailgun', + 'enabled': true, + 'type': 'sms', + 'credentials': {},}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await messaging.createSendgridProvider( + '', + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method updateSendgridProvider()', async () => { + const data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'name': 'Mailgun', + 'provider': 'mailgun', + 'enabled': true, + 'type': 'sms', + 'credentials': {},}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await messaging.updateSendgridProvider( + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method createSmtpProvider()', async () => { + const data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'name': 'Mailgun', + 'provider': 'mailgun', + 'enabled': true, + 'type': 'sms', + 'credentials': {},}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await messaging.createSmtpProvider( + '', + '', + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method createSMTPProvider()', async () => { + const data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'name': 'Mailgun', + 'provider': 'mailgun', + 'enabled': true, + 'type': 'sms', + 'credentials': {},}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await messaging.createSMTPProvider( + '', + '', + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method updateSmtpProvider()', async () => { + const data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'name': 'Mailgun', + 'provider': 'mailgun', + 'enabled': true, + 'type': 'sms', + 'credentials': {},}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await messaging.updateSmtpProvider( + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method updateSMTPProvider()', async () => { + const data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'name': 'Mailgun', + 'provider': 'mailgun', + 'enabled': true, + 'type': 'sms', + 'credentials': {},}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await messaging.updateSMTPProvider( + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method createTelesignProvider()', async () => { + const data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'name': 'Mailgun', + 'provider': 'mailgun', + 'enabled': true, + 'type': 'sms', + 'credentials': {},}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await messaging.createTelesignProvider( + '', + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method updateTelesignProvider()', async () => { + const data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'name': 'Mailgun', + 'provider': 'mailgun', + 'enabled': true, + 'type': 'sms', + 'credentials': {},}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await messaging.updateTelesignProvider( + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method createTextmagicProvider()', async () => { + const data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'name': 'Mailgun', + 'provider': 'mailgun', + 'enabled': true, + 'type': 'sms', + 'credentials': {},}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await messaging.createTextmagicProvider( + '', + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method updateTextmagicProvider()', async () => { + const data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'name': 'Mailgun', + 'provider': 'mailgun', + 'enabled': true, + 'type': 'sms', + 'credentials': {},}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await messaging.updateTextmagicProvider( + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method createTwilioProvider()', async () => { + const data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'name': 'Mailgun', + 'provider': 'mailgun', + 'enabled': true, + 'type': 'sms', + 'credentials': {},}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await messaging.createTwilioProvider( + '', + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method updateTwilioProvider()', async () => { + const data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'name': 'Mailgun', + 'provider': 'mailgun', + 'enabled': true, + 'type': 'sms', + 'credentials': {},}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await messaging.updateTwilioProvider( + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method createVonageProvider()', async () => { + const data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'name': 'Mailgun', + 'provider': 'mailgun', + 'enabled': true, + 'type': 'sms', + 'credentials': {},}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await messaging.createVonageProvider( + '', + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method updateVonageProvider()', async () => { + const data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'name': 'Mailgun', + 'provider': 'mailgun', + 'enabled': true, + 'type': 'sms', + 'credentials': {},}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await messaging.updateVonageProvider( + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method getProvider()', async () => { + const data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'name': 'Mailgun', + 'provider': 'mailgun', + 'enabled': true, + 'type': 'sms', + 'credentials': {},}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await messaging.getProvider( + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method deleteProvider()', async () => { + const data = {message: ""}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await messaging.deleteProvider( + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method listProviderLogs()', async () => { + const data = { + 'total': 5, + 'logs': [],}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await messaging.listProviderLogs( + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method listSubscriberLogs()', async () => { + const data = { + 'total': 5, + 'logs': [],}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await messaging.listSubscriberLogs( + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method listTopics()', async () => { + const data = { + 'total': 5, + 'topics': [],}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await messaging.listTopics( + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method createTopic()', async () => { + const data = { + '\$id': '259125845563242502', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'name': 'events', + 'emailTotal': 100, + 'smsTotal': 100, + 'pushTotal': 100, + 'subscribe': [],}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await messaging.createTopic( + '', + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method getTopic()', async () => { + const data = { + '\$id': '259125845563242502', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'name': 'events', + 'emailTotal': 100, + 'smsTotal': 100, + 'pushTotal': 100, + 'subscribe': [],}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await messaging.getTopic( + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method updateTopic()', async () => { + const data = { + '\$id': '259125845563242502', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'name': 'events', + 'emailTotal': 100, + 'smsTotal': 100, + 'pushTotal': 100, + 'subscribe': [],}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await messaging.updateTopic( + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method deleteTopic()', async () => { + const data = {message: ""}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await messaging.deleteTopic( + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method listTopicLogs()', async () => { + const data = { + 'total': 5, + 'logs': [],}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await messaging.listTopicLogs( + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method listSubscribers()', async () => { + const data = { + 'total': 5, + 'subscribers': [],}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await messaging.listSubscribers( + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method createSubscriber()', async () => { + const data = { + '\$id': '259125845563242502', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'targetId': '259125845563242502', + 'target': {}, + 'userId': '5e5ea5c16897e', + 'userName': 'Aegon Targaryen', + 'topicId': '259125845563242502', + 'providerType': 'email',}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await messaging.createSubscriber( + '', + '', + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method getSubscriber()', async () => { + const data = { + '\$id': '259125845563242502', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'targetId': '259125845563242502', + 'target': {}, + 'userId': '5e5ea5c16897e', + 'userName': 'Aegon Targaryen', + 'topicId': '259125845563242502', + 'providerType': 'email',}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await messaging.getSubscriber( + '', + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method deleteSubscriber()', async () => { + const data = {message: ""}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await messaging.deleteSubscriber( + '', + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + }) diff --git a/test/services/project.test.js b/test/services/project.test.js new file mode 100644 index 00000000..81c53b5e --- /dev/null +++ b/test/services/project.test.js @@ -0,0 +1,109 @@ +const { Client } = require("../../dist/client"); +const { InputFile } = require("../../dist/inputFile"); +const { Project } = require("../../dist/services/project"); + +const { fetch: mockedFetch, Response } = require("node-fetch-native-with-agent"); +jest.mock('node-fetch-native-with-agent', () => ({ ...jest.requireActual('node-fetch-native-with-agent'), fetch: jest.fn() })); + +describe('Project', () => { + const client = new Client(); + const project = new Project(client); + + + test('test method listVariables()', async () => { + const data = { + 'total': 5, + 'variables': [],}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await project.listVariables( + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method createVariable()', async () => { + const data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'key': 'API_KEY', + 'value': 'myPa\$\$word1', + 'secret': true, + 'resourceType': 'function', + 'resourceId': 'myAwesomeFunction',}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await project.createVariable( + '', + '', + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method getVariable()', async () => { + const data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'key': 'API_KEY', + 'value': 'myPa\$\$word1', + 'secret': true, + 'resourceType': 'function', + 'resourceId': 'myAwesomeFunction',}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await project.getVariable( + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method updateVariable()', async () => { + const data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'key': 'API_KEY', + 'value': 'myPa\$\$word1', + 'secret': true, + 'resourceType': 'function', + 'resourceId': 'myAwesomeFunction',}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await project.updateVariable( + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method deleteVariable()', async () => { + const data = {message: ""}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await project.deleteVariable( + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + }) diff --git a/test/services/sites.test.js b/test/services/sites.test.js new file mode 100644 index 00000000..75f88054 --- /dev/null +++ b/test/services/sites.test.js @@ -0,0 +1,729 @@ +const { Client } = require("../../dist/client"); +const { InputFile } = require("../../dist/inputFile"); +const { Sites } = require("../../dist/services/sites"); + +const { fetch: mockedFetch, Response } = require("node-fetch-native-with-agent"); +jest.mock('node-fetch-native-with-agent', () => ({ ...jest.requireActual('node-fetch-native-with-agent'), fetch: jest.fn() })); + +describe('Sites', () => { + const client = new Client(); + const sites = new Sites(client); + + + test('test method list()', async () => { + const data = { + 'total': 5, + 'sites': [],}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await sites.list( + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method create()', async () => { + const data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'name': 'My Site', + 'enabled': true, + 'live': true, + 'logging': true, + 'framework': 'react', + 'deploymentRetention': 7, + 'deploymentId': '5e5ea5c16897e', + 'deploymentCreatedAt': '2020-10-15T06:38:00.000+00:00', + 'deploymentScreenshotLight': '5e5ea5c16897e', + 'deploymentScreenshotDark': '5e5ea5c16897e', + 'latestDeploymentId': '5e5ea5c16897e', + 'latestDeploymentCreatedAt': '2020-10-15T06:38:00.000+00:00', + 'latestDeploymentStatus': 'ready', + 'vars': [], + 'timeout': 300, + 'installCommand': 'npm install', + 'buildCommand': 'npm run build', + 'startCommand': 'node custom-server.mjs', + 'outputDirectory': 'build', + 'installationId': '6m40at4ejk5h2u9s1hboo', + 'providerRepositoryId': 'appwrite', + 'providerBranch': 'main', + 'providerRootDirectory': 'sites/helloWorld', + 'providerSilentMode': true, + 'buildSpecification': 's-1vcpu-512mb', + 'runtimeSpecification': 's-1vcpu-512mb', + 'buildRuntime': 'node-22', + 'adapter': 'static', + 'fallbackFile': 'index.html',}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await sites.create( + '', + '', + 'analog', + 'node-14.5', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method listFrameworks()', async () => { + const data = { + 'total': 5, + 'frameworks': [],}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await sites.listFrameworks( + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method listSpecifications()', async () => { + const data = { + 'total': 5, + 'specifications': [],}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await sites.listSpecifications( + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method get()', async () => { + const data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'name': 'My Site', + 'enabled': true, + 'live': true, + 'logging': true, + 'framework': 'react', + 'deploymentRetention': 7, + 'deploymentId': '5e5ea5c16897e', + 'deploymentCreatedAt': '2020-10-15T06:38:00.000+00:00', + 'deploymentScreenshotLight': '5e5ea5c16897e', + 'deploymentScreenshotDark': '5e5ea5c16897e', + 'latestDeploymentId': '5e5ea5c16897e', + 'latestDeploymentCreatedAt': '2020-10-15T06:38:00.000+00:00', + 'latestDeploymentStatus': 'ready', + 'vars': [], + 'timeout': 300, + 'installCommand': 'npm install', + 'buildCommand': 'npm run build', + 'startCommand': 'node custom-server.mjs', + 'outputDirectory': 'build', + 'installationId': '6m40at4ejk5h2u9s1hboo', + 'providerRepositoryId': 'appwrite', + 'providerBranch': 'main', + 'providerRootDirectory': 'sites/helloWorld', + 'providerSilentMode': true, + 'buildSpecification': 's-1vcpu-512mb', + 'runtimeSpecification': 's-1vcpu-512mb', + 'buildRuntime': 'node-22', + 'adapter': 'static', + 'fallbackFile': 'index.html',}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await sites.get( + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method update()', async () => { + const data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'name': 'My Site', + 'enabled': true, + 'live': true, + 'logging': true, + 'framework': 'react', + 'deploymentRetention': 7, + 'deploymentId': '5e5ea5c16897e', + 'deploymentCreatedAt': '2020-10-15T06:38:00.000+00:00', + 'deploymentScreenshotLight': '5e5ea5c16897e', + 'deploymentScreenshotDark': '5e5ea5c16897e', + 'latestDeploymentId': '5e5ea5c16897e', + 'latestDeploymentCreatedAt': '2020-10-15T06:38:00.000+00:00', + 'latestDeploymentStatus': 'ready', + 'vars': [], + 'timeout': 300, + 'installCommand': 'npm install', + 'buildCommand': 'npm run build', + 'startCommand': 'node custom-server.mjs', + 'outputDirectory': 'build', + 'installationId': '6m40at4ejk5h2u9s1hboo', + 'providerRepositoryId': 'appwrite', + 'providerBranch': 'main', + 'providerRootDirectory': 'sites/helloWorld', + 'providerSilentMode': true, + 'buildSpecification': 's-1vcpu-512mb', + 'runtimeSpecification': 's-1vcpu-512mb', + 'buildRuntime': 'node-22', + 'adapter': 'static', + 'fallbackFile': 'index.html',}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await sites.update( + '', + '', + 'analog', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method delete()', async () => { + const data = {message: ""}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await sites.delete( + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method updateSiteDeployment()', async () => { + const data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'name': 'My Site', + 'enabled': true, + 'live': true, + 'logging': true, + 'framework': 'react', + 'deploymentRetention': 7, + 'deploymentId': '5e5ea5c16897e', + 'deploymentCreatedAt': '2020-10-15T06:38:00.000+00:00', + 'deploymentScreenshotLight': '5e5ea5c16897e', + 'deploymentScreenshotDark': '5e5ea5c16897e', + 'latestDeploymentId': '5e5ea5c16897e', + 'latestDeploymentCreatedAt': '2020-10-15T06:38:00.000+00:00', + 'latestDeploymentStatus': 'ready', + 'vars': [], + 'timeout': 300, + 'installCommand': 'npm install', + 'buildCommand': 'npm run build', + 'startCommand': 'node custom-server.mjs', + 'outputDirectory': 'build', + 'installationId': '6m40at4ejk5h2u9s1hboo', + 'providerRepositoryId': 'appwrite', + 'providerBranch': 'main', + 'providerRootDirectory': 'sites/helloWorld', + 'providerSilentMode': true, + 'buildSpecification': 's-1vcpu-512mb', + 'runtimeSpecification': 's-1vcpu-512mb', + 'buildRuntime': 'node-22', + 'adapter': 'static', + 'fallbackFile': 'index.html',}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await sites.updateSiteDeployment( + '', + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method listDeployments()', async () => { + const data = { + 'total': 5, + 'deployments': [],}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await sites.listDeployments( + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method createDeployment()', async () => { + const data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'type': 'vcs', + 'resourceId': '5e5ea6g16897e', + 'resourceType': 'functions', + 'entrypoint': 'index.js', + 'sourceSize': 128, + 'buildSize': 128, + 'totalSize': 128, + 'buildId': '5e5ea5c16897e', + 'activate': true, + 'screenshotLight': '5e5ea5c16897e', + 'screenshotDark': '5e5ea5c16897e', + 'status': 'ready', + 'buildLogs': 'Compiling source files...', + 'buildDuration': 128, + 'providerRepositoryName': 'database', + 'providerRepositoryOwner': 'utopia', + 'providerRepositoryUrl': 'https://github.com/vermakhushboo/g4-node-function', + 'providerCommitHash': '7c3f25d', + 'providerCommitAuthorUrl': 'https://github.com/vermakhushboo', + 'providerCommitAuthor': 'Khushboo Verma', + 'providerCommitMessage': 'Update index.js', + 'providerCommitUrl': 'https://github.com/vermakhushboo/g4-node-function/commit/60c0416257a9cbcdd96b2d370c38d8f8d150ccfb', + 'providerBranch': '0.7.x', + 'providerBranchUrl': 'https://github.com/vermakhushboo/appwrite/tree/0.7.x',}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await sites.createDeployment( + '', + InputFile.fromBuffer(new Uint8Array(0), 'image.png'), + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method createDuplicateDeployment()', async () => { + const data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'type': 'vcs', + 'resourceId': '5e5ea6g16897e', + 'resourceType': 'functions', + 'entrypoint': 'index.js', + 'sourceSize': 128, + 'buildSize': 128, + 'totalSize': 128, + 'buildId': '5e5ea5c16897e', + 'activate': true, + 'screenshotLight': '5e5ea5c16897e', + 'screenshotDark': '5e5ea5c16897e', + 'status': 'ready', + 'buildLogs': 'Compiling source files...', + 'buildDuration': 128, + 'providerRepositoryName': 'database', + 'providerRepositoryOwner': 'utopia', + 'providerRepositoryUrl': 'https://github.com/vermakhushboo/g4-node-function', + 'providerCommitHash': '7c3f25d', + 'providerCommitAuthorUrl': 'https://github.com/vermakhushboo', + 'providerCommitAuthor': 'Khushboo Verma', + 'providerCommitMessage': 'Update index.js', + 'providerCommitUrl': 'https://github.com/vermakhushboo/g4-node-function/commit/60c0416257a9cbcdd96b2d370c38d8f8d150ccfb', + 'providerBranch': '0.7.x', + 'providerBranchUrl': 'https://github.com/vermakhushboo/appwrite/tree/0.7.x',}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await sites.createDuplicateDeployment( + '', + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method createTemplateDeployment()', async () => { + const data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'type': 'vcs', + 'resourceId': '5e5ea6g16897e', + 'resourceType': 'functions', + 'entrypoint': 'index.js', + 'sourceSize': 128, + 'buildSize': 128, + 'totalSize': 128, + 'buildId': '5e5ea5c16897e', + 'activate': true, + 'screenshotLight': '5e5ea5c16897e', + 'screenshotDark': '5e5ea5c16897e', + 'status': 'ready', + 'buildLogs': 'Compiling source files...', + 'buildDuration': 128, + 'providerRepositoryName': 'database', + 'providerRepositoryOwner': 'utopia', + 'providerRepositoryUrl': 'https://github.com/vermakhushboo/g4-node-function', + 'providerCommitHash': '7c3f25d', + 'providerCommitAuthorUrl': 'https://github.com/vermakhushboo', + 'providerCommitAuthor': 'Khushboo Verma', + 'providerCommitMessage': 'Update index.js', + 'providerCommitUrl': 'https://github.com/vermakhushboo/g4-node-function/commit/60c0416257a9cbcdd96b2d370c38d8f8d150ccfb', + 'providerBranch': '0.7.x', + 'providerBranchUrl': 'https://github.com/vermakhushboo/appwrite/tree/0.7.x',}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await sites.createTemplateDeployment( + '', + '', + '', + '', + 'branch', + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method createVcsDeployment()', async () => { + const data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'type': 'vcs', + 'resourceId': '5e5ea6g16897e', + 'resourceType': 'functions', + 'entrypoint': 'index.js', + 'sourceSize': 128, + 'buildSize': 128, + 'totalSize': 128, + 'buildId': '5e5ea5c16897e', + 'activate': true, + 'screenshotLight': '5e5ea5c16897e', + 'screenshotDark': '5e5ea5c16897e', + 'status': 'ready', + 'buildLogs': 'Compiling source files...', + 'buildDuration': 128, + 'providerRepositoryName': 'database', + 'providerRepositoryOwner': 'utopia', + 'providerRepositoryUrl': 'https://github.com/vermakhushboo/g4-node-function', + 'providerCommitHash': '7c3f25d', + 'providerCommitAuthorUrl': 'https://github.com/vermakhushboo', + 'providerCommitAuthor': 'Khushboo Verma', + 'providerCommitMessage': 'Update index.js', + 'providerCommitUrl': 'https://github.com/vermakhushboo/g4-node-function/commit/60c0416257a9cbcdd96b2d370c38d8f8d150ccfb', + 'providerBranch': '0.7.x', + 'providerBranchUrl': 'https://github.com/vermakhushboo/appwrite/tree/0.7.x',}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await sites.createVcsDeployment( + '', + 'branch', + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method getDeployment()', async () => { + const data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'type': 'vcs', + 'resourceId': '5e5ea6g16897e', + 'resourceType': 'functions', + 'entrypoint': 'index.js', + 'sourceSize': 128, + 'buildSize': 128, + 'totalSize': 128, + 'buildId': '5e5ea5c16897e', + 'activate': true, + 'screenshotLight': '5e5ea5c16897e', + 'screenshotDark': '5e5ea5c16897e', + 'status': 'ready', + 'buildLogs': 'Compiling source files...', + 'buildDuration': 128, + 'providerRepositoryName': 'database', + 'providerRepositoryOwner': 'utopia', + 'providerRepositoryUrl': 'https://github.com/vermakhushboo/g4-node-function', + 'providerCommitHash': '7c3f25d', + 'providerCommitAuthorUrl': 'https://github.com/vermakhushboo', + 'providerCommitAuthor': 'Khushboo Verma', + 'providerCommitMessage': 'Update index.js', + 'providerCommitUrl': 'https://github.com/vermakhushboo/g4-node-function/commit/60c0416257a9cbcdd96b2d370c38d8f8d150ccfb', + 'providerBranch': '0.7.x', + 'providerBranchUrl': 'https://github.com/vermakhushboo/appwrite/tree/0.7.x',}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await sites.getDeployment( + '', + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method deleteDeployment()', async () => { + const data = {message: ""}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await sites.deleteDeployment( + '', + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method getDeploymentDownload()', async () => { + const data = new ArrayBuffer(0); + mockedFetch.mockImplementation(() => new Response(data)); + + const response = await sites.getDeploymentDownload( + '', + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method updateDeploymentStatus()', async () => { + const data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'type': 'vcs', + 'resourceId': '5e5ea6g16897e', + 'resourceType': 'functions', + 'entrypoint': 'index.js', + 'sourceSize': 128, + 'buildSize': 128, + 'totalSize': 128, + 'buildId': '5e5ea5c16897e', + 'activate': true, + 'screenshotLight': '5e5ea5c16897e', + 'screenshotDark': '5e5ea5c16897e', + 'status': 'ready', + 'buildLogs': 'Compiling source files...', + 'buildDuration': 128, + 'providerRepositoryName': 'database', + 'providerRepositoryOwner': 'utopia', + 'providerRepositoryUrl': 'https://github.com/vermakhushboo/g4-node-function', + 'providerCommitHash': '7c3f25d', + 'providerCommitAuthorUrl': 'https://github.com/vermakhushboo', + 'providerCommitAuthor': 'Khushboo Verma', + 'providerCommitMessage': 'Update index.js', + 'providerCommitUrl': 'https://github.com/vermakhushboo/g4-node-function/commit/60c0416257a9cbcdd96b2d370c38d8f8d150ccfb', + 'providerBranch': '0.7.x', + 'providerBranchUrl': 'https://github.com/vermakhushboo/appwrite/tree/0.7.x',}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await sites.updateDeploymentStatus( + '', + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method listLogs()', async () => { + const data = { + 'total': 5, + 'executions': [],}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await sites.listLogs( + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method getLog()', async () => { + const data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\$permissions': [], + 'functionId': '5e5ea6g16897e', + 'deploymentId': '5e5ea5c16897e', + 'trigger': 'http', + 'status': 'processing', + 'requestMethod': 'GET', + 'requestPath': '/articles?id=5', + 'requestHeaders': [], + 'responseStatusCode': 200, + 'responseBody': '', + 'responseHeaders': [], + 'logs': '', + 'errors': '', + 'duration': 0.4,}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await sites.getLog( + '', + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method deleteLog()', async () => { + const data = {message: ""}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await sites.deleteLog( + '', + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method listVariables()', async () => { + const data = { + 'total': 5, + 'variables': [],}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await sites.listVariables( + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method createVariable()', async () => { + const data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'key': 'API_KEY', + 'value': 'myPa\$\$word1', + 'secret': true, + 'resourceType': 'function', + 'resourceId': 'myAwesomeFunction',}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await sites.createVariable( + '', + '', + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method getVariable()', async () => { + const data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'key': 'API_KEY', + 'value': 'myPa\$\$word1', + 'secret': true, + 'resourceType': 'function', + 'resourceId': 'myAwesomeFunction',}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await sites.getVariable( + '', + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method updateVariable()', async () => { + const data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'key': 'API_KEY', + 'value': 'myPa\$\$word1', + 'secret': true, + 'resourceType': 'function', + 'resourceId': 'myAwesomeFunction',}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await sites.updateVariable( + '', + '', + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method deleteVariable()', async () => { + const data = {message: ""}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await sites.deleteVariable( + '', + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + }) diff --git a/test/services/storage.test.js b/test/services/storage.test.js new file mode 100644 index 00000000..43f5d0c7 --- /dev/null +++ b/test/services/storage.test.js @@ -0,0 +1,288 @@ +const { Client } = require("../../dist/client"); +const { InputFile } = require("../../dist/inputFile"); +const { Storage } = require("../../dist/services/storage"); + +const { fetch: mockedFetch, Response } = require("node-fetch-native-with-agent"); +jest.mock('node-fetch-native-with-agent', () => ({ ...jest.requireActual('node-fetch-native-with-agent'), fetch: jest.fn() })); + +describe('Storage', () => { + const client = new Client(); + const storage = new Storage(client); + + + test('test method listBuckets()', async () => { + const data = { + 'total': 5, + 'buckets': [],}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await storage.listBuckets( + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method createBucket()', async () => { + const data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\$permissions': [], + 'fileSecurity': true, + 'name': 'Documents', + 'enabled': true, + 'maximumFileSize': 100, + 'allowedFileExtensions': [], + 'compression': 'gzip', + 'encryption': true, + 'antivirus': true, + 'transformations': true, + 'totalSize': 128,}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await storage.createBucket( + '', + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method getBucket()', async () => { + const data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\$permissions': [], + 'fileSecurity': true, + 'name': 'Documents', + 'enabled': true, + 'maximumFileSize': 100, + 'allowedFileExtensions': [], + 'compression': 'gzip', + 'encryption': true, + 'antivirus': true, + 'transformations': true, + 'totalSize': 128,}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await storage.getBucket( + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method updateBucket()', async () => { + const data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\$permissions': [], + 'fileSecurity': true, + 'name': 'Documents', + 'enabled': true, + 'maximumFileSize': 100, + 'allowedFileExtensions': [], + 'compression': 'gzip', + 'encryption': true, + 'antivirus': true, + 'transformations': true, + 'totalSize': 128,}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await storage.updateBucket( + '', + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method deleteBucket()', async () => { + const data = {message: ""}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await storage.deleteBucket( + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method listFiles()', async () => { + const data = { + 'total': 5, + 'files': [],}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await storage.listFiles( + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method createFile()', async () => { + const data = { + '\$id': '5e5ea5c16897e', + 'bucketId': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\$permissions': [], + 'name': 'Pink.png', + 'signature': '5d529fd02b544198ae075bd57c1762bb', + 'mimeType': 'image/png', + 'sizeOriginal': 17890, + 'chunksTotal': 17890, + 'chunksUploaded': 17890, + 'encryption': true, + 'compression': 'gzip',}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await storage.createFile( + '', + '', + InputFile.fromBuffer(new Uint8Array(0), 'image.png'), + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method getFile()', async () => { + const data = { + '\$id': '5e5ea5c16897e', + 'bucketId': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\$permissions': [], + 'name': 'Pink.png', + 'signature': '5d529fd02b544198ae075bd57c1762bb', + 'mimeType': 'image/png', + 'sizeOriginal': 17890, + 'chunksTotal': 17890, + 'chunksUploaded': 17890, + 'encryption': true, + 'compression': 'gzip',}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await storage.getFile( + '', + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method updateFile()', async () => { + const data = { + '\$id': '5e5ea5c16897e', + 'bucketId': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\$permissions': [], + 'name': 'Pink.png', + 'signature': '5d529fd02b544198ae075bd57c1762bb', + 'mimeType': 'image/png', + 'sizeOriginal': 17890, + 'chunksTotal': 17890, + 'chunksUploaded': 17890, + 'encryption': true, + 'compression': 'gzip',}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await storage.updateFile( + '', + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method deleteFile()', async () => { + const data = {message: ""}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await storage.deleteFile( + '', + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method getFileDownload()', async () => { + const data = new ArrayBuffer(0); + mockedFetch.mockImplementation(() => new Response(data)); + + const response = await storage.getFileDownload( + '', + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method getFilePreview()', async () => { + const data = new ArrayBuffer(0); + mockedFetch.mockImplementation(() => new Response(data)); + + const response = await storage.getFilePreview( + '', + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method getFileView()', async () => { + const data = new ArrayBuffer(0); + mockedFetch.mockImplementation(() => new Response(data)); + + const response = await storage.getFileView( + '', + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + }) diff --git a/test/services/tables-d-b.test.js b/test/services/tables-d-b.test.js new file mode 100644 index 00000000..8b475203 --- /dev/null +++ b/test/services/tables-d-b.test.js @@ -0,0 +1,1574 @@ +const { Client } = require("../../dist/client"); +const { InputFile } = require("../../dist/inputFile"); +const { TablesDB } = require("../../dist/services/tables-db"); + +const { fetch: mockedFetch, Response } = require("node-fetch-native-with-agent"); +jest.mock('node-fetch-native-with-agent', () => ({ ...jest.requireActual('node-fetch-native-with-agent'), fetch: jest.fn() })); + +describe('TablesDB', () => { + const client = new Client(); + const tablesDB = new TablesDB(client); + + + test('test method list()', async () => { + const data = { + 'total': 5, + 'databases': [],}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await tablesDB.list( + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method create()', async () => { + const data = { + '\$id': '5e5ea5c16897e', + 'name': 'My Database', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'enabled': true, + 'type': 'legacy', + 'policies': [], + 'archives': [],}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await tablesDB.create( + '', + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method listTransactions()', async () => { + const data = { + 'total': 5, + 'transactions': [],}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await tablesDB.listTransactions( + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method createTransaction()', async () => { + const data = { + '\$id': '259125845563242502', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'status': 'pending', + 'operations': 5, + 'expiresAt': '2020-10-15T06:38:00.000+00:00',}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await tablesDB.createTransaction( + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method getTransaction()', async () => { + const data = { + '\$id': '259125845563242502', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'status': 'pending', + 'operations': 5, + 'expiresAt': '2020-10-15T06:38:00.000+00:00',}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await tablesDB.getTransaction( + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method updateTransaction()', async () => { + const data = { + '\$id': '259125845563242502', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'status': 'pending', + 'operations': 5, + 'expiresAt': '2020-10-15T06:38:00.000+00:00',}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await tablesDB.updateTransaction( + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method deleteTransaction()', async () => { + const data = {message: ""}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await tablesDB.deleteTransaction( + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method createOperations()', async () => { + const data = { + '\$id': '259125845563242502', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'status': 'pending', + 'operations': 5, + 'expiresAt': '2020-10-15T06:38:00.000+00:00',}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await tablesDB.createOperations( + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method get()', async () => { + const data = { + '\$id': '5e5ea5c16897e', + 'name': 'My Database', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'enabled': true, + 'type': 'legacy', + 'policies': [], + 'archives': [],}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await tablesDB.get( + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method update()', async () => { + const data = { + '\$id': '5e5ea5c16897e', + 'name': 'My Database', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'enabled': true, + 'type': 'legacy', + 'policies': [], + 'archives': [],}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await tablesDB.update( + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method delete()', async () => { + const data = {message: ""}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await tablesDB.delete( + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method listTables()', async () => { + const data = { + 'total': 5, + 'tables': [],}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await tablesDB.listTables( + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method createTable()', async () => { + const data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\$permissions': [], + 'databaseId': '5e5ea5c16897e', + 'name': 'My Table', + 'enabled': true, + 'rowSecurity': true, + 'columns': [], + 'indexes': [], + 'bytesMax': 65535, + 'bytesUsed': 1500,}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await tablesDB.createTable( + '', + '', + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method getTable()', async () => { + const data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\$permissions': [], + 'databaseId': '5e5ea5c16897e', + 'name': 'My Table', + 'enabled': true, + 'rowSecurity': true, + 'columns': [], + 'indexes': [], + 'bytesMax': 65535, + 'bytesUsed': 1500,}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await tablesDB.getTable( + '', + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method updateTable()', async () => { + const data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\$permissions': [], + 'databaseId': '5e5ea5c16897e', + 'name': 'My Table', + 'enabled': true, + 'rowSecurity': true, + 'columns': [], + 'indexes': [], + 'bytesMax': 65535, + 'bytesUsed': 1500,}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await tablesDB.updateTable( + '', + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method deleteTable()', async () => { + const data = {message: ""}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await tablesDB.deleteTable( + '', + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method listColumns()', async () => { + const data = { + 'total': 5, + 'columns': [],}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await tablesDB.listColumns( + '', + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method createBooleanColumn()', async () => { + const data = { + 'key': 'isEnabled', + 'type': 'boolean', + 'status': 'available', + 'error': 'string', + 'required': true, + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00',}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await tablesDB.createBooleanColumn( + '', + '', + '', + true, + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method updateBooleanColumn()', async () => { + const data = { + 'key': 'isEnabled', + 'type': 'boolean', + 'status': 'available', + 'error': 'string', + 'required': true, + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00',}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await tablesDB.updateBooleanColumn( + '', + '', + '', + true, + true, + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method createDatetimeColumn()', async () => { + const data = { + 'key': 'birthDay', + 'type': 'datetime', + 'status': 'available', + 'error': 'string', + 'required': true, + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'format': 'datetime',}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await tablesDB.createDatetimeColumn( + '', + '', + '', + true, + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method updateDatetimeColumn()', async () => { + const data = { + 'key': 'birthDay', + 'type': 'datetime', + 'status': 'available', + 'error': 'string', + 'required': true, + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'format': 'datetime',}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await tablesDB.updateDatetimeColumn( + '', + '', + '', + true, + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method createEmailColumn()', async () => { + const data = { + 'key': 'userEmail', + 'type': 'string', + 'status': 'available', + 'error': 'string', + 'required': true, + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'format': 'email',}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await tablesDB.createEmailColumn( + '', + '', + '', + true, + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method updateEmailColumn()', async () => { + const data = { + 'key': 'userEmail', + 'type': 'string', + 'status': 'available', + 'error': 'string', + 'required': true, + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'format': 'email',}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await tablesDB.updateEmailColumn( + '', + '', + '', + true, + 'email@example.com', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method createEnumColumn()', async () => { + const data = { + 'key': 'status', + 'type': 'string', + 'status': 'available', + 'error': 'string', + 'required': true, + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'elements': [], + 'format': 'enum',}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await tablesDB.createEnumColumn( + '', + '', + '', + [], + true, + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method updateEnumColumn()', async () => { + const data = { + 'key': 'status', + 'type': 'string', + 'status': 'available', + 'error': 'string', + 'required': true, + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'elements': [], + 'format': 'enum',}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await tablesDB.updateEnumColumn( + '', + '', + '', + [], + true, + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method createFloatColumn()', async () => { + const data = { + 'key': 'percentageCompleted', + 'type': 'double', + 'status': 'available', + 'error': 'string', + 'required': true, + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00',}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await tablesDB.createFloatColumn( + '', + '', + '', + true, + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method updateFloatColumn()', async () => { + const data = { + 'key': 'percentageCompleted', + 'type': 'double', + 'status': 'available', + 'error': 'string', + 'required': true, + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00',}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await tablesDB.updateFloatColumn( + '', + '', + '', + true, + 1.0, + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method createIntegerColumn()', async () => { + const data = { + 'key': 'count', + 'type': 'integer', + 'status': 'available', + 'error': 'string', + 'required': true, + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00',}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await tablesDB.createIntegerColumn( + '', + '', + '', + true, + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method updateIntegerColumn()', async () => { + const data = { + 'key': 'count', + 'type': 'integer', + 'status': 'available', + 'error': 'string', + 'required': true, + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00',}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await tablesDB.updateIntegerColumn( + '', + '', + '', + true, + 1, + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method createIpColumn()', async () => { + const data = { + 'key': 'ipAddress', + 'type': 'string', + 'status': 'available', + 'error': 'string', + 'required': true, + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'format': 'ip',}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await tablesDB.createIpColumn( + '', + '', + '', + true, + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method updateIpColumn()', async () => { + const data = { + 'key': 'ipAddress', + 'type': 'string', + 'status': 'available', + 'error': 'string', + 'required': true, + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'format': 'ip',}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await tablesDB.updateIpColumn( + '', + '', + '', + true, + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method createLineColumn()', async () => { + const data = { + 'key': 'fullName', + 'type': 'string', + 'status': 'available', + 'error': 'string', + 'required': true, + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00',}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await tablesDB.createLineColumn( + '', + '', + '', + true, + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method updateLineColumn()', async () => { + const data = { + 'key': 'fullName', + 'type': 'string', + 'status': 'available', + 'error': 'string', + 'required': true, + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00',}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await tablesDB.updateLineColumn( + '', + '', + '', + true, + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method createLongtextColumn()', async () => { + const data = { + 'key': 'fullName', + 'type': 'string', + 'status': 'available', + 'error': 'string', + 'required': true, + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00',}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await tablesDB.createLongtextColumn( + '', + '', + '', + true, + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method updateLongtextColumn()', async () => { + const data = { + 'key': 'fullName', + 'type': 'string', + 'status': 'available', + 'error': 'string', + 'required': true, + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00',}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await tablesDB.updateLongtextColumn( + '', + '', + '', + true, + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method createMediumtextColumn()', async () => { + const data = { + 'key': 'fullName', + 'type': 'string', + 'status': 'available', + 'error': 'string', + 'required': true, + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00',}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await tablesDB.createMediumtextColumn( + '', + '', + '', + true, + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method updateMediumtextColumn()', async () => { + const data = { + 'key': 'fullName', + 'type': 'string', + 'status': 'available', + 'error': 'string', + 'required': true, + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00',}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await tablesDB.updateMediumtextColumn( + '', + '', + '', + true, + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method createPointColumn()', async () => { + const data = { + 'key': 'fullName', + 'type': 'string', + 'status': 'available', + 'error': 'string', + 'required': true, + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00',}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await tablesDB.createPointColumn( + '', + '', + '', + true, + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method updatePointColumn()', async () => { + const data = { + 'key': 'fullName', + 'type': 'string', + 'status': 'available', + 'error': 'string', + 'required': true, + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00',}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await tablesDB.updatePointColumn( + '', + '', + '', + true, + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method createPolygonColumn()', async () => { + const data = { + 'key': 'fullName', + 'type': 'string', + 'status': 'available', + 'error': 'string', + 'required': true, + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00',}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await tablesDB.createPolygonColumn( + '', + '', + '', + true, + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method updatePolygonColumn()', async () => { + const data = { + 'key': 'fullName', + 'type': 'string', + 'status': 'available', + 'error': 'string', + 'required': true, + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00',}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await tablesDB.updatePolygonColumn( + '', + '', + '', + true, + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method createRelationshipColumn()', async () => { + const data = { + 'key': 'fullName', + 'type': 'string', + 'status': 'available', + 'error': 'string', + 'required': true, + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'relatedTable': 'table', + 'relationType': 'oneToOne|oneToMany|manyToOne|manyToMany', + 'twoWay': true, + 'twoWayKey': 'string', + 'onDelete': 'restrict|cascade|setNull', + 'side': 'parent|child',}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await tablesDB.createRelationshipColumn( + '', + '', + '', + 'oneToOne', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method createStringColumn()', async () => { + const data = { + 'key': 'fullName', + 'type': 'string', + 'status': 'available', + 'error': 'string', + 'required': true, + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'size': 128,}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await tablesDB.createStringColumn( + '', + '', + '', + 1, + true, + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method updateStringColumn()', async () => { + const data = { + 'key': 'fullName', + 'type': 'string', + 'status': 'available', + 'error': 'string', + 'required': true, + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'size': 128,}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await tablesDB.updateStringColumn( + '', + '', + '', + true, + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method createTextColumn()', async () => { + const data = { + 'key': 'fullName', + 'type': 'string', + 'status': 'available', + 'error': 'string', + 'required': true, + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00',}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await tablesDB.createTextColumn( + '', + '', + '', + true, + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method updateTextColumn()', async () => { + const data = { + 'key': 'fullName', + 'type': 'string', + 'status': 'available', + 'error': 'string', + 'required': true, + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00',}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await tablesDB.updateTextColumn( + '', + '', + '', + true, + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method createUrlColumn()', async () => { + const data = { + 'key': 'githubUrl', + 'type': 'string', + 'status': 'available', + 'error': 'string', + 'required': true, + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'format': 'url',}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await tablesDB.createUrlColumn( + '', + '', + '', + true, + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method updateUrlColumn()', async () => { + const data = { + 'key': 'githubUrl', + 'type': 'string', + 'status': 'available', + 'error': 'string', + 'required': true, + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'format': 'url',}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await tablesDB.updateUrlColumn( + '', + '', + '', + true, + 'https://example.com', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method createVarcharColumn()', async () => { + const data = { + 'key': 'fullName', + 'type': 'string', + 'status': 'available', + 'error': 'string', + 'required': true, + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'size': 128,}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await tablesDB.createVarcharColumn( + '', + '', + '', + 1, + true, + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method updateVarcharColumn()', async () => { + const data = { + 'key': 'fullName', + 'type': 'string', + 'status': 'available', + 'error': 'string', + 'required': true, + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'size': 128,}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await tablesDB.updateVarcharColumn( + '', + '', + '', + true, + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method getColumn()', async () => { + const data = { + 'key': 'isEnabled', + 'type': 'boolean', + 'status': 'available', + 'error': 'string', + 'required': true, + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00',}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await tablesDB.getColumn( + '', + '', + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method deleteColumn()', async () => { + const data = {message: ""}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await tablesDB.deleteColumn( + '', + '', + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method updateRelationshipColumn()', async () => { + const data = { + 'key': 'fullName', + 'type': 'string', + 'status': 'available', + 'error': 'string', + 'required': true, + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'relatedTable': 'table', + 'relationType': 'oneToOne|oneToMany|manyToOne|manyToMany', + 'twoWay': true, + 'twoWayKey': 'string', + 'onDelete': 'restrict|cascade|setNull', + 'side': 'parent|child',}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await tablesDB.updateRelationshipColumn( + '', + '', + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method listIndexes()', async () => { + const data = { + 'total': 5, + 'indexes': [],}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await tablesDB.listIndexes( + '', + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method createIndex()', async () => { + const data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'key': 'index1', + 'type': 'primary', + 'status': 'available', + 'error': 'string', + 'columns': [], + 'lengths': [],}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await tablesDB.createIndex( + '', + '', + '', + 'key', + [], + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method getIndex()', async () => { + const data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'key': 'index1', + 'type': 'primary', + 'status': 'available', + 'error': 'string', + 'columns': [], + 'lengths': [],}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await tablesDB.getIndex( + '', + '', + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method deleteIndex()', async () => { + const data = {message: ""}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await tablesDB.deleteIndex( + '', + '', + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method listRows()', async () => { + const data = { + 'total': 5, + 'rows': [],}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await tablesDB.listRows( + '', + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method createRow()', async () => { + const data = { + '\$id': '5e5ea5c16897e', + '\$sequence': '1', + '\$tableId': '5e5ea5c15117e', + '\$databaseId': '5e5ea5c15117e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\$permissions': [],}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await tablesDB.createRow( + '', + '', + '', + {}, + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method createRows()', async () => { + const data = { + 'total': 5, + 'rows': [],}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await tablesDB.createRows( + '', + '', + [], + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method upsertRows()', async () => { + const data = { + 'total': 5, + 'rows': [],}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await tablesDB.upsertRows( + '', + '', + [], + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method updateRows()', async () => { + const data = { + 'total': 5, + 'rows': [],}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await tablesDB.updateRows( + '', + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method deleteRows()', async () => { + const data = { + 'total': 5, + 'rows': [],}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await tablesDB.deleteRows( + '', + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method getRow()', async () => { + const data = { + '\$id': '5e5ea5c16897e', + '\$sequence': '1', + '\$tableId': '5e5ea5c15117e', + '\$databaseId': '5e5ea5c15117e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\$permissions': [],}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await tablesDB.getRow( + '', + '', + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method upsertRow()', async () => { + const data = { + '\$id': '5e5ea5c16897e', + '\$sequence': '1', + '\$tableId': '5e5ea5c15117e', + '\$databaseId': '5e5ea5c15117e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\$permissions': [],}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await tablesDB.upsertRow( + '', + '', + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method updateRow()', async () => { + const data = { + '\$id': '5e5ea5c16897e', + '\$sequence': '1', + '\$tableId': '5e5ea5c15117e', + '\$databaseId': '5e5ea5c15117e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\$permissions': [],}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await tablesDB.updateRow( + '', + '', + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method deleteRow()', async () => { + const data = {message: ""}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await tablesDB.deleteRow( + '', + '', + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method decrementRowColumn()', async () => { + const data = { + '\$id': '5e5ea5c16897e', + '\$sequence': '1', + '\$tableId': '5e5ea5c15117e', + '\$databaseId': '5e5ea5c15117e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\$permissions': [],}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await tablesDB.decrementRowColumn( + '', + '', + '', + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method incrementRowColumn()', async () => { + const data = { + '\$id': '5e5ea5c16897e', + '\$sequence': '1', + '\$tableId': '5e5ea5c15117e', + '\$databaseId': '5e5ea5c15117e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\$permissions': [],}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await tablesDB.incrementRowColumn( + '', + '', + '', + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + }) diff --git a/test/services/teams.test.js b/test/services/teams.test.js new file mode 100644 index 00000000..df5c9ac1 --- /dev/null +++ b/test/services/teams.test.js @@ -0,0 +1,278 @@ +const { Client } = require("../../dist/client"); +const { InputFile } = require("../../dist/inputFile"); +const { Teams } = require("../../dist/services/teams"); + +const { fetch: mockedFetch, Response } = require("node-fetch-native-with-agent"); +jest.mock('node-fetch-native-with-agent', () => ({ ...jest.requireActual('node-fetch-native-with-agent'), fetch: jest.fn() })); + +describe('Teams', () => { + const client = new Client(); + const teams = new Teams(client); + + + test('test method list()', async () => { + const data = { + 'total': 5, + 'teams': [],}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await teams.list( + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method create()', async () => { + const data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'name': 'VIP', + 'total': 7, + 'prefs': {},}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await teams.create( + '', + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method get()', async () => { + const data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'name': 'VIP', + 'total': 7, + 'prefs': {},}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await teams.get( + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method updateName()', async () => { + const data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'name': 'VIP', + 'total': 7, + 'prefs': {},}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await teams.updateName( + '', + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method delete()', async () => { + const data = {message: ""}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await teams.delete( + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method listMemberships()', async () => { + const data = { + 'total': 5, + 'memberships': [],}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await teams.listMemberships( + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method createMembership()', async () => { + const data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'userId': '5e5ea5c16897e', + 'userName': 'John Doe', + 'userEmail': 'john@appwrite.io', + 'teamId': '5e5ea5c16897e', + 'teamName': 'VIP', + 'invited': '2020-10-15T06:38:00.000+00:00', + 'joined': '2020-10-15T06:38:00.000+00:00', + 'confirm': true, + 'mfa': true, + 'roles': [],}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await teams.createMembership( + '', + [], + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method getMembership()', async () => { + const data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'userId': '5e5ea5c16897e', + 'userName': 'John Doe', + 'userEmail': 'john@appwrite.io', + 'teamId': '5e5ea5c16897e', + 'teamName': 'VIP', + 'invited': '2020-10-15T06:38:00.000+00:00', + 'joined': '2020-10-15T06:38:00.000+00:00', + 'confirm': true, + 'mfa': true, + 'roles': [],}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await teams.getMembership( + '', + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method updateMembership()', async () => { + const data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'userId': '5e5ea5c16897e', + 'userName': 'John Doe', + 'userEmail': 'john@appwrite.io', + 'teamId': '5e5ea5c16897e', + 'teamName': 'VIP', + 'invited': '2020-10-15T06:38:00.000+00:00', + 'joined': '2020-10-15T06:38:00.000+00:00', + 'confirm': true, + 'mfa': true, + 'roles': [],}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await teams.updateMembership( + '', + '', + [], + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method deleteMembership()', async () => { + const data = {message: ""}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await teams.deleteMembership( + '', + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method updateMembershipStatus()', async () => { + const data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'userId': '5e5ea5c16897e', + 'userName': 'John Doe', + 'userEmail': 'john@appwrite.io', + 'teamId': '5e5ea5c16897e', + 'teamName': 'VIP', + 'invited': '2020-10-15T06:38:00.000+00:00', + 'joined': '2020-10-15T06:38:00.000+00:00', + 'confirm': true, + 'mfa': true, + 'roles': [],}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await teams.updateMembershipStatus( + '', + '', + '', + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method getPrefs()', async () => { + const data = {}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await teams.getPrefs( + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method updatePrefs()', async () => { + const data = {}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await teams.updatePrefs( + '', + {}, + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + }) diff --git a/test/services/tokens.test.js b/test/services/tokens.test.js new file mode 100644 index 00000000..b9c14cb4 --- /dev/null +++ b/test/services/tokens.test.js @@ -0,0 +1,107 @@ +const { Client } = require("../../dist/client"); +const { InputFile } = require("../../dist/inputFile"); +const { Tokens } = require("../../dist/services/tokens"); + +const { fetch: mockedFetch, Response } = require("node-fetch-native-with-agent"); +jest.mock('node-fetch-native-with-agent', () => ({ ...jest.requireActual('node-fetch-native-with-agent'), fetch: jest.fn() })); + +describe('Tokens', () => { + const client = new Client(); + const tokens = new Tokens(client); + + + test('test method list()', async () => { + const data = { + 'total': 5, + 'tokens': [],}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await tokens.list( + '', + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method createFileToken()', async () => { + const data = { + '\$id': 'bb8ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + 'resourceId': '5e5ea5c168bb8:5e5ea5c168bb8', + 'resourceType': 'files', + 'expire': '2020-10-15T06:38:00.000+00:00', + 'secret': 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c', + 'accessedAt': '2020-10-15T06:38:00.000+00:00',}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await tokens.createFileToken( + '', + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method get()', async () => { + const data = { + '\$id': 'bb8ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + 'resourceId': '5e5ea5c168bb8:5e5ea5c168bb8', + 'resourceType': 'files', + 'expire': '2020-10-15T06:38:00.000+00:00', + 'secret': 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c', + 'accessedAt': '2020-10-15T06:38:00.000+00:00',}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await tokens.get( + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method update()', async () => { + const data = { + '\$id': 'bb8ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + 'resourceId': '5e5ea5c168bb8:5e5ea5c168bb8', + 'resourceType': 'files', + 'expire': '2020-10-15T06:38:00.000+00:00', + 'secret': 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c', + 'accessedAt': '2020-10-15T06:38:00.000+00:00',}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await tokens.update( + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method delete()', async () => { + const data = {message: ""}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await tokens.delete( + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + }) diff --git a/test/services/users.test.js b/test/services/users.test.js new file mode 100644 index 00000000..c01295da --- /dev/null +++ b/test/services/users.test.js @@ -0,0 +1,1145 @@ +const { Client } = require("../../dist/client"); +const { InputFile } = require("../../dist/inputFile"); +const { Users } = require("../../dist/services/users"); + +const { fetch: mockedFetch, Response } = require("node-fetch-native-with-agent"); +jest.mock('node-fetch-native-with-agent', () => ({ ...jest.requireActual('node-fetch-native-with-agent'), fetch: jest.fn() })); + +describe('Users', () => { + const client = new Client(); + const users = new Users(client); + + + test('test method list()', async () => { + const data = { + 'total': 5, + 'users': [],}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await users.list( + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method create()', async () => { + const data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'name': 'John Doe', + 'registration': '2020-10-15T06:38:00.000+00:00', + 'status': true, + 'labels': [], + 'passwordUpdate': '2020-10-15T06:38:00.000+00:00', + 'email': 'john@appwrite.io', + 'phone': '+4930901820', + 'emailVerification': true, + 'phoneVerification': true, + 'mfa': true, + 'prefs': {}, + 'targets': [], + 'accessedAt': '2020-10-15T06:38:00.000+00:00',}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await users.create( + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method createArgon2User()', async () => { + const data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'name': 'John Doe', + 'registration': '2020-10-15T06:38:00.000+00:00', + 'status': true, + 'labels': [], + 'passwordUpdate': '2020-10-15T06:38:00.000+00:00', + 'email': 'john@appwrite.io', + 'phone': '+4930901820', + 'emailVerification': true, + 'phoneVerification': true, + 'mfa': true, + 'prefs': {}, + 'targets': [], + 'accessedAt': '2020-10-15T06:38:00.000+00:00',}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await users.createArgon2User( + '', + 'email@example.com', + 'password', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method createBcryptUser()', async () => { + const data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'name': 'John Doe', + 'registration': '2020-10-15T06:38:00.000+00:00', + 'status': true, + 'labels': [], + 'passwordUpdate': '2020-10-15T06:38:00.000+00:00', + 'email': 'john@appwrite.io', + 'phone': '+4930901820', + 'emailVerification': true, + 'phoneVerification': true, + 'mfa': true, + 'prefs': {}, + 'targets': [], + 'accessedAt': '2020-10-15T06:38:00.000+00:00',}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await users.createBcryptUser( + '', + 'email@example.com', + 'password', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method listIdentities()', async () => { + const data = { + 'total': 5, + 'identities': [],}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await users.listIdentities( + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method deleteIdentity()', async () => { + const data = {message: ""}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await users.deleteIdentity( + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method createMD5User()', async () => { + const data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'name': 'John Doe', + 'registration': '2020-10-15T06:38:00.000+00:00', + 'status': true, + 'labels': [], + 'passwordUpdate': '2020-10-15T06:38:00.000+00:00', + 'email': 'john@appwrite.io', + 'phone': '+4930901820', + 'emailVerification': true, + 'phoneVerification': true, + 'mfa': true, + 'prefs': {}, + 'targets': [], + 'accessedAt': '2020-10-15T06:38:00.000+00:00',}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await users.createMD5User( + '', + 'email@example.com', + 'password', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method createPHPassUser()', async () => { + const data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'name': 'John Doe', + 'registration': '2020-10-15T06:38:00.000+00:00', + 'status': true, + 'labels': [], + 'passwordUpdate': '2020-10-15T06:38:00.000+00:00', + 'email': 'john@appwrite.io', + 'phone': '+4930901820', + 'emailVerification': true, + 'phoneVerification': true, + 'mfa': true, + 'prefs': {}, + 'targets': [], + 'accessedAt': '2020-10-15T06:38:00.000+00:00',}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await users.createPHPassUser( + '', + 'email@example.com', + 'password', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method createScryptUser()', async () => { + const data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'name': 'John Doe', + 'registration': '2020-10-15T06:38:00.000+00:00', + 'status': true, + 'labels': [], + 'passwordUpdate': '2020-10-15T06:38:00.000+00:00', + 'email': 'john@appwrite.io', + 'phone': '+4930901820', + 'emailVerification': true, + 'phoneVerification': true, + 'mfa': true, + 'prefs': {}, + 'targets': [], + 'accessedAt': '2020-10-15T06:38:00.000+00:00',}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await users.createScryptUser( + '', + 'email@example.com', + 'password', + '', + 1, + 1, + 1, + 1, + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method createScryptModifiedUser()', async () => { + const data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'name': 'John Doe', + 'registration': '2020-10-15T06:38:00.000+00:00', + 'status': true, + 'labels': [], + 'passwordUpdate': '2020-10-15T06:38:00.000+00:00', + 'email': 'john@appwrite.io', + 'phone': '+4930901820', + 'emailVerification': true, + 'phoneVerification': true, + 'mfa': true, + 'prefs': {}, + 'targets': [], + 'accessedAt': '2020-10-15T06:38:00.000+00:00',}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await users.createScryptModifiedUser( + '', + 'email@example.com', + 'password', + '', + '', + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method createSHAUser()', async () => { + const data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'name': 'John Doe', + 'registration': '2020-10-15T06:38:00.000+00:00', + 'status': true, + 'labels': [], + 'passwordUpdate': '2020-10-15T06:38:00.000+00:00', + 'email': 'john@appwrite.io', + 'phone': '+4930901820', + 'emailVerification': true, + 'phoneVerification': true, + 'mfa': true, + 'prefs': {}, + 'targets': [], + 'accessedAt': '2020-10-15T06:38:00.000+00:00',}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await users.createSHAUser( + '', + 'email@example.com', + 'password', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method get()', async () => { + const data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'name': 'John Doe', + 'registration': '2020-10-15T06:38:00.000+00:00', + 'status': true, + 'labels': [], + 'passwordUpdate': '2020-10-15T06:38:00.000+00:00', + 'email': 'john@appwrite.io', + 'phone': '+4930901820', + 'emailVerification': true, + 'phoneVerification': true, + 'mfa': true, + 'prefs': {}, + 'targets': [], + 'accessedAt': '2020-10-15T06:38:00.000+00:00',}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await users.get( + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method delete()', async () => { + const data = {message: ""}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await users.delete( + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method updateEmail()', async () => { + const data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'name': 'John Doe', + 'registration': '2020-10-15T06:38:00.000+00:00', + 'status': true, + 'labels': [], + 'passwordUpdate': '2020-10-15T06:38:00.000+00:00', + 'email': 'john@appwrite.io', + 'phone': '+4930901820', + 'emailVerification': true, + 'phoneVerification': true, + 'mfa': true, + 'prefs': {}, + 'targets': [], + 'accessedAt': '2020-10-15T06:38:00.000+00:00',}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await users.updateEmail( + '', + 'email@example.com', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method updateImpersonator()', async () => { + const data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'name': 'John Doe', + 'registration': '2020-10-15T06:38:00.000+00:00', + 'status': true, + 'labels': [], + 'passwordUpdate': '2020-10-15T06:38:00.000+00:00', + 'email': 'john@appwrite.io', + 'phone': '+4930901820', + 'emailVerification': true, + 'phoneVerification': true, + 'mfa': true, + 'prefs': {}, + 'targets': [], + 'accessedAt': '2020-10-15T06:38:00.000+00:00',}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await users.updateImpersonator( + '', + true, + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method createJWT()', async () => { + const data = { + 'jwt': 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c',}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await users.createJWT( + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method updateLabels()', async () => { + const data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'name': 'John Doe', + 'registration': '2020-10-15T06:38:00.000+00:00', + 'status': true, + 'labels': [], + 'passwordUpdate': '2020-10-15T06:38:00.000+00:00', + 'email': 'john@appwrite.io', + 'phone': '+4930901820', + 'emailVerification': true, + 'phoneVerification': true, + 'mfa': true, + 'prefs': {}, + 'targets': [], + 'accessedAt': '2020-10-15T06:38:00.000+00:00',}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await users.updateLabels( + '', + [], + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method listLogs()', async () => { + const data = { + 'total': 5, + 'logs': [],}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await users.listLogs( + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method listMemberships()', async () => { + const data = { + 'total': 5, + 'memberships': [],}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await users.listMemberships( + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method updateMfa()', async () => { + const data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'name': 'John Doe', + 'registration': '2020-10-15T06:38:00.000+00:00', + 'status': true, + 'labels': [], + 'passwordUpdate': '2020-10-15T06:38:00.000+00:00', + 'email': 'john@appwrite.io', + 'phone': '+4930901820', + 'emailVerification': true, + 'phoneVerification': true, + 'mfa': true, + 'prefs': {}, + 'targets': [], + 'accessedAt': '2020-10-15T06:38:00.000+00:00',}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await users.updateMfa( + '', + true, + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method updateMFA()', async () => { + const data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'name': 'John Doe', + 'registration': '2020-10-15T06:38:00.000+00:00', + 'status': true, + 'labels': [], + 'passwordUpdate': '2020-10-15T06:38:00.000+00:00', + 'email': 'john@appwrite.io', + 'phone': '+4930901820', + 'emailVerification': true, + 'phoneVerification': true, + 'mfa': true, + 'prefs': {}, + 'targets': [], + 'accessedAt': '2020-10-15T06:38:00.000+00:00',}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await users.updateMFA( + '', + true, + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method deleteMfaAuthenticator()', async () => { + const data = {message: ""}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await users.deleteMfaAuthenticator( + '', + 'totp', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method deleteMFAAuthenticator()', async () => { + const data = {message: ""}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await users.deleteMFAAuthenticator( + '', + 'totp', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method listMfaFactors()', async () => { + const data = { + 'totp': true, + 'phone': true, + 'email': true, + 'recoveryCode': true,}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await users.listMfaFactors( + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method listMFAFactors()', async () => { + const data = { + 'totp': true, + 'phone': true, + 'email': true, + 'recoveryCode': true,}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await users.listMFAFactors( + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method getMfaRecoveryCodes()', async () => { + const data = { + 'recoveryCodes': [],}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await users.getMfaRecoveryCodes( + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method getMFARecoveryCodes()', async () => { + const data = { + 'recoveryCodes': [],}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await users.getMFARecoveryCodes( + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method updateMfaRecoveryCodes()', async () => { + const data = { + 'recoveryCodes': [],}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await users.updateMfaRecoveryCodes( + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method updateMFARecoveryCodes()', async () => { + const data = { + 'recoveryCodes': [],}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await users.updateMFARecoveryCodes( + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method createMfaRecoveryCodes()', async () => { + const data = { + 'recoveryCodes': [],}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await users.createMfaRecoveryCodes( + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method createMFARecoveryCodes()', async () => { + const data = { + 'recoveryCodes': [],}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await users.createMFARecoveryCodes( + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method updateName()', async () => { + const data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'name': 'John Doe', + 'registration': '2020-10-15T06:38:00.000+00:00', + 'status': true, + 'labels': [], + 'passwordUpdate': '2020-10-15T06:38:00.000+00:00', + 'email': 'john@appwrite.io', + 'phone': '+4930901820', + 'emailVerification': true, + 'phoneVerification': true, + 'mfa': true, + 'prefs': {}, + 'targets': [], + 'accessedAt': '2020-10-15T06:38:00.000+00:00',}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await users.updateName( + '', + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method updatePassword()', async () => { + const data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'name': 'John Doe', + 'registration': '2020-10-15T06:38:00.000+00:00', + 'status': true, + 'labels': [], + 'passwordUpdate': '2020-10-15T06:38:00.000+00:00', + 'email': 'john@appwrite.io', + 'phone': '+4930901820', + 'emailVerification': true, + 'phoneVerification': true, + 'mfa': true, + 'prefs': {}, + 'targets': [], + 'accessedAt': '2020-10-15T06:38:00.000+00:00',}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await users.updatePassword( + '', + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method updatePhone()', async () => { + const data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'name': 'John Doe', + 'registration': '2020-10-15T06:38:00.000+00:00', + 'status': true, + 'labels': [], + 'passwordUpdate': '2020-10-15T06:38:00.000+00:00', + 'email': 'john@appwrite.io', + 'phone': '+4930901820', + 'emailVerification': true, + 'phoneVerification': true, + 'mfa': true, + 'prefs': {}, + 'targets': [], + 'accessedAt': '2020-10-15T06:38:00.000+00:00',}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await users.updatePhone( + '', + '+12065550100', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method getPrefs()', async () => { + const data = {}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await users.getPrefs( + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method updatePrefs()', async () => { + const data = {}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await users.updatePrefs( + '', + {}, + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method listSessions()', async () => { + const data = { + 'total': 5, + 'sessions': [],}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await users.listSessions( + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method createSession()', async () => { + const data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'userId': '5e5bb8c16897e', + 'expire': '2020-10-15T06:38:00.000+00:00', + 'provider': 'email', + 'providerUid': 'user@example.com', + 'providerAccessToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', + 'providerAccessTokenExpiry': '2020-10-15T06:38:00.000+00:00', + 'providerRefreshToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', + 'ip': '127.0.0.1', + 'osCode': 'Mac', + 'osName': 'Mac', + 'osVersion': 'Mac', + 'clientType': 'browser', + 'clientCode': 'CM', + 'clientName': 'Chrome Mobile iOS', + 'clientVersion': '84.0', + 'clientEngine': 'WebKit', + 'clientEngineVersion': '605.1.15', + 'deviceName': 'smartphone', + 'deviceBrand': 'Google', + 'deviceModel': 'Nexus 5', + 'countryCode': 'US', + 'countryName': 'United States', + 'current': true, + 'factors': [], + 'secret': '5e5bb8c16897e', + 'mfaUpdatedAt': '2020-10-15T06:38:00.000+00:00',}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await users.createSession( + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method deleteSessions()', async () => { + const data = {message: ""}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await users.deleteSessions( + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method deleteSession()', async () => { + const data = {message: ""}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await users.deleteSession( + '', + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method updateStatus()', async () => { + const data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'name': 'John Doe', + 'registration': '2020-10-15T06:38:00.000+00:00', + 'status': true, + 'labels': [], + 'passwordUpdate': '2020-10-15T06:38:00.000+00:00', + 'email': 'john@appwrite.io', + 'phone': '+4930901820', + 'emailVerification': true, + 'phoneVerification': true, + 'mfa': true, + 'prefs': {}, + 'targets': [], + 'accessedAt': '2020-10-15T06:38:00.000+00:00',}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await users.updateStatus( + '', + true, + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method listTargets()', async () => { + const data = { + 'total': 5, + 'targets': [],}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await users.listTargets( + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method createTarget()', async () => { + const data = { + '\$id': '259125845563242502', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'name': 'Apple iPhone 12', + 'userId': '259125845563242502', + 'providerType': 'email', + 'identifier': 'token', + 'expired': true,}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await users.createTarget( + '', + '', + 'email', + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method getTarget()', async () => { + const data = { + '\$id': '259125845563242502', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'name': 'Apple iPhone 12', + 'userId': '259125845563242502', + 'providerType': 'email', + 'identifier': 'token', + 'expired': true,}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await users.getTarget( + '', + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method updateTarget()', async () => { + const data = { + '\$id': '259125845563242502', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'name': 'Apple iPhone 12', + 'userId': '259125845563242502', + 'providerType': 'email', + 'identifier': 'token', + 'expired': true,}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await users.updateTarget( + '', + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method deleteTarget()', async () => { + const data = {message: ""}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await users.deleteTarget( + '', + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method createToken()', async () => { + const data = { + '\$id': 'bb8ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + 'userId': '5e5ea5c168bb8', + 'secret': '', + 'expire': '2020-10-15T06:38:00.000+00:00', + 'phrase': 'Golden Fox',}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await users.createToken( + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method updateEmailVerification()', async () => { + const data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'name': 'John Doe', + 'registration': '2020-10-15T06:38:00.000+00:00', + 'status': true, + 'labels': [], + 'passwordUpdate': '2020-10-15T06:38:00.000+00:00', + 'email': 'john@appwrite.io', + 'phone': '+4930901820', + 'emailVerification': true, + 'phoneVerification': true, + 'mfa': true, + 'prefs': {}, + 'targets': [], + 'accessedAt': '2020-10-15T06:38:00.000+00:00',}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await users.updateEmailVerification( + '', + true, + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method updatePhoneVerification()', async () => { + const data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'name': 'John Doe', + 'registration': '2020-10-15T06:38:00.000+00:00', + 'status': true, + 'labels': [], + 'passwordUpdate': '2020-10-15T06:38:00.000+00:00', + 'email': 'john@appwrite.io', + 'phone': '+4930901820', + 'emailVerification': true, + 'phoneVerification': true, + 'mfa': true, + 'prefs': {}, + 'targets': [], + 'accessedAt': '2020-10-15T06:38:00.000+00:00',}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await users.updatePhoneVerification( + '', + true, + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + }) diff --git a/test/services/vectors-d-b.test.js b/test/services/vectors-d-b.test.js new file mode 100644 index 00000000..d5e74ded --- /dev/null +++ b/test/services/vectors-d-b.test.js @@ -0,0 +1,632 @@ +const { Client } = require("../../dist/client"); +const { InputFile } = require("../../dist/inputFile"); +const { VectorsDB } = require("../../dist/services/vectors-db"); + +const { fetch: mockedFetch, Response } = require("node-fetch-native-with-agent"); +jest.mock('node-fetch-native-with-agent', () => ({ ...jest.requireActual('node-fetch-native-with-agent'), fetch: jest.fn() })); + +describe('VectorsDB', () => { + const client = new Client(); + const vectorsDB = new VectorsDB(client); + + + test('test method list()', async () => { + const data = { + 'total': 5, + 'databases': [],}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await vectorsDB.list( + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method create()', async () => { + const data = { + '\$id': '5e5ea5c16897e', + 'name': 'My Database', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'enabled': true, + 'type': 'legacy', + 'policies': [], + 'archives': [],}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await vectorsDB.create( + '', + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method createTextEmbeddings()', async () => { + const data = { + 'total': 5, + 'embeddings': [],}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await vectorsDB.createTextEmbeddings( + [], + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method listTransactions()', async () => { + const data = { + 'total': 5, + 'transactions': [],}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await vectorsDB.listTransactions( + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method createTransaction()', async () => { + const data = { + '\$id': '259125845563242502', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'status': 'pending', + 'operations': 5, + 'expiresAt': '2020-10-15T06:38:00.000+00:00',}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await vectorsDB.createTransaction( + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method getTransaction()', async () => { + const data = { + '\$id': '259125845563242502', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'status': 'pending', + 'operations': 5, + 'expiresAt': '2020-10-15T06:38:00.000+00:00',}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await vectorsDB.getTransaction( + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method updateTransaction()', async () => { + const data = { + '\$id': '259125845563242502', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'status': 'pending', + 'operations': 5, + 'expiresAt': '2020-10-15T06:38:00.000+00:00',}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await vectorsDB.updateTransaction( + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method deleteTransaction()', async () => { + const data = {message: ""}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await vectorsDB.deleteTransaction( + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method createOperations()', async () => { + const data = { + '\$id': '259125845563242502', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'status': 'pending', + 'operations': 5, + 'expiresAt': '2020-10-15T06:38:00.000+00:00',}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await vectorsDB.createOperations( + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method get()', async () => { + const data = { + '\$id': '5e5ea5c16897e', + 'name': 'My Database', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'enabled': true, + 'type': 'legacy', + 'policies': [], + 'archives': [],}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await vectorsDB.get( + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method update()', async () => { + const data = { + '\$id': '5e5ea5c16897e', + 'name': 'My Database', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'enabled': true, + 'type': 'legacy', + 'policies': [], + 'archives': [],}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await vectorsDB.update( + '', + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method delete()', async () => { + const data = {message: ""}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await vectorsDB.delete( + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method listCollections()', async () => { + const data = { + 'total': 5, + 'collections': [],}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await vectorsDB.listCollections( + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method createCollection()', async () => { + const data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\$permissions': [], + 'databaseId': '5e5ea5c16897e', + 'name': 'My Collection', + 'enabled': true, + 'documentSecurity': true, + 'attributes': [], + 'indexes': [], + 'bytesMax': 65535, + 'bytesUsed': 1500, + 'dimension': 1536,}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await vectorsDB.createCollection( + '', + '', + '', + 1, + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method getCollection()', async () => { + const data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\$permissions': [], + 'databaseId': '5e5ea5c16897e', + 'name': 'My Collection', + 'enabled': true, + 'documentSecurity': true, + 'attributes': [], + 'indexes': [], + 'bytesMax': 65535, + 'bytesUsed': 1500, + 'dimension': 1536,}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await vectorsDB.getCollection( + '', + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method updateCollection()', async () => { + const data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\$permissions': [], + 'databaseId': '5e5ea5c16897e', + 'name': 'My Collection', + 'enabled': true, + 'documentSecurity': true, + 'attributes': [], + 'indexes': [], + 'bytesMax': 65535, + 'bytesUsed': 1500, + 'dimension': 1536,}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await vectorsDB.updateCollection( + '', + '', + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method deleteCollection()', async () => { + const data = {message: ""}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await vectorsDB.deleteCollection( + '', + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method listDocuments()', async () => { + const data = { + 'total': 5, + 'documents': [],}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await vectorsDB.listDocuments( + '', + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method createDocument()', async () => { + const data = { + '\$id': '5e5ea5c16897e', + '\$sequence': '1', + '\$collectionId': '5e5ea5c15117e', + '\$databaseId': '5e5ea5c15117e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\$permissions': [],}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await vectorsDB.createDocument( + '', + '', + '', + {}, + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method createDocuments()', async () => { + const data = { + 'total': 5, + 'documents': [],}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await vectorsDB.createDocuments( + '', + '', + [], + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method upsertDocuments()', async () => { + const data = { + 'total': 5, + 'documents': [],}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await vectorsDB.upsertDocuments( + '', + '', + [], + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method updateDocuments()', async () => { + const data = { + 'total': 5, + 'documents': [],}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await vectorsDB.updateDocuments( + '', + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method deleteDocuments()', async () => { + const data = { + 'total': 5, + 'documents': [],}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await vectorsDB.deleteDocuments( + '', + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method getDocument()', async () => { + const data = { + '\$id': '5e5ea5c16897e', + '\$sequence': '1', + '\$collectionId': '5e5ea5c15117e', + '\$databaseId': '5e5ea5c15117e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\$permissions': [],}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await vectorsDB.getDocument( + '', + '', + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method upsertDocument()', async () => { + const data = { + '\$id': '5e5ea5c16897e', + '\$sequence': '1', + '\$collectionId': '5e5ea5c15117e', + '\$databaseId': '5e5ea5c15117e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\$permissions': [],}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await vectorsDB.upsertDocument( + '', + '', + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method updateDocument()', async () => { + const data = { + '\$id': '5e5ea5c16897e', + '\$sequence': '1', + '\$collectionId': '5e5ea5c15117e', + '\$databaseId': '5e5ea5c15117e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\$permissions': [],}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await vectorsDB.updateDocument( + '', + '', + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method deleteDocument()', async () => { + const data = {message: ""}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await vectorsDB.deleteDocument( + '', + '', + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method listIndexes()', async () => { + const data = { + 'total': 5, + 'indexes': [],}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await vectorsDB.listIndexes( + '', + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method createIndex()', async () => { + const data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'key': 'index1', + 'type': 'primary', + 'status': 'available', + 'error': 'string', + 'attributes': [], + 'lengths': [],}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await vectorsDB.createIndex( + '', + '', + '', + 'hnsw_euclidean', + [], + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method getIndex()', async () => { + const data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'key': 'index1', + 'type': 'primary', + 'status': 'available', + 'error': 'string', + 'attributes': [], + 'lengths': [],}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await vectorsDB.getIndex( + '', + '', + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method deleteIndex()', async () => { + const data = {message: ""}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await vectorsDB.deleteIndex( + '', + '', + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + }) diff --git a/test/services/webhooks.test.js b/test/services/webhooks.test.js new file mode 100644 index 00000000..642b4a73 --- /dev/null +++ b/test/services/webhooks.test.js @@ -0,0 +1,155 @@ +const { Client } = require("../../dist/client"); +const { InputFile } = require("../../dist/inputFile"); +const { Webhooks } = require("../../dist/services/webhooks"); + +const { fetch: mockedFetch, Response } = require("node-fetch-native-with-agent"); +jest.mock('node-fetch-native-with-agent', () => ({ ...jest.requireActual('node-fetch-native-with-agent'), fetch: jest.fn() })); + +describe('Webhooks', () => { + const client = new Client(); + const webhooks = new Webhooks(client); + + + test('test method list()', async () => { + const data = { + 'total': 5, + 'webhooks': [],}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await webhooks.list( + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method create()', async () => { + const data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'name': 'My Webhook', + 'url': 'https://example.com/webhook', + 'events': [], + 'security': true, + 'httpUser': 'username', + 'httpPass': 'password', + 'signatureKey': 'ad3d581ca230e2b7059c545e5a', + 'enabled': true, + 'logs': 'Failed to connect to remote server.', + 'attempts': 10,}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await webhooks.create( + '', + '', + '', + [], + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method get()', async () => { + const data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'name': 'My Webhook', + 'url': 'https://example.com/webhook', + 'events': [], + 'security': true, + 'httpUser': 'username', + 'httpPass': 'password', + 'signatureKey': 'ad3d581ca230e2b7059c545e5a', + 'enabled': true, + 'logs': 'Failed to connect to remote server.', + 'attempts': 10,}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await webhooks.get( + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method update()', async () => { + const data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'name': 'My Webhook', + 'url': 'https://example.com/webhook', + 'events': [], + 'security': true, + 'httpUser': 'username', + 'httpPass': 'password', + 'signatureKey': 'ad3d581ca230e2b7059c545e5a', + 'enabled': true, + 'logs': 'Failed to connect to remote server.', + 'attempts': 10,}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await webhooks.update( + '', + '', + '', + [], + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method delete()', async () => { + const data = {message: ""}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await webhooks.delete( + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method updateSignature()', async () => { + const data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'name': 'My Webhook', + 'url': 'https://example.com/webhook', + 'events': [], + 'security': true, + 'httpUser': 'username', + 'httpPass': 'password', + 'signatureKey': 'ad3d581ca230e2b7059c545e5a', + 'enabled': true, + 'logs': 'Failed to connect to remote server.', + 'attempts': 10,}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await webhooks.updateSignature( + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + }) From 0e0805cd374de41bc38a27fda7de2ff2a591a74d Mon Sep 17 00:00:00 2001 From: root Date: Wed, 25 Mar 2026 04:24:58 +0000 Subject: [PATCH 2/9] chore: update Node.js SDK to 23.0.0 --- CHANGELOG.md | 5 +++-- README.md | 2 +- package.json | 2 +- src/client.ts | 4 ++-- 4 files changed, 7 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3b6ec129..43308acd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,8 +1,9 @@ # Change Log -## 22.1.3 +## 23.0.0 -* Updated `DocumentsDB` docs and `DatabasesIndexType` usage; bumped API version badge to 1.9.0 +* [BREAKING] Changed `$sequence` type from `int` to `string` for rows and documents +* Updated `DatabasesIndexType` usage; bumped API version badge to 1.9.0 ## 22.1.2 diff --git a/README.md b/README.md index 0a3903ad..08afc79c 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ [![Twitter Account](https://img.shields.io/twitter/follow/appwrite?color=00acee&label=twitter&style=flat-square)](https://twitter.com/appwrite) [![Discord](https://img.shields.io/discord/564160730845151244?label=discord&style=flat-square)](https://appwrite.io/discord) -**This SDK is compatible with Appwrite server version 1.8.x. For older versions, please check [previous releases](https://github.com/appwrite/sdk-for-node/releases).** +**This SDK is compatible with Appwrite server version 1.9.x. For older versions, please check [previous releases](https://github.com/appwrite/sdk-for-node/releases).** > This is the Node.js SDK for integrating with Appwrite from your Node.js server-side code. If you're looking to integrate from the browser, you should check [appwrite/sdk-for-web](https://github.com/appwrite/sdk-for-web) diff --git a/package.json b/package.json index 897b77ba..ba6c7eec 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "node-appwrite", "homepage": "https://appwrite.io/support", "description": "Appwrite is an open-source self-hosted backend server that abstracts and simplifies complex and repetitive development tasks behind a very simple REST API", - "version": "22.1.3", + "version": "23.0.0", "license": "BSD-3-Clause", "main": "dist/index.js", "type": "commonjs", diff --git a/src/client.ts b/src/client.ts index d427cbc3..75a63a91 100644 --- a/src/client.ts +++ b/src/client.ts @@ -73,7 +73,7 @@ class AppwriteException extends Error { } function getUserAgent() { - let ua = 'AppwriteNodeJSSDK/22.1.3'; + let ua = 'AppwriteNodeJSSDK/23.0.0'; // `process` is a global in Node.js, but not fully available in all runtimes. const platform: string[] = []; @@ -125,7 +125,7 @@ class Client { 'x-sdk-name': 'Node.js', 'x-sdk-platform': 'server', 'x-sdk-language': 'nodejs', - 'x-sdk-version': '22.1.3', + 'x-sdk-version': '23.0.0', 'user-agent' : getUserAgent(), 'X-Appwrite-Response-Format': '1.9.0', }; From 8f72c8c1dd9c8f1458de784743566d2f324b95b8 Mon Sep 17 00:00:00 2001 From: root Date: Wed, 25 Mar 2026 05:26:53 +0000 Subject: [PATCH 3/9] chore: update Node.js SDK to 23.0.0 --- .../examples/documentsdb/create-collection.md | 21 - docs/examples/documentsdb/create-document.md | 24 - docs/examples/documentsdb/create-documents.md | 16 - docs/examples/documentsdb/create-index.md | 20 - .../examples/documentsdb/create-operations.md | 25 - .../documentsdb/create-transaction.md | 14 - docs/examples/documentsdb/create.md | 16 - .../decrement-document-attribute.md | 20 - .../examples/documentsdb/delete-collection.md | 15 - docs/examples/documentsdb/delete-document.md | 17 - docs/examples/documentsdb/delete-documents.md | 17 - docs/examples/documentsdb/delete-index.md | 16 - .../documentsdb/delete-transaction.md | 14 - docs/examples/documentsdb/delete.md | 14 - docs/examples/documentsdb/get-collection.md | 15 - docs/examples/documentsdb/get-document.md | 18 - docs/examples/documentsdb/get-index.md | 16 - docs/examples/documentsdb/get-transaction.md | 14 - docs/examples/documentsdb/get.md | 14 - .../increment-document-attribute.md | 20 - docs/examples/documentsdb/list-collections.md | 17 - docs/examples/documentsdb/list-documents.md | 19 - docs/examples/documentsdb/list-indexes.md | 17 - .../examples/documentsdb/list-transactions.md | 14 - docs/examples/documentsdb/list.md | 16 - .../examples/documentsdb/update-collection.md | 19 - docs/examples/documentsdb/update-document.md | 19 - docs/examples/documentsdb/update-documents.md | 18 - .../documentsdb/update-transaction.md | 16 - docs/examples/documentsdb/update.md | 16 - docs/examples/documentsdb/upsert-document.md | 19 - docs/examples/documentsdb/upsert-documents.md | 17 - docs/examples/vectorsdb/create-collection.md | 20 - docs/examples/vectorsdb/create-document.md | 28 - docs/examples/vectorsdb/create-documents.md | 16 - docs/examples/vectorsdb/create-index.md | 20 - docs/examples/vectorsdb/create-operations.md | 25 - .../vectorsdb/create-text-embeddings.md | 15 - docs/examples/vectorsdb/create-transaction.md | 14 - docs/examples/vectorsdb/create.md | 16 - docs/examples/vectorsdb/delete-collection.md | 15 - docs/examples/vectorsdb/delete-document.md | 17 - docs/examples/vectorsdb/delete-documents.md | 17 - docs/examples/vectorsdb/delete-index.md | 16 - docs/examples/vectorsdb/delete-transaction.md | 14 - docs/examples/vectorsdb/delete.md | 14 - docs/examples/vectorsdb/get-collection.md | 15 - docs/examples/vectorsdb/get-document.md | 18 - docs/examples/vectorsdb/get-index.md | 16 - docs/examples/vectorsdb/get-transaction.md | 14 - docs/examples/vectorsdb/get.md | 14 - docs/examples/vectorsdb/list-collections.md | 17 - docs/examples/vectorsdb/list-documents.md | 19 - docs/examples/vectorsdb/list-indexes.md | 17 - docs/examples/vectorsdb/list-transactions.md | 14 - docs/examples/vectorsdb/list.md | 16 - docs/examples/vectorsdb/update-collection.md | 20 - docs/examples/vectorsdb/update-document.md | 19 - docs/examples/vectorsdb/update-documents.md | 18 - docs/examples/vectorsdb/update-transaction.md | 16 - docs/examples/vectorsdb/update.md | 16 - docs/examples/vectorsdb/upsert-document.md | 19 - docs/examples/vectorsdb/upsert-documents.md | 17 - src/index.ts | 2 - src/services/documents-db.ts | 2349 ----------------- src/services/vectors-db.ts | 2170 --------------- test/services/documents-d-b.test.js | 660 ----- test/services/vectors-d-b.test.js | 632 ----- 68 files changed, 6898 deletions(-) delete mode 100644 docs/examples/documentsdb/create-collection.md delete mode 100644 docs/examples/documentsdb/create-document.md delete mode 100644 docs/examples/documentsdb/create-documents.md delete mode 100644 docs/examples/documentsdb/create-index.md delete mode 100644 docs/examples/documentsdb/create-operations.md delete mode 100644 docs/examples/documentsdb/create-transaction.md delete mode 100644 docs/examples/documentsdb/create.md delete mode 100644 docs/examples/documentsdb/decrement-document-attribute.md delete mode 100644 docs/examples/documentsdb/delete-collection.md delete mode 100644 docs/examples/documentsdb/delete-document.md delete mode 100644 docs/examples/documentsdb/delete-documents.md delete mode 100644 docs/examples/documentsdb/delete-index.md delete mode 100644 docs/examples/documentsdb/delete-transaction.md delete mode 100644 docs/examples/documentsdb/delete.md delete mode 100644 docs/examples/documentsdb/get-collection.md delete mode 100644 docs/examples/documentsdb/get-document.md delete mode 100644 docs/examples/documentsdb/get-index.md delete mode 100644 docs/examples/documentsdb/get-transaction.md delete mode 100644 docs/examples/documentsdb/get.md delete mode 100644 docs/examples/documentsdb/increment-document-attribute.md delete mode 100644 docs/examples/documentsdb/list-collections.md delete mode 100644 docs/examples/documentsdb/list-documents.md delete mode 100644 docs/examples/documentsdb/list-indexes.md delete mode 100644 docs/examples/documentsdb/list-transactions.md delete mode 100644 docs/examples/documentsdb/list.md delete mode 100644 docs/examples/documentsdb/update-collection.md delete mode 100644 docs/examples/documentsdb/update-document.md delete mode 100644 docs/examples/documentsdb/update-documents.md delete mode 100644 docs/examples/documentsdb/update-transaction.md delete mode 100644 docs/examples/documentsdb/update.md delete mode 100644 docs/examples/documentsdb/upsert-document.md delete mode 100644 docs/examples/documentsdb/upsert-documents.md delete mode 100644 docs/examples/vectorsdb/create-collection.md delete mode 100644 docs/examples/vectorsdb/create-document.md delete mode 100644 docs/examples/vectorsdb/create-documents.md delete mode 100644 docs/examples/vectorsdb/create-index.md delete mode 100644 docs/examples/vectorsdb/create-operations.md delete mode 100644 docs/examples/vectorsdb/create-text-embeddings.md delete mode 100644 docs/examples/vectorsdb/create-transaction.md delete mode 100644 docs/examples/vectorsdb/create.md delete mode 100644 docs/examples/vectorsdb/delete-collection.md delete mode 100644 docs/examples/vectorsdb/delete-document.md delete mode 100644 docs/examples/vectorsdb/delete-documents.md delete mode 100644 docs/examples/vectorsdb/delete-index.md delete mode 100644 docs/examples/vectorsdb/delete-transaction.md delete mode 100644 docs/examples/vectorsdb/delete.md delete mode 100644 docs/examples/vectorsdb/get-collection.md delete mode 100644 docs/examples/vectorsdb/get-document.md delete mode 100644 docs/examples/vectorsdb/get-index.md delete mode 100644 docs/examples/vectorsdb/get-transaction.md delete mode 100644 docs/examples/vectorsdb/get.md delete mode 100644 docs/examples/vectorsdb/list-collections.md delete mode 100644 docs/examples/vectorsdb/list-documents.md delete mode 100644 docs/examples/vectorsdb/list-indexes.md delete mode 100644 docs/examples/vectorsdb/list-transactions.md delete mode 100644 docs/examples/vectorsdb/list.md delete mode 100644 docs/examples/vectorsdb/update-collection.md delete mode 100644 docs/examples/vectorsdb/update-document.md delete mode 100644 docs/examples/vectorsdb/update-documents.md delete mode 100644 docs/examples/vectorsdb/update-transaction.md delete mode 100644 docs/examples/vectorsdb/update.md delete mode 100644 docs/examples/vectorsdb/upsert-document.md delete mode 100644 docs/examples/vectorsdb/upsert-documents.md delete mode 100644 src/services/documents-db.ts delete mode 100644 src/services/vectors-db.ts delete mode 100644 test/services/documents-d-b.test.js delete mode 100644 test/services/vectors-d-b.test.js diff --git a/docs/examples/documentsdb/create-collection.md b/docs/examples/documentsdb/create-collection.md deleted file mode 100644 index 6e25ad42..00000000 --- a/docs/examples/documentsdb/create-collection.md +++ /dev/null @@ -1,21 +0,0 @@ -```javascript -const sdk = require('node-appwrite'); - -const client = new sdk.Client() - .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - .setProject('') // Your project ID - .setKey(''); // Your secret API key - -const documentsDB = new sdk.DocumentsDB(client); - -const result = await documentsDB.createCollection({ - databaseId: '', - collectionId: '', - name: '', - permissions: [sdk.Permission.read(sdk.Role.any())], // optional - documentSecurity: false, // optional - enabled: false, // optional - attributes: [], // optional - indexes: [] // optional -}); -``` diff --git a/docs/examples/documentsdb/create-document.md b/docs/examples/documentsdb/create-document.md deleted file mode 100644 index 62daf212..00000000 --- a/docs/examples/documentsdb/create-document.md +++ /dev/null @@ -1,24 +0,0 @@ -```javascript -const sdk = require('node-appwrite'); - -const client = new sdk.Client() - .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - .setProject('') // Your project ID - .setSession(''); // The user session to authenticate with - -const documentsDB = new sdk.DocumentsDB(client); - -const result = await documentsDB.createDocument({ - databaseId: '', - collectionId: '', - documentId: '', - data: { - "username": "walter.obrien", - "email": "walter.obrien@example.com", - "fullName": "Walter O'Brien", - "age": 30, - "isAdmin": false - }, - permissions: [sdk.Permission.read(sdk.Role.any())] // optional -}); -``` diff --git a/docs/examples/documentsdb/create-documents.md b/docs/examples/documentsdb/create-documents.md deleted file mode 100644 index c990675c..00000000 --- a/docs/examples/documentsdb/create-documents.md +++ /dev/null @@ -1,16 +0,0 @@ -```javascript -const sdk = require('node-appwrite'); - -const client = new sdk.Client() - .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - .setProject('') // Your project ID - .setSession(''); // The user session to authenticate with - -const documentsDB = new sdk.DocumentsDB(client); - -const result = await documentsDB.createDocuments({ - databaseId: '', - collectionId: '', - documents: [] -}); -``` diff --git a/docs/examples/documentsdb/create-index.md b/docs/examples/documentsdb/create-index.md deleted file mode 100644 index bece398c..00000000 --- a/docs/examples/documentsdb/create-index.md +++ /dev/null @@ -1,20 +0,0 @@ -```javascript -const sdk = require('node-appwrite'); - -const client = new sdk.Client() - .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - .setProject('') // Your project ID - .setKey(''); // Your secret API key - -const documentsDB = new sdk.DocumentsDB(client); - -const result = await documentsDB.createIndex({ - databaseId: '', - collectionId: '', - key: '', - type: sdk.DocumentsDBIndexType.Key, - attributes: [], - orders: [sdk.OrderBy.Asc], // optional - lengths: [] // optional -}); -``` diff --git a/docs/examples/documentsdb/create-operations.md b/docs/examples/documentsdb/create-operations.md deleted file mode 100644 index 464cc672..00000000 --- a/docs/examples/documentsdb/create-operations.md +++ /dev/null @@ -1,25 +0,0 @@ -```javascript -const sdk = require('node-appwrite'); - -const client = new sdk.Client() - .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - .setProject('') // Your project ID - .setKey(''); // Your secret API key - -const documentsDB = new sdk.DocumentsDB(client); - -const result = await documentsDB.createOperations({ - transactionId: '', - operations: [ - { - "action": "create", - "databaseId": "", - "collectionId": "", - "documentId": "", - "data": { - "name": "Walter O'Brien" - } - } - ] // optional -}); -``` diff --git a/docs/examples/documentsdb/create-transaction.md b/docs/examples/documentsdb/create-transaction.md deleted file mode 100644 index 73bbb2fa..00000000 --- a/docs/examples/documentsdb/create-transaction.md +++ /dev/null @@ -1,14 +0,0 @@ -```javascript -const sdk = require('node-appwrite'); - -const client = new sdk.Client() - .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - .setProject('') // Your project ID - .setKey(''); // Your secret API key - -const documentsDB = new sdk.DocumentsDB(client); - -const result = await documentsDB.createTransaction({ - ttl: 60 // optional -}); -``` diff --git a/docs/examples/documentsdb/create.md b/docs/examples/documentsdb/create.md deleted file mode 100644 index d6eb4357..00000000 --- a/docs/examples/documentsdb/create.md +++ /dev/null @@ -1,16 +0,0 @@ -```javascript -const sdk = require('node-appwrite'); - -const client = new sdk.Client() - .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - .setProject('') // Your project ID - .setKey(''); // Your secret API key - -const documentsDB = new sdk.DocumentsDB(client); - -const result = await documentsDB.create({ - databaseId: '', - name: '', - enabled: false // optional -}); -``` diff --git a/docs/examples/documentsdb/decrement-document-attribute.md b/docs/examples/documentsdb/decrement-document-attribute.md deleted file mode 100644 index 1f3f8dc2..00000000 --- a/docs/examples/documentsdb/decrement-document-attribute.md +++ /dev/null @@ -1,20 +0,0 @@ -```javascript -const sdk = require('node-appwrite'); - -const client = new sdk.Client() - .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - .setProject('') // Your project ID - .setSession(''); // The user session to authenticate with - -const documentsDB = new sdk.DocumentsDB(client); - -const result = await documentsDB.decrementDocumentAttribute({ - databaseId: '', - collectionId: '', - documentId: '', - attribute: '', - value: null, // optional - min: null, // optional - transactionId: '' // optional -}); -``` diff --git a/docs/examples/documentsdb/delete-collection.md b/docs/examples/documentsdb/delete-collection.md deleted file mode 100644 index 44cb7cc2..00000000 --- a/docs/examples/documentsdb/delete-collection.md +++ /dev/null @@ -1,15 +0,0 @@ -```javascript -const sdk = require('node-appwrite'); - -const client = new sdk.Client() - .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - .setProject('') // Your project ID - .setKey(''); // Your secret API key - -const documentsDB = new sdk.DocumentsDB(client); - -const result = await documentsDB.deleteCollection({ - databaseId: '', - collectionId: '' -}); -``` diff --git a/docs/examples/documentsdb/delete-document.md b/docs/examples/documentsdb/delete-document.md deleted file mode 100644 index 05363fc7..00000000 --- a/docs/examples/documentsdb/delete-document.md +++ /dev/null @@ -1,17 +0,0 @@ -```javascript -const sdk = require('node-appwrite'); - -const client = new sdk.Client() - .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - .setProject('') // Your project ID - .setSession(''); // The user session to authenticate with - -const documentsDB = new sdk.DocumentsDB(client); - -const result = await documentsDB.deleteDocument({ - databaseId: '', - collectionId: '', - documentId: '', - transactionId: '' // optional -}); -``` diff --git a/docs/examples/documentsdb/delete-documents.md b/docs/examples/documentsdb/delete-documents.md deleted file mode 100644 index 9c9d0201..00000000 --- a/docs/examples/documentsdb/delete-documents.md +++ /dev/null @@ -1,17 +0,0 @@ -```javascript -const sdk = require('node-appwrite'); - -const client = new sdk.Client() - .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - .setProject('') // Your project ID - .setKey(''); // Your secret API key - -const documentsDB = new sdk.DocumentsDB(client); - -const result = await documentsDB.deleteDocuments({ - databaseId: '', - collectionId: '', - queries: [], // optional - transactionId: '' // optional -}); -``` diff --git a/docs/examples/documentsdb/delete-index.md b/docs/examples/documentsdb/delete-index.md deleted file mode 100644 index cfdfd3e2..00000000 --- a/docs/examples/documentsdb/delete-index.md +++ /dev/null @@ -1,16 +0,0 @@ -```javascript -const sdk = require('node-appwrite'); - -const client = new sdk.Client() - .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - .setProject('') // Your project ID - .setKey(''); // Your secret API key - -const documentsDB = new sdk.DocumentsDB(client); - -const result = await documentsDB.deleteIndex({ - databaseId: '', - collectionId: '', - key: '' -}); -``` diff --git a/docs/examples/documentsdb/delete-transaction.md b/docs/examples/documentsdb/delete-transaction.md deleted file mode 100644 index a8b1e9ec..00000000 --- a/docs/examples/documentsdb/delete-transaction.md +++ /dev/null @@ -1,14 +0,0 @@ -```javascript -const sdk = require('node-appwrite'); - -const client = new sdk.Client() - .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - .setProject('') // Your project ID - .setKey(''); // Your secret API key - -const documentsDB = new sdk.DocumentsDB(client); - -const result = await documentsDB.deleteTransaction({ - transactionId: '' -}); -``` diff --git a/docs/examples/documentsdb/delete.md b/docs/examples/documentsdb/delete.md deleted file mode 100644 index 9f6d6c88..00000000 --- a/docs/examples/documentsdb/delete.md +++ /dev/null @@ -1,14 +0,0 @@ -```javascript -const sdk = require('node-appwrite'); - -const client = new sdk.Client() - .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - .setProject('') // Your project ID - .setKey(''); // Your secret API key - -const documentsDB = new sdk.DocumentsDB(client); - -const result = await documentsDB.delete({ - databaseId: '' -}); -``` diff --git a/docs/examples/documentsdb/get-collection.md b/docs/examples/documentsdb/get-collection.md deleted file mode 100644 index 49b419c1..00000000 --- a/docs/examples/documentsdb/get-collection.md +++ /dev/null @@ -1,15 +0,0 @@ -```javascript -const sdk = require('node-appwrite'); - -const client = new sdk.Client() - .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - .setProject('') // Your project ID - .setKey(''); // Your secret API key - -const documentsDB = new sdk.DocumentsDB(client); - -const result = await documentsDB.getCollection({ - databaseId: '', - collectionId: '' -}); -``` diff --git a/docs/examples/documentsdb/get-document.md b/docs/examples/documentsdb/get-document.md deleted file mode 100644 index 7ef838c8..00000000 --- a/docs/examples/documentsdb/get-document.md +++ /dev/null @@ -1,18 +0,0 @@ -```javascript -const sdk = require('node-appwrite'); - -const client = new sdk.Client() - .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - .setProject('') // Your project ID - .setSession(''); // The user session to authenticate with - -const documentsDB = new sdk.DocumentsDB(client); - -const result = await documentsDB.getDocument({ - databaseId: '', - collectionId: '', - documentId: '', - queries: [], // optional - transactionId: '' // optional -}); -``` diff --git a/docs/examples/documentsdb/get-index.md b/docs/examples/documentsdb/get-index.md deleted file mode 100644 index a44b6d08..00000000 --- a/docs/examples/documentsdb/get-index.md +++ /dev/null @@ -1,16 +0,0 @@ -```javascript -const sdk = require('node-appwrite'); - -const client = new sdk.Client() - .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - .setProject('') // Your project ID - .setKey(''); // Your secret API key - -const documentsDB = new sdk.DocumentsDB(client); - -const result = await documentsDB.getIndex({ - databaseId: '', - collectionId: '', - key: '' -}); -``` diff --git a/docs/examples/documentsdb/get-transaction.md b/docs/examples/documentsdb/get-transaction.md deleted file mode 100644 index 74de2fc0..00000000 --- a/docs/examples/documentsdb/get-transaction.md +++ /dev/null @@ -1,14 +0,0 @@ -```javascript -const sdk = require('node-appwrite'); - -const client = new sdk.Client() - .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - .setProject('') // Your project ID - .setKey(''); // Your secret API key - -const documentsDB = new sdk.DocumentsDB(client); - -const result = await documentsDB.getTransaction({ - transactionId: '' -}); -``` diff --git a/docs/examples/documentsdb/get.md b/docs/examples/documentsdb/get.md deleted file mode 100644 index 5b867708..00000000 --- a/docs/examples/documentsdb/get.md +++ /dev/null @@ -1,14 +0,0 @@ -```javascript -const sdk = require('node-appwrite'); - -const client = new sdk.Client() - .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - .setProject('') // Your project ID - .setKey(''); // Your secret API key - -const documentsDB = new sdk.DocumentsDB(client); - -const result = await documentsDB.get({ - databaseId: '' -}); -``` diff --git a/docs/examples/documentsdb/increment-document-attribute.md b/docs/examples/documentsdb/increment-document-attribute.md deleted file mode 100644 index 931d73c0..00000000 --- a/docs/examples/documentsdb/increment-document-attribute.md +++ /dev/null @@ -1,20 +0,0 @@ -```javascript -const sdk = require('node-appwrite'); - -const client = new sdk.Client() - .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - .setProject('') // Your project ID - .setSession(''); // The user session to authenticate with - -const documentsDB = new sdk.DocumentsDB(client); - -const result = await documentsDB.incrementDocumentAttribute({ - databaseId: '', - collectionId: '', - documentId: '', - attribute: '', - value: null, // optional - max: null, // optional - transactionId: '' // optional -}); -``` diff --git a/docs/examples/documentsdb/list-collections.md b/docs/examples/documentsdb/list-collections.md deleted file mode 100644 index d640873e..00000000 --- a/docs/examples/documentsdb/list-collections.md +++ /dev/null @@ -1,17 +0,0 @@ -```javascript -const sdk = require('node-appwrite'); - -const client = new sdk.Client() - .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - .setProject('') // Your project ID - .setKey(''); // Your secret API key - -const documentsDB = new sdk.DocumentsDB(client); - -const result = await documentsDB.listCollections({ - databaseId: '', - queries: [], // optional - search: '', // optional - total: false // optional -}); -``` diff --git a/docs/examples/documentsdb/list-documents.md b/docs/examples/documentsdb/list-documents.md deleted file mode 100644 index 5d061737..00000000 --- a/docs/examples/documentsdb/list-documents.md +++ /dev/null @@ -1,19 +0,0 @@ -```javascript -const sdk = require('node-appwrite'); - -const client = new sdk.Client() - .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - .setProject('') // Your project ID - .setSession(''); // The user session to authenticate with - -const documentsDB = new sdk.DocumentsDB(client); - -const result = await documentsDB.listDocuments({ - databaseId: '', - collectionId: '', - queries: [], // optional - transactionId: '', // optional - total: false, // optional - ttl: 0 // optional -}); -``` diff --git a/docs/examples/documentsdb/list-indexes.md b/docs/examples/documentsdb/list-indexes.md deleted file mode 100644 index 35c48a84..00000000 --- a/docs/examples/documentsdb/list-indexes.md +++ /dev/null @@ -1,17 +0,0 @@ -```javascript -const sdk = require('node-appwrite'); - -const client = new sdk.Client() - .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - .setProject('') // Your project ID - .setKey(''); // Your secret API key - -const documentsDB = new sdk.DocumentsDB(client); - -const result = await documentsDB.listIndexes({ - databaseId: '', - collectionId: '', - queries: [], // optional - total: false // optional -}); -``` diff --git a/docs/examples/documentsdb/list-transactions.md b/docs/examples/documentsdb/list-transactions.md deleted file mode 100644 index 5caad1f5..00000000 --- a/docs/examples/documentsdb/list-transactions.md +++ /dev/null @@ -1,14 +0,0 @@ -```javascript -const sdk = require('node-appwrite'); - -const client = new sdk.Client() - .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - .setProject('') // Your project ID - .setKey(''); // Your secret API key - -const documentsDB = new sdk.DocumentsDB(client); - -const result = await documentsDB.listTransactions({ - queries: [] // optional -}); -``` diff --git a/docs/examples/documentsdb/list.md b/docs/examples/documentsdb/list.md deleted file mode 100644 index 70ce780c..00000000 --- a/docs/examples/documentsdb/list.md +++ /dev/null @@ -1,16 +0,0 @@ -```javascript -const sdk = require('node-appwrite'); - -const client = new sdk.Client() - .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - .setProject('') // Your project ID - .setKey(''); // Your secret API key - -const documentsDB = new sdk.DocumentsDB(client); - -const result = await documentsDB.list({ - queries: [], // optional - search: '', // optional - total: false // optional -}); -``` diff --git a/docs/examples/documentsdb/update-collection.md b/docs/examples/documentsdb/update-collection.md deleted file mode 100644 index 48ba26f9..00000000 --- a/docs/examples/documentsdb/update-collection.md +++ /dev/null @@ -1,19 +0,0 @@ -```javascript -const sdk = require('node-appwrite'); - -const client = new sdk.Client() - .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - .setProject('') // Your project ID - .setKey(''); // Your secret API key - -const documentsDB = new sdk.DocumentsDB(client); - -const result = await documentsDB.updateCollection({ - databaseId: '', - collectionId: '', - name: '', - permissions: [sdk.Permission.read(sdk.Role.any())], // optional - documentSecurity: false, // optional - enabled: false // optional -}); -``` diff --git a/docs/examples/documentsdb/update-document.md b/docs/examples/documentsdb/update-document.md deleted file mode 100644 index 17e2d8ff..00000000 --- a/docs/examples/documentsdb/update-document.md +++ /dev/null @@ -1,19 +0,0 @@ -```javascript -const sdk = require('node-appwrite'); - -const client = new sdk.Client() - .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - .setProject('') // Your project ID - .setSession(''); // The user session to authenticate with - -const documentsDB = new sdk.DocumentsDB(client); - -const result = await documentsDB.updateDocument({ - databaseId: '', - collectionId: '', - documentId: '', - data: {}, // optional - permissions: [sdk.Permission.read(sdk.Role.any())], // optional - transactionId: '' // optional -}); -``` diff --git a/docs/examples/documentsdb/update-documents.md b/docs/examples/documentsdb/update-documents.md deleted file mode 100644 index bb5869e6..00000000 --- a/docs/examples/documentsdb/update-documents.md +++ /dev/null @@ -1,18 +0,0 @@ -```javascript -const sdk = require('node-appwrite'); - -const client = new sdk.Client() - .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - .setProject('') // Your project ID - .setKey(''); // Your secret API key - -const documentsDB = new sdk.DocumentsDB(client); - -const result = await documentsDB.updateDocuments({ - databaseId: '', - collectionId: '', - data: {}, // optional - queries: [], // optional - transactionId: '' // optional -}); -``` diff --git a/docs/examples/documentsdb/update-transaction.md b/docs/examples/documentsdb/update-transaction.md deleted file mode 100644 index 2d5c1d65..00000000 --- a/docs/examples/documentsdb/update-transaction.md +++ /dev/null @@ -1,16 +0,0 @@ -```javascript -const sdk = require('node-appwrite'); - -const client = new sdk.Client() - .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - .setProject('') // Your project ID - .setKey(''); // Your secret API key - -const documentsDB = new sdk.DocumentsDB(client); - -const result = await documentsDB.updateTransaction({ - transactionId: '', - commit: false, // optional - rollback: false // optional -}); -``` diff --git a/docs/examples/documentsdb/update.md b/docs/examples/documentsdb/update.md deleted file mode 100644 index bc41f2e8..00000000 --- a/docs/examples/documentsdb/update.md +++ /dev/null @@ -1,16 +0,0 @@ -```javascript -const sdk = require('node-appwrite'); - -const client = new sdk.Client() - .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - .setProject('') // Your project ID - .setKey(''); // Your secret API key - -const documentsDB = new sdk.DocumentsDB(client); - -const result = await documentsDB.update({ - databaseId: '', - name: '', - enabled: false // optional -}); -``` diff --git a/docs/examples/documentsdb/upsert-document.md b/docs/examples/documentsdb/upsert-document.md deleted file mode 100644 index 27d66b3b..00000000 --- a/docs/examples/documentsdb/upsert-document.md +++ /dev/null @@ -1,19 +0,0 @@ -```javascript -const sdk = require('node-appwrite'); - -const client = new sdk.Client() - .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - .setProject('') // Your project ID - .setSession(''); // The user session to authenticate with - -const documentsDB = new sdk.DocumentsDB(client); - -const result = await documentsDB.upsertDocument({ - databaseId: '', - collectionId: '', - documentId: '', - data: {}, // optional - permissions: [sdk.Permission.read(sdk.Role.any())], // optional - transactionId: '' // optional -}); -``` diff --git a/docs/examples/documentsdb/upsert-documents.md b/docs/examples/documentsdb/upsert-documents.md deleted file mode 100644 index 5efd848f..00000000 --- a/docs/examples/documentsdb/upsert-documents.md +++ /dev/null @@ -1,17 +0,0 @@ -```javascript -const sdk = require('node-appwrite'); - -const client = new sdk.Client() - .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - .setProject('') // Your project ID - .setKey(''); // Your secret API key - -const documentsDB = new sdk.DocumentsDB(client); - -const result = await documentsDB.upsertDocuments({ - databaseId: '', - collectionId: '', - documents: [], - transactionId: '' // optional -}); -``` diff --git a/docs/examples/vectorsdb/create-collection.md b/docs/examples/vectorsdb/create-collection.md deleted file mode 100644 index 8745693d..00000000 --- a/docs/examples/vectorsdb/create-collection.md +++ /dev/null @@ -1,20 +0,0 @@ -```javascript -const sdk = require('node-appwrite'); - -const client = new sdk.Client() - .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - .setProject('') // Your project ID - .setKey(''); // Your secret API key - -const vectorsDB = new sdk.VectorsDB(client); - -const result = await vectorsDB.createCollection({ - databaseId: '', - collectionId: '', - name: '', - dimension: 1, - permissions: [sdk.Permission.read(sdk.Role.any())], // optional - documentSecurity: false, // optional - enabled: false // optional -}); -``` diff --git a/docs/examples/vectorsdb/create-document.md b/docs/examples/vectorsdb/create-document.md deleted file mode 100644 index dc007a91..00000000 --- a/docs/examples/vectorsdb/create-document.md +++ /dev/null @@ -1,28 +0,0 @@ -```javascript -const sdk = require('node-appwrite'); - -const client = new sdk.Client() - .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - .setProject('') // Your project ID - .setSession(''); // The user session to authenticate with - -const vectorsDB = new sdk.VectorsDB(client); - -const result = await vectorsDB.createDocument({ - databaseId: '', - collectionId: '', - documentId: '', - data: { - "embeddings": [ - 0.12, - -0.55, - 0.88, - 1.02 - ], - "metadata": { - "key": "value" - } - }, - permissions: [sdk.Permission.read(sdk.Role.any())] // optional -}); -``` diff --git a/docs/examples/vectorsdb/create-documents.md b/docs/examples/vectorsdb/create-documents.md deleted file mode 100644 index 04cad8ca..00000000 --- a/docs/examples/vectorsdb/create-documents.md +++ /dev/null @@ -1,16 +0,0 @@ -```javascript -const sdk = require('node-appwrite'); - -const client = new sdk.Client() - .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - .setProject('') // Your project ID - .setKey(''); // Your secret API key - -const vectorsDB = new sdk.VectorsDB(client); - -const result = await vectorsDB.createDocuments({ - databaseId: '', - collectionId: '', - documents: [] -}); -``` diff --git a/docs/examples/vectorsdb/create-index.md b/docs/examples/vectorsdb/create-index.md deleted file mode 100644 index b865aa6f..00000000 --- a/docs/examples/vectorsdb/create-index.md +++ /dev/null @@ -1,20 +0,0 @@ -```javascript -const sdk = require('node-appwrite'); - -const client = new sdk.Client() - .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - .setProject('') // Your project ID - .setKey(''); // Your secret API key - -const vectorsDB = new sdk.VectorsDB(client); - -const result = await vectorsDB.createIndex({ - databaseId: '', - collectionId: '', - key: '', - type: sdk.VectorsDBIndexType.HnswEuclidean, - attributes: [], - orders: [sdk.OrderBy.Asc], // optional - lengths: [] // optional -}); -``` diff --git a/docs/examples/vectorsdb/create-operations.md b/docs/examples/vectorsdb/create-operations.md deleted file mode 100644 index f8858957..00000000 --- a/docs/examples/vectorsdb/create-operations.md +++ /dev/null @@ -1,25 +0,0 @@ -```javascript -const sdk = require('node-appwrite'); - -const client = new sdk.Client() - .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - .setProject('') // Your project ID - .setKey(''); // Your secret API key - -const vectorsDB = new sdk.VectorsDB(client); - -const result = await vectorsDB.createOperations({ - transactionId: '', - operations: [ - { - "action": "create", - "databaseId": "", - "collectionId": "", - "documentId": "", - "data": { - "name": "Walter O'Brien" - } - } - ] // optional -}); -``` diff --git a/docs/examples/vectorsdb/create-text-embeddings.md b/docs/examples/vectorsdb/create-text-embeddings.md deleted file mode 100644 index 1afac117..00000000 --- a/docs/examples/vectorsdb/create-text-embeddings.md +++ /dev/null @@ -1,15 +0,0 @@ -```javascript -const sdk = require('node-appwrite'); - -const client = new sdk.Client() - .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - .setProject('') // Your project ID - .setKey(''); // Your secret API key - -const vectorsDB = new sdk.VectorsDB(client); - -const result = await vectorsDB.createTextEmbeddings({ - texts: [], - model: sdk.Model.Embeddinggemma // optional -}); -``` diff --git a/docs/examples/vectorsdb/create-transaction.md b/docs/examples/vectorsdb/create-transaction.md deleted file mode 100644 index ef39679c..00000000 --- a/docs/examples/vectorsdb/create-transaction.md +++ /dev/null @@ -1,14 +0,0 @@ -```javascript -const sdk = require('node-appwrite'); - -const client = new sdk.Client() - .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - .setProject('') // Your project ID - .setKey(''); // Your secret API key - -const vectorsDB = new sdk.VectorsDB(client); - -const result = await vectorsDB.createTransaction({ - ttl: 60 // optional -}); -``` diff --git a/docs/examples/vectorsdb/create.md b/docs/examples/vectorsdb/create.md deleted file mode 100644 index e7177fa5..00000000 --- a/docs/examples/vectorsdb/create.md +++ /dev/null @@ -1,16 +0,0 @@ -```javascript -const sdk = require('node-appwrite'); - -const client = new sdk.Client() - .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - .setProject('') // Your project ID - .setKey(''); // Your secret API key - -const vectorsDB = new sdk.VectorsDB(client); - -const result = await vectorsDB.create({ - databaseId: '', - name: '', - enabled: false // optional -}); -``` diff --git a/docs/examples/vectorsdb/delete-collection.md b/docs/examples/vectorsdb/delete-collection.md deleted file mode 100644 index 5e66e78d..00000000 --- a/docs/examples/vectorsdb/delete-collection.md +++ /dev/null @@ -1,15 +0,0 @@ -```javascript -const sdk = require('node-appwrite'); - -const client = new sdk.Client() - .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - .setProject('') // Your project ID - .setKey(''); // Your secret API key - -const vectorsDB = new sdk.VectorsDB(client); - -const result = await vectorsDB.deleteCollection({ - databaseId: '', - collectionId: '' -}); -``` diff --git a/docs/examples/vectorsdb/delete-document.md b/docs/examples/vectorsdb/delete-document.md deleted file mode 100644 index 0e115e86..00000000 --- a/docs/examples/vectorsdb/delete-document.md +++ /dev/null @@ -1,17 +0,0 @@ -```javascript -const sdk = require('node-appwrite'); - -const client = new sdk.Client() - .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - .setProject('') // Your project ID - .setSession(''); // The user session to authenticate with - -const vectorsDB = new sdk.VectorsDB(client); - -const result = await vectorsDB.deleteDocument({ - databaseId: '', - collectionId: '', - documentId: '', - transactionId: '' // optional -}); -``` diff --git a/docs/examples/vectorsdb/delete-documents.md b/docs/examples/vectorsdb/delete-documents.md deleted file mode 100644 index 7c8d2eca..00000000 --- a/docs/examples/vectorsdb/delete-documents.md +++ /dev/null @@ -1,17 +0,0 @@ -```javascript -const sdk = require('node-appwrite'); - -const client = new sdk.Client() - .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - .setProject('') // Your project ID - .setKey(''); // Your secret API key - -const vectorsDB = new sdk.VectorsDB(client); - -const result = await vectorsDB.deleteDocuments({ - databaseId: '', - collectionId: '', - queries: [], // optional - transactionId: '' // optional -}); -``` diff --git a/docs/examples/vectorsdb/delete-index.md b/docs/examples/vectorsdb/delete-index.md deleted file mode 100644 index 8c09bf5a..00000000 --- a/docs/examples/vectorsdb/delete-index.md +++ /dev/null @@ -1,16 +0,0 @@ -```javascript -const sdk = require('node-appwrite'); - -const client = new sdk.Client() - .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - .setProject('') // Your project ID - .setKey(''); // Your secret API key - -const vectorsDB = new sdk.VectorsDB(client); - -const result = await vectorsDB.deleteIndex({ - databaseId: '', - collectionId: '', - key: '' -}); -``` diff --git a/docs/examples/vectorsdb/delete-transaction.md b/docs/examples/vectorsdb/delete-transaction.md deleted file mode 100644 index 7b361c61..00000000 --- a/docs/examples/vectorsdb/delete-transaction.md +++ /dev/null @@ -1,14 +0,0 @@ -```javascript -const sdk = require('node-appwrite'); - -const client = new sdk.Client() - .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - .setProject('') // Your project ID - .setKey(''); // Your secret API key - -const vectorsDB = new sdk.VectorsDB(client); - -const result = await vectorsDB.deleteTransaction({ - transactionId: '' -}); -``` diff --git a/docs/examples/vectorsdb/delete.md b/docs/examples/vectorsdb/delete.md deleted file mode 100644 index 3a2d160f..00000000 --- a/docs/examples/vectorsdb/delete.md +++ /dev/null @@ -1,14 +0,0 @@ -```javascript -const sdk = require('node-appwrite'); - -const client = new sdk.Client() - .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - .setProject('') // Your project ID - .setKey(''); // Your secret API key - -const vectorsDB = new sdk.VectorsDB(client); - -const result = await vectorsDB.delete({ - databaseId: '' -}); -``` diff --git a/docs/examples/vectorsdb/get-collection.md b/docs/examples/vectorsdb/get-collection.md deleted file mode 100644 index 0f419ffb..00000000 --- a/docs/examples/vectorsdb/get-collection.md +++ /dev/null @@ -1,15 +0,0 @@ -```javascript -const sdk = require('node-appwrite'); - -const client = new sdk.Client() - .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - .setProject('') // Your project ID - .setKey(''); // Your secret API key - -const vectorsDB = new sdk.VectorsDB(client); - -const result = await vectorsDB.getCollection({ - databaseId: '', - collectionId: '' -}); -``` diff --git a/docs/examples/vectorsdb/get-document.md b/docs/examples/vectorsdb/get-document.md deleted file mode 100644 index 568c4f53..00000000 --- a/docs/examples/vectorsdb/get-document.md +++ /dev/null @@ -1,18 +0,0 @@ -```javascript -const sdk = require('node-appwrite'); - -const client = new sdk.Client() - .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - .setProject('') // Your project ID - .setSession(''); // The user session to authenticate with - -const vectorsDB = new sdk.VectorsDB(client); - -const result = await vectorsDB.getDocument({ - databaseId: '', - collectionId: '', - documentId: '', - queries: [], // optional - transactionId: '' // optional -}); -``` diff --git a/docs/examples/vectorsdb/get-index.md b/docs/examples/vectorsdb/get-index.md deleted file mode 100644 index 34a337b1..00000000 --- a/docs/examples/vectorsdb/get-index.md +++ /dev/null @@ -1,16 +0,0 @@ -```javascript -const sdk = require('node-appwrite'); - -const client = new sdk.Client() - .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - .setProject('') // Your project ID - .setKey(''); // Your secret API key - -const vectorsDB = new sdk.VectorsDB(client); - -const result = await vectorsDB.getIndex({ - databaseId: '', - collectionId: '', - key: '' -}); -``` diff --git a/docs/examples/vectorsdb/get-transaction.md b/docs/examples/vectorsdb/get-transaction.md deleted file mode 100644 index 9240c005..00000000 --- a/docs/examples/vectorsdb/get-transaction.md +++ /dev/null @@ -1,14 +0,0 @@ -```javascript -const sdk = require('node-appwrite'); - -const client = new sdk.Client() - .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - .setProject('') // Your project ID - .setKey(''); // Your secret API key - -const vectorsDB = new sdk.VectorsDB(client); - -const result = await vectorsDB.getTransaction({ - transactionId: '' -}); -``` diff --git a/docs/examples/vectorsdb/get.md b/docs/examples/vectorsdb/get.md deleted file mode 100644 index 4660d56a..00000000 --- a/docs/examples/vectorsdb/get.md +++ /dev/null @@ -1,14 +0,0 @@ -```javascript -const sdk = require('node-appwrite'); - -const client = new sdk.Client() - .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - .setProject('') // Your project ID - .setKey(''); // Your secret API key - -const vectorsDB = new sdk.VectorsDB(client); - -const result = await vectorsDB.get({ - databaseId: '' -}); -``` diff --git a/docs/examples/vectorsdb/list-collections.md b/docs/examples/vectorsdb/list-collections.md deleted file mode 100644 index 3e28a482..00000000 --- a/docs/examples/vectorsdb/list-collections.md +++ /dev/null @@ -1,17 +0,0 @@ -```javascript -const sdk = require('node-appwrite'); - -const client = new sdk.Client() - .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - .setProject('') // Your project ID - .setKey(''); // Your secret API key - -const vectorsDB = new sdk.VectorsDB(client); - -const result = await vectorsDB.listCollections({ - databaseId: '', - queries: [], // optional - search: '', // optional - total: false // optional -}); -``` diff --git a/docs/examples/vectorsdb/list-documents.md b/docs/examples/vectorsdb/list-documents.md deleted file mode 100644 index 34d00aa4..00000000 --- a/docs/examples/vectorsdb/list-documents.md +++ /dev/null @@ -1,19 +0,0 @@ -```javascript -const sdk = require('node-appwrite'); - -const client = new sdk.Client() - .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - .setProject('') // Your project ID - .setSession(''); // The user session to authenticate with - -const vectorsDB = new sdk.VectorsDB(client); - -const result = await vectorsDB.listDocuments({ - databaseId: '', - collectionId: '', - queries: [], // optional - transactionId: '', // optional - total: false, // optional - ttl: 0 // optional -}); -``` diff --git a/docs/examples/vectorsdb/list-indexes.md b/docs/examples/vectorsdb/list-indexes.md deleted file mode 100644 index c7289253..00000000 --- a/docs/examples/vectorsdb/list-indexes.md +++ /dev/null @@ -1,17 +0,0 @@ -```javascript -const sdk = require('node-appwrite'); - -const client = new sdk.Client() - .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - .setProject('') // Your project ID - .setKey(''); // Your secret API key - -const vectorsDB = new sdk.VectorsDB(client); - -const result = await vectorsDB.listIndexes({ - databaseId: '', - collectionId: '', - queries: [], // optional - total: false // optional -}); -``` diff --git a/docs/examples/vectorsdb/list-transactions.md b/docs/examples/vectorsdb/list-transactions.md deleted file mode 100644 index 2a7ab778..00000000 --- a/docs/examples/vectorsdb/list-transactions.md +++ /dev/null @@ -1,14 +0,0 @@ -```javascript -const sdk = require('node-appwrite'); - -const client = new sdk.Client() - .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - .setProject('') // Your project ID - .setKey(''); // Your secret API key - -const vectorsDB = new sdk.VectorsDB(client); - -const result = await vectorsDB.listTransactions({ - queries: [] // optional -}); -``` diff --git a/docs/examples/vectorsdb/list.md b/docs/examples/vectorsdb/list.md deleted file mode 100644 index b067d0a4..00000000 --- a/docs/examples/vectorsdb/list.md +++ /dev/null @@ -1,16 +0,0 @@ -```javascript -const sdk = require('node-appwrite'); - -const client = new sdk.Client() - .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - .setProject('') // Your project ID - .setKey(''); // Your secret API key - -const vectorsDB = new sdk.VectorsDB(client); - -const result = await vectorsDB.list({ - queries: [], // optional - search: '', // optional - total: false // optional -}); -``` diff --git a/docs/examples/vectorsdb/update-collection.md b/docs/examples/vectorsdb/update-collection.md deleted file mode 100644 index ecfb1d53..00000000 --- a/docs/examples/vectorsdb/update-collection.md +++ /dev/null @@ -1,20 +0,0 @@ -```javascript -const sdk = require('node-appwrite'); - -const client = new sdk.Client() - .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - .setProject('') // Your project ID - .setKey(''); // Your secret API key - -const vectorsDB = new sdk.VectorsDB(client); - -const result = await vectorsDB.updateCollection({ - databaseId: '', - collectionId: '', - name: '', - dimension: 1, // optional - permissions: [sdk.Permission.read(sdk.Role.any())], // optional - documentSecurity: false, // optional - enabled: false // optional -}); -``` diff --git a/docs/examples/vectorsdb/update-document.md b/docs/examples/vectorsdb/update-document.md deleted file mode 100644 index 05091037..00000000 --- a/docs/examples/vectorsdb/update-document.md +++ /dev/null @@ -1,19 +0,0 @@ -```javascript -const sdk = require('node-appwrite'); - -const client = new sdk.Client() - .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - .setProject('') // Your project ID - .setSession(''); // The user session to authenticate with - -const vectorsDB = new sdk.VectorsDB(client); - -const result = await vectorsDB.updateDocument({ - databaseId: '', - collectionId: '', - documentId: '', - data: {}, // optional - permissions: [sdk.Permission.read(sdk.Role.any())], // optional - transactionId: '' // optional -}); -``` diff --git a/docs/examples/vectorsdb/update-documents.md b/docs/examples/vectorsdb/update-documents.md deleted file mode 100644 index 58733e79..00000000 --- a/docs/examples/vectorsdb/update-documents.md +++ /dev/null @@ -1,18 +0,0 @@ -```javascript -const sdk = require('node-appwrite'); - -const client = new sdk.Client() - .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - .setProject('') // Your project ID - .setKey(''); // Your secret API key - -const vectorsDB = new sdk.VectorsDB(client); - -const result = await vectorsDB.updateDocuments({ - databaseId: '', - collectionId: '', - data: {}, // optional - queries: [], // optional - transactionId: '' // optional -}); -``` diff --git a/docs/examples/vectorsdb/update-transaction.md b/docs/examples/vectorsdb/update-transaction.md deleted file mode 100644 index 37c14a1b..00000000 --- a/docs/examples/vectorsdb/update-transaction.md +++ /dev/null @@ -1,16 +0,0 @@ -```javascript -const sdk = require('node-appwrite'); - -const client = new sdk.Client() - .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - .setProject('') // Your project ID - .setKey(''); // Your secret API key - -const vectorsDB = new sdk.VectorsDB(client); - -const result = await vectorsDB.updateTransaction({ - transactionId: '', - commit: false, // optional - rollback: false // optional -}); -``` diff --git a/docs/examples/vectorsdb/update.md b/docs/examples/vectorsdb/update.md deleted file mode 100644 index ff7d737e..00000000 --- a/docs/examples/vectorsdb/update.md +++ /dev/null @@ -1,16 +0,0 @@ -```javascript -const sdk = require('node-appwrite'); - -const client = new sdk.Client() - .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - .setProject('') // Your project ID - .setKey(''); // Your secret API key - -const vectorsDB = new sdk.VectorsDB(client); - -const result = await vectorsDB.update({ - databaseId: '', - name: '', - enabled: false // optional -}); -``` diff --git a/docs/examples/vectorsdb/upsert-document.md b/docs/examples/vectorsdb/upsert-document.md deleted file mode 100644 index 96c823aa..00000000 --- a/docs/examples/vectorsdb/upsert-document.md +++ /dev/null @@ -1,19 +0,0 @@ -```javascript -const sdk = require('node-appwrite'); - -const client = new sdk.Client() - .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - .setProject('') // Your project ID - .setSession(''); // The user session to authenticate with - -const vectorsDB = new sdk.VectorsDB(client); - -const result = await vectorsDB.upsertDocument({ - databaseId: '', - collectionId: '', - documentId: '', - data: {}, // optional - permissions: [sdk.Permission.read(sdk.Role.any())], // optional - transactionId: '' // optional -}); -``` diff --git a/docs/examples/vectorsdb/upsert-documents.md b/docs/examples/vectorsdb/upsert-documents.md deleted file mode 100644 index 36e20ac7..00000000 --- a/docs/examples/vectorsdb/upsert-documents.md +++ /dev/null @@ -1,17 +0,0 @@ -```javascript -const sdk = require('node-appwrite'); - -const client = new sdk.Client() - .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - .setProject('') // Your project ID - .setKey(''); // Your secret API key - -const vectorsDB = new sdk.VectorsDB(client); - -const result = await vectorsDB.upsertDocuments({ - databaseId: '', - collectionId: '', - documents: [], - transactionId: '' // optional -}); -``` diff --git a/src/index.ts b/src/index.ts index ac7e25aa..ee851533 100644 --- a/src/index.ts +++ b/src/index.ts @@ -4,7 +4,6 @@ export { Activities } from './services/activities'; export { Avatars } from './services/avatars'; export { Backups } from './services/backups'; export { Databases } from './services/databases'; -export { DocumentsDB } from './services/documents-db'; export { Functions } from './services/functions'; export { Graphql } from './services/graphql'; export { Health } from './services/health'; @@ -17,7 +16,6 @@ export { TablesDB } from './services/tables-db'; export { Teams } from './services/teams'; export { Tokens } from './services/tokens'; export { Users } from './services/users'; -export { VectorsDB } from './services/vectors-db'; export { Webhooks } from './services/webhooks'; export type { Models, Payload, UploadProgress } from './client'; export type { QueryTypes, QueryTypesList } from './query'; diff --git a/src/services/documents-db.ts b/src/services/documents-db.ts deleted file mode 100644 index 71dd25d7..00000000 --- a/src/services/documents-db.ts +++ /dev/null @@ -1,2349 +0,0 @@ -import { AppwriteException, Client, type Payload, UploadProgress } from '../client'; -import type { Models } from '../models'; - -import { DocumentsDBIndexType } from '../enums/documents-db-index-type'; -import { OrderBy } from '../enums/order-by'; - -export class DocumentsDB { - client: Client; - - constructor(client: Client) { - this.client = client; - } - - /** - * Get a list of all databases from the current Appwrite project. You can use the search parameter to filter your results. - * - * @param {string[]} params.queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following columns: name - * @param {string} params.search - Search term to filter your list results. Max length: 256 chars. - * @param {boolean} params.total - When set to false, the total count returned will be 0 and will not be calculated. - * @throws {AppwriteException} - * @returns {Promise} - */ - list(params?: { queries?: string[], search?: string, total?: boolean }): Promise; - /** - * Get a list of all databases from the current Appwrite project. You can use the search parameter to filter your results. - * - * @param {string[]} queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following columns: name - * @param {string} search - Search term to filter your list results. Max length: 256 chars. - * @param {boolean} total - When set to false, the total count returned will be 0 and will not be calculated. - * @throws {AppwriteException} - * @returns {Promise} - * @deprecated Use the object parameter style method for a better developer experience. - */ - list(queries?: string[], search?: string, total?: boolean): Promise; - list( - paramsOrFirst?: { queries?: string[], search?: string, total?: boolean } | string[], - ...rest: [(string)?, (boolean)?] - ): Promise { - let params: { queries?: string[], search?: string, total?: boolean }; - - if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { queries?: string[], search?: string, total?: boolean }; - } else { - params = { - queries: paramsOrFirst as string[], - search: rest[0] as string, - total: rest[1] as boolean - }; - } - - const queries = params.queries; - const search = params.search; - const total = params.total; - - - const apiPath = '/documentsdb'; - const payload: Payload = {}; - if (typeof queries !== 'undefined') { - payload['queries'] = queries; - } - if (typeof search !== 'undefined') { - payload['search'] = search; - } - if (typeof total !== 'undefined') { - payload['total'] = total; - } - const uri = new URL(this.client.config.endpoint + apiPath); - - const apiHeaders: { [header: string]: string } = { - } - - return this.client.call( - 'get', - uri, - apiHeaders, - payload, - ); - } - - /** - * Create a new Database. - * - * - * @param {string} params.databaseId - Unique Id. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. - * @param {string} params.name - Database name. Max length: 128 chars. - * @param {boolean} params.enabled - Is the database enabled? When set to 'disabled', users cannot access the database but Server SDKs with an API key can still read and write to the database. No data is lost when this is toggled. - * @throws {AppwriteException} - * @returns {Promise} - */ - create(params: { databaseId: string, name: string, enabled?: boolean }): Promise; - /** - * Create a new Database. - * - * - * @param {string} databaseId - Unique Id. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. - * @param {string} name - Database name. Max length: 128 chars. - * @param {boolean} enabled - Is the database enabled? When set to 'disabled', users cannot access the database but Server SDKs with an API key can still read and write to the database. No data is lost when this is toggled. - * @throws {AppwriteException} - * @returns {Promise} - * @deprecated Use the object parameter style method for a better developer experience. - */ - create(databaseId: string, name: string, enabled?: boolean): Promise; - create( - paramsOrFirst: { databaseId: string, name: string, enabled?: boolean } | string, - ...rest: [(string)?, (boolean)?] - ): Promise { - let params: { databaseId: string, name: string, enabled?: boolean }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, name: string, enabled?: boolean }; - } else { - params = { - databaseId: paramsOrFirst as string, - name: rest[0] as string, - enabled: rest[1] as boolean - }; - } - - const databaseId = params.databaseId; - const name = params.name; - const enabled = params.enabled; - - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); - } - if (typeof name === 'undefined') { - throw new AppwriteException('Missing required parameter: "name"'); - } - - const apiPath = '/documentsdb'; - const payload: Payload = {}; - if (typeof databaseId !== 'undefined') { - payload['databaseId'] = databaseId; - } - if (typeof name !== 'undefined') { - payload['name'] = name; - } - if (typeof enabled !== 'undefined') { - payload['enabled'] = enabled; - } - const uri = new URL(this.client.config.endpoint + apiPath); - - const apiHeaders: { [header: string]: string } = { - 'content-type': 'application/json', - } - - return this.client.call( - 'post', - uri, - apiHeaders, - payload, - ); - } - - /** - * - * @param {string[]} params.queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). - * @throws {AppwriteException} - * @returns {Promise} - */ - listTransactions(params?: { queries?: string[] }): Promise; - /** - * - * @param {string[]} queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). - * @throws {AppwriteException} - * @returns {Promise} - * @deprecated Use the object parameter style method for a better developer experience. - */ - listTransactions(queries?: string[]): Promise; - listTransactions( - paramsOrFirst?: { queries?: string[] } | string[] - ): Promise { - let params: { queries?: string[] }; - - if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { queries?: string[] }; - } else { - params = { - queries: paramsOrFirst as string[] - }; - } - - const queries = params.queries; - - - const apiPath = '/documentsdb/transactions'; - const payload: Payload = {}; - if (typeof queries !== 'undefined') { - payload['queries'] = queries; - } - const uri = new URL(this.client.config.endpoint + apiPath); - - const apiHeaders: { [header: string]: string } = { - } - - return this.client.call( - 'get', - uri, - apiHeaders, - payload, - ); - } - - /** - * - * @param {number} params.ttl - Seconds before the transaction expires. - * @throws {AppwriteException} - * @returns {Promise} - */ - createTransaction(params?: { ttl?: number }): Promise; - /** - * - * @param {number} ttl - Seconds before the transaction expires. - * @throws {AppwriteException} - * @returns {Promise} - * @deprecated Use the object parameter style method for a better developer experience. - */ - createTransaction(ttl?: number): Promise; - createTransaction( - paramsOrFirst?: { ttl?: number } | number - ): Promise { - let params: { ttl?: number }; - - if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { ttl?: number }; - } else { - params = { - ttl: paramsOrFirst as number - }; - } - - const ttl = params.ttl; - - - const apiPath = '/documentsdb/transactions'; - const payload: Payload = {}; - if (typeof ttl !== 'undefined') { - payload['ttl'] = ttl; - } - const uri = new URL(this.client.config.endpoint + apiPath); - - const apiHeaders: { [header: string]: string } = { - 'content-type': 'application/json', - } - - return this.client.call( - 'post', - uri, - apiHeaders, - payload, - ); - } - - /** - * - * @param {string} params.transactionId - Transaction ID. - * @throws {AppwriteException} - * @returns {Promise} - */ - getTransaction(params: { transactionId: string }): Promise; - /** - * - * @param {string} transactionId - Transaction ID. - * @throws {AppwriteException} - * @returns {Promise} - * @deprecated Use the object parameter style method for a better developer experience. - */ - getTransaction(transactionId: string): Promise; - getTransaction( - paramsOrFirst: { transactionId: string } | string - ): Promise { - let params: { transactionId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { transactionId: string }; - } else { - params = { - transactionId: paramsOrFirst as string - }; - } - - const transactionId = params.transactionId; - - if (typeof transactionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "transactionId"'); - } - - const apiPath = '/documentsdb/transactions/{transactionId}'.replace('{transactionId}', transactionId); - const payload: Payload = {}; - const uri = new URL(this.client.config.endpoint + apiPath); - - const apiHeaders: { [header: string]: string } = { - } - - return this.client.call( - 'get', - uri, - apiHeaders, - payload, - ); - } - - /** - * - * @param {string} params.transactionId - Transaction ID. - * @param {boolean} params.commit - Commit transaction? - * @param {boolean} params.rollback - Rollback transaction? - * @throws {AppwriteException} - * @returns {Promise} - */ - updateTransaction(params: { transactionId: string, commit?: boolean, rollback?: boolean }): Promise; - /** - * - * @param {string} transactionId - Transaction ID. - * @param {boolean} commit - Commit transaction? - * @param {boolean} rollback - Rollback transaction? - * @throws {AppwriteException} - * @returns {Promise} - * @deprecated Use the object parameter style method for a better developer experience. - */ - updateTransaction(transactionId: string, commit?: boolean, rollback?: boolean): Promise; - updateTransaction( - paramsOrFirst: { transactionId: string, commit?: boolean, rollback?: boolean } | string, - ...rest: [(boolean)?, (boolean)?] - ): Promise { - let params: { transactionId: string, commit?: boolean, rollback?: boolean }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { transactionId: string, commit?: boolean, rollback?: boolean }; - } else { - params = { - transactionId: paramsOrFirst as string, - commit: rest[0] as boolean, - rollback: rest[1] as boolean - }; - } - - const transactionId = params.transactionId; - const commit = params.commit; - const rollback = params.rollback; - - if (typeof transactionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "transactionId"'); - } - - const apiPath = '/documentsdb/transactions/{transactionId}'.replace('{transactionId}', transactionId); - const payload: Payload = {}; - if (typeof commit !== 'undefined') { - payload['commit'] = commit; - } - if (typeof rollback !== 'undefined') { - payload['rollback'] = rollback; - } - const uri = new URL(this.client.config.endpoint + apiPath); - - const apiHeaders: { [header: string]: string } = { - 'content-type': 'application/json', - } - - return this.client.call( - 'patch', - uri, - apiHeaders, - payload, - ); - } - - /** - * - * @param {string} params.transactionId - Transaction ID. - * @throws {AppwriteException} - * @returns {Promise<{}>} - */ - deleteTransaction(params: { transactionId: string }): Promise<{}>; - /** - * - * @param {string} transactionId - Transaction ID. - * @throws {AppwriteException} - * @returns {Promise<{}>} - * @deprecated Use the object parameter style method for a better developer experience. - */ - deleteTransaction(transactionId: string): Promise<{}>; - deleteTransaction( - paramsOrFirst: { transactionId: string } | string - ): Promise<{}> { - let params: { transactionId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { transactionId: string }; - } else { - params = { - transactionId: paramsOrFirst as string - }; - } - - const transactionId = params.transactionId; - - if (typeof transactionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "transactionId"'); - } - - const apiPath = '/documentsdb/transactions/{transactionId}'.replace('{transactionId}', transactionId); - const payload: Payload = {}; - const uri = new URL(this.client.config.endpoint + apiPath); - - const apiHeaders: { [header: string]: string } = { - 'content-type': 'application/json', - } - - return this.client.call( - 'delete', - uri, - apiHeaders, - payload, - ); - } - - /** - * - * @param {string} params.transactionId - Transaction ID. - * @param {object[]} params.operations - Array of staged operations. - * @throws {AppwriteException} - * @returns {Promise} - */ - createOperations(params: { transactionId: string, operations?: object[] }): Promise; - /** - * - * @param {string} transactionId - Transaction ID. - * @param {object[]} operations - Array of staged operations. - * @throws {AppwriteException} - * @returns {Promise} - * @deprecated Use the object parameter style method for a better developer experience. - */ - createOperations(transactionId: string, operations?: object[]): Promise; - createOperations( - paramsOrFirst: { transactionId: string, operations?: object[] } | string, - ...rest: [(object[])?] - ): Promise { - let params: { transactionId: string, operations?: object[] }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { transactionId: string, operations?: object[] }; - } else { - params = { - transactionId: paramsOrFirst as string, - operations: rest[0] as object[] - }; - } - - const transactionId = params.transactionId; - const operations = params.operations; - - if (typeof transactionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "transactionId"'); - } - - const apiPath = '/documentsdb/transactions/{transactionId}/operations'.replace('{transactionId}', transactionId); - const payload: Payload = {}; - if (typeof operations !== 'undefined') { - payload['operations'] = operations; - } - const uri = new URL(this.client.config.endpoint + apiPath); - - const apiHeaders: { [header: string]: string } = { - 'content-type': 'application/json', - } - - return this.client.call( - 'post', - uri, - apiHeaders, - payload, - ); - } - - /** - * Get a database by its unique ID. This endpoint response returns a JSON object with the database metadata. - * - * @param {string} params.databaseId - Database ID. - * @throws {AppwriteException} - * @returns {Promise} - */ - get(params: { databaseId: string }): Promise; - /** - * Get a database by its unique ID. This endpoint response returns a JSON object with the database metadata. - * - * @param {string} databaseId - Database ID. - * @throws {AppwriteException} - * @returns {Promise} - * @deprecated Use the object parameter style method for a better developer experience. - */ - get(databaseId: string): Promise; - get( - paramsOrFirst: { databaseId: string } | string - ): Promise { - let params: { databaseId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string }; - } else { - params = { - databaseId: paramsOrFirst as string - }; - } - - const databaseId = params.databaseId; - - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); - } - - const apiPath = '/documentsdb/{databaseId}'.replace('{databaseId}', databaseId); - const payload: Payload = {}; - const uri = new URL(this.client.config.endpoint + apiPath); - - const apiHeaders: { [header: string]: string } = { - } - - return this.client.call( - 'get', - uri, - apiHeaders, - payload, - ); - } - - /** - * Update a database by its unique ID. - * - * @param {string} params.databaseId - Database ID. - * @param {string} params.name - Database name. Max length: 128 chars. - * @param {boolean} params.enabled - Is database enabled? When set to 'disabled', users cannot access the database but Server SDKs with an API key can still read and write to the database. No data is lost when this is toggled. - * @throws {AppwriteException} - * @returns {Promise} - */ - update(params: { databaseId: string, name: string, enabled?: boolean }): Promise; - /** - * Update a database by its unique ID. - * - * @param {string} databaseId - Database ID. - * @param {string} name - Database name. Max length: 128 chars. - * @param {boolean} enabled - Is database enabled? When set to 'disabled', users cannot access the database but Server SDKs with an API key can still read and write to the database. No data is lost when this is toggled. - * @throws {AppwriteException} - * @returns {Promise} - * @deprecated Use the object parameter style method for a better developer experience. - */ - update(databaseId: string, name: string, enabled?: boolean): Promise; - update( - paramsOrFirst: { databaseId: string, name: string, enabled?: boolean } | string, - ...rest: [(string)?, (boolean)?] - ): Promise { - let params: { databaseId: string, name: string, enabled?: boolean }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, name: string, enabled?: boolean }; - } else { - params = { - databaseId: paramsOrFirst as string, - name: rest[0] as string, - enabled: rest[1] as boolean - }; - } - - const databaseId = params.databaseId; - const name = params.name; - const enabled = params.enabled; - - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); - } - if (typeof name === 'undefined') { - throw new AppwriteException('Missing required parameter: "name"'); - } - - const apiPath = '/documentsdb/{databaseId}'.replace('{databaseId}', databaseId); - const payload: Payload = {}; - if (typeof name !== 'undefined') { - payload['name'] = name; - } - if (typeof enabled !== 'undefined') { - payload['enabled'] = enabled; - } - const uri = new URL(this.client.config.endpoint + apiPath); - - const apiHeaders: { [header: string]: string } = { - 'content-type': 'application/json', - } - - return this.client.call( - 'put', - uri, - apiHeaders, - payload, - ); - } - - /** - * Delete a database by its unique ID. Only API keys with with databases.write scope can delete a database. - * - * @param {string} params.databaseId - Database ID. - * @throws {AppwriteException} - * @returns {Promise<{}>} - */ - delete(params: { databaseId: string }): Promise<{}>; - /** - * Delete a database by its unique ID. Only API keys with with databases.write scope can delete a database. - * - * @param {string} databaseId - Database ID. - * @throws {AppwriteException} - * @returns {Promise<{}>} - * @deprecated Use the object parameter style method for a better developer experience. - */ - delete(databaseId: string): Promise<{}>; - delete( - paramsOrFirst: { databaseId: string } | string - ): Promise<{}> { - let params: { databaseId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string }; - } else { - params = { - databaseId: paramsOrFirst as string - }; - } - - const databaseId = params.databaseId; - - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); - } - - const apiPath = '/documentsdb/{databaseId}'.replace('{databaseId}', databaseId); - const payload: Payload = {}; - const uri = new URL(this.client.config.endpoint + apiPath); - - const apiHeaders: { [header: string]: string } = { - 'content-type': 'application/json', - } - - return this.client.call( - 'delete', - uri, - apiHeaders, - payload, - ); - } - - /** - * Get a list of all collections that belong to the provided databaseId. You can use the search parameter to filter your results. - * - * @param {string} params.databaseId - Database ID. - * @param {string[]} params.queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: name, enabled, documentSecurity - * @param {string} params.search - Search term to filter your list results. Max length: 256 chars. - * @param {boolean} params.total - When set to false, the total count returned will be 0 and will not be calculated. - * @throws {AppwriteException} - * @returns {Promise} - */ - listCollections(params: { databaseId: string, queries?: string[], search?: string, total?: boolean }): Promise; - /** - * Get a list of all collections that belong to the provided databaseId. You can use the search parameter to filter your results. - * - * @param {string} databaseId - Database ID. - * @param {string[]} queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: name, enabled, documentSecurity - * @param {string} search - Search term to filter your list results. Max length: 256 chars. - * @param {boolean} total - When set to false, the total count returned will be 0 and will not be calculated. - * @throws {AppwriteException} - * @returns {Promise} - * @deprecated Use the object parameter style method for a better developer experience. - */ - listCollections(databaseId: string, queries?: string[], search?: string, total?: boolean): Promise; - listCollections( - paramsOrFirst: { databaseId: string, queries?: string[], search?: string, total?: boolean } | string, - ...rest: [(string[])?, (string)?, (boolean)?] - ): Promise { - let params: { databaseId: string, queries?: string[], search?: string, total?: boolean }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, queries?: string[], search?: string, total?: boolean }; - } else { - params = { - databaseId: paramsOrFirst as string, - queries: rest[0] as string[], - search: rest[1] as string, - total: rest[2] as boolean - }; - } - - const databaseId = params.databaseId; - const queries = params.queries; - const search = params.search; - const total = params.total; - - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); - } - - const apiPath = '/documentsdb/{databaseId}/collections'.replace('{databaseId}', databaseId); - const payload: Payload = {}; - if (typeof queries !== 'undefined') { - payload['queries'] = queries; - } - if (typeof search !== 'undefined') { - payload['search'] = search; - } - if (typeof total !== 'undefined') { - payload['total'] = total; - } - const uri = new URL(this.client.config.endpoint + apiPath); - - const apiHeaders: { [header: string]: string } = { - } - - return this.client.call( - 'get', - uri, - apiHeaders, - payload, - ); - } - - /** - * Create a new Collection. Before using this route, you should create a new database resource using either a [server integration](https://appwrite.io/docs/server/databases#documentsDBCreateCollection) API or directly from your database console. - * - * @param {string} params.databaseId - Database ID. - * @param {string} params.collectionId - Unique Id. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. - * @param {string} params.name - Collection name. Max length: 128 chars. - * @param {string[]} params.permissions - An array of permissions strings. By default, no user is granted with any permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). - * @param {boolean} params.documentSecurity - Enables configuring permissions for individual documents. A user needs one of document or collection level permissions to access a document. [Learn more about permissions](https://appwrite.io/docs/permissions). - * @param {boolean} params.enabled - Is collection enabled? When set to 'disabled', users cannot access the collection but Server SDKs with and API key can still read and write to the collection. No data is lost when this is toggled. - * @param {object[]} params.attributes - Array of attribute definitions to create. Each attribute should contain: key (string), type (string: string, integer, float, boolean, datetime, relationship), size (integer, required for string type), required (boolean, optional), default (mixed, optional), array (boolean, optional), and type-specific options. - * @param {object[]} params.indexes - Array of index definitions to create. Each index should contain: key (string), type (string: key, fulltext, unique, spatial), attributes (array of attribute keys), orders (array of ASC/DESC, optional), and lengths (array of integers, optional). - * @throws {AppwriteException} - * @returns {Promise} - */ - createCollection(params: { databaseId: string, collectionId: string, name: string, permissions?: string[], documentSecurity?: boolean, enabled?: boolean, attributes?: object[], indexes?: object[] }): Promise; - /** - * Create a new Collection. Before using this route, you should create a new database resource using either a [server integration](https://appwrite.io/docs/server/databases#documentsDBCreateCollection) API or directly from your database console. - * - * @param {string} databaseId - Database ID. - * @param {string} collectionId - Unique Id. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. - * @param {string} name - Collection name. Max length: 128 chars. - * @param {string[]} permissions - An array of permissions strings. By default, no user is granted with any permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). - * @param {boolean} documentSecurity - Enables configuring permissions for individual documents. A user needs one of document or collection level permissions to access a document. [Learn more about permissions](https://appwrite.io/docs/permissions). - * @param {boolean} enabled - Is collection enabled? When set to 'disabled', users cannot access the collection but Server SDKs with and API key can still read and write to the collection. No data is lost when this is toggled. - * @param {object[]} attributes - Array of attribute definitions to create. Each attribute should contain: key (string), type (string: string, integer, float, boolean, datetime, relationship), size (integer, required for string type), required (boolean, optional), default (mixed, optional), array (boolean, optional), and type-specific options. - * @param {object[]} indexes - Array of index definitions to create. Each index should contain: key (string), type (string: key, fulltext, unique, spatial), attributes (array of attribute keys), orders (array of ASC/DESC, optional), and lengths (array of integers, optional). - * @throws {AppwriteException} - * @returns {Promise} - * @deprecated Use the object parameter style method for a better developer experience. - */ - createCollection(databaseId: string, collectionId: string, name: string, permissions?: string[], documentSecurity?: boolean, enabled?: boolean, attributes?: object[], indexes?: object[]): Promise; - createCollection( - paramsOrFirst: { databaseId: string, collectionId: string, name: string, permissions?: string[], documentSecurity?: boolean, enabled?: boolean, attributes?: object[], indexes?: object[] } | string, - ...rest: [(string)?, (string)?, (string[])?, (boolean)?, (boolean)?, (object[])?, (object[])?] - ): Promise { - let params: { databaseId: string, collectionId: string, name: string, permissions?: string[], documentSecurity?: boolean, enabled?: boolean, attributes?: object[], indexes?: object[] }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, name: string, permissions?: string[], documentSecurity?: boolean, enabled?: boolean, attributes?: object[], indexes?: object[] }; - } else { - params = { - databaseId: paramsOrFirst as string, - collectionId: rest[0] as string, - name: rest[1] as string, - permissions: rest[2] as string[], - documentSecurity: rest[3] as boolean, - enabled: rest[4] as boolean, - attributes: rest[5] as object[], - indexes: rest[6] as object[] - }; - } - - const databaseId = params.databaseId; - const collectionId = params.collectionId; - const name = params.name; - const permissions = params.permissions; - const documentSecurity = params.documentSecurity; - const enabled = params.enabled; - const attributes = params.attributes; - const indexes = params.indexes; - - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); - } - if (typeof collectionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "collectionId"'); - } - if (typeof name === 'undefined') { - throw new AppwriteException('Missing required parameter: "name"'); - } - - const apiPath = '/documentsdb/{databaseId}/collections'.replace('{databaseId}', databaseId); - const payload: Payload = {}; - if (typeof collectionId !== 'undefined') { - payload['collectionId'] = collectionId; - } - if (typeof name !== 'undefined') { - payload['name'] = name; - } - if (typeof permissions !== 'undefined') { - payload['permissions'] = permissions; - } - if (typeof documentSecurity !== 'undefined') { - payload['documentSecurity'] = documentSecurity; - } - if (typeof enabled !== 'undefined') { - payload['enabled'] = enabled; - } - if (typeof attributes !== 'undefined') { - payload['attributes'] = attributes; - } - if (typeof indexes !== 'undefined') { - payload['indexes'] = indexes; - } - const uri = new URL(this.client.config.endpoint + apiPath); - - const apiHeaders: { [header: string]: string } = { - 'content-type': 'application/json', - } - - return this.client.call( - 'post', - uri, - apiHeaders, - payload, - ); - } - - /** - * Get a collection by its unique ID. This endpoint response returns a JSON object with the collection metadata. - * - * @param {string} params.databaseId - Database ID. - * @param {string} params.collectionId - Collection ID. - * @throws {AppwriteException} - * @returns {Promise} - */ - getCollection(params: { databaseId: string, collectionId: string }): Promise; - /** - * Get a collection by its unique ID. This endpoint response returns a JSON object with the collection metadata. - * - * @param {string} databaseId - Database ID. - * @param {string} collectionId - Collection ID. - * @throws {AppwriteException} - * @returns {Promise} - * @deprecated Use the object parameter style method for a better developer experience. - */ - getCollection(databaseId: string, collectionId: string): Promise; - getCollection( - paramsOrFirst: { databaseId: string, collectionId: string } | string, - ...rest: [(string)?] - ): Promise { - let params: { databaseId: string, collectionId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string }; - } else { - params = { - databaseId: paramsOrFirst as string, - collectionId: rest[0] as string - }; - } - - const databaseId = params.databaseId; - const collectionId = params.collectionId; - - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); - } - if (typeof collectionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "collectionId"'); - } - - const apiPath = '/documentsdb/{databaseId}/collections/{collectionId}'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId); - const payload: Payload = {}; - const uri = new URL(this.client.config.endpoint + apiPath); - - const apiHeaders: { [header: string]: string } = { - } - - return this.client.call( - 'get', - uri, - apiHeaders, - payload, - ); - } - - /** - * Update a collection by its unique ID. - * - * @param {string} params.databaseId - Database ID. - * @param {string} params.collectionId - Collection ID. - * @param {string} params.name - Collection name. Max length: 128 chars. - * @param {string[]} params.permissions - An array of permission strings. By default, the current permissions are inherited. [Learn more about permissions](https://appwrite.io/docs/permissions). - * @param {boolean} params.documentSecurity - Enables configuring permissions for individual documents. A user needs one of document or collection level permissions to access a document. [Learn more about permissions](https://appwrite.io/docs/permissions). - * @param {boolean} params.enabled - Is collection enabled? When set to 'disabled', users cannot access the collection but Server SDKs with and API key can still read and write to the collection. No data is lost when this is toggled. - * @throws {AppwriteException} - * @returns {Promise} - */ - updateCollection(params: { databaseId: string, collectionId: string, name: string, permissions?: string[], documentSecurity?: boolean, enabled?: boolean }): Promise; - /** - * Update a collection by its unique ID. - * - * @param {string} databaseId - Database ID. - * @param {string} collectionId - Collection ID. - * @param {string} name - Collection name. Max length: 128 chars. - * @param {string[]} permissions - An array of permission strings. By default, the current permissions are inherited. [Learn more about permissions](https://appwrite.io/docs/permissions). - * @param {boolean} documentSecurity - Enables configuring permissions for individual documents. A user needs one of document or collection level permissions to access a document. [Learn more about permissions](https://appwrite.io/docs/permissions). - * @param {boolean} enabled - Is collection enabled? When set to 'disabled', users cannot access the collection but Server SDKs with and API key can still read and write to the collection. No data is lost when this is toggled. - * @throws {AppwriteException} - * @returns {Promise} - * @deprecated Use the object parameter style method for a better developer experience. - */ - updateCollection(databaseId: string, collectionId: string, name: string, permissions?: string[], documentSecurity?: boolean, enabled?: boolean): Promise; - updateCollection( - paramsOrFirst: { databaseId: string, collectionId: string, name: string, permissions?: string[], documentSecurity?: boolean, enabled?: boolean } | string, - ...rest: [(string)?, (string)?, (string[])?, (boolean)?, (boolean)?] - ): Promise { - let params: { databaseId: string, collectionId: string, name: string, permissions?: string[], documentSecurity?: boolean, enabled?: boolean }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, name: string, permissions?: string[], documentSecurity?: boolean, enabled?: boolean }; - } else { - params = { - databaseId: paramsOrFirst as string, - collectionId: rest[0] as string, - name: rest[1] as string, - permissions: rest[2] as string[], - documentSecurity: rest[3] as boolean, - enabled: rest[4] as boolean - }; - } - - const databaseId = params.databaseId; - const collectionId = params.collectionId; - const name = params.name; - const permissions = params.permissions; - const documentSecurity = params.documentSecurity; - const enabled = params.enabled; - - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); - } - if (typeof collectionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "collectionId"'); - } - if (typeof name === 'undefined') { - throw new AppwriteException('Missing required parameter: "name"'); - } - - const apiPath = '/documentsdb/{databaseId}/collections/{collectionId}'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId); - const payload: Payload = {}; - if (typeof name !== 'undefined') { - payload['name'] = name; - } - if (typeof permissions !== 'undefined') { - payload['permissions'] = permissions; - } - if (typeof documentSecurity !== 'undefined') { - payload['documentSecurity'] = documentSecurity; - } - if (typeof enabled !== 'undefined') { - payload['enabled'] = enabled; - } - const uri = new URL(this.client.config.endpoint + apiPath); - - const apiHeaders: { [header: string]: string } = { - 'content-type': 'application/json', - } - - return this.client.call( - 'put', - uri, - apiHeaders, - payload, - ); - } - - /** - * Delete a collection by its unique ID. Only users with write permissions have access to delete this resource. - * - * @param {string} params.databaseId - Database ID. - * @param {string} params.collectionId - Collection ID. - * @throws {AppwriteException} - * @returns {Promise<{}>} - */ - deleteCollection(params: { databaseId: string, collectionId: string }): Promise<{}>; - /** - * Delete a collection by its unique ID. Only users with write permissions have access to delete this resource. - * - * @param {string} databaseId - Database ID. - * @param {string} collectionId - Collection ID. - * @throws {AppwriteException} - * @returns {Promise<{}>} - * @deprecated Use the object parameter style method for a better developer experience. - */ - deleteCollection(databaseId: string, collectionId: string): Promise<{}>; - deleteCollection( - paramsOrFirst: { databaseId: string, collectionId: string } | string, - ...rest: [(string)?] - ): Promise<{}> { - let params: { databaseId: string, collectionId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string }; - } else { - params = { - databaseId: paramsOrFirst as string, - collectionId: rest[0] as string - }; - } - - const databaseId = params.databaseId; - const collectionId = params.collectionId; - - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); - } - if (typeof collectionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "collectionId"'); - } - - const apiPath = '/documentsdb/{databaseId}/collections/{collectionId}'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId); - const payload: Payload = {}; - const uri = new URL(this.client.config.endpoint + apiPath); - - const apiHeaders: { [header: string]: string } = { - 'content-type': 'application/json', - } - - return this.client.call( - 'delete', - uri, - apiHeaders, - payload, - ); - } - - /** - * Get a list of all the user's documents in a given collection. You can use the query params to filter your results. - * - * @param {string} params.databaseId - Database ID. - * @param {string} params.collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). - * @param {string[]} params.queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. - * @param {string} params.transactionId - Transaction ID to read uncommitted changes within the transaction. - * @param {boolean} params.total - When set to false, the total count returned will be 0 and will not be calculated. - * @param {number} params.ttl - TTL (seconds) for cached responses when caching is enabled for select queries. Must be between 0 and 86400 (24 hours). - * @throws {AppwriteException} - * @returns {Promise>} - */ - listDocuments(params: { databaseId: string, collectionId: string, queries?: string[], transactionId?: string, total?: boolean, ttl?: number }): Promise>; - /** - * Get a list of all the user's documents in a given collection. You can use the query params to filter your results. - * - * @param {string} databaseId - Database ID. - * @param {string} collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). - * @param {string[]} queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. - * @param {string} transactionId - Transaction ID to read uncommitted changes within the transaction. - * @param {boolean} total - When set to false, the total count returned will be 0 and will not be calculated. - * @param {number} ttl - TTL (seconds) for cached responses when caching is enabled for select queries. Must be between 0 and 86400 (24 hours). - * @throws {AppwriteException} - * @returns {Promise>} - * @deprecated Use the object parameter style method for a better developer experience. - */ - listDocuments(databaseId: string, collectionId: string, queries?: string[], transactionId?: string, total?: boolean, ttl?: number): Promise>; - listDocuments( - paramsOrFirst: { databaseId: string, collectionId: string, queries?: string[], transactionId?: string, total?: boolean, ttl?: number } | string, - ...rest: [(string)?, (string[])?, (string)?, (boolean)?, (number)?] - ): Promise> { - let params: { databaseId: string, collectionId: string, queries?: string[], transactionId?: string, total?: boolean, ttl?: number }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, queries?: string[], transactionId?: string, total?: boolean, ttl?: number }; - } else { - params = { - databaseId: paramsOrFirst as string, - collectionId: rest[0] as string, - queries: rest[1] as string[], - transactionId: rest[2] as string, - total: rest[3] as boolean, - ttl: rest[4] as number - }; - } - - const databaseId = params.databaseId; - const collectionId = params.collectionId; - const queries = params.queries; - const transactionId = params.transactionId; - const total = params.total; - const ttl = params.ttl; - - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); - } - if (typeof collectionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "collectionId"'); - } - - const apiPath = '/documentsdb/{databaseId}/collections/{collectionId}/documents'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId); - const payload: Payload = {}; - if (typeof queries !== 'undefined') { - payload['queries'] = queries; - } - if (typeof transactionId !== 'undefined') { - payload['transactionId'] = transactionId; - } - if (typeof total !== 'undefined') { - payload['total'] = total; - } - if (typeof ttl !== 'undefined') { - payload['ttl'] = ttl; - } - const uri = new URL(this.client.config.endpoint + apiPath); - - const apiHeaders: { [header: string]: string } = { - } - - return this.client.call( - 'get', - uri, - apiHeaders, - payload, - ); - } - - /** - * Create a new Document. Before using this route, you should create a new collection resource using either a [server integration](https://appwrite.io/docs/server/databases#documentsDBCreateCollection) API or directly from your database console. - * - * @param {string} params.databaseId - Database ID. - * @param {string} params.collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). Make sure to define attributes before creating documents. - * @param {string} params.documentId - Document ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. - * @param {Document extends Models.DefaultDocument ? Partial & Record : Partial & Omit} params.data - Document data as JSON object. - * @param {string[]} params.permissions - An array of permissions strings. By default, only the current user is granted all permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). - * @throws {AppwriteException} - * @returns {Promise} - */ - createDocument(params: { databaseId: string, collectionId: string, documentId: string, data: Document extends Models.DefaultDocument ? Partial & Record : Partial & Omit, permissions?: string[] }): Promise; - /** - * Create a new Document. Before using this route, you should create a new collection resource using either a [server integration](https://appwrite.io/docs/server/databases#documentsDBCreateCollection) API or directly from your database console. - * - * @param {string} databaseId - Database ID. - * @param {string} collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). Make sure to define attributes before creating documents. - * @param {string} documentId - Document ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. - * @param {Document extends Models.DefaultDocument ? Partial & Record : Partial & Omit} data - Document data as JSON object. - * @param {string[]} permissions - An array of permissions strings. By default, only the current user is granted all permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). - * @throws {AppwriteException} - * @returns {Promise} - * @deprecated Use the object parameter style method for a better developer experience. - */ - createDocument(databaseId: string, collectionId: string, documentId: string, data: Document extends Models.DefaultDocument ? Partial & Record : Partial & Omit, permissions?: string[]): Promise; - createDocument( - paramsOrFirst: { databaseId: string, collectionId: string, documentId: string, data: Document extends Models.DefaultDocument ? Partial & Record : Partial & Omit, permissions?: string[] } | string, - ...rest: [(string)?, (string)?, (Document extends Models.DefaultDocument ? Partial & Record : Partial & Omit)?, (string[])?] - ): Promise { - let params: { databaseId: string, collectionId: string, documentId: string, data: Document extends Models.DefaultDocument ? Partial & Record : Partial & Omit, permissions?: string[] }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, documentId: string, data: Document extends Models.DefaultDocument ? Partial & Record : Partial & Omit, permissions?: string[] }; - } else { - params = { - databaseId: paramsOrFirst as string, - collectionId: rest[0] as string, - documentId: rest[1] as string, - data: rest[2] as Document extends Models.DefaultDocument ? Partial & Record : Partial & Omit, - permissions: rest[3] as string[] - }; - } - - const databaseId = params.databaseId; - const collectionId = params.collectionId; - const documentId = params.documentId; - const data = params.data; - const permissions = params.permissions; - - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); - } - if (typeof collectionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "collectionId"'); - } - if (typeof documentId === 'undefined') { - throw new AppwriteException('Missing required parameter: "documentId"'); - } - if (typeof data === 'undefined') { - throw new AppwriteException('Missing required parameter: "data"'); - } - - const apiPath = '/documentsdb/{databaseId}/collections/{collectionId}/documents'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId); - const payload: Payload = {}; - if (typeof documentId !== 'undefined') { - payload['documentId'] = documentId; - } - if (typeof data !== 'undefined') { - payload['data'] = data; - } - if (typeof permissions !== 'undefined') { - payload['permissions'] = permissions; - } - const uri = new URL(this.client.config.endpoint + apiPath); - - const apiHeaders: { [header: string]: string } = { - 'content-type': 'application/json', - } - - return this.client.call( - 'post', - uri, - apiHeaders, - payload, - ); - } - - /** - * Create new Documents. Before using this route, you should create a new collection resource using either a [server integration](https://appwrite.io/docs/server/databases#documentsDBCreateCollection) API or directly from your database console. - * - * @param {string} params.databaseId - Database ID. - * @param {string} params.collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). Make sure to define attributes before creating documents. - * @param {object[]} params.documents - Array of documents data as JSON objects. - * @throws {AppwriteException} - * @returns {Promise>} - */ - createDocuments(params: { databaseId: string, collectionId: string, documents: object[] }): Promise>; - /** - * Create new Documents. Before using this route, you should create a new collection resource using either a [server integration](https://appwrite.io/docs/server/databases#documentsDBCreateCollection) API or directly from your database console. - * - * @param {string} databaseId - Database ID. - * @param {string} collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). Make sure to define attributes before creating documents. - * @param {object[]} documents - Array of documents data as JSON objects. - * @throws {AppwriteException} - * @returns {Promise>} - * @deprecated Use the object parameter style method for a better developer experience. - */ - createDocuments(databaseId: string, collectionId: string, documents: object[]): Promise>; - createDocuments( - paramsOrFirst: { databaseId: string, collectionId: string, documents: object[] } | string, - ...rest: [(string)?, (object[])?] - ): Promise> { - let params: { databaseId: string, collectionId: string, documents: object[] }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, documents: object[] }; - } else { - params = { - databaseId: paramsOrFirst as string, - collectionId: rest[0] as string, - documents: rest[1] as object[] - }; - } - - const databaseId = params.databaseId; - const collectionId = params.collectionId; - const documents = params.documents; - - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); - } - if (typeof collectionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "collectionId"'); - } - if (typeof documents === 'undefined') { - throw new AppwriteException('Missing required parameter: "documents"'); - } - - const apiPath = '/documentsdb/{databaseId}/collections/{collectionId}/documents'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId); - const payload: Payload = {}; - if (typeof documents !== 'undefined') { - payload['documents'] = documents; - } - const uri = new URL(this.client.config.endpoint + apiPath); - - const apiHeaders: { [header: string]: string } = { - 'content-type': 'application/json', - } - - return this.client.call( - 'post', - uri, - apiHeaders, - payload, - ); - } - - /** - * Create or update Documents. Before using this route, you should create a new collection resource using either a [server integration](https://appwrite.io/docs/server/databases#documentsDBCreateCollection) API or directly from your database console. - * - * - * @param {string} params.databaseId - Database ID. - * @param {string} params.collectionId - Collection ID. - * @param {object[]} params.documents - Array of document data as JSON objects. May contain partial documents. - * @param {string} params.transactionId - Transaction ID for staging the operation. - * @throws {AppwriteException} - * @returns {Promise>} - */ - upsertDocuments(params: { databaseId: string, collectionId: string, documents: object[], transactionId?: string }): Promise>; - /** - * Create or update Documents. Before using this route, you should create a new collection resource using either a [server integration](https://appwrite.io/docs/server/databases#documentsDBCreateCollection) API or directly from your database console. - * - * - * @param {string} databaseId - Database ID. - * @param {string} collectionId - Collection ID. - * @param {object[]} documents - Array of document data as JSON objects. May contain partial documents. - * @param {string} transactionId - Transaction ID for staging the operation. - * @throws {AppwriteException} - * @returns {Promise>} - * @deprecated Use the object parameter style method for a better developer experience. - */ - upsertDocuments(databaseId: string, collectionId: string, documents: object[], transactionId?: string): Promise>; - upsertDocuments( - paramsOrFirst: { databaseId: string, collectionId: string, documents: object[], transactionId?: string } | string, - ...rest: [(string)?, (object[])?, (string)?] - ): Promise> { - let params: { databaseId: string, collectionId: string, documents: object[], transactionId?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, documents: object[], transactionId?: string }; - } else { - params = { - databaseId: paramsOrFirst as string, - collectionId: rest[0] as string, - documents: rest[1] as object[], - transactionId: rest[2] as string - }; - } - - const databaseId = params.databaseId; - const collectionId = params.collectionId; - const documents = params.documents; - const transactionId = params.transactionId; - - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); - } - if (typeof collectionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "collectionId"'); - } - if (typeof documents === 'undefined') { - throw new AppwriteException('Missing required parameter: "documents"'); - } - - const apiPath = '/documentsdb/{databaseId}/collections/{collectionId}/documents'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId); - const payload: Payload = {}; - if (typeof documents !== 'undefined') { - payload['documents'] = documents; - } - if (typeof transactionId !== 'undefined') { - payload['transactionId'] = transactionId; - } - const uri = new URL(this.client.config.endpoint + apiPath); - - const apiHeaders: { [header: string]: string } = { - 'content-type': 'application/json', - } - - return this.client.call( - 'put', - uri, - apiHeaders, - payload, - ); - } - - /** - * Update all documents that match your queries, if no queries are submitted then all documents are updated. You can pass only specific fields to be updated. - * - * @param {string} params.databaseId - Database ID. - * @param {string} params.collectionId - Collection ID. - * @param {object} params.data - Document data as JSON object. Include only attribute and value pairs to be updated. - * @param {string[]} params.queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. - * @param {string} params.transactionId - Transaction ID for staging the operation. - * @throws {AppwriteException} - * @returns {Promise>} - */ - updateDocuments(params: { databaseId: string, collectionId: string, data?: object, queries?: string[], transactionId?: string }): Promise>; - /** - * Update all documents that match your queries, if no queries are submitted then all documents are updated. You can pass only specific fields to be updated. - * - * @param {string} databaseId - Database ID. - * @param {string} collectionId - Collection ID. - * @param {object} data - Document data as JSON object. Include only attribute and value pairs to be updated. - * @param {string[]} queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. - * @param {string} transactionId - Transaction ID for staging the operation. - * @throws {AppwriteException} - * @returns {Promise>} - * @deprecated Use the object parameter style method for a better developer experience. - */ - updateDocuments(databaseId: string, collectionId: string, data?: object, queries?: string[], transactionId?: string): Promise>; - updateDocuments( - paramsOrFirst: { databaseId: string, collectionId: string, data?: object, queries?: string[], transactionId?: string } | string, - ...rest: [(string)?, (object)?, (string[])?, (string)?] - ): Promise> { - let params: { databaseId: string, collectionId: string, data?: object, queries?: string[], transactionId?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, data?: object, queries?: string[], transactionId?: string }; - } else { - params = { - databaseId: paramsOrFirst as string, - collectionId: rest[0] as string, - data: rest[1] as object, - queries: rest[2] as string[], - transactionId: rest[3] as string - }; - } - - const databaseId = params.databaseId; - const collectionId = params.collectionId; - const data = params.data; - const queries = params.queries; - const transactionId = params.transactionId; - - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); - } - if (typeof collectionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "collectionId"'); - } - - const apiPath = '/documentsdb/{databaseId}/collections/{collectionId}/documents'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId); - const payload: Payload = {}; - if (typeof data !== 'undefined') { - payload['data'] = data; - } - if (typeof queries !== 'undefined') { - payload['queries'] = queries; - } - if (typeof transactionId !== 'undefined') { - payload['transactionId'] = transactionId; - } - const uri = new URL(this.client.config.endpoint + apiPath); - - const apiHeaders: { [header: string]: string } = { - 'content-type': 'application/json', - } - - return this.client.call( - 'patch', - uri, - apiHeaders, - payload, - ); - } - - /** - * Bulk delete documents using queries, if no queries are passed then all documents are deleted. - * - * @param {string} params.databaseId - Database ID. - * @param {string} params.collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). - * @param {string[]} params.queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. - * @param {string} params.transactionId - Transaction ID for staging the operation. - * @throws {AppwriteException} - * @returns {Promise>} - */ - deleteDocuments(params: { databaseId: string, collectionId: string, queries?: string[], transactionId?: string }): Promise>; - /** - * Bulk delete documents using queries, if no queries are passed then all documents are deleted. - * - * @param {string} databaseId - Database ID. - * @param {string} collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). - * @param {string[]} queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. - * @param {string} transactionId - Transaction ID for staging the operation. - * @throws {AppwriteException} - * @returns {Promise>} - * @deprecated Use the object parameter style method for a better developer experience. - */ - deleteDocuments(databaseId: string, collectionId: string, queries?: string[], transactionId?: string): Promise>; - deleteDocuments( - paramsOrFirst: { databaseId: string, collectionId: string, queries?: string[], transactionId?: string } | string, - ...rest: [(string)?, (string[])?, (string)?] - ): Promise> { - let params: { databaseId: string, collectionId: string, queries?: string[], transactionId?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, queries?: string[], transactionId?: string }; - } else { - params = { - databaseId: paramsOrFirst as string, - collectionId: rest[0] as string, - queries: rest[1] as string[], - transactionId: rest[2] as string - }; - } - - const databaseId = params.databaseId; - const collectionId = params.collectionId; - const queries = params.queries; - const transactionId = params.transactionId; - - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); - } - if (typeof collectionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "collectionId"'); - } - - const apiPath = '/documentsdb/{databaseId}/collections/{collectionId}/documents'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId); - const payload: Payload = {}; - if (typeof queries !== 'undefined') { - payload['queries'] = queries; - } - if (typeof transactionId !== 'undefined') { - payload['transactionId'] = transactionId; - } - const uri = new URL(this.client.config.endpoint + apiPath); - - const apiHeaders: { [header: string]: string } = { - 'content-type': 'application/json', - } - - return this.client.call( - 'delete', - uri, - apiHeaders, - payload, - ); - } - - /** - * Get a document by its unique ID. This endpoint response returns a JSON object with the document data. - * - * @param {string} params.databaseId - Database ID. - * @param {string} params.collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). - * @param {string} params.documentId - Document ID. - * @param {string[]} params.queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. - * @param {string} params.transactionId - Transaction ID to read uncommitted changes within the transaction. - * @throws {AppwriteException} - * @returns {Promise} - */ - getDocument(params: { databaseId: string, collectionId: string, documentId: string, queries?: string[], transactionId?: string }): Promise; - /** - * Get a document by its unique ID. This endpoint response returns a JSON object with the document data. - * - * @param {string} databaseId - Database ID. - * @param {string} collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). - * @param {string} documentId - Document ID. - * @param {string[]} queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. - * @param {string} transactionId - Transaction ID to read uncommitted changes within the transaction. - * @throws {AppwriteException} - * @returns {Promise} - * @deprecated Use the object parameter style method for a better developer experience. - */ - getDocument(databaseId: string, collectionId: string, documentId: string, queries?: string[], transactionId?: string): Promise; - getDocument( - paramsOrFirst: { databaseId: string, collectionId: string, documentId: string, queries?: string[], transactionId?: string } | string, - ...rest: [(string)?, (string)?, (string[])?, (string)?] - ): Promise { - let params: { databaseId: string, collectionId: string, documentId: string, queries?: string[], transactionId?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, documentId: string, queries?: string[], transactionId?: string }; - } else { - params = { - databaseId: paramsOrFirst as string, - collectionId: rest[0] as string, - documentId: rest[1] as string, - queries: rest[2] as string[], - transactionId: rest[3] as string - }; - } - - const databaseId = params.databaseId; - const collectionId = params.collectionId; - const documentId = params.documentId; - const queries = params.queries; - const transactionId = params.transactionId; - - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); - } - if (typeof collectionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "collectionId"'); - } - if (typeof documentId === 'undefined') { - throw new AppwriteException('Missing required parameter: "documentId"'); - } - - const apiPath = '/documentsdb/{databaseId}/collections/{collectionId}/documents/{documentId}'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId).replace('{documentId}', documentId); - const payload: Payload = {}; - if (typeof queries !== 'undefined') { - payload['queries'] = queries; - } - if (typeof transactionId !== 'undefined') { - payload['transactionId'] = transactionId; - } - const uri = new URL(this.client.config.endpoint + apiPath); - - const apiHeaders: { [header: string]: string } = { - } - - return this.client.call( - 'get', - uri, - apiHeaders, - payload, - ); - } - - /** - * Create or update a Document. Before using this route, you should create a new collection resource using either a [server integration](https://appwrite.io/docs/server/databases#documentsDBCreateCollection) API or directly from your database console. - * - * @param {string} params.databaseId - Database ID. - * @param {string} params.collectionId - Collection ID. - * @param {string} params.documentId - Document ID. - * @param {Document extends Models.DefaultDocument ? Partial & Record : Partial & Partial>} params.data - Document data as JSON object. Include all required fields of the document to be created or updated. - * @param {string[]} params.permissions - An array of permissions strings. By default, the current permissions are inherited. [Learn more about permissions](https://appwrite.io/docs/permissions). - * @param {string} params.transactionId - Transaction ID for staging the operation. - * @throws {AppwriteException} - * @returns {Promise} - */ - upsertDocument(params: { databaseId: string, collectionId: string, documentId: string, data?: Document extends Models.DefaultDocument ? Partial & Record : Partial & Partial>, permissions?: string[], transactionId?: string }): Promise; - /** - * Create or update a Document. Before using this route, you should create a new collection resource using either a [server integration](https://appwrite.io/docs/server/databases#documentsDBCreateCollection) API or directly from your database console. - * - * @param {string} databaseId - Database ID. - * @param {string} collectionId - Collection ID. - * @param {string} documentId - Document ID. - * @param {Document extends Models.DefaultDocument ? Partial & Record : Partial & Partial>} data - Document data as JSON object. Include all required fields of the document to be created or updated. - * @param {string[]} permissions - An array of permissions strings. By default, the current permissions are inherited. [Learn more about permissions](https://appwrite.io/docs/permissions). - * @param {string} transactionId - Transaction ID for staging the operation. - * @throws {AppwriteException} - * @returns {Promise} - * @deprecated Use the object parameter style method for a better developer experience. - */ - upsertDocument(databaseId: string, collectionId: string, documentId: string, data?: Document extends Models.DefaultDocument ? Partial & Record : Partial & Partial>, permissions?: string[], transactionId?: string): Promise; - upsertDocument( - paramsOrFirst: { databaseId: string, collectionId: string, documentId: string, data?: Document extends Models.DefaultDocument ? Partial & Record : Partial & Partial>, permissions?: string[], transactionId?: string } | string, - ...rest: [(string)?, (string)?, (Document extends Models.DefaultDocument ? Partial & Record : Partial & Partial>)?, (string[])?, (string)?] - ): Promise { - let params: { databaseId: string, collectionId: string, documentId: string, data?: Document extends Models.DefaultDocument ? Partial & Record : Partial & Partial>, permissions?: string[], transactionId?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, documentId: string, data?: Document extends Models.DefaultDocument ? Partial & Record : Partial & Partial>, permissions?: string[], transactionId?: string }; - } else { - params = { - databaseId: paramsOrFirst as string, - collectionId: rest[0] as string, - documentId: rest[1] as string, - data: rest[2] as Document extends Models.DefaultDocument ? Partial & Record : Partial & Partial>, - permissions: rest[3] as string[], - transactionId: rest[4] as string - }; - } - - const databaseId = params.databaseId; - const collectionId = params.collectionId; - const documentId = params.documentId; - const data = params.data; - const permissions = params.permissions; - const transactionId = params.transactionId; - - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); - } - if (typeof collectionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "collectionId"'); - } - if (typeof documentId === 'undefined') { - throw new AppwriteException('Missing required parameter: "documentId"'); - } - - const apiPath = '/documentsdb/{databaseId}/collections/{collectionId}/documents/{documentId}'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId).replace('{documentId}', documentId); - const payload: Payload = {}; - if (typeof data !== 'undefined') { - payload['data'] = data; - } - if (typeof permissions !== 'undefined') { - payload['permissions'] = permissions; - } - if (typeof transactionId !== 'undefined') { - payload['transactionId'] = transactionId; - } - const uri = new URL(this.client.config.endpoint + apiPath); - - const apiHeaders: { [header: string]: string } = { - 'content-type': 'application/json', - } - - return this.client.call( - 'put', - uri, - apiHeaders, - payload, - ); - } - - /** - * Update a document by its unique ID. Using the patch method you can pass only specific fields that will get updated. - * - * @param {string} params.databaseId - Database ID. - * @param {string} params.collectionId - Collection ID. - * @param {string} params.documentId - Document ID. - * @param {Document extends Models.DefaultDocument ? Partial & Record : Partial & Partial>} params.data - Document data as JSON object. Include only fields and value pairs to be updated. - * @param {string[]} params.permissions - An array of permissions strings. By default, the current permissions are inherited. [Learn more about permissions](https://appwrite.io/docs/permissions). - * @param {string} params.transactionId - Transaction ID for staging the operation. - * @throws {AppwriteException} - * @returns {Promise} - */ - updateDocument(params: { databaseId: string, collectionId: string, documentId: string, data?: Document extends Models.DefaultDocument ? Partial & Record : Partial & Partial>, permissions?: string[], transactionId?: string }): Promise; - /** - * Update a document by its unique ID. Using the patch method you can pass only specific fields that will get updated. - * - * @param {string} databaseId - Database ID. - * @param {string} collectionId - Collection ID. - * @param {string} documentId - Document ID. - * @param {Document extends Models.DefaultDocument ? Partial & Record : Partial & Partial>} data - Document data as JSON object. Include only fields and value pairs to be updated. - * @param {string[]} permissions - An array of permissions strings. By default, the current permissions are inherited. [Learn more about permissions](https://appwrite.io/docs/permissions). - * @param {string} transactionId - Transaction ID for staging the operation. - * @throws {AppwriteException} - * @returns {Promise} - * @deprecated Use the object parameter style method for a better developer experience. - */ - updateDocument(databaseId: string, collectionId: string, documentId: string, data?: Document extends Models.DefaultDocument ? Partial & Record : Partial & Partial>, permissions?: string[], transactionId?: string): Promise; - updateDocument( - paramsOrFirst: { databaseId: string, collectionId: string, documentId: string, data?: Document extends Models.DefaultDocument ? Partial & Record : Partial & Partial>, permissions?: string[], transactionId?: string } | string, - ...rest: [(string)?, (string)?, (Document extends Models.DefaultDocument ? Partial & Record : Partial & Partial>)?, (string[])?, (string)?] - ): Promise { - let params: { databaseId: string, collectionId: string, documentId: string, data?: Document extends Models.DefaultDocument ? Partial & Record : Partial & Partial>, permissions?: string[], transactionId?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, documentId: string, data?: Document extends Models.DefaultDocument ? Partial & Record : Partial & Partial>, permissions?: string[], transactionId?: string }; - } else { - params = { - databaseId: paramsOrFirst as string, - collectionId: rest[0] as string, - documentId: rest[1] as string, - data: rest[2] as Document extends Models.DefaultDocument ? Partial & Record : Partial & Partial>, - permissions: rest[3] as string[], - transactionId: rest[4] as string - }; - } - - const databaseId = params.databaseId; - const collectionId = params.collectionId; - const documentId = params.documentId; - const data = params.data; - const permissions = params.permissions; - const transactionId = params.transactionId; - - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); - } - if (typeof collectionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "collectionId"'); - } - if (typeof documentId === 'undefined') { - throw new AppwriteException('Missing required parameter: "documentId"'); - } - - const apiPath = '/documentsdb/{databaseId}/collections/{collectionId}/documents/{documentId}'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId).replace('{documentId}', documentId); - const payload: Payload = {}; - if (typeof data !== 'undefined') { - payload['data'] = data; - } - if (typeof permissions !== 'undefined') { - payload['permissions'] = permissions; - } - if (typeof transactionId !== 'undefined') { - payload['transactionId'] = transactionId; - } - const uri = new URL(this.client.config.endpoint + apiPath); - - const apiHeaders: { [header: string]: string } = { - 'content-type': 'application/json', - } - - return this.client.call( - 'patch', - uri, - apiHeaders, - payload, - ); - } - - /** - * Delete a document by its unique ID. - * - * @param {string} params.databaseId - Database ID. - * @param {string} params.collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). - * @param {string} params.documentId - Document ID. - * @param {string} params.transactionId - Transaction ID for staging the operation. - * @throws {AppwriteException} - * @returns {Promise<{}>} - */ - deleteDocument(params: { databaseId: string, collectionId: string, documentId: string, transactionId?: string }): Promise<{}>; - /** - * Delete a document by its unique ID. - * - * @param {string} databaseId - Database ID. - * @param {string} collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). - * @param {string} documentId - Document ID. - * @param {string} transactionId - Transaction ID for staging the operation. - * @throws {AppwriteException} - * @returns {Promise<{}>} - * @deprecated Use the object parameter style method for a better developer experience. - */ - deleteDocument(databaseId: string, collectionId: string, documentId: string, transactionId?: string): Promise<{}>; - deleteDocument( - paramsOrFirst: { databaseId: string, collectionId: string, documentId: string, transactionId?: string } | string, - ...rest: [(string)?, (string)?, (string)?] - ): Promise<{}> { - let params: { databaseId: string, collectionId: string, documentId: string, transactionId?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, documentId: string, transactionId?: string }; - } else { - params = { - databaseId: paramsOrFirst as string, - collectionId: rest[0] as string, - documentId: rest[1] as string, - transactionId: rest[2] as string - }; - } - - const databaseId = params.databaseId; - const collectionId = params.collectionId; - const documentId = params.documentId; - const transactionId = params.transactionId; - - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); - } - if (typeof collectionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "collectionId"'); - } - if (typeof documentId === 'undefined') { - throw new AppwriteException('Missing required parameter: "documentId"'); - } - - const apiPath = '/documentsdb/{databaseId}/collections/{collectionId}/documents/{documentId}'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId).replace('{documentId}', documentId); - const payload: Payload = {}; - if (typeof transactionId !== 'undefined') { - payload['transactionId'] = transactionId; - } - const uri = new URL(this.client.config.endpoint + apiPath); - - const apiHeaders: { [header: string]: string } = { - 'content-type': 'application/json', - } - - return this.client.call( - 'delete', - uri, - apiHeaders, - payload, - ); - } - - /** - * Decrement a specific column of a row by a given value. - * - * @param {string} params.databaseId - Database ID. - * @param {string} params.collectionId - Collection ID. - * @param {string} params.documentId - Document ID. - * @param {string} params.attribute - Attribute key. - * @param {number} params.value - Value to decrement the attribute by. The value must be a number. - * @param {number} params.min - Minimum value for the attribute. If the current value is lesser than this value, an exception will be thrown. - * @param {string} params.transactionId - Transaction ID for staging the operation. - * @throws {AppwriteException} - * @returns {Promise} - */ - decrementDocumentAttribute(params: { databaseId: string, collectionId: string, documentId: string, attribute: string, value?: number, min?: number, transactionId?: string }): Promise; - /** - * Decrement a specific column of a row by a given value. - * - * @param {string} databaseId - Database ID. - * @param {string} collectionId - Collection ID. - * @param {string} documentId - Document ID. - * @param {string} attribute - Attribute key. - * @param {number} value - Value to decrement the attribute by. The value must be a number. - * @param {number} min - Minimum value for the attribute. If the current value is lesser than this value, an exception will be thrown. - * @param {string} transactionId - Transaction ID for staging the operation. - * @throws {AppwriteException} - * @returns {Promise} - * @deprecated Use the object parameter style method for a better developer experience. - */ - decrementDocumentAttribute(databaseId: string, collectionId: string, documentId: string, attribute: string, value?: number, min?: number, transactionId?: string): Promise; - decrementDocumentAttribute( - paramsOrFirst: { databaseId: string, collectionId: string, documentId: string, attribute: string, value?: number, min?: number, transactionId?: string } | string, - ...rest: [(string)?, (string)?, (string)?, (number)?, (number)?, (string)?] - ): Promise { - let params: { databaseId: string, collectionId: string, documentId: string, attribute: string, value?: number, min?: number, transactionId?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, documentId: string, attribute: string, value?: number, min?: number, transactionId?: string }; - } else { - params = { - databaseId: paramsOrFirst as string, - collectionId: rest[0] as string, - documentId: rest[1] as string, - attribute: rest[2] as string, - value: rest[3] as number, - min: rest[4] as number, - transactionId: rest[5] as string - }; - } - - const databaseId = params.databaseId; - const collectionId = params.collectionId; - const documentId = params.documentId; - const attribute = params.attribute; - const value = params.value; - const min = params.min; - const transactionId = params.transactionId; - - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); - } - if (typeof collectionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "collectionId"'); - } - if (typeof documentId === 'undefined') { - throw new AppwriteException('Missing required parameter: "documentId"'); - } - if (typeof attribute === 'undefined') { - throw new AppwriteException('Missing required parameter: "attribute"'); - } - - const apiPath = '/documentsdb/{databaseId}/collections/{collectionId}/documents/{documentId}/{attribute}/decrement'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId).replace('{documentId}', documentId).replace('{attribute}', attribute); - const payload: Payload = {}; - if (typeof value !== 'undefined') { - payload['value'] = value; - } - if (typeof min !== 'undefined') { - payload['min'] = min; - } - if (typeof transactionId !== 'undefined') { - payload['transactionId'] = transactionId; - } - const uri = new URL(this.client.config.endpoint + apiPath); - - const apiHeaders: { [header: string]: string } = { - 'content-type': 'application/json', - } - - return this.client.call( - 'patch', - uri, - apiHeaders, - payload, - ); - } - - /** - * Increment a specific column of a row by a given value. - * - * @param {string} params.databaseId - Database ID. - * @param {string} params.collectionId - Collection ID. - * @param {string} params.documentId - Document ID. - * @param {string} params.attribute - Attribute key. - * @param {number} params.value - Value to increment the attribute by. The value must be a number. - * @param {number} params.max - Maximum value for the attribute. If the current value is greater than this value, an error will be thrown. - * @param {string} params.transactionId - Transaction ID for staging the operation. - * @throws {AppwriteException} - * @returns {Promise} - */ - incrementDocumentAttribute(params: { databaseId: string, collectionId: string, documentId: string, attribute: string, value?: number, max?: number, transactionId?: string }): Promise; - /** - * Increment a specific column of a row by a given value. - * - * @param {string} databaseId - Database ID. - * @param {string} collectionId - Collection ID. - * @param {string} documentId - Document ID. - * @param {string} attribute - Attribute key. - * @param {number} value - Value to increment the attribute by. The value must be a number. - * @param {number} max - Maximum value for the attribute. If the current value is greater than this value, an error will be thrown. - * @param {string} transactionId - Transaction ID for staging the operation. - * @throws {AppwriteException} - * @returns {Promise} - * @deprecated Use the object parameter style method for a better developer experience. - */ - incrementDocumentAttribute(databaseId: string, collectionId: string, documentId: string, attribute: string, value?: number, max?: number, transactionId?: string): Promise; - incrementDocumentAttribute( - paramsOrFirst: { databaseId: string, collectionId: string, documentId: string, attribute: string, value?: number, max?: number, transactionId?: string } | string, - ...rest: [(string)?, (string)?, (string)?, (number)?, (number)?, (string)?] - ): Promise { - let params: { databaseId: string, collectionId: string, documentId: string, attribute: string, value?: number, max?: number, transactionId?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, documentId: string, attribute: string, value?: number, max?: number, transactionId?: string }; - } else { - params = { - databaseId: paramsOrFirst as string, - collectionId: rest[0] as string, - documentId: rest[1] as string, - attribute: rest[2] as string, - value: rest[3] as number, - max: rest[4] as number, - transactionId: rest[5] as string - }; - } - - const databaseId = params.databaseId; - const collectionId = params.collectionId; - const documentId = params.documentId; - const attribute = params.attribute; - const value = params.value; - const max = params.max; - const transactionId = params.transactionId; - - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); - } - if (typeof collectionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "collectionId"'); - } - if (typeof documentId === 'undefined') { - throw new AppwriteException('Missing required parameter: "documentId"'); - } - if (typeof attribute === 'undefined') { - throw new AppwriteException('Missing required parameter: "attribute"'); - } - - const apiPath = '/documentsdb/{databaseId}/collections/{collectionId}/documents/{documentId}/{attribute}/increment'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId).replace('{documentId}', documentId).replace('{attribute}', attribute); - const payload: Payload = {}; - if (typeof value !== 'undefined') { - payload['value'] = value; - } - if (typeof max !== 'undefined') { - payload['max'] = max; - } - if (typeof transactionId !== 'undefined') { - payload['transactionId'] = transactionId; - } - const uri = new URL(this.client.config.endpoint + apiPath); - - const apiHeaders: { [header: string]: string } = { - 'content-type': 'application/json', - } - - return this.client.call( - 'patch', - uri, - apiHeaders, - payload, - ); - } - - /** - * List indexes in the collection. - * - * @param {string} params.databaseId - Database ID. - * @param {string} params.collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). - * @param {string[]} params.queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: key, type, status, attributes, error - * @param {boolean} params.total - When set to false, the total count returned will be 0 and will not be calculated. - * @throws {AppwriteException} - * @returns {Promise} - */ - listIndexes(params: { databaseId: string, collectionId: string, queries?: string[], total?: boolean }): Promise; - /** - * List indexes in the collection. - * - * @param {string} databaseId - Database ID. - * @param {string} collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). - * @param {string[]} queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: key, type, status, attributes, error - * @param {boolean} total - When set to false, the total count returned will be 0 and will not be calculated. - * @throws {AppwriteException} - * @returns {Promise} - * @deprecated Use the object parameter style method for a better developer experience. - */ - listIndexes(databaseId: string, collectionId: string, queries?: string[], total?: boolean): Promise; - listIndexes( - paramsOrFirst: { databaseId: string, collectionId: string, queries?: string[], total?: boolean } | string, - ...rest: [(string)?, (string[])?, (boolean)?] - ): Promise { - let params: { databaseId: string, collectionId: string, queries?: string[], total?: boolean }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, queries?: string[], total?: boolean }; - } else { - params = { - databaseId: paramsOrFirst as string, - collectionId: rest[0] as string, - queries: rest[1] as string[], - total: rest[2] as boolean - }; - } - - const databaseId = params.databaseId; - const collectionId = params.collectionId; - const queries = params.queries; - const total = params.total; - - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); - } - if (typeof collectionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "collectionId"'); - } - - const apiPath = '/documentsdb/{databaseId}/collections/{collectionId}/indexes'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId); - const payload: Payload = {}; - if (typeof queries !== 'undefined') { - payload['queries'] = queries; - } - if (typeof total !== 'undefined') { - payload['total'] = total; - } - const uri = new URL(this.client.config.endpoint + apiPath); - - const apiHeaders: { [header: string]: string } = { - } - - return this.client.call( - 'get', - uri, - apiHeaders, - payload, - ); - } - - /** - * Creates an index on the attributes listed. Your index should include all the attributes you will query in a single request. - * Attributes can be `key`, `fulltext`, and `unique`. - * - * @param {string} params.databaseId - Database ID. - * @param {string} params.collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). - * @param {string} params.key - Index Key. - * @param {DocumentsDBIndexType} params.type - Index type. - * @param {string[]} params.attributes - Array of attributes to index. Maximum of 100 attributes are allowed, each 32 characters long. - * @param {OrderBy[]} params.orders - Array of index orders. Maximum of 100 orders are allowed. - * @param {number[]} params.lengths - Length of index. Maximum of 100 - * @throws {AppwriteException} - * @returns {Promise} - */ - createIndex(params: { databaseId: string, collectionId: string, key: string, type: DocumentsDBIndexType, attributes: string[], orders?: OrderBy[], lengths?: number[] }): Promise; - /** - * Creates an index on the attributes listed. Your index should include all the attributes you will query in a single request. - * Attributes can be `key`, `fulltext`, and `unique`. - * - * @param {string} databaseId - Database ID. - * @param {string} collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). - * @param {string} key - Index Key. - * @param {DocumentsDBIndexType} type - Index type. - * @param {string[]} attributes - Array of attributes to index. Maximum of 100 attributes are allowed, each 32 characters long. - * @param {OrderBy[]} orders - Array of index orders. Maximum of 100 orders are allowed. - * @param {number[]} lengths - Length of index. Maximum of 100 - * @throws {AppwriteException} - * @returns {Promise} - * @deprecated Use the object parameter style method for a better developer experience. - */ - createIndex(databaseId: string, collectionId: string, key: string, type: DocumentsDBIndexType, attributes: string[], orders?: OrderBy[], lengths?: number[]): Promise; - createIndex( - paramsOrFirst: { databaseId: string, collectionId: string, key: string, type: DocumentsDBIndexType, attributes: string[], orders?: OrderBy[], lengths?: number[] } | string, - ...rest: [(string)?, (string)?, (DocumentsDBIndexType)?, (string[])?, (OrderBy[])?, (number[])?] - ): Promise { - let params: { databaseId: string, collectionId: string, key: string, type: DocumentsDBIndexType, attributes: string[], orders?: OrderBy[], lengths?: number[] }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, key: string, type: DocumentsDBIndexType, attributes: string[], orders?: OrderBy[], lengths?: number[] }; - } else { - params = { - databaseId: paramsOrFirst as string, - collectionId: rest[0] as string, - key: rest[1] as string, - type: rest[2] as DocumentsDBIndexType, - attributes: rest[3] as string[], - orders: rest[4] as OrderBy[], - lengths: rest[5] as number[] - }; - } - - const databaseId = params.databaseId; - const collectionId = params.collectionId; - const key = params.key; - const type = params.type; - const attributes = params.attributes; - const orders = params.orders; - const lengths = params.lengths; - - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); - } - if (typeof collectionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "collectionId"'); - } - if (typeof key === 'undefined') { - throw new AppwriteException('Missing required parameter: "key"'); - } - if (typeof type === 'undefined') { - throw new AppwriteException('Missing required parameter: "type"'); - } - if (typeof attributes === 'undefined') { - throw new AppwriteException('Missing required parameter: "attributes"'); - } - - const apiPath = '/documentsdb/{databaseId}/collections/{collectionId}/indexes'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId); - const payload: Payload = {}; - if (typeof key !== 'undefined') { - payload['key'] = key; - } - if (typeof type !== 'undefined') { - payload['type'] = type; - } - if (typeof attributes !== 'undefined') { - payload['attributes'] = attributes; - } - if (typeof orders !== 'undefined') { - payload['orders'] = orders; - } - if (typeof lengths !== 'undefined') { - payload['lengths'] = lengths; - } - const uri = new URL(this.client.config.endpoint + apiPath); - - const apiHeaders: { [header: string]: string } = { - 'content-type': 'application/json', - } - - return this.client.call( - 'post', - uri, - apiHeaders, - payload, - ); - } - - /** - * Get index by ID. - * - * @param {string} params.databaseId - Database ID. - * @param {string} params.collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). - * @param {string} params.key - Index Key. - * @throws {AppwriteException} - * @returns {Promise} - */ - getIndex(params: { databaseId: string, collectionId: string, key: string }): Promise; - /** - * Get index by ID. - * - * @param {string} databaseId - Database ID. - * @param {string} collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). - * @param {string} key - Index Key. - * @throws {AppwriteException} - * @returns {Promise} - * @deprecated Use the object parameter style method for a better developer experience. - */ - getIndex(databaseId: string, collectionId: string, key: string): Promise; - getIndex( - paramsOrFirst: { databaseId: string, collectionId: string, key: string } | string, - ...rest: [(string)?, (string)?] - ): Promise { - let params: { databaseId: string, collectionId: string, key: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, key: string }; - } else { - params = { - databaseId: paramsOrFirst as string, - collectionId: rest[0] as string, - key: rest[1] as string - }; - } - - const databaseId = params.databaseId; - const collectionId = params.collectionId; - const key = params.key; - - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); - } - if (typeof collectionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "collectionId"'); - } - if (typeof key === 'undefined') { - throw new AppwriteException('Missing required parameter: "key"'); - } - - const apiPath = '/documentsdb/{databaseId}/collections/{collectionId}/indexes/{key}'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId).replace('{key}', key); - const payload: Payload = {}; - const uri = new URL(this.client.config.endpoint + apiPath); - - const apiHeaders: { [header: string]: string } = { - } - - return this.client.call( - 'get', - uri, - apiHeaders, - payload, - ); - } - - /** - * Delete an index. - * - * @param {string} params.databaseId - Database ID. - * @param {string} params.collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). - * @param {string} params.key - Index Key. - * @throws {AppwriteException} - * @returns {Promise<{}>} - */ - deleteIndex(params: { databaseId: string, collectionId: string, key: string }): Promise<{}>; - /** - * Delete an index. - * - * @param {string} databaseId - Database ID. - * @param {string} collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). - * @param {string} key - Index Key. - * @throws {AppwriteException} - * @returns {Promise<{}>} - * @deprecated Use the object parameter style method for a better developer experience. - */ - deleteIndex(databaseId: string, collectionId: string, key: string): Promise<{}>; - deleteIndex( - paramsOrFirst: { databaseId: string, collectionId: string, key: string } | string, - ...rest: [(string)?, (string)?] - ): Promise<{}> { - let params: { databaseId: string, collectionId: string, key: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, key: string }; - } else { - params = { - databaseId: paramsOrFirst as string, - collectionId: rest[0] as string, - key: rest[1] as string - }; - } - - const databaseId = params.databaseId; - const collectionId = params.collectionId; - const key = params.key; - - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); - } - if (typeof collectionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "collectionId"'); - } - if (typeof key === 'undefined') { - throw new AppwriteException('Missing required parameter: "key"'); - } - - const apiPath = '/documentsdb/{databaseId}/collections/{collectionId}/indexes/{key}'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId).replace('{key}', key); - const payload: Payload = {}; - const uri = new URL(this.client.config.endpoint + apiPath); - - const apiHeaders: { [header: string]: string } = { - 'content-type': 'application/json', - } - - return this.client.call( - 'delete', - uri, - apiHeaders, - payload, - ); - } -} diff --git a/src/services/vectors-db.ts b/src/services/vectors-db.ts deleted file mode 100644 index 5a9dca25..00000000 --- a/src/services/vectors-db.ts +++ /dev/null @@ -1,2170 +0,0 @@ -import { AppwriteException, Client, type Payload, UploadProgress } from '../client'; -import type { Models } from '../models'; - -import { Model } from '../enums/model'; -import { VectorsDBIndexType } from '../enums/vectors-db-index-type'; -import { OrderBy } from '../enums/order-by'; - -export class VectorsDB { - client: Client; - - constructor(client: Client) { - this.client = client; - } - - /** - * - * @param {string[]} params.queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following columns: name - * @param {string} params.search - Search term to filter your list results. Max length: 256 chars. - * @param {boolean} params.total - When set to false, the total count returned will be 0 and will not be calculated. - * @throws {AppwriteException} - * @returns {Promise} - */ - list(params?: { queries?: string[], search?: string, total?: boolean }): Promise; - /** - * - * @param {string[]} queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following columns: name - * @param {string} search - Search term to filter your list results. Max length: 256 chars. - * @param {boolean} total - When set to false, the total count returned will be 0 and will not be calculated. - * @throws {AppwriteException} - * @returns {Promise} - * @deprecated Use the object parameter style method for a better developer experience. - */ - list(queries?: string[], search?: string, total?: boolean): Promise; - list( - paramsOrFirst?: { queries?: string[], search?: string, total?: boolean } | string[], - ...rest: [(string)?, (boolean)?] - ): Promise { - let params: { queries?: string[], search?: string, total?: boolean }; - - if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { queries?: string[], search?: string, total?: boolean }; - } else { - params = { - queries: paramsOrFirst as string[], - search: rest[0] as string, - total: rest[1] as boolean - }; - } - - const queries = params.queries; - const search = params.search; - const total = params.total; - - - const apiPath = '/vectorsdb'; - const payload: Payload = {}; - if (typeof queries !== 'undefined') { - payload['queries'] = queries; - } - if (typeof search !== 'undefined') { - payload['search'] = search; - } - if (typeof total !== 'undefined') { - payload['total'] = total; - } - const uri = new URL(this.client.config.endpoint + apiPath); - - const apiHeaders: { [header: string]: string } = { - } - - return this.client.call( - 'get', - uri, - apiHeaders, - payload, - ); - } - - /** - * - * @param {string} params.databaseId - Unique Id. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. - * @param {string} params.name - Database name. Max length: 128 chars. - * @param {boolean} params.enabled - Is the database enabled? When set to 'disabled', users cannot access the database but Server SDKs with an API key can still read and write to the database. No data is lost when this is toggled. - * @throws {AppwriteException} - * @returns {Promise} - */ - create(params: { databaseId: string, name: string, enabled?: boolean }): Promise; - /** - * - * @param {string} databaseId - Unique Id. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. - * @param {string} name - Database name. Max length: 128 chars. - * @param {boolean} enabled - Is the database enabled? When set to 'disabled', users cannot access the database but Server SDKs with an API key can still read and write to the database. No data is lost when this is toggled. - * @throws {AppwriteException} - * @returns {Promise} - * @deprecated Use the object parameter style method for a better developer experience. - */ - create(databaseId: string, name: string, enabled?: boolean): Promise; - create( - paramsOrFirst: { databaseId: string, name: string, enabled?: boolean } | string, - ...rest: [(string)?, (boolean)?] - ): Promise { - let params: { databaseId: string, name: string, enabled?: boolean }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, name: string, enabled?: boolean }; - } else { - params = { - databaseId: paramsOrFirst as string, - name: rest[0] as string, - enabled: rest[1] as boolean - }; - } - - const databaseId = params.databaseId; - const name = params.name; - const enabled = params.enabled; - - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); - } - if (typeof name === 'undefined') { - throw new AppwriteException('Missing required parameter: "name"'); - } - - const apiPath = '/vectorsdb'; - const payload: Payload = {}; - if (typeof databaseId !== 'undefined') { - payload['databaseId'] = databaseId; - } - if (typeof name !== 'undefined') { - payload['name'] = name; - } - if (typeof enabled !== 'undefined') { - payload['enabled'] = enabled; - } - const uri = new URL(this.client.config.endpoint + apiPath); - - const apiHeaders: { [header: string]: string } = { - 'content-type': 'application/json', - } - - return this.client.call( - 'post', - uri, - apiHeaders, - payload, - ); - } - - /** - * - * @param {string[]} params.texts - Array of text to generate embeddings. - * @param {Model} params.model - The embedding model to use for generating vector embeddings. - * @throws {AppwriteException} - * @returns {Promise} - */ - createTextEmbeddings(params: { texts: string[], model?: Model }): Promise; - /** - * - * @param {string[]} texts - Array of text to generate embeddings. - * @param {Model} model - The embedding model to use for generating vector embeddings. - * @throws {AppwriteException} - * @returns {Promise} - * @deprecated Use the object parameter style method for a better developer experience. - */ - createTextEmbeddings(texts: string[], model?: Model): Promise; - createTextEmbeddings( - paramsOrFirst: { texts: string[], model?: Model } | string[], - ...rest: [(Model)?] - ): Promise { - let params: { texts: string[], model?: Model }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { texts: string[], model?: Model }; - } else { - params = { - texts: paramsOrFirst as string[], - model: rest[0] as Model - }; - } - - const texts = params.texts; - const model = params.model; - - if (typeof texts === 'undefined') { - throw new AppwriteException('Missing required parameter: "texts"'); - } - - const apiPath = '/vectorsdb/embeddings/text'; - const payload: Payload = {}; - if (typeof texts !== 'undefined') { - payload['texts'] = texts; - } - if (typeof model !== 'undefined') { - payload['model'] = model; - } - const uri = new URL(this.client.config.endpoint + apiPath); - - const apiHeaders: { [header: string]: string } = { - 'content-type': 'application/json', - } - - return this.client.call( - 'post', - uri, - apiHeaders, - payload, - ); - } - - /** - * - * @param {string[]} params.queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). - * @throws {AppwriteException} - * @returns {Promise} - */ - listTransactions(params?: { queries?: string[] }): Promise; - /** - * - * @param {string[]} queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). - * @throws {AppwriteException} - * @returns {Promise} - * @deprecated Use the object parameter style method for a better developer experience. - */ - listTransactions(queries?: string[]): Promise; - listTransactions( - paramsOrFirst?: { queries?: string[] } | string[] - ): Promise { - let params: { queries?: string[] }; - - if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { queries?: string[] }; - } else { - params = { - queries: paramsOrFirst as string[] - }; - } - - const queries = params.queries; - - - const apiPath = '/vectorsdb/transactions'; - const payload: Payload = {}; - if (typeof queries !== 'undefined') { - payload['queries'] = queries; - } - const uri = new URL(this.client.config.endpoint + apiPath); - - const apiHeaders: { [header: string]: string } = { - } - - return this.client.call( - 'get', - uri, - apiHeaders, - payload, - ); - } - - /** - * - * @param {number} params.ttl - Seconds before the transaction expires. - * @throws {AppwriteException} - * @returns {Promise} - */ - createTransaction(params?: { ttl?: number }): Promise; - /** - * - * @param {number} ttl - Seconds before the transaction expires. - * @throws {AppwriteException} - * @returns {Promise} - * @deprecated Use the object parameter style method for a better developer experience. - */ - createTransaction(ttl?: number): Promise; - createTransaction( - paramsOrFirst?: { ttl?: number } | number - ): Promise { - let params: { ttl?: number }; - - if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { ttl?: number }; - } else { - params = { - ttl: paramsOrFirst as number - }; - } - - const ttl = params.ttl; - - - const apiPath = '/vectorsdb/transactions'; - const payload: Payload = {}; - if (typeof ttl !== 'undefined') { - payload['ttl'] = ttl; - } - const uri = new URL(this.client.config.endpoint + apiPath); - - const apiHeaders: { [header: string]: string } = { - 'content-type': 'application/json', - } - - return this.client.call( - 'post', - uri, - apiHeaders, - payload, - ); - } - - /** - * - * @param {string} params.transactionId - Transaction ID. - * @throws {AppwriteException} - * @returns {Promise} - */ - getTransaction(params: { transactionId: string }): Promise; - /** - * - * @param {string} transactionId - Transaction ID. - * @throws {AppwriteException} - * @returns {Promise} - * @deprecated Use the object parameter style method for a better developer experience. - */ - getTransaction(transactionId: string): Promise; - getTransaction( - paramsOrFirst: { transactionId: string } | string - ): Promise { - let params: { transactionId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { transactionId: string }; - } else { - params = { - transactionId: paramsOrFirst as string - }; - } - - const transactionId = params.transactionId; - - if (typeof transactionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "transactionId"'); - } - - const apiPath = '/vectorsdb/transactions/{transactionId}'.replace('{transactionId}', transactionId); - const payload: Payload = {}; - const uri = new URL(this.client.config.endpoint + apiPath); - - const apiHeaders: { [header: string]: string } = { - } - - return this.client.call( - 'get', - uri, - apiHeaders, - payload, - ); - } - - /** - * - * @param {string} params.transactionId - Transaction ID. - * @param {boolean} params.commit - Commit transaction? - * @param {boolean} params.rollback - Rollback transaction? - * @throws {AppwriteException} - * @returns {Promise} - */ - updateTransaction(params: { transactionId: string, commit?: boolean, rollback?: boolean }): Promise; - /** - * - * @param {string} transactionId - Transaction ID. - * @param {boolean} commit - Commit transaction? - * @param {boolean} rollback - Rollback transaction? - * @throws {AppwriteException} - * @returns {Promise} - * @deprecated Use the object parameter style method for a better developer experience. - */ - updateTransaction(transactionId: string, commit?: boolean, rollback?: boolean): Promise; - updateTransaction( - paramsOrFirst: { transactionId: string, commit?: boolean, rollback?: boolean } | string, - ...rest: [(boolean)?, (boolean)?] - ): Promise { - let params: { transactionId: string, commit?: boolean, rollback?: boolean }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { transactionId: string, commit?: boolean, rollback?: boolean }; - } else { - params = { - transactionId: paramsOrFirst as string, - commit: rest[0] as boolean, - rollback: rest[1] as boolean - }; - } - - const transactionId = params.transactionId; - const commit = params.commit; - const rollback = params.rollback; - - if (typeof transactionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "transactionId"'); - } - - const apiPath = '/vectorsdb/transactions/{transactionId}'.replace('{transactionId}', transactionId); - const payload: Payload = {}; - if (typeof commit !== 'undefined') { - payload['commit'] = commit; - } - if (typeof rollback !== 'undefined') { - payload['rollback'] = rollback; - } - const uri = new URL(this.client.config.endpoint + apiPath); - - const apiHeaders: { [header: string]: string } = { - 'content-type': 'application/json', - } - - return this.client.call( - 'patch', - uri, - apiHeaders, - payload, - ); - } - - /** - * - * @param {string} params.transactionId - Transaction ID. - * @throws {AppwriteException} - * @returns {Promise<{}>} - */ - deleteTransaction(params: { transactionId: string }): Promise<{}>; - /** - * - * @param {string} transactionId - Transaction ID. - * @throws {AppwriteException} - * @returns {Promise<{}>} - * @deprecated Use the object parameter style method for a better developer experience. - */ - deleteTransaction(transactionId: string): Promise<{}>; - deleteTransaction( - paramsOrFirst: { transactionId: string } | string - ): Promise<{}> { - let params: { transactionId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { transactionId: string }; - } else { - params = { - transactionId: paramsOrFirst as string - }; - } - - const transactionId = params.transactionId; - - if (typeof transactionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "transactionId"'); - } - - const apiPath = '/vectorsdb/transactions/{transactionId}'.replace('{transactionId}', transactionId); - const payload: Payload = {}; - const uri = new URL(this.client.config.endpoint + apiPath); - - const apiHeaders: { [header: string]: string } = { - 'content-type': 'application/json', - } - - return this.client.call( - 'delete', - uri, - apiHeaders, - payload, - ); - } - - /** - * - * @param {string} params.transactionId - Transaction ID. - * @param {object[]} params.operations - Array of staged operations. - * @throws {AppwriteException} - * @returns {Promise} - */ - createOperations(params: { transactionId: string, operations?: object[] }): Promise; - /** - * - * @param {string} transactionId - Transaction ID. - * @param {object[]} operations - Array of staged operations. - * @throws {AppwriteException} - * @returns {Promise} - * @deprecated Use the object parameter style method for a better developer experience. - */ - createOperations(transactionId: string, operations?: object[]): Promise; - createOperations( - paramsOrFirst: { transactionId: string, operations?: object[] } | string, - ...rest: [(object[])?] - ): Promise { - let params: { transactionId: string, operations?: object[] }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { transactionId: string, operations?: object[] }; - } else { - params = { - transactionId: paramsOrFirst as string, - operations: rest[0] as object[] - }; - } - - const transactionId = params.transactionId; - const operations = params.operations; - - if (typeof transactionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "transactionId"'); - } - - const apiPath = '/vectorsdb/transactions/{transactionId}/operations'.replace('{transactionId}', transactionId); - const payload: Payload = {}; - if (typeof operations !== 'undefined') { - payload['operations'] = operations; - } - const uri = new URL(this.client.config.endpoint + apiPath); - - const apiHeaders: { [header: string]: string } = { - 'content-type': 'application/json', - } - - return this.client.call( - 'post', - uri, - apiHeaders, - payload, - ); - } - - /** - * - * @param {string} params.databaseId - Database ID. - * @throws {AppwriteException} - * @returns {Promise} - */ - get(params: { databaseId: string }): Promise; - /** - * - * @param {string} databaseId - Database ID. - * @throws {AppwriteException} - * @returns {Promise} - * @deprecated Use the object parameter style method for a better developer experience. - */ - get(databaseId: string): Promise; - get( - paramsOrFirst: { databaseId: string } | string - ): Promise { - let params: { databaseId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string }; - } else { - params = { - databaseId: paramsOrFirst as string - }; - } - - const databaseId = params.databaseId; - - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); - } - - const apiPath = '/vectorsdb/{databaseId}'.replace('{databaseId}', databaseId); - const payload: Payload = {}; - const uri = new URL(this.client.config.endpoint + apiPath); - - const apiHeaders: { [header: string]: string } = { - } - - return this.client.call( - 'get', - uri, - apiHeaders, - payload, - ); - } - - /** - * - * @param {string} params.databaseId - Database ID. - * @param {string} params.name - Database name. Max length: 128 chars. - * @param {boolean} params.enabled - Is database enabled? When set to 'disabled', users cannot access the database but Server SDKs with an API key can still read and write to the database. No data is lost when this is toggled. - * @throws {AppwriteException} - * @returns {Promise} - */ - update(params: { databaseId: string, name: string, enabled?: boolean }): Promise; - /** - * - * @param {string} databaseId - Database ID. - * @param {string} name - Database name. Max length: 128 chars. - * @param {boolean} enabled - Is database enabled? When set to 'disabled', users cannot access the database but Server SDKs with an API key can still read and write to the database. No data is lost when this is toggled. - * @throws {AppwriteException} - * @returns {Promise} - * @deprecated Use the object parameter style method for a better developer experience. - */ - update(databaseId: string, name: string, enabled?: boolean): Promise; - update( - paramsOrFirst: { databaseId: string, name: string, enabled?: boolean } | string, - ...rest: [(string)?, (boolean)?] - ): Promise { - let params: { databaseId: string, name: string, enabled?: boolean }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, name: string, enabled?: boolean }; - } else { - params = { - databaseId: paramsOrFirst as string, - name: rest[0] as string, - enabled: rest[1] as boolean - }; - } - - const databaseId = params.databaseId; - const name = params.name; - const enabled = params.enabled; - - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); - } - if (typeof name === 'undefined') { - throw new AppwriteException('Missing required parameter: "name"'); - } - - const apiPath = '/vectorsdb/{databaseId}'.replace('{databaseId}', databaseId); - const payload: Payload = {}; - if (typeof name !== 'undefined') { - payload['name'] = name; - } - if (typeof enabled !== 'undefined') { - payload['enabled'] = enabled; - } - const uri = new URL(this.client.config.endpoint + apiPath); - - const apiHeaders: { [header: string]: string } = { - 'content-type': 'application/json', - } - - return this.client.call( - 'put', - uri, - apiHeaders, - payload, - ); - } - - /** - * - * @param {string} params.databaseId - Database ID. - * @throws {AppwriteException} - * @returns {Promise<{}>} - */ - delete(params: { databaseId: string }): Promise<{}>; - /** - * - * @param {string} databaseId - Database ID. - * @throws {AppwriteException} - * @returns {Promise<{}>} - * @deprecated Use the object parameter style method for a better developer experience. - */ - delete(databaseId: string): Promise<{}>; - delete( - paramsOrFirst: { databaseId: string } | string - ): Promise<{}> { - let params: { databaseId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string }; - } else { - params = { - databaseId: paramsOrFirst as string - }; - } - - const databaseId = params.databaseId; - - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); - } - - const apiPath = '/vectorsdb/{databaseId}'.replace('{databaseId}', databaseId); - const payload: Payload = {}; - const uri = new URL(this.client.config.endpoint + apiPath); - - const apiHeaders: { [header: string]: string } = { - 'content-type': 'application/json', - } - - return this.client.call( - 'delete', - uri, - apiHeaders, - payload, - ); - } - - /** - * - * @param {string} params.databaseId - Database ID. - * @param {string[]} params.queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: name, enabled, documentSecurity - * @param {string} params.search - Search term to filter your list results. Max length: 256 chars. - * @param {boolean} params.total - When set to false, the total count returned will be 0 and will not be calculated. - * @throws {AppwriteException} - * @returns {Promise} - */ - listCollections(params: { databaseId: string, queries?: string[], search?: string, total?: boolean }): Promise; - /** - * - * @param {string} databaseId - Database ID. - * @param {string[]} queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: name, enabled, documentSecurity - * @param {string} search - Search term to filter your list results. Max length: 256 chars. - * @param {boolean} total - When set to false, the total count returned will be 0 and will not be calculated. - * @throws {AppwriteException} - * @returns {Promise} - * @deprecated Use the object parameter style method for a better developer experience. - */ - listCollections(databaseId: string, queries?: string[], search?: string, total?: boolean): Promise; - listCollections( - paramsOrFirst: { databaseId: string, queries?: string[], search?: string, total?: boolean } | string, - ...rest: [(string[])?, (string)?, (boolean)?] - ): Promise { - let params: { databaseId: string, queries?: string[], search?: string, total?: boolean }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, queries?: string[], search?: string, total?: boolean }; - } else { - params = { - databaseId: paramsOrFirst as string, - queries: rest[0] as string[], - search: rest[1] as string, - total: rest[2] as boolean - }; - } - - const databaseId = params.databaseId; - const queries = params.queries; - const search = params.search; - const total = params.total; - - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); - } - - const apiPath = '/vectorsdb/{databaseId}/collections'.replace('{databaseId}', databaseId); - const payload: Payload = {}; - if (typeof queries !== 'undefined') { - payload['queries'] = queries; - } - if (typeof search !== 'undefined') { - payload['search'] = search; - } - if (typeof total !== 'undefined') { - payload['total'] = total; - } - const uri = new URL(this.client.config.endpoint + apiPath); - - const apiHeaders: { [header: string]: string } = { - } - - return this.client.call( - 'get', - uri, - apiHeaders, - payload, - ); - } - - /** - * - * @param {string} params.databaseId - Database ID. - * @param {string} params.collectionId - Unique Id. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. - * @param {string} params.name - Collection name. Max length: 128 chars. - * @param {number} params.dimension - Embedding dimension. - * @param {string[]} params.permissions - An array of permissions strings. By default, no user is granted with any permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). - * @param {boolean} params.documentSecurity - Enables configuring permissions for individual documents. A user needs one of document or collection level permissions to access a document. [Learn more about permissions](https://appwrite.io/docs/permissions). - * @param {boolean} params.enabled - Is collection enabled? When set to 'disabled', users cannot access the collection but Server SDKs with and API key can still read and write to the collection. No data is lost when this is toggled. - * @throws {AppwriteException} - * @returns {Promise} - */ - createCollection(params: { databaseId: string, collectionId: string, name: string, dimension: number, permissions?: string[], documentSecurity?: boolean, enabled?: boolean }): Promise; - /** - * - * @param {string} databaseId - Database ID. - * @param {string} collectionId - Unique Id. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. - * @param {string} name - Collection name. Max length: 128 chars. - * @param {number} dimension - Embedding dimension. - * @param {string[]} permissions - An array of permissions strings. By default, no user is granted with any permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). - * @param {boolean} documentSecurity - Enables configuring permissions for individual documents. A user needs one of document or collection level permissions to access a document. [Learn more about permissions](https://appwrite.io/docs/permissions). - * @param {boolean} enabled - Is collection enabled? When set to 'disabled', users cannot access the collection but Server SDKs with and API key can still read and write to the collection. No data is lost when this is toggled. - * @throws {AppwriteException} - * @returns {Promise} - * @deprecated Use the object parameter style method for a better developer experience. - */ - createCollection(databaseId: string, collectionId: string, name: string, dimension: number, permissions?: string[], documentSecurity?: boolean, enabled?: boolean): Promise; - createCollection( - paramsOrFirst: { databaseId: string, collectionId: string, name: string, dimension: number, permissions?: string[], documentSecurity?: boolean, enabled?: boolean } | string, - ...rest: [(string)?, (string)?, (number)?, (string[])?, (boolean)?, (boolean)?] - ): Promise { - let params: { databaseId: string, collectionId: string, name: string, dimension: number, permissions?: string[], documentSecurity?: boolean, enabled?: boolean }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, name: string, dimension: number, permissions?: string[], documentSecurity?: boolean, enabled?: boolean }; - } else { - params = { - databaseId: paramsOrFirst as string, - collectionId: rest[0] as string, - name: rest[1] as string, - dimension: rest[2] as number, - permissions: rest[3] as string[], - documentSecurity: rest[4] as boolean, - enabled: rest[5] as boolean - }; - } - - const databaseId = params.databaseId; - const collectionId = params.collectionId; - const name = params.name; - const dimension = params.dimension; - const permissions = params.permissions; - const documentSecurity = params.documentSecurity; - const enabled = params.enabled; - - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); - } - if (typeof collectionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "collectionId"'); - } - if (typeof name === 'undefined') { - throw new AppwriteException('Missing required parameter: "name"'); - } - if (typeof dimension === 'undefined') { - throw new AppwriteException('Missing required parameter: "dimension"'); - } - - const apiPath = '/vectorsdb/{databaseId}/collections'.replace('{databaseId}', databaseId); - const payload: Payload = {}; - if (typeof collectionId !== 'undefined') { - payload['collectionId'] = collectionId; - } - if (typeof name !== 'undefined') { - payload['name'] = name; - } - if (typeof dimension !== 'undefined') { - payload['dimension'] = dimension; - } - if (typeof permissions !== 'undefined') { - payload['permissions'] = permissions; - } - if (typeof documentSecurity !== 'undefined') { - payload['documentSecurity'] = documentSecurity; - } - if (typeof enabled !== 'undefined') { - payload['enabled'] = enabled; - } - const uri = new URL(this.client.config.endpoint + apiPath); - - const apiHeaders: { [header: string]: string } = { - 'content-type': 'application/json', - } - - return this.client.call( - 'post', - uri, - apiHeaders, - payload, - ); - } - - /** - * - * @param {string} params.databaseId - Database ID. - * @param {string} params.collectionId - Collection ID. - * @throws {AppwriteException} - * @returns {Promise} - */ - getCollection(params: { databaseId: string, collectionId: string }): Promise; - /** - * - * @param {string} databaseId - Database ID. - * @param {string} collectionId - Collection ID. - * @throws {AppwriteException} - * @returns {Promise} - * @deprecated Use the object parameter style method for a better developer experience. - */ - getCollection(databaseId: string, collectionId: string): Promise; - getCollection( - paramsOrFirst: { databaseId: string, collectionId: string } | string, - ...rest: [(string)?] - ): Promise { - let params: { databaseId: string, collectionId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string }; - } else { - params = { - databaseId: paramsOrFirst as string, - collectionId: rest[0] as string - }; - } - - const databaseId = params.databaseId; - const collectionId = params.collectionId; - - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); - } - if (typeof collectionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "collectionId"'); - } - - const apiPath = '/vectorsdb/{databaseId}/collections/{collectionId}'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId); - const payload: Payload = {}; - const uri = new URL(this.client.config.endpoint + apiPath); - - const apiHeaders: { [header: string]: string } = { - } - - return this.client.call( - 'get', - uri, - apiHeaders, - payload, - ); - } - - /** - * - * @param {string} params.databaseId - Database ID. - * @param {string} params.collectionId - Collection ID. - * @param {string} params.name - Collection name. Max length: 128 chars. - * @param {number} params.dimension - Embedding dimensions. - * @param {string[]} params.permissions - An array of permission strings. By default, the current permissions are inherited. [Learn more about permissions](https://appwrite.io/docs/permissions). - * @param {boolean} params.documentSecurity - Enables configuring permissions for individual documents. A user needs one of document or collection level permissions to access a document. [Learn more about permissions](https://appwrite.io/docs/permissions). - * @param {boolean} params.enabled - Is collection enabled? When set to 'disabled', users cannot access the collection but Server SDKs with and API key can still read and write to the collection. No data is lost when this is toggled. - * @throws {AppwriteException} - * @returns {Promise} - */ - updateCollection(params: { databaseId: string, collectionId: string, name: string, dimension?: number, permissions?: string[], documentSecurity?: boolean, enabled?: boolean }): Promise; - /** - * - * @param {string} databaseId - Database ID. - * @param {string} collectionId - Collection ID. - * @param {string} name - Collection name. Max length: 128 chars. - * @param {number} dimension - Embedding dimensions. - * @param {string[]} permissions - An array of permission strings. By default, the current permissions are inherited. [Learn more about permissions](https://appwrite.io/docs/permissions). - * @param {boolean} documentSecurity - Enables configuring permissions for individual documents. A user needs one of document or collection level permissions to access a document. [Learn more about permissions](https://appwrite.io/docs/permissions). - * @param {boolean} enabled - Is collection enabled? When set to 'disabled', users cannot access the collection but Server SDKs with and API key can still read and write to the collection. No data is lost when this is toggled. - * @throws {AppwriteException} - * @returns {Promise} - * @deprecated Use the object parameter style method for a better developer experience. - */ - updateCollection(databaseId: string, collectionId: string, name: string, dimension?: number, permissions?: string[], documentSecurity?: boolean, enabled?: boolean): Promise; - updateCollection( - paramsOrFirst: { databaseId: string, collectionId: string, name: string, dimension?: number, permissions?: string[], documentSecurity?: boolean, enabled?: boolean } | string, - ...rest: [(string)?, (string)?, (number)?, (string[])?, (boolean)?, (boolean)?] - ): Promise { - let params: { databaseId: string, collectionId: string, name: string, dimension?: number, permissions?: string[], documentSecurity?: boolean, enabled?: boolean }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, name: string, dimension?: number, permissions?: string[], documentSecurity?: boolean, enabled?: boolean }; - } else { - params = { - databaseId: paramsOrFirst as string, - collectionId: rest[0] as string, - name: rest[1] as string, - dimension: rest[2] as number, - permissions: rest[3] as string[], - documentSecurity: rest[4] as boolean, - enabled: rest[5] as boolean - }; - } - - const databaseId = params.databaseId; - const collectionId = params.collectionId; - const name = params.name; - const dimension = params.dimension; - const permissions = params.permissions; - const documentSecurity = params.documentSecurity; - const enabled = params.enabled; - - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); - } - if (typeof collectionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "collectionId"'); - } - if (typeof name === 'undefined') { - throw new AppwriteException('Missing required parameter: "name"'); - } - - const apiPath = '/vectorsdb/{databaseId}/collections/{collectionId}'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId); - const payload: Payload = {}; - if (typeof name !== 'undefined') { - payload['name'] = name; - } - if (typeof dimension !== 'undefined') { - payload['dimension'] = dimension; - } - if (typeof permissions !== 'undefined') { - payload['permissions'] = permissions; - } - if (typeof documentSecurity !== 'undefined') { - payload['documentSecurity'] = documentSecurity; - } - if (typeof enabled !== 'undefined') { - payload['enabled'] = enabled; - } - const uri = new URL(this.client.config.endpoint + apiPath); - - const apiHeaders: { [header: string]: string } = { - 'content-type': 'application/json', - } - - return this.client.call( - 'put', - uri, - apiHeaders, - payload, - ); - } - - /** - * - * @param {string} params.databaseId - Database ID. - * @param {string} params.collectionId - Collection ID. - * @throws {AppwriteException} - * @returns {Promise<{}>} - */ - deleteCollection(params: { databaseId: string, collectionId: string }): Promise<{}>; - /** - * - * @param {string} databaseId - Database ID. - * @param {string} collectionId - Collection ID. - * @throws {AppwriteException} - * @returns {Promise<{}>} - * @deprecated Use the object parameter style method for a better developer experience. - */ - deleteCollection(databaseId: string, collectionId: string): Promise<{}>; - deleteCollection( - paramsOrFirst: { databaseId: string, collectionId: string } | string, - ...rest: [(string)?] - ): Promise<{}> { - let params: { databaseId: string, collectionId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string }; - } else { - params = { - databaseId: paramsOrFirst as string, - collectionId: rest[0] as string - }; - } - - const databaseId = params.databaseId; - const collectionId = params.collectionId; - - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); - } - if (typeof collectionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "collectionId"'); - } - - const apiPath = '/vectorsdb/{databaseId}/collections/{collectionId}'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId); - const payload: Payload = {}; - const uri = new URL(this.client.config.endpoint + apiPath); - - const apiHeaders: { [header: string]: string } = { - 'content-type': 'application/json', - } - - return this.client.call( - 'delete', - uri, - apiHeaders, - payload, - ); - } - - /** - * - * @param {string} params.databaseId - Database ID. - * @param {string} params.collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). - * @param {string[]} params.queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. - * @param {string} params.transactionId - Transaction ID to read uncommitted changes within the transaction. - * @param {boolean} params.total - When set to false, the total count returned will be 0 and will not be calculated. - * @param {number} params.ttl - TTL (seconds) for cached responses when caching is enabled for select queries. Must be between 0 and 86400 (24 hours). - * @throws {AppwriteException} - * @returns {Promise>} - */ - listDocuments(params: { databaseId: string, collectionId: string, queries?: string[], transactionId?: string, total?: boolean, ttl?: number }): Promise>; - /** - * - * @param {string} databaseId - Database ID. - * @param {string} collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). - * @param {string[]} queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. - * @param {string} transactionId - Transaction ID to read uncommitted changes within the transaction. - * @param {boolean} total - When set to false, the total count returned will be 0 and will not be calculated. - * @param {number} ttl - TTL (seconds) for cached responses when caching is enabled for select queries. Must be between 0 and 86400 (24 hours). - * @throws {AppwriteException} - * @returns {Promise>} - * @deprecated Use the object parameter style method for a better developer experience. - */ - listDocuments(databaseId: string, collectionId: string, queries?: string[], transactionId?: string, total?: boolean, ttl?: number): Promise>; - listDocuments( - paramsOrFirst: { databaseId: string, collectionId: string, queries?: string[], transactionId?: string, total?: boolean, ttl?: number } | string, - ...rest: [(string)?, (string[])?, (string)?, (boolean)?, (number)?] - ): Promise> { - let params: { databaseId: string, collectionId: string, queries?: string[], transactionId?: string, total?: boolean, ttl?: number }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, queries?: string[], transactionId?: string, total?: boolean, ttl?: number }; - } else { - params = { - databaseId: paramsOrFirst as string, - collectionId: rest[0] as string, - queries: rest[1] as string[], - transactionId: rest[2] as string, - total: rest[3] as boolean, - ttl: rest[4] as number - }; - } - - const databaseId = params.databaseId; - const collectionId = params.collectionId; - const queries = params.queries; - const transactionId = params.transactionId; - const total = params.total; - const ttl = params.ttl; - - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); - } - if (typeof collectionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "collectionId"'); - } - - const apiPath = '/vectorsdb/{databaseId}/collections/{collectionId}/documents'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId); - const payload: Payload = {}; - if (typeof queries !== 'undefined') { - payload['queries'] = queries; - } - if (typeof transactionId !== 'undefined') { - payload['transactionId'] = transactionId; - } - if (typeof total !== 'undefined') { - payload['total'] = total; - } - if (typeof ttl !== 'undefined') { - payload['ttl'] = ttl; - } - const uri = new URL(this.client.config.endpoint + apiPath); - - const apiHeaders: { [header: string]: string } = { - } - - return this.client.call( - 'get', - uri, - apiHeaders, - payload, - ); - } - - /** - * - * @param {string} params.databaseId - Database ID. - * @param {string} params.collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). Make sure to define attributes before creating documents. - * @param {string} params.documentId - Document ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. - * @param {Document extends Models.DefaultDocument ? Partial & Record : Partial & Omit} params.data - Document data as JSON object. - * @param {string[]} params.permissions - An array of permissions strings. By default, only the current user is granted all permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). - * @throws {AppwriteException} - * @returns {Promise} - */ - createDocument(params: { databaseId: string, collectionId: string, documentId: string, data: Document extends Models.DefaultDocument ? Partial & Record : Partial & Omit, permissions?: string[] }): Promise; - /** - * - * @param {string} databaseId - Database ID. - * @param {string} collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). Make sure to define attributes before creating documents. - * @param {string} documentId - Document ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. - * @param {Document extends Models.DefaultDocument ? Partial & Record : Partial & Omit} data - Document data as JSON object. - * @param {string[]} permissions - An array of permissions strings. By default, only the current user is granted all permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). - * @throws {AppwriteException} - * @returns {Promise} - * @deprecated Use the object parameter style method for a better developer experience. - */ - createDocument(databaseId: string, collectionId: string, documentId: string, data: Document extends Models.DefaultDocument ? Partial & Record : Partial & Omit, permissions?: string[]): Promise; - createDocument( - paramsOrFirst: { databaseId: string, collectionId: string, documentId: string, data: Document extends Models.DefaultDocument ? Partial & Record : Partial & Omit, permissions?: string[] } | string, - ...rest: [(string)?, (string)?, (Document extends Models.DefaultDocument ? Partial & Record : Partial & Omit)?, (string[])?] - ): Promise { - let params: { databaseId: string, collectionId: string, documentId: string, data: Document extends Models.DefaultDocument ? Partial & Record : Partial & Omit, permissions?: string[] }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, documentId: string, data: Document extends Models.DefaultDocument ? Partial & Record : Partial & Omit, permissions?: string[] }; - } else { - params = { - databaseId: paramsOrFirst as string, - collectionId: rest[0] as string, - documentId: rest[1] as string, - data: rest[2] as Document extends Models.DefaultDocument ? Partial & Record : Partial & Omit, - permissions: rest[3] as string[] - }; - } - - const databaseId = params.databaseId; - const collectionId = params.collectionId; - const documentId = params.documentId; - const data = params.data; - const permissions = params.permissions; - - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); - } - if (typeof collectionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "collectionId"'); - } - if (typeof documentId === 'undefined') { - throw new AppwriteException('Missing required parameter: "documentId"'); - } - if (typeof data === 'undefined') { - throw new AppwriteException('Missing required parameter: "data"'); - } - - const apiPath = '/vectorsdb/{databaseId}/collections/{collectionId}/documents'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId); - const payload: Payload = {}; - if (typeof documentId !== 'undefined') { - payload['documentId'] = documentId; - } - if (typeof data !== 'undefined') { - payload['data'] = data; - } - if (typeof permissions !== 'undefined') { - payload['permissions'] = permissions; - } - const uri = new URL(this.client.config.endpoint + apiPath); - - const apiHeaders: { [header: string]: string } = { - 'content-type': 'application/json', - } - - return this.client.call( - 'post', - uri, - apiHeaders, - payload, - ); - } - - /** - * - * @param {string} params.databaseId - Database ID. - * @param {string} params.collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). Make sure to define attributes before creating documents. - * @param {object[]} params.documents - Array of documents data as JSON objects. - * @throws {AppwriteException} - * @returns {Promise>} - */ - createDocuments(params: { databaseId: string, collectionId: string, documents: object[] }): Promise>; - /** - * - * @param {string} databaseId - Database ID. - * @param {string} collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). Make sure to define attributes before creating documents. - * @param {object[]} documents - Array of documents data as JSON objects. - * @throws {AppwriteException} - * @returns {Promise>} - * @deprecated Use the object parameter style method for a better developer experience. - */ - createDocuments(databaseId: string, collectionId: string, documents: object[]): Promise>; - createDocuments( - paramsOrFirst: { databaseId: string, collectionId: string, documents: object[] } | string, - ...rest: [(string)?, (object[])?] - ): Promise> { - let params: { databaseId: string, collectionId: string, documents: object[] }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, documents: object[] }; - } else { - params = { - databaseId: paramsOrFirst as string, - collectionId: rest[0] as string, - documents: rest[1] as object[] - }; - } - - const databaseId = params.databaseId; - const collectionId = params.collectionId; - const documents = params.documents; - - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); - } - if (typeof collectionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "collectionId"'); - } - if (typeof documents === 'undefined') { - throw new AppwriteException('Missing required parameter: "documents"'); - } - - const apiPath = '/vectorsdb/{databaseId}/collections/{collectionId}/documents'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId); - const payload: Payload = {}; - if (typeof documents !== 'undefined') { - payload['documents'] = documents; - } - const uri = new URL(this.client.config.endpoint + apiPath); - - const apiHeaders: { [header: string]: string } = { - 'content-type': 'application/json', - } - - return this.client.call( - 'post', - uri, - apiHeaders, - payload, - ); - } - - /** - * - * @param {string} params.databaseId - Database ID. - * @param {string} params.collectionId - Collection ID. - * @param {object[]} params.documents - Array of document data as JSON objects. May contain partial documents. - * @param {string} params.transactionId - Transaction ID for staging the operation. - * @throws {AppwriteException} - * @returns {Promise>} - */ - upsertDocuments(params: { databaseId: string, collectionId: string, documents: object[], transactionId?: string }): Promise>; - /** - * - * @param {string} databaseId - Database ID. - * @param {string} collectionId - Collection ID. - * @param {object[]} documents - Array of document data as JSON objects. May contain partial documents. - * @param {string} transactionId - Transaction ID for staging the operation. - * @throws {AppwriteException} - * @returns {Promise>} - * @deprecated Use the object parameter style method for a better developer experience. - */ - upsertDocuments(databaseId: string, collectionId: string, documents: object[], transactionId?: string): Promise>; - upsertDocuments( - paramsOrFirst: { databaseId: string, collectionId: string, documents: object[], transactionId?: string } | string, - ...rest: [(string)?, (object[])?, (string)?] - ): Promise> { - let params: { databaseId: string, collectionId: string, documents: object[], transactionId?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, documents: object[], transactionId?: string }; - } else { - params = { - databaseId: paramsOrFirst as string, - collectionId: rest[0] as string, - documents: rest[1] as object[], - transactionId: rest[2] as string - }; - } - - const databaseId = params.databaseId; - const collectionId = params.collectionId; - const documents = params.documents; - const transactionId = params.transactionId; - - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); - } - if (typeof collectionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "collectionId"'); - } - if (typeof documents === 'undefined') { - throw new AppwriteException('Missing required parameter: "documents"'); - } - - const apiPath = '/vectorsdb/{databaseId}/collections/{collectionId}/documents'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId); - const payload: Payload = {}; - if (typeof documents !== 'undefined') { - payload['documents'] = documents; - } - if (typeof transactionId !== 'undefined') { - payload['transactionId'] = transactionId; - } - const uri = new URL(this.client.config.endpoint + apiPath); - - const apiHeaders: { [header: string]: string } = { - 'content-type': 'application/json', - } - - return this.client.call( - 'put', - uri, - apiHeaders, - payload, - ); - } - - /** - * - * @param {string} params.databaseId - Database ID. - * @param {string} params.collectionId - Collection ID. - * @param {object} params.data - Document data as JSON object. Include only attribute and value pairs to be updated. - * @param {string[]} params.queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. - * @param {string} params.transactionId - Transaction ID for staging the operation. - * @throws {AppwriteException} - * @returns {Promise>} - */ - updateDocuments(params: { databaseId: string, collectionId: string, data?: object, queries?: string[], transactionId?: string }): Promise>; - /** - * - * @param {string} databaseId - Database ID. - * @param {string} collectionId - Collection ID. - * @param {object} data - Document data as JSON object. Include only attribute and value pairs to be updated. - * @param {string[]} queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. - * @param {string} transactionId - Transaction ID for staging the operation. - * @throws {AppwriteException} - * @returns {Promise>} - * @deprecated Use the object parameter style method for a better developer experience. - */ - updateDocuments(databaseId: string, collectionId: string, data?: object, queries?: string[], transactionId?: string): Promise>; - updateDocuments( - paramsOrFirst: { databaseId: string, collectionId: string, data?: object, queries?: string[], transactionId?: string } | string, - ...rest: [(string)?, (object)?, (string[])?, (string)?] - ): Promise> { - let params: { databaseId: string, collectionId: string, data?: object, queries?: string[], transactionId?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, data?: object, queries?: string[], transactionId?: string }; - } else { - params = { - databaseId: paramsOrFirst as string, - collectionId: rest[0] as string, - data: rest[1] as object, - queries: rest[2] as string[], - transactionId: rest[3] as string - }; - } - - const databaseId = params.databaseId; - const collectionId = params.collectionId; - const data = params.data; - const queries = params.queries; - const transactionId = params.transactionId; - - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); - } - if (typeof collectionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "collectionId"'); - } - - const apiPath = '/vectorsdb/{databaseId}/collections/{collectionId}/documents'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId); - const payload: Payload = {}; - if (typeof data !== 'undefined') { - payload['data'] = data; - } - if (typeof queries !== 'undefined') { - payload['queries'] = queries; - } - if (typeof transactionId !== 'undefined') { - payload['transactionId'] = transactionId; - } - const uri = new URL(this.client.config.endpoint + apiPath); - - const apiHeaders: { [header: string]: string } = { - 'content-type': 'application/json', - } - - return this.client.call( - 'patch', - uri, - apiHeaders, - payload, - ); - } - - /** - * - * @param {string} params.databaseId - Database ID. - * @param {string} params.collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). - * @param {string[]} params.queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. - * @param {string} params.transactionId - Transaction ID for staging the operation. - * @throws {AppwriteException} - * @returns {Promise>} - */ - deleteDocuments(params: { databaseId: string, collectionId: string, queries?: string[], transactionId?: string }): Promise>; - /** - * - * @param {string} databaseId - Database ID. - * @param {string} collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). - * @param {string[]} queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. - * @param {string} transactionId - Transaction ID for staging the operation. - * @throws {AppwriteException} - * @returns {Promise>} - * @deprecated Use the object parameter style method for a better developer experience. - */ - deleteDocuments(databaseId: string, collectionId: string, queries?: string[], transactionId?: string): Promise>; - deleteDocuments( - paramsOrFirst: { databaseId: string, collectionId: string, queries?: string[], transactionId?: string } | string, - ...rest: [(string)?, (string[])?, (string)?] - ): Promise> { - let params: { databaseId: string, collectionId: string, queries?: string[], transactionId?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, queries?: string[], transactionId?: string }; - } else { - params = { - databaseId: paramsOrFirst as string, - collectionId: rest[0] as string, - queries: rest[1] as string[], - transactionId: rest[2] as string - }; - } - - const databaseId = params.databaseId; - const collectionId = params.collectionId; - const queries = params.queries; - const transactionId = params.transactionId; - - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); - } - if (typeof collectionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "collectionId"'); - } - - const apiPath = '/vectorsdb/{databaseId}/collections/{collectionId}/documents'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId); - const payload: Payload = {}; - if (typeof queries !== 'undefined') { - payload['queries'] = queries; - } - if (typeof transactionId !== 'undefined') { - payload['transactionId'] = transactionId; - } - const uri = new URL(this.client.config.endpoint + apiPath); - - const apiHeaders: { [header: string]: string } = { - 'content-type': 'application/json', - } - - return this.client.call( - 'delete', - uri, - apiHeaders, - payload, - ); - } - - /** - * - * @param {string} params.databaseId - Database ID. - * @param {string} params.collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). - * @param {string} params.documentId - Document ID. - * @param {string[]} params.queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. - * @param {string} params.transactionId - Transaction ID to read uncommitted changes within the transaction. - * @throws {AppwriteException} - * @returns {Promise} - */ - getDocument(params: { databaseId: string, collectionId: string, documentId: string, queries?: string[], transactionId?: string }): Promise; - /** - * - * @param {string} databaseId - Database ID. - * @param {string} collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). - * @param {string} documentId - Document ID. - * @param {string[]} queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. - * @param {string} transactionId - Transaction ID to read uncommitted changes within the transaction. - * @throws {AppwriteException} - * @returns {Promise} - * @deprecated Use the object parameter style method for a better developer experience. - */ - getDocument(databaseId: string, collectionId: string, documentId: string, queries?: string[], transactionId?: string): Promise; - getDocument( - paramsOrFirst: { databaseId: string, collectionId: string, documentId: string, queries?: string[], transactionId?: string } | string, - ...rest: [(string)?, (string)?, (string[])?, (string)?] - ): Promise { - let params: { databaseId: string, collectionId: string, documentId: string, queries?: string[], transactionId?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, documentId: string, queries?: string[], transactionId?: string }; - } else { - params = { - databaseId: paramsOrFirst as string, - collectionId: rest[0] as string, - documentId: rest[1] as string, - queries: rest[2] as string[], - transactionId: rest[3] as string - }; - } - - const databaseId = params.databaseId; - const collectionId = params.collectionId; - const documentId = params.documentId; - const queries = params.queries; - const transactionId = params.transactionId; - - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); - } - if (typeof collectionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "collectionId"'); - } - if (typeof documentId === 'undefined') { - throw new AppwriteException('Missing required parameter: "documentId"'); - } - - const apiPath = '/vectorsdb/{databaseId}/collections/{collectionId}/documents/{documentId}'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId).replace('{documentId}', documentId); - const payload: Payload = {}; - if (typeof queries !== 'undefined') { - payload['queries'] = queries; - } - if (typeof transactionId !== 'undefined') { - payload['transactionId'] = transactionId; - } - const uri = new URL(this.client.config.endpoint + apiPath); - - const apiHeaders: { [header: string]: string } = { - } - - return this.client.call( - 'get', - uri, - apiHeaders, - payload, - ); - } - - /** - * - * @param {string} params.databaseId - Database ID. - * @param {string} params.collectionId - Collection ID. - * @param {string} params.documentId - Document ID. - * @param {Document extends Models.DefaultDocument ? Partial & Record : Partial & Partial>} params.data - Document data as JSON object. Include all required fields of the document to be created or updated. - * @param {string[]} params.permissions - An array of permissions strings. By default, the current permissions are inherited. [Learn more about permissions](https://appwrite.io/docs/permissions). - * @param {string} params.transactionId - Transaction ID for staging the operation. - * @throws {AppwriteException} - * @returns {Promise} - */ - upsertDocument(params: { databaseId: string, collectionId: string, documentId: string, data?: Document extends Models.DefaultDocument ? Partial & Record : Partial & Partial>, permissions?: string[], transactionId?: string }): Promise; - /** - * - * @param {string} databaseId - Database ID. - * @param {string} collectionId - Collection ID. - * @param {string} documentId - Document ID. - * @param {Document extends Models.DefaultDocument ? Partial & Record : Partial & Partial>} data - Document data as JSON object. Include all required fields of the document to be created or updated. - * @param {string[]} permissions - An array of permissions strings. By default, the current permissions are inherited. [Learn more about permissions](https://appwrite.io/docs/permissions). - * @param {string} transactionId - Transaction ID for staging the operation. - * @throws {AppwriteException} - * @returns {Promise} - * @deprecated Use the object parameter style method for a better developer experience. - */ - upsertDocument(databaseId: string, collectionId: string, documentId: string, data?: Document extends Models.DefaultDocument ? Partial & Record : Partial & Partial>, permissions?: string[], transactionId?: string): Promise; - upsertDocument( - paramsOrFirst: { databaseId: string, collectionId: string, documentId: string, data?: Document extends Models.DefaultDocument ? Partial & Record : Partial & Partial>, permissions?: string[], transactionId?: string } | string, - ...rest: [(string)?, (string)?, (Document extends Models.DefaultDocument ? Partial & Record : Partial & Partial>)?, (string[])?, (string)?] - ): Promise { - let params: { databaseId: string, collectionId: string, documentId: string, data?: Document extends Models.DefaultDocument ? Partial & Record : Partial & Partial>, permissions?: string[], transactionId?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, documentId: string, data?: Document extends Models.DefaultDocument ? Partial & Record : Partial & Partial>, permissions?: string[], transactionId?: string }; - } else { - params = { - databaseId: paramsOrFirst as string, - collectionId: rest[0] as string, - documentId: rest[1] as string, - data: rest[2] as Document extends Models.DefaultDocument ? Partial & Record : Partial & Partial>, - permissions: rest[3] as string[], - transactionId: rest[4] as string - }; - } - - const databaseId = params.databaseId; - const collectionId = params.collectionId; - const documentId = params.documentId; - const data = params.data; - const permissions = params.permissions; - const transactionId = params.transactionId; - - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); - } - if (typeof collectionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "collectionId"'); - } - if (typeof documentId === 'undefined') { - throw new AppwriteException('Missing required parameter: "documentId"'); - } - - const apiPath = '/vectorsdb/{databaseId}/collections/{collectionId}/documents/{documentId}'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId).replace('{documentId}', documentId); - const payload: Payload = {}; - if (typeof data !== 'undefined') { - payload['data'] = data; - } - if (typeof permissions !== 'undefined') { - payload['permissions'] = permissions; - } - if (typeof transactionId !== 'undefined') { - payload['transactionId'] = transactionId; - } - const uri = new URL(this.client.config.endpoint + apiPath); - - const apiHeaders: { [header: string]: string } = { - 'content-type': 'application/json', - } - - return this.client.call( - 'put', - uri, - apiHeaders, - payload, - ); - } - - /** - * - * @param {string} params.databaseId - Database ID. - * @param {string} params.collectionId - Collection ID. - * @param {string} params.documentId - Document ID. - * @param {Document extends Models.DefaultDocument ? Partial & Record : Partial & Partial>} params.data - Document data as JSON object. Include only fields and value pairs to be updated. - * @param {string[]} params.permissions - An array of permissions strings. By default, the current permissions are inherited. [Learn more about permissions](https://appwrite.io/docs/permissions). - * @param {string} params.transactionId - Transaction ID for staging the operation. - * @throws {AppwriteException} - * @returns {Promise} - */ - updateDocument(params: { databaseId: string, collectionId: string, documentId: string, data?: Document extends Models.DefaultDocument ? Partial & Record : Partial & Partial>, permissions?: string[], transactionId?: string }): Promise; - /** - * - * @param {string} databaseId - Database ID. - * @param {string} collectionId - Collection ID. - * @param {string} documentId - Document ID. - * @param {Document extends Models.DefaultDocument ? Partial & Record : Partial & Partial>} data - Document data as JSON object. Include only fields and value pairs to be updated. - * @param {string[]} permissions - An array of permissions strings. By default, the current permissions are inherited. [Learn more about permissions](https://appwrite.io/docs/permissions). - * @param {string} transactionId - Transaction ID for staging the operation. - * @throws {AppwriteException} - * @returns {Promise} - * @deprecated Use the object parameter style method for a better developer experience. - */ - updateDocument(databaseId: string, collectionId: string, documentId: string, data?: Document extends Models.DefaultDocument ? Partial & Record : Partial & Partial>, permissions?: string[], transactionId?: string): Promise; - updateDocument( - paramsOrFirst: { databaseId: string, collectionId: string, documentId: string, data?: Document extends Models.DefaultDocument ? Partial & Record : Partial & Partial>, permissions?: string[], transactionId?: string } | string, - ...rest: [(string)?, (string)?, (Document extends Models.DefaultDocument ? Partial & Record : Partial & Partial>)?, (string[])?, (string)?] - ): Promise { - let params: { databaseId: string, collectionId: string, documentId: string, data?: Document extends Models.DefaultDocument ? Partial & Record : Partial & Partial>, permissions?: string[], transactionId?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, documentId: string, data?: Document extends Models.DefaultDocument ? Partial & Record : Partial & Partial>, permissions?: string[], transactionId?: string }; - } else { - params = { - databaseId: paramsOrFirst as string, - collectionId: rest[0] as string, - documentId: rest[1] as string, - data: rest[2] as Document extends Models.DefaultDocument ? Partial & Record : Partial & Partial>, - permissions: rest[3] as string[], - transactionId: rest[4] as string - }; - } - - const databaseId = params.databaseId; - const collectionId = params.collectionId; - const documentId = params.documentId; - const data = params.data; - const permissions = params.permissions; - const transactionId = params.transactionId; - - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); - } - if (typeof collectionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "collectionId"'); - } - if (typeof documentId === 'undefined') { - throw new AppwriteException('Missing required parameter: "documentId"'); - } - - const apiPath = '/vectorsdb/{databaseId}/collections/{collectionId}/documents/{documentId}'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId).replace('{documentId}', documentId); - const payload: Payload = {}; - if (typeof data !== 'undefined') { - payload['data'] = data; - } - if (typeof permissions !== 'undefined') { - payload['permissions'] = permissions; - } - if (typeof transactionId !== 'undefined') { - payload['transactionId'] = transactionId; - } - const uri = new URL(this.client.config.endpoint + apiPath); - - const apiHeaders: { [header: string]: string } = { - 'content-type': 'application/json', - } - - return this.client.call( - 'patch', - uri, - apiHeaders, - payload, - ); - } - - /** - * - * @param {string} params.databaseId - Database ID. - * @param {string} params.collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). - * @param {string} params.documentId - Document ID. - * @param {string} params.transactionId - Transaction ID for staging the operation. - * @throws {AppwriteException} - * @returns {Promise<{}>} - */ - deleteDocument(params: { databaseId: string, collectionId: string, documentId: string, transactionId?: string }): Promise<{}>; - /** - * - * @param {string} databaseId - Database ID. - * @param {string} collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). - * @param {string} documentId - Document ID. - * @param {string} transactionId - Transaction ID for staging the operation. - * @throws {AppwriteException} - * @returns {Promise<{}>} - * @deprecated Use the object parameter style method for a better developer experience. - */ - deleteDocument(databaseId: string, collectionId: string, documentId: string, transactionId?: string): Promise<{}>; - deleteDocument( - paramsOrFirst: { databaseId: string, collectionId: string, documentId: string, transactionId?: string } | string, - ...rest: [(string)?, (string)?, (string)?] - ): Promise<{}> { - let params: { databaseId: string, collectionId: string, documentId: string, transactionId?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, documentId: string, transactionId?: string }; - } else { - params = { - databaseId: paramsOrFirst as string, - collectionId: rest[0] as string, - documentId: rest[1] as string, - transactionId: rest[2] as string - }; - } - - const databaseId = params.databaseId; - const collectionId = params.collectionId; - const documentId = params.documentId; - const transactionId = params.transactionId; - - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); - } - if (typeof collectionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "collectionId"'); - } - if (typeof documentId === 'undefined') { - throw new AppwriteException('Missing required parameter: "documentId"'); - } - - const apiPath = '/vectorsdb/{databaseId}/collections/{collectionId}/documents/{documentId}'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId).replace('{documentId}', documentId); - const payload: Payload = {}; - if (typeof transactionId !== 'undefined') { - payload['transactionId'] = transactionId; - } - const uri = new URL(this.client.config.endpoint + apiPath); - - const apiHeaders: { [header: string]: string } = { - 'content-type': 'application/json', - } - - return this.client.call( - 'delete', - uri, - apiHeaders, - payload, - ); - } - - /** - * - * @param {string} params.databaseId - Database ID. - * @param {string} params.collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). - * @param {string[]} params.queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: key, type, status, attributes, error - * @param {boolean} params.total - When set to false, the total count returned will be 0 and will not be calculated. - * @throws {AppwriteException} - * @returns {Promise} - */ - listIndexes(params: { databaseId: string, collectionId: string, queries?: string[], total?: boolean }): Promise; - /** - * - * @param {string} databaseId - Database ID. - * @param {string} collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). - * @param {string[]} queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: key, type, status, attributes, error - * @param {boolean} total - When set to false, the total count returned will be 0 and will not be calculated. - * @throws {AppwriteException} - * @returns {Promise} - * @deprecated Use the object parameter style method for a better developer experience. - */ - listIndexes(databaseId: string, collectionId: string, queries?: string[], total?: boolean): Promise; - listIndexes( - paramsOrFirst: { databaseId: string, collectionId: string, queries?: string[], total?: boolean } | string, - ...rest: [(string)?, (string[])?, (boolean)?] - ): Promise { - let params: { databaseId: string, collectionId: string, queries?: string[], total?: boolean }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, queries?: string[], total?: boolean }; - } else { - params = { - databaseId: paramsOrFirst as string, - collectionId: rest[0] as string, - queries: rest[1] as string[], - total: rest[2] as boolean - }; - } - - const databaseId = params.databaseId; - const collectionId = params.collectionId; - const queries = params.queries; - const total = params.total; - - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); - } - if (typeof collectionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "collectionId"'); - } - - const apiPath = '/vectorsdb/{databaseId}/collections/{collectionId}/indexes'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId); - const payload: Payload = {}; - if (typeof queries !== 'undefined') { - payload['queries'] = queries; - } - if (typeof total !== 'undefined') { - payload['total'] = total; - } - const uri = new URL(this.client.config.endpoint + apiPath); - - const apiHeaders: { [header: string]: string } = { - } - - return this.client.call( - 'get', - uri, - apiHeaders, - payload, - ); - } - - /** - * - * @param {string} params.databaseId - Database ID. - * @param {string} params.collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). - * @param {string} params.key - Index Key. - * @param {VectorsDBIndexType} params.type - Index type. - * @param {string[]} params.attributes - Array of attributes to index. Maximum of 100 attributes are allowed, each 32 characters long. - * @param {OrderBy[]} params.orders - Array of index orders. Maximum of 100 orders are allowed. - * @param {number[]} params.lengths - Length of index. Maximum of 100 - * @throws {AppwriteException} - * @returns {Promise} - */ - createIndex(params: { databaseId: string, collectionId: string, key: string, type: VectorsDBIndexType, attributes: string[], orders?: OrderBy[], lengths?: number[] }): Promise; - /** - * - * @param {string} databaseId - Database ID. - * @param {string} collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). - * @param {string} key - Index Key. - * @param {VectorsDBIndexType} type - Index type. - * @param {string[]} attributes - Array of attributes to index. Maximum of 100 attributes are allowed, each 32 characters long. - * @param {OrderBy[]} orders - Array of index orders. Maximum of 100 orders are allowed. - * @param {number[]} lengths - Length of index. Maximum of 100 - * @throws {AppwriteException} - * @returns {Promise} - * @deprecated Use the object parameter style method for a better developer experience. - */ - createIndex(databaseId: string, collectionId: string, key: string, type: VectorsDBIndexType, attributes: string[], orders?: OrderBy[], lengths?: number[]): Promise; - createIndex( - paramsOrFirst: { databaseId: string, collectionId: string, key: string, type: VectorsDBIndexType, attributes: string[], orders?: OrderBy[], lengths?: number[] } | string, - ...rest: [(string)?, (string)?, (VectorsDBIndexType)?, (string[])?, (OrderBy[])?, (number[])?] - ): Promise { - let params: { databaseId: string, collectionId: string, key: string, type: VectorsDBIndexType, attributes: string[], orders?: OrderBy[], lengths?: number[] }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, key: string, type: VectorsDBIndexType, attributes: string[], orders?: OrderBy[], lengths?: number[] }; - } else { - params = { - databaseId: paramsOrFirst as string, - collectionId: rest[0] as string, - key: rest[1] as string, - type: rest[2] as VectorsDBIndexType, - attributes: rest[3] as string[], - orders: rest[4] as OrderBy[], - lengths: rest[5] as number[] - }; - } - - const databaseId = params.databaseId; - const collectionId = params.collectionId; - const key = params.key; - const type = params.type; - const attributes = params.attributes; - const orders = params.orders; - const lengths = params.lengths; - - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); - } - if (typeof collectionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "collectionId"'); - } - if (typeof key === 'undefined') { - throw new AppwriteException('Missing required parameter: "key"'); - } - if (typeof type === 'undefined') { - throw new AppwriteException('Missing required parameter: "type"'); - } - if (typeof attributes === 'undefined') { - throw new AppwriteException('Missing required parameter: "attributes"'); - } - - const apiPath = '/vectorsdb/{databaseId}/collections/{collectionId}/indexes'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId); - const payload: Payload = {}; - if (typeof key !== 'undefined') { - payload['key'] = key; - } - if (typeof type !== 'undefined') { - payload['type'] = type; - } - if (typeof attributes !== 'undefined') { - payload['attributes'] = attributes; - } - if (typeof orders !== 'undefined') { - payload['orders'] = orders; - } - if (typeof lengths !== 'undefined') { - payload['lengths'] = lengths; - } - const uri = new URL(this.client.config.endpoint + apiPath); - - const apiHeaders: { [header: string]: string } = { - 'content-type': 'application/json', - } - - return this.client.call( - 'post', - uri, - apiHeaders, - payload, - ); - } - - /** - * - * @param {string} params.databaseId - Database ID. - * @param {string} params.collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). - * @param {string} params.key - Index Key. - * @throws {AppwriteException} - * @returns {Promise} - */ - getIndex(params: { databaseId: string, collectionId: string, key: string }): Promise; - /** - * - * @param {string} databaseId - Database ID. - * @param {string} collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). - * @param {string} key - Index Key. - * @throws {AppwriteException} - * @returns {Promise} - * @deprecated Use the object parameter style method for a better developer experience. - */ - getIndex(databaseId: string, collectionId: string, key: string): Promise; - getIndex( - paramsOrFirst: { databaseId: string, collectionId: string, key: string } | string, - ...rest: [(string)?, (string)?] - ): Promise { - let params: { databaseId: string, collectionId: string, key: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, key: string }; - } else { - params = { - databaseId: paramsOrFirst as string, - collectionId: rest[0] as string, - key: rest[1] as string - }; - } - - const databaseId = params.databaseId; - const collectionId = params.collectionId; - const key = params.key; - - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); - } - if (typeof collectionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "collectionId"'); - } - if (typeof key === 'undefined') { - throw new AppwriteException('Missing required parameter: "key"'); - } - - const apiPath = '/vectorsdb/{databaseId}/collections/{collectionId}/indexes/{key}'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId).replace('{key}', key); - const payload: Payload = {}; - const uri = new URL(this.client.config.endpoint + apiPath); - - const apiHeaders: { [header: string]: string } = { - } - - return this.client.call( - 'get', - uri, - apiHeaders, - payload, - ); - } - - /** - * - * @param {string} params.databaseId - Database ID. - * @param {string} params.collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). - * @param {string} params.key - Index Key. - * @throws {AppwriteException} - * @returns {Promise<{}>} - */ - deleteIndex(params: { databaseId: string, collectionId: string, key: string }): Promise<{}>; - /** - * - * @param {string} databaseId - Database ID. - * @param {string} collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). - * @param {string} key - Index Key. - * @throws {AppwriteException} - * @returns {Promise<{}>} - * @deprecated Use the object parameter style method for a better developer experience. - */ - deleteIndex(databaseId: string, collectionId: string, key: string): Promise<{}>; - deleteIndex( - paramsOrFirst: { databaseId: string, collectionId: string, key: string } | string, - ...rest: [(string)?, (string)?] - ): Promise<{}> { - let params: { databaseId: string, collectionId: string, key: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, key: string }; - } else { - params = { - databaseId: paramsOrFirst as string, - collectionId: rest[0] as string, - key: rest[1] as string - }; - } - - const databaseId = params.databaseId; - const collectionId = params.collectionId; - const key = params.key; - - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); - } - if (typeof collectionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "collectionId"'); - } - if (typeof key === 'undefined') { - throw new AppwriteException('Missing required parameter: "key"'); - } - - const apiPath = '/vectorsdb/{databaseId}/collections/{collectionId}/indexes/{key}'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId).replace('{key}', key); - const payload: Payload = {}; - const uri = new URL(this.client.config.endpoint + apiPath); - - const apiHeaders: { [header: string]: string } = { - 'content-type': 'application/json', - } - - return this.client.call( - 'delete', - uri, - apiHeaders, - payload, - ); - } -} diff --git a/test/services/documents-d-b.test.js b/test/services/documents-d-b.test.js deleted file mode 100644 index 7df9ef7d..00000000 --- a/test/services/documents-d-b.test.js +++ /dev/null @@ -1,660 +0,0 @@ -const { Client } = require("../../dist/client"); -const { InputFile } = require("../../dist/inputFile"); -const { DocumentsDB } = require("../../dist/services/documents-db"); - -const { fetch: mockedFetch, Response } = require("node-fetch-native-with-agent"); -jest.mock('node-fetch-native-with-agent', () => ({ ...jest.requireActual('node-fetch-native-with-agent'), fetch: jest.fn() })); - -describe('DocumentsDB', () => { - const client = new Client(); - const documentsDB = new DocumentsDB(client); - - - test('test method list()', async () => { - const data = { - 'total': 5, - 'databases': [],}; - mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await documentsDB.list( - ); - - // Remove custom toString method on the objects to allow for clean data comparison. - delete response.toString; - - expect(response).toEqual(data); - }); - - test('test method create()', async () => { - const data = { - '\$id': '5e5ea5c16897e', - 'name': 'My Database', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'enabled': true, - 'type': 'legacy', - 'policies': [], - 'archives': [],}; - mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await documentsDB.create( - '', - '', - ); - - // Remove custom toString method on the objects to allow for clean data comparison. - delete response.toString; - - expect(response).toEqual(data); - }); - - test('test method listTransactions()', async () => { - const data = { - 'total': 5, - 'transactions': [],}; - mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await documentsDB.listTransactions( - ); - - // Remove custom toString method on the objects to allow for clean data comparison. - delete response.toString; - - expect(response).toEqual(data); - }); - - test('test method createTransaction()', async () => { - const data = { - '\$id': '259125845563242502', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'status': 'pending', - 'operations': 5, - 'expiresAt': '2020-10-15T06:38:00.000+00:00',}; - mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await documentsDB.createTransaction( - ); - - // Remove custom toString method on the objects to allow for clean data comparison. - delete response.toString; - - expect(response).toEqual(data); - }); - - test('test method getTransaction()', async () => { - const data = { - '\$id': '259125845563242502', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'status': 'pending', - 'operations': 5, - 'expiresAt': '2020-10-15T06:38:00.000+00:00',}; - mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await documentsDB.getTransaction( - '', - ); - - // Remove custom toString method on the objects to allow for clean data comparison. - delete response.toString; - - expect(response).toEqual(data); - }); - - test('test method updateTransaction()', async () => { - const data = { - '\$id': '259125845563242502', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'status': 'pending', - 'operations': 5, - 'expiresAt': '2020-10-15T06:38:00.000+00:00',}; - mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await documentsDB.updateTransaction( - '', - ); - - // Remove custom toString method on the objects to allow for clean data comparison. - delete response.toString; - - expect(response).toEqual(data); - }); - - test('test method deleteTransaction()', async () => { - const data = {message: ""}; - mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await documentsDB.deleteTransaction( - '', - ); - - // Remove custom toString method on the objects to allow for clean data comparison. - delete response.toString; - - expect(response).toEqual(data); - }); - - test('test method createOperations()', async () => { - const data = { - '\$id': '259125845563242502', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'status': 'pending', - 'operations': 5, - 'expiresAt': '2020-10-15T06:38:00.000+00:00',}; - mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await documentsDB.createOperations( - '', - ); - - // Remove custom toString method on the objects to allow for clean data comparison. - delete response.toString; - - expect(response).toEqual(data); - }); - - test('test method get()', async () => { - const data = { - '\$id': '5e5ea5c16897e', - 'name': 'My Database', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'enabled': true, - 'type': 'legacy', - 'policies': [], - 'archives': [],}; - mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await documentsDB.get( - '', - ); - - // Remove custom toString method on the objects to allow for clean data comparison. - delete response.toString; - - expect(response).toEqual(data); - }); - - test('test method update()', async () => { - const data = { - '\$id': '5e5ea5c16897e', - 'name': 'My Database', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'enabled': true, - 'type': 'legacy', - 'policies': [], - 'archives': [],}; - mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await documentsDB.update( - '', - '', - ); - - // Remove custom toString method on the objects to allow for clean data comparison. - delete response.toString; - - expect(response).toEqual(data); - }); - - test('test method delete()', async () => { - const data = {message: ""}; - mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await documentsDB.delete( - '', - ); - - // Remove custom toString method on the objects to allow for clean data comparison. - delete response.toString; - - expect(response).toEqual(data); - }); - - test('test method listCollections()', async () => { - const data = { - 'total': 5, - 'collections': [],}; - mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await documentsDB.listCollections( - '', - ); - - // Remove custom toString method on the objects to allow for clean data comparison. - delete response.toString; - - expect(response).toEqual(data); - }); - - test('test method createCollection()', async () => { - const data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - '\$permissions': [], - 'databaseId': '5e5ea5c16897e', - 'name': 'My Collection', - 'enabled': true, - 'documentSecurity': true, - 'attributes': [], - 'indexes': [], - 'bytesMax': 65535, - 'bytesUsed': 1500,}; - mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await documentsDB.createCollection( - '', - '', - '', - ); - - // Remove custom toString method on the objects to allow for clean data comparison. - delete response.toString; - - expect(response).toEqual(data); - }); - - test('test method getCollection()', async () => { - const data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - '\$permissions': [], - 'databaseId': '5e5ea5c16897e', - 'name': 'My Collection', - 'enabled': true, - 'documentSecurity': true, - 'attributes': [], - 'indexes': [], - 'bytesMax': 65535, - 'bytesUsed': 1500,}; - mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await documentsDB.getCollection( - '', - '', - ); - - // Remove custom toString method on the objects to allow for clean data comparison. - delete response.toString; - - expect(response).toEqual(data); - }); - - test('test method updateCollection()', async () => { - const data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - '\$permissions': [], - 'databaseId': '5e5ea5c16897e', - 'name': 'My Collection', - 'enabled': true, - 'documentSecurity': true, - 'attributes': [], - 'indexes': [], - 'bytesMax': 65535, - 'bytesUsed': 1500,}; - mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await documentsDB.updateCollection( - '', - '', - '', - ); - - // Remove custom toString method on the objects to allow for clean data comparison. - delete response.toString; - - expect(response).toEqual(data); - }); - - test('test method deleteCollection()', async () => { - const data = {message: ""}; - mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await documentsDB.deleteCollection( - '', - '', - ); - - // Remove custom toString method on the objects to allow for clean data comparison. - delete response.toString; - - expect(response).toEqual(data); - }); - - test('test method listDocuments()', async () => { - const data = { - 'total': 5, - 'documents': [],}; - mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await documentsDB.listDocuments( - '', - '', - ); - - // Remove custom toString method on the objects to allow for clean data comparison. - delete response.toString; - - expect(response).toEqual(data); - }); - - test('test method createDocument()', async () => { - const data = { - '\$id': '5e5ea5c16897e', - '\$sequence': '1', - '\$collectionId': '5e5ea5c15117e', - '\$databaseId': '5e5ea5c15117e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - '\$permissions': [],}; - mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await documentsDB.createDocument( - '', - '', - '', - {}, - ); - - // Remove custom toString method on the objects to allow for clean data comparison. - delete response.toString; - - expect(response).toEqual(data); - }); - - test('test method createDocuments()', async () => { - const data = { - 'total': 5, - 'documents': [],}; - mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await documentsDB.createDocuments( - '', - '', - [], - ); - - // Remove custom toString method on the objects to allow for clean data comparison. - delete response.toString; - - expect(response).toEqual(data); - }); - - test('test method upsertDocuments()', async () => { - const data = { - 'total': 5, - 'documents': [],}; - mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await documentsDB.upsertDocuments( - '', - '', - [], - ); - - // Remove custom toString method on the objects to allow for clean data comparison. - delete response.toString; - - expect(response).toEqual(data); - }); - - test('test method updateDocuments()', async () => { - const data = { - 'total': 5, - 'documents': [],}; - mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await documentsDB.updateDocuments( - '', - '', - ); - - // Remove custom toString method on the objects to allow for clean data comparison. - delete response.toString; - - expect(response).toEqual(data); - }); - - test('test method deleteDocuments()', async () => { - const data = { - 'total': 5, - 'documents': [],}; - mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await documentsDB.deleteDocuments( - '', - '', - ); - - // Remove custom toString method on the objects to allow for clean data comparison. - delete response.toString; - - expect(response).toEqual(data); - }); - - test('test method getDocument()', async () => { - const data = { - '\$id': '5e5ea5c16897e', - '\$sequence': '1', - '\$collectionId': '5e5ea5c15117e', - '\$databaseId': '5e5ea5c15117e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - '\$permissions': [],}; - mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await documentsDB.getDocument( - '', - '', - '', - ); - - // Remove custom toString method on the objects to allow for clean data comparison. - delete response.toString; - - expect(response).toEqual(data); - }); - - test('test method upsertDocument()', async () => { - const data = { - '\$id': '5e5ea5c16897e', - '\$sequence': '1', - '\$collectionId': '5e5ea5c15117e', - '\$databaseId': '5e5ea5c15117e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - '\$permissions': [],}; - mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await documentsDB.upsertDocument( - '', - '', - '', - ); - - // Remove custom toString method on the objects to allow for clean data comparison. - delete response.toString; - - expect(response).toEqual(data); - }); - - test('test method updateDocument()', async () => { - const data = { - '\$id': '5e5ea5c16897e', - '\$sequence': '1', - '\$collectionId': '5e5ea5c15117e', - '\$databaseId': '5e5ea5c15117e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - '\$permissions': [],}; - mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await documentsDB.updateDocument( - '', - '', - '', - ); - - // Remove custom toString method on the objects to allow for clean data comparison. - delete response.toString; - - expect(response).toEqual(data); - }); - - test('test method deleteDocument()', async () => { - const data = {message: ""}; - mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await documentsDB.deleteDocument( - '', - '', - '', - ); - - // Remove custom toString method on the objects to allow for clean data comparison. - delete response.toString; - - expect(response).toEqual(data); - }); - - test('test method decrementDocumentAttribute()', async () => { - const data = { - '\$id': '5e5ea5c16897e', - '\$sequence': '1', - '\$collectionId': '5e5ea5c15117e', - '\$databaseId': '5e5ea5c15117e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - '\$permissions': [],}; - mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await documentsDB.decrementDocumentAttribute( - '', - '', - '', - '', - ); - - // Remove custom toString method on the objects to allow for clean data comparison. - delete response.toString; - - expect(response).toEqual(data); - }); - - test('test method incrementDocumentAttribute()', async () => { - const data = { - '\$id': '5e5ea5c16897e', - '\$sequence': '1', - '\$collectionId': '5e5ea5c15117e', - '\$databaseId': '5e5ea5c15117e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - '\$permissions': [],}; - mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await documentsDB.incrementDocumentAttribute( - '', - '', - '', - '', - ); - - // Remove custom toString method on the objects to allow for clean data comparison. - delete response.toString; - - expect(response).toEqual(data); - }); - - test('test method listIndexes()', async () => { - const data = { - 'total': 5, - 'indexes': [],}; - mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await documentsDB.listIndexes( - '', - '', - ); - - // Remove custom toString method on the objects to allow for clean data comparison. - delete response.toString; - - expect(response).toEqual(data); - }); - - test('test method createIndex()', async () => { - const data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'key': 'index1', - 'type': 'primary', - 'status': 'available', - 'error': 'string', - 'attributes': [], - 'lengths': [],}; - mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await documentsDB.createIndex( - '', - '', - '', - 'key', - [], - ); - - // Remove custom toString method on the objects to allow for clean data comparison. - delete response.toString; - - expect(response).toEqual(data); - }); - - test('test method getIndex()', async () => { - const data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'key': 'index1', - 'type': 'primary', - 'status': 'available', - 'error': 'string', - 'attributes': [], - 'lengths': [],}; - mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await documentsDB.getIndex( - '', - '', - '', - ); - - // Remove custom toString method on the objects to allow for clean data comparison. - delete response.toString; - - expect(response).toEqual(data); - }); - - test('test method deleteIndex()', async () => { - const data = {message: ""}; - mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await documentsDB.deleteIndex( - '', - '', - '', - ); - - // Remove custom toString method on the objects to allow for clean data comparison. - delete response.toString; - - expect(response).toEqual(data); - }); - }) diff --git a/test/services/vectors-d-b.test.js b/test/services/vectors-d-b.test.js deleted file mode 100644 index d5e74ded..00000000 --- a/test/services/vectors-d-b.test.js +++ /dev/null @@ -1,632 +0,0 @@ -const { Client } = require("../../dist/client"); -const { InputFile } = require("../../dist/inputFile"); -const { VectorsDB } = require("../../dist/services/vectors-db"); - -const { fetch: mockedFetch, Response } = require("node-fetch-native-with-agent"); -jest.mock('node-fetch-native-with-agent', () => ({ ...jest.requireActual('node-fetch-native-with-agent'), fetch: jest.fn() })); - -describe('VectorsDB', () => { - const client = new Client(); - const vectorsDB = new VectorsDB(client); - - - test('test method list()', async () => { - const data = { - 'total': 5, - 'databases': [],}; - mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await vectorsDB.list( - ); - - // Remove custom toString method on the objects to allow for clean data comparison. - delete response.toString; - - expect(response).toEqual(data); - }); - - test('test method create()', async () => { - const data = { - '\$id': '5e5ea5c16897e', - 'name': 'My Database', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'enabled': true, - 'type': 'legacy', - 'policies': [], - 'archives': [],}; - mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await vectorsDB.create( - '', - '', - ); - - // Remove custom toString method on the objects to allow for clean data comparison. - delete response.toString; - - expect(response).toEqual(data); - }); - - test('test method createTextEmbeddings()', async () => { - const data = { - 'total': 5, - 'embeddings': [],}; - mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await vectorsDB.createTextEmbeddings( - [], - ); - - // Remove custom toString method on the objects to allow for clean data comparison. - delete response.toString; - - expect(response).toEqual(data); - }); - - test('test method listTransactions()', async () => { - const data = { - 'total': 5, - 'transactions': [],}; - mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await vectorsDB.listTransactions( - ); - - // Remove custom toString method on the objects to allow for clean data comparison. - delete response.toString; - - expect(response).toEqual(data); - }); - - test('test method createTransaction()', async () => { - const data = { - '\$id': '259125845563242502', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'status': 'pending', - 'operations': 5, - 'expiresAt': '2020-10-15T06:38:00.000+00:00',}; - mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await vectorsDB.createTransaction( - ); - - // Remove custom toString method on the objects to allow for clean data comparison. - delete response.toString; - - expect(response).toEqual(data); - }); - - test('test method getTransaction()', async () => { - const data = { - '\$id': '259125845563242502', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'status': 'pending', - 'operations': 5, - 'expiresAt': '2020-10-15T06:38:00.000+00:00',}; - mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await vectorsDB.getTransaction( - '', - ); - - // Remove custom toString method on the objects to allow for clean data comparison. - delete response.toString; - - expect(response).toEqual(data); - }); - - test('test method updateTransaction()', async () => { - const data = { - '\$id': '259125845563242502', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'status': 'pending', - 'operations': 5, - 'expiresAt': '2020-10-15T06:38:00.000+00:00',}; - mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await vectorsDB.updateTransaction( - '', - ); - - // Remove custom toString method on the objects to allow for clean data comparison. - delete response.toString; - - expect(response).toEqual(data); - }); - - test('test method deleteTransaction()', async () => { - const data = {message: ""}; - mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await vectorsDB.deleteTransaction( - '', - ); - - // Remove custom toString method on the objects to allow for clean data comparison. - delete response.toString; - - expect(response).toEqual(data); - }); - - test('test method createOperations()', async () => { - const data = { - '\$id': '259125845563242502', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'status': 'pending', - 'operations': 5, - 'expiresAt': '2020-10-15T06:38:00.000+00:00',}; - mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await vectorsDB.createOperations( - '', - ); - - // Remove custom toString method on the objects to allow for clean data comparison. - delete response.toString; - - expect(response).toEqual(data); - }); - - test('test method get()', async () => { - const data = { - '\$id': '5e5ea5c16897e', - 'name': 'My Database', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'enabled': true, - 'type': 'legacy', - 'policies': [], - 'archives': [],}; - mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await vectorsDB.get( - '', - ); - - // Remove custom toString method on the objects to allow for clean data comparison. - delete response.toString; - - expect(response).toEqual(data); - }); - - test('test method update()', async () => { - const data = { - '\$id': '5e5ea5c16897e', - 'name': 'My Database', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'enabled': true, - 'type': 'legacy', - 'policies': [], - 'archives': [],}; - mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await vectorsDB.update( - '', - '', - ); - - // Remove custom toString method on the objects to allow for clean data comparison. - delete response.toString; - - expect(response).toEqual(data); - }); - - test('test method delete()', async () => { - const data = {message: ""}; - mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await vectorsDB.delete( - '', - ); - - // Remove custom toString method on the objects to allow for clean data comparison. - delete response.toString; - - expect(response).toEqual(data); - }); - - test('test method listCollections()', async () => { - const data = { - 'total': 5, - 'collections': [],}; - mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await vectorsDB.listCollections( - '', - ); - - // Remove custom toString method on the objects to allow for clean data comparison. - delete response.toString; - - expect(response).toEqual(data); - }); - - test('test method createCollection()', async () => { - const data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - '\$permissions': [], - 'databaseId': '5e5ea5c16897e', - 'name': 'My Collection', - 'enabled': true, - 'documentSecurity': true, - 'attributes': [], - 'indexes': [], - 'bytesMax': 65535, - 'bytesUsed': 1500, - 'dimension': 1536,}; - mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await vectorsDB.createCollection( - '', - '', - '', - 1, - ); - - // Remove custom toString method on the objects to allow for clean data comparison. - delete response.toString; - - expect(response).toEqual(data); - }); - - test('test method getCollection()', async () => { - const data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - '\$permissions': [], - 'databaseId': '5e5ea5c16897e', - 'name': 'My Collection', - 'enabled': true, - 'documentSecurity': true, - 'attributes': [], - 'indexes': [], - 'bytesMax': 65535, - 'bytesUsed': 1500, - 'dimension': 1536,}; - mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await vectorsDB.getCollection( - '', - '', - ); - - // Remove custom toString method on the objects to allow for clean data comparison. - delete response.toString; - - expect(response).toEqual(data); - }); - - test('test method updateCollection()', async () => { - const data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - '\$permissions': [], - 'databaseId': '5e5ea5c16897e', - 'name': 'My Collection', - 'enabled': true, - 'documentSecurity': true, - 'attributes': [], - 'indexes': [], - 'bytesMax': 65535, - 'bytesUsed': 1500, - 'dimension': 1536,}; - mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await vectorsDB.updateCollection( - '', - '', - '', - ); - - // Remove custom toString method on the objects to allow for clean data comparison. - delete response.toString; - - expect(response).toEqual(data); - }); - - test('test method deleteCollection()', async () => { - const data = {message: ""}; - mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await vectorsDB.deleteCollection( - '', - '', - ); - - // Remove custom toString method on the objects to allow for clean data comparison. - delete response.toString; - - expect(response).toEqual(data); - }); - - test('test method listDocuments()', async () => { - const data = { - 'total': 5, - 'documents': [],}; - mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await vectorsDB.listDocuments( - '', - '', - ); - - // Remove custom toString method on the objects to allow for clean data comparison. - delete response.toString; - - expect(response).toEqual(data); - }); - - test('test method createDocument()', async () => { - const data = { - '\$id': '5e5ea5c16897e', - '\$sequence': '1', - '\$collectionId': '5e5ea5c15117e', - '\$databaseId': '5e5ea5c15117e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - '\$permissions': [],}; - mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await vectorsDB.createDocument( - '', - '', - '', - {}, - ); - - // Remove custom toString method on the objects to allow for clean data comparison. - delete response.toString; - - expect(response).toEqual(data); - }); - - test('test method createDocuments()', async () => { - const data = { - 'total': 5, - 'documents': [],}; - mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await vectorsDB.createDocuments( - '', - '', - [], - ); - - // Remove custom toString method on the objects to allow for clean data comparison. - delete response.toString; - - expect(response).toEqual(data); - }); - - test('test method upsertDocuments()', async () => { - const data = { - 'total': 5, - 'documents': [],}; - mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await vectorsDB.upsertDocuments( - '', - '', - [], - ); - - // Remove custom toString method on the objects to allow for clean data comparison. - delete response.toString; - - expect(response).toEqual(data); - }); - - test('test method updateDocuments()', async () => { - const data = { - 'total': 5, - 'documents': [],}; - mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await vectorsDB.updateDocuments( - '', - '', - ); - - // Remove custom toString method on the objects to allow for clean data comparison. - delete response.toString; - - expect(response).toEqual(data); - }); - - test('test method deleteDocuments()', async () => { - const data = { - 'total': 5, - 'documents': [],}; - mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await vectorsDB.deleteDocuments( - '', - '', - ); - - // Remove custom toString method on the objects to allow for clean data comparison. - delete response.toString; - - expect(response).toEqual(data); - }); - - test('test method getDocument()', async () => { - const data = { - '\$id': '5e5ea5c16897e', - '\$sequence': '1', - '\$collectionId': '5e5ea5c15117e', - '\$databaseId': '5e5ea5c15117e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - '\$permissions': [],}; - mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await vectorsDB.getDocument( - '', - '', - '', - ); - - // Remove custom toString method on the objects to allow for clean data comparison. - delete response.toString; - - expect(response).toEqual(data); - }); - - test('test method upsertDocument()', async () => { - const data = { - '\$id': '5e5ea5c16897e', - '\$sequence': '1', - '\$collectionId': '5e5ea5c15117e', - '\$databaseId': '5e5ea5c15117e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - '\$permissions': [],}; - mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await vectorsDB.upsertDocument( - '', - '', - '', - ); - - // Remove custom toString method on the objects to allow for clean data comparison. - delete response.toString; - - expect(response).toEqual(data); - }); - - test('test method updateDocument()', async () => { - const data = { - '\$id': '5e5ea5c16897e', - '\$sequence': '1', - '\$collectionId': '5e5ea5c15117e', - '\$databaseId': '5e5ea5c15117e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - '\$permissions': [],}; - mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await vectorsDB.updateDocument( - '', - '', - '', - ); - - // Remove custom toString method on the objects to allow for clean data comparison. - delete response.toString; - - expect(response).toEqual(data); - }); - - test('test method deleteDocument()', async () => { - const data = {message: ""}; - mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await vectorsDB.deleteDocument( - '', - '', - '', - ); - - // Remove custom toString method on the objects to allow for clean data comparison. - delete response.toString; - - expect(response).toEqual(data); - }); - - test('test method listIndexes()', async () => { - const data = { - 'total': 5, - 'indexes': [],}; - mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await vectorsDB.listIndexes( - '', - '', - ); - - // Remove custom toString method on the objects to allow for clean data comparison. - delete response.toString; - - expect(response).toEqual(data); - }); - - test('test method createIndex()', async () => { - const data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'key': 'index1', - 'type': 'primary', - 'status': 'available', - 'error': 'string', - 'attributes': [], - 'lengths': [],}; - mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await vectorsDB.createIndex( - '', - '', - '', - 'hnsw_euclidean', - [], - ); - - // Remove custom toString method on the objects to allow for clean data comparison. - delete response.toString; - - expect(response).toEqual(data); - }); - - test('test method getIndex()', async () => { - const data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'key': 'index1', - 'type': 'primary', - 'status': 'available', - 'error': 'string', - 'attributes': [], - 'lengths': [],}; - mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await vectorsDB.getIndex( - '', - '', - '', - ); - - // Remove custom toString method on the objects to allow for clean data comparison. - delete response.toString; - - expect(response).toEqual(data); - }); - - test('test method deleteIndex()', async () => { - const data = {message: ""}; - mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await vectorsDB.deleteIndex( - '', - '', - '', - ); - - // Remove custom toString method on the objects to allow for clean data comparison. - delete response.toString; - - expect(response).toEqual(data); - }); - }) From 32068e1390ed06407f5499617320eabc6da3c3b4 Mon Sep 17 00:00:00 2001 From: root Date: Wed, 25 Mar 2026 06:42:54 +0000 Subject: [PATCH 4/9] chore: update Node.js SDK to 23.0.0 --- src/enums/documents-db-index-type.ts | 6 - src/enums/model.ts | 3 - src/enums/template-reference-type.ts | 2 +- src/enums/vcs-reference-type.ts | 1 - src/enums/vectors-db-index-type.ts | 8 - src/index.ts | 7 +- src/models.ts | 4706 +++++++++++++------------- src/services/health.ts | 255 -- test/services/health.test.js | 70 - 9 files changed, 2262 insertions(+), 2796 deletions(-) delete mode 100644 src/enums/documents-db-index-type.ts delete mode 100644 src/enums/model.ts delete mode 100644 src/enums/vectors-db-index-type.ts diff --git a/src/enums/documents-db-index-type.ts b/src/enums/documents-db-index-type.ts deleted file mode 100644 index 8b65e173..00000000 --- a/src/enums/documents-db-index-type.ts +++ /dev/null @@ -1,6 +0,0 @@ -export enum DocumentsDBIndexType { - Key = 'key', - Fulltext = 'fulltext', - Unique = 'unique', - Spatial = 'spatial', -} \ No newline at end of file diff --git a/src/enums/model.ts b/src/enums/model.ts deleted file mode 100644 index 78e605e3..00000000 --- a/src/enums/model.ts +++ /dev/null @@ -1,3 +0,0 @@ -export enum Model { - Embeddinggemma = 'embeddinggemma', -} \ No newline at end of file diff --git a/src/enums/template-reference-type.ts b/src/enums/template-reference-type.ts index c714c2c8..bd72cfb5 100644 --- a/src/enums/template-reference-type.ts +++ b/src/enums/template-reference-type.ts @@ -1,5 +1,5 @@ export enum TemplateReferenceType { - Branch = 'branch', Commit = 'commit', + Branch = 'branch', Tag = 'tag', } \ No newline at end of file diff --git a/src/enums/vcs-reference-type.ts b/src/enums/vcs-reference-type.ts index cb5270f5..5bbae171 100644 --- a/src/enums/vcs-reference-type.ts +++ b/src/enums/vcs-reference-type.ts @@ -1,5 +1,4 @@ export enum VCSReferenceType { Branch = 'branch', Commit = 'commit', - Tag = 'tag', } \ No newline at end of file diff --git a/src/enums/vectors-db-index-type.ts b/src/enums/vectors-db-index-type.ts deleted file mode 100644 index a38d5ea1..00000000 --- a/src/enums/vectors-db-index-type.ts +++ /dev/null @@ -1,8 +0,0 @@ -export enum VectorsDBIndexType { - HnswEuclidean = 'hnsw_euclidean', - HnswDot = 'hnsw_dot', - HnswCosine = 'hnsw_cosine', - Object = 'object', - Key = 'key', - Unique = 'unique', -} \ No newline at end of file diff --git a/src/index.ts b/src/index.ts index ee851533..f6c5c05b 100644 --- a/src/index.ts +++ b/src/index.ts @@ -38,7 +38,6 @@ export { RelationshipType } from './enums/relationship-type'; export { RelationMutate } from './enums/relation-mutate'; export { DatabasesIndexType } from './enums/databases-index-type'; export { OrderBy } from './enums/order-by'; -export { DocumentsDBIndexType } from './enums/documents-db-index-type'; export { Runtime } from './enums/runtime'; export { Scopes } from './enums/scopes'; export { TemplateReferenceType } from './enums/template-reference-type'; @@ -56,15 +55,13 @@ export { ImageGravity } from './enums/image-gravity'; export { TablesDBIndexType } from './enums/tables-db-index-type'; export { PasswordHash } from './enums/password-hash'; export { MessagingProviderType } from './enums/messaging-provider-type'; -export { Model } from './enums/model'; -export { VectorsDBIndexType } from './enums/vectors-db-index-type'; export { DatabaseType } from './enums/database-type'; export { AttributeStatus } from './enums/attribute-status'; -export { ColumnStatus } from './enums/column-status'; export { IndexStatus } from './enums/index-status'; export { DeploymentStatus } from './enums/deployment-status'; export { ExecutionTrigger } from './enums/execution-trigger'; export { ExecutionStatus } from './enums/execution-status'; -export { HealthAntivirusStatus } from './enums/health-antivirus-status'; export { HealthCheckStatus } from './enums/health-check-status'; +export { HealthAntivirusStatus } from './enums/health-antivirus-status'; export { MessageStatus } from './enums/message-status'; +export { ColumnStatus } from './enums/column-status'; diff --git a/src/models.ts b/src/models.ts index 0958a926..049b933a 100644 --- a/src/models.ts +++ b/src/models.ts @@ -1,13 +1,13 @@ import { DatabaseType } from "./enums/database-type" import { AttributeStatus } from "./enums/attribute-status" -import { ColumnStatus } from "./enums/column-status" import { IndexStatus } from "./enums/index-status" import { DeploymentStatus } from "./enums/deployment-status" import { ExecutionTrigger } from "./enums/execution-trigger" import { ExecutionStatus } from "./enums/execution-status" -import { HealthAntivirusStatus } from "./enums/health-antivirus-status" import { HealthCheckStatus } from "./enums/health-check-status" +import { HealthAntivirusStatus } from "./enums/health-antivirus-status" import { MessageStatus } from "./enums/message-status" +import { ColumnStatus } from "./enums/column-status" /** * Appwrite Models @@ -17,129 +17,93 @@ export namespace Models { declare const __default: unique symbol; /** - * Rows List + * User */ - export type RowList = { + export type User = { /** - * Total number of rows that matched your query. + * User ID. */ - total: number; + $id: string; /** - * List of rows. + * User creation date in ISO 8601 format. */ - rows: Row[]; - } - - /** - * Documents List - */ - export type DocumentList = { + $createdAt: string; /** - * Total number of documents that matched your query. + * User update date in ISO 8601 format. */ - total: number; + $updatedAt: string; /** - * List of documents. + * User name. */ - documents: Document[]; - } - - /** - * Tables List - */ - export type TableList = { + name: string; /** - * Total number of tables that matched your query. + * Hashed user password. */ - total: number; + password?: string; /** - * List of tables. + * Password hashing algorithm. */ - tables: Table[]; - } - - /** - * Collections List - */ - export type CollectionList = { + hash?: string; /** - * Total number of collections that matched your query. + * Password hashing algorithm configuration. */ - total: number; + hashOptions?: object; /** - * List of collections. + * User registration date in ISO 8601 format. */ - collections: Collection[]; - } - - /** - * Databases List - */ - export type DatabaseList = { + registration: string; /** - * Total number of databases that matched your query. + * User status. Pass `true` for enabled and `false` for disabled. */ - total: number; + status: boolean; /** - * List of databases. + * Labels for the user. */ - databases: Database[]; - } - - /** - * Indexes List - */ - export type IndexList = { + labels: string[]; /** - * Total number of indexes that matched your query. + * Password update time in ISO 8601 format. */ - total: number; + passwordUpdate: string; /** - * List of indexes. + * User email address. */ - indexes: Index[]; - } - - /** - * Column Indexes List - */ - export type ColumnIndexList = { + email: string; /** - * Total number of indexes that matched your query. + * User phone number in E.164 format. */ - total: number; + phone: string; /** - * List of indexes. + * Email verification status. */ - indexes: ColumnIndex[]; - } - - /** - * Users List - */ - export type UserList = { + emailVerification: boolean; /** - * Total number of users that matched your query. + * Phone verification status. */ - total: number; + phoneVerification: boolean; /** - * List of users. + * Multi factor authentication status. */ - users: User[]; - } - - /** - * Sessions List - */ - export type SessionList = { + mfa: boolean; /** - * Total number of sessions that matched your query. + * User preferences as a key-value object */ - total: number; + prefs: Preferences; /** - * List of sessions. + * A user-owned message receiver. A single user may have multiple e.g. emails, phones, and a browser. Each target is registered with a single provider. */ - sessions: Session[]; + targets: Target[]; + /** + * Most recent access date in ISO 8601 format. This attribute is only updated again after 24 hours. + */ + accessedAt: string; + /** + * Whether the user can impersonate other users. + */ + impersonator?: boolean; + /** + * ID of the original actor performing the impersonation. Present only when the current request is impersonating another user. Internal audit logs attribute the action to this user, while the impersonated target is recorded only in internal audit payload data. + */ + impersonatorUserId?: string; } /** @@ -156,6 +120,16 @@ export namespace Models { identities: Identity[]; } + /** + * JWT + */ + export type Jwt = { + /** + * JWT encoded string. + */ + jwt: string; + } + /** * Logs List */ @@ -171,831 +145,776 @@ export namespace Models { } /** - * Files List + * MFAType */ - export type FileList = { + export type MfaType = { /** - * Total number of files that matched your query. + * Secret token used for TOTP factor. */ - total: number; + secret: string; /** - * List of files. + * URI for authenticator apps. */ - files: File[]; + uri: string; } /** - * Buckets List + * MFA Challenge */ - export type BucketList = { + export type MfaChallenge = { /** - * Total number of buckets that matched your query. + * Token ID. */ - total: number; + $id: string; /** - * List of buckets. + * Token creation date in ISO 8601 format. */ - buckets: Bucket[]; - } - - /** - * Resource Tokens List - */ - export type ResourceTokenList = { + $createdAt: string; /** - * Total number of tokens that matched your query. + * User ID. */ - total: number; + userId: string; /** - * List of tokens. + * Token expiration date in ISO 8601 format. */ - tokens: ResourceToken[]; + expire: string; } /** - * Teams List + * Session */ - export type TeamList = { + export type Session = { /** - * Total number of teams that matched your query. + * Session ID. */ - total: number; + $id: string; /** - * List of teams. + * Session creation date in ISO 8601 format. */ - teams: Team[]; - } - - /** - * Memberships List - */ - export type MembershipList = { + $createdAt: string; /** - * Total number of memberships that matched your query. + * Session update date in ISO 8601 format. */ - total: number; + $updatedAt: string; /** - * List of memberships. + * User ID. */ - memberships: Membership[]; - } - - /** - * Sites List - */ - export type SiteList = { + userId: string; /** - * Total number of sites that matched your query. + * Session expiration date in ISO 8601 format. */ - total: number; + expire: string; /** - * List of sites. + * Session Provider. */ - sites: Site[]; - } - - /** - * Functions List - */ - export type FunctionList = { + provider: string; /** - * Total number of functions that matched your query. + * Session Provider User ID. */ - total: number; + providerUid: string; /** - * List of functions. + * Session Provider Access Token. */ - functions: Function[]; - } - - /** - * Frameworks List - */ - export type FrameworkList = { + providerAccessToken: string; /** - * Total number of frameworks that matched your query. + * The date of when the access token expires in ISO 8601 format. */ - total: number; + providerAccessTokenExpiry: string; /** - * List of frameworks. + * Session Provider Refresh Token. */ - frameworks: Framework[]; - } - - /** - * Runtimes List - */ - export type RuntimeList = { + providerRefreshToken: string; /** - * Total number of runtimes that matched your query. + * IP in use when the session was created. */ - total: number; + ip: string; /** - * List of runtimes. + * Operating system code name. View list of [available options](https://github.com/appwrite/appwrite/blob/master/docs/lists/os.json). */ - runtimes: Runtime[]; - } - - /** - * Deployments List - */ - export type DeploymentList = { + osCode: string; /** - * Total number of deployments that matched your query. + * Operating system name. */ - total: number; + osName: string; /** - * List of deployments. + * Operating system version. */ - deployments: Deployment[]; - } - - /** - * Executions List - */ - export type ExecutionList = { + osVersion: string; /** - * Total number of executions that matched your query. + * Client type. */ - total: number; + clientType: string; /** - * List of executions. + * Client code name. View list of [available options](https://github.com/appwrite/appwrite/blob/master/docs/lists/clients.json). */ - executions: Execution[]; - } - - /** - * Webhooks List - */ - export type WebhookList = { + clientCode: string; /** - * Total number of webhooks that matched your query. + * Client name. */ - total: number; + clientName: string; /** - * List of webhooks. + * Client version. */ - webhooks: Webhook[]; - } - - /** - * Countries List - */ - export type CountryList = { + clientVersion: string; /** - * Total number of countries that matched your query. + * Client engine name. */ - total: number; + clientEngine: string; /** - * List of countries. + * Client engine name. */ - countries: Country[]; - } - - /** - * Continents List - */ - export type ContinentList = { + clientEngineVersion: string; /** - * Total number of continents that matched your query. + * Device name. */ - total: number; + deviceName: string; /** - * List of continents. + * Device brand name. */ - continents: Continent[]; - } - - /** - * Languages List - */ - export type LanguageList = { + deviceBrand: string; /** - * Total number of languages that matched your query. + * Device model name. */ - total: number; + deviceModel: string; /** - * List of languages. + * Country two-character ISO 3166-1 alpha code. */ - languages: Language[]; - } - - /** - * Currencies List - */ - export type CurrencyList = { + countryCode: string; /** - * Total number of currencies that matched your query. + * Country name. */ - total: number; + countryName: string; /** - * List of currencies. + * Returns true if this the current user session. */ - currencies: Currency[]; - } - - /** - * Phones List - */ - export type PhoneList = { + current: boolean; /** - * Total number of phones that matched your query. + * Returns a list of active session factors. */ - total: number; + factors: string[]; /** - * List of phones. + * Secret used to authenticate the user. Only included if the request was made with an API key */ - phones: Phone[]; + secret: string; + /** + * Most recent date in ISO 8601 format when the session successfully passed MFA challenge. + */ + mfaUpdatedAt: string; } /** - * Variables List + * MFAFactors */ - export type VariableList = { + export type MfaFactors = { /** - * Total number of variables that matched your query. + * Can TOTP be used for MFA challenge for this account. */ - total: number; + totp: boolean; /** - * List of variables. + * Can phone (SMS) be used for MFA challenge for this account. */ - variables: Variable[]; - } - - /** - * Status List - */ - export type HealthStatusList = { + phone: boolean; /** - * Total number of statuses that matched your query. + * Can email be used for MFA challenge for this account. */ - total: number; + email: boolean; /** - * List of statuses. + * Can recovery code be used for MFA challenge for this account. */ - statuses: HealthStatus[]; + recoveryCode: boolean; } /** - * Locale codes list + * MFA Recovery Codes */ - export type LocaleCodeList = { - /** - * Total number of localeCodes that matched your query. - */ - total: number; + export type MfaRecoveryCodes = { /** - * List of localeCodes. + * Recovery codes. */ - localeCodes: LocaleCode[]; + recoveryCodes: string[]; } /** - * Provider list + * Preferences */ - export type ProviderList = { - /** - * Total number of providers that matched your query. - */ - total: number; - /** - * List of providers. - */ - providers: Provider[]; + export type Preferences = { } + export type DefaultPreferences = Preferences & { + [key: string]: any; + [__default]: true; + }; + /** - * Message list + * Token */ - export type MessageList = { + export type Token = { /** - * Total number of messages that matched your query. + * Token ID. */ - total: number; + $id: string; /** - * List of messages. + * Token creation date in ISO 8601 format. */ - messages: Message[]; - } - - /** - * Topic list - */ - export type TopicList = { + $createdAt: string; /** - * Total number of topics that matched your query. + * User ID. */ - total: number; + userId: string; /** - * List of topics. + * Token secret key. This will return an empty string unless the response is returned using an API key or as part of a webhook payload. */ - topics: Topic[]; - } - - /** - * Subscriber list - */ - export type SubscriberList = { + secret: string; /** - * Total number of subscribers that matched your query. + * Token expiration date in ISO 8601 format. */ - total: number; + expire: string; /** - * List of subscribers. + * Security phrase of a token. Empty if security phrase was not requested when creating a token. It includes randomly generated phrase which is also sent in the external resource such as email. */ - subscribers: Subscriber[]; + phrase: string; } /** - * Target list + * Sessions List */ - export type TargetList = { + export type SessionList = { /** - * Total number of targets that matched your query. + * Total number of sessions that matched your query. */ total: number; /** - * List of targets. + * List of sessions. */ - targets: Target[]; + sessions: Session[]; } /** - * Transaction List + * Activity event list */ - export type TransactionList = { + export type ActivityEventList = { /** - * Total number of transactions that matched your query. + * Total number of events that matched your query. */ total: number; /** - * List of transactions. + * List of events. */ - transactions: Transaction[]; + events: ActivityEvent[]; } /** - * Specifications List + * ActivityEvent */ - export type SpecificationList = { + export type ActivityEvent = { /** - * Total number of specifications that matched your query. + * Event ID. */ - total: number; + $id: string; /** - * List of specifications. + * User type. */ - specifications: Specification[]; - } - - /** - * VectorsDB Collections List - */ - export type VectorsdbCollectionList = { + userType: string; /** - * Total number of collections that matched your query. + * User ID. */ - total: number; + userId: string; /** - * List of collections. + * User Email. */ - collections: VectorsdbCollection[]; - } - - /** - * Embedding list - */ - export type EmbeddingList = { + userEmail: string; /** - * Total number of embeddings that matched your query. + * User Name. */ - total: number; + userName: string; /** - * List of embeddings. + * Resource parent. */ - embeddings: Embedding[]; - } - - /** - * Database - */ - export type Database = { + resourceParent: string; /** - * Database ID. + * Resource type. */ - $id: string; + resourceType: string; /** - * Database name. + * Resource ID. */ - name: string; + resourceId: string; /** - * Database creation date in ISO 8601 format. + * Resource. */ - $createdAt: string; + resource: string; /** - * Database update date in ISO 8601 format. + * Event name. */ - $updatedAt: string; + event: string; /** - * If database is enabled. Can be 'enabled' or 'disabled'. When disabled, the database is inaccessible to users, but remains accessible to Server SDKs using API keys. + * User agent. */ - enabled: boolean; + userAgent: string; /** - * Database type. + * IP address. */ - type: DatabaseType; + ip: string; /** - * Database backup policies. + * API mode when event triggered. */ - policies: Index[]; + mode: string; /** - * Database backup archives. + * Location. */ - archives: Collection[]; - } - - /** - * Embedding - */ - export type Embedding = { + country: string; /** - * Embedding model used to generate embeddings. + * Log creation date in ISO 8601 format. */ - model: string; + time: string; /** - * Number of dimensions for each embedding vector. + * Project ID. */ - dimension: number; + projectId: string; /** - * Embedding vector values. If an error occurs, this will be an empty array. + * Team ID. */ - embedding: number[]; + teamId: string; /** - * Error message if embedding generation fails. Empty string if no error. + * Hostname. */ - error: string; - } - - /** - * Collection - */ - export type Collection = { + hostname: string; /** - * Collection ID. + * Operating system code name. View list of [available options](https://github.com/appwrite/appwrite/blob/master/docs/lists/os.json). */ - $id: string; + osCode: string; /** - * Collection creation date in ISO 8601 format. + * Operating system name. */ - $createdAt: string; + osName: string; /** - * Collection update date in ISO 8601 format. + * Operating system version. */ - $updatedAt: string; + osVersion: string; /** - * Collection permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). + * Client type. */ - $permissions: string[]; + clientType: string; /** - * Database ID. + * Client code name. View list of [available options](https://github.com/appwrite/appwrite/blob/master/docs/lists/clients.json). */ - databaseId: string; + clientCode: string; /** - * Collection name. + * Client name. */ - name: string; + clientName: string; /** - * Collection enabled. Can be 'enabled' or 'disabled'. When disabled, the collection is inaccessible to users, but remains accessible to Server SDKs using API keys. + * Client version. */ - enabled: boolean; + clientVersion: string; /** - * Whether document-level permissions are enabled. [Learn more about permissions](https://appwrite.io/docs/permissions). + * Client engine name. */ - documentSecurity: boolean; + clientEngine: string; /** - * Collection attributes. + * Client engine name. */ - attributes: (Models.AttributeBoolean | Models.AttributeInteger | Models.AttributeFloat | Models.AttributeEmail | Models.AttributeEnum | Models.AttributeUrl | Models.AttributeIp | Models.AttributeDatetime | Models.AttributeRelationship | Models.AttributePoint | Models.AttributeLine | Models.AttributePolygon | Models.AttributeVarchar | Models.AttributeText | Models.AttributeMediumtext | Models.AttributeLongtext | Models.AttributeString)[]; + clientEngineVersion: string; /** - * Collection indexes. + * Device name. */ - indexes: Index[]; + deviceName: string; /** - * Maximum document size in bytes. Returns 0 when no limit applies. + * Device brand name. */ - bytesMax: number; + deviceBrand: string; /** - * Currently used document size in bytes based on defined attributes. + * Device model name. */ - bytesUsed: number; + deviceModel: string; + /** + * Country two-character ISO 3166-1 alpha code. + */ + countryCode: string; + /** + * Country name. + */ + countryName: string; } /** - * Attributes List + * Backup archive list */ - export type AttributeList = { + export type BackupArchiveList = { /** - * Total number of attributes in the given collection. + * Total number of archives that matched your query. */ total: number; /** - * List of attributes. + * List of archives. */ - attributes: (Models.AttributeBoolean | Models.AttributeInteger | Models.AttributeFloat | Models.AttributeEmail | Models.AttributeEnum | Models.AttributeUrl | Models.AttributeIp | Models.AttributeDatetime | Models.AttributeRelationship | Models.AttributePoint | Models.AttributeLine | Models.AttributePolygon | Models.AttributeVarchar | Models.AttributeText | Models.AttributeMediumtext | Models.AttributeLongtext | Models.AttributeString)[]; + archives: BackupArchive[]; } /** - * AttributeString + * Archive */ - export type AttributeString = { + export type BackupArchive = { /** - * Attribute Key. + * Archive ID. */ - key: string; + $id: string; /** - * Attribute type. + * Archive creation time in ISO 8601 format. */ - type: string; + $createdAt: string; /** - * Attribute status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` + * Archive update date in ISO 8601 format. */ - status: AttributeStatus; + $updatedAt: string; /** - * Error message. Displays error generated on failure of creating or deleting an attribute. + * Archive policy ID. */ - error: string; + policyId: string; /** - * Is attribute required? + * Archive size in bytes. */ - required: boolean; + size: number; /** - * Is attribute an array? + * The status of the archive creation. Possible values: pending, processing, uploading, completed, failed. */ - array?: boolean; + status: string; /** - * Attribute creation date in ISO 8601 format. + * The backup start time. */ - $createdAt: string; + startedAt: string; /** - * Attribute update date in ISO 8601 format. + * Migration ID. */ - $updatedAt: string; + migrationId: string; /** - * Attribute size. + * The services that are backed up by this archive. */ - size: number; + services: string[]; /** - * Default value for attribute when not provided. Cannot be set when attribute is required. + * The resources that are backed up by this archive. */ - default?: string; + resources: string[]; /** - * Defines whether this attribute is encrypted or not. + * The resource ID to backup. Set only if this archive should backup a single resource. */ - encrypt?: boolean; + resourceId?: string; + /** + * The resource type to backup. Set only if this archive should backup a single resource. + */ + resourceType?: string; } /** - * AttributeInteger + * Backup policy list */ - export type AttributeInteger = { - /** - * Attribute Key. - */ - key: string; - /** - * Attribute type. - */ - type: string; + export type BackupPolicyList = { /** - * Attribute status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` + * Total number of policies that matched your query. */ - status: AttributeStatus; + total: number; /** - * Error message. Displays error generated on failure of creating or deleting an attribute. + * List of policies. */ - error: string; + policies: BackupPolicy[]; + } + + /** + * backup + */ + export type BackupPolicy = { /** - * Is attribute required? + * Backup policy ID. */ - required: boolean; + $id: string; /** - * Is attribute an array? + * Backup policy name. */ - array?: boolean; + name: string; /** - * Attribute creation date in ISO 8601 format. + * Policy creation date in ISO 8601 format. */ $createdAt: string; /** - * Attribute update date in ISO 8601 format. + * Policy update date in ISO 8601 format. */ $updatedAt: string; /** - * Minimum value to enforce for new documents. + * The services that are backed up by this policy. */ - min?: number | bigint; + services: string[]; /** - * Maximum value to enforce for new documents. + * The resources that are backed up by this policy. */ - max?: number | bigint; + resources: string[]; /** - * Default value for attribute when not provided. Cannot be set when attribute is required. + * The resource ID to backup. Set only if this policy should backup a single resource. */ - default?: number; - } - - /** - * AttributeFloat - */ - export type AttributeFloat = { + resourceId?: string; /** - * Attribute Key. + * The resource type to backup. Set only if this policy should backup a single resource. */ - key: string; + resourceType?: string; /** - * Attribute type. - */ - type: string; - /** - * Attribute status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` + * How many days to keep the backup before it will be automatically deleted. */ - status: AttributeStatus; + retention: number; /** - * Error message. Displays error generated on failure of creating or deleting an attribute. + * Policy backup schedule in CRON format. */ - error: string; + schedule: string; /** - * Is attribute required? + * Is this policy enabled. */ - required: boolean; + enabled: boolean; + } + + /** + * Restoration + */ + export type BackupRestoration = { /** - * Is attribute an array? + * Restoration ID. */ - array?: boolean; + $id: string; /** - * Attribute creation date in ISO 8601 format. + * Restoration creation time in ISO 8601 format. */ $createdAt: string; /** - * Attribute update date in ISO 8601 format. + * Restoration update date in ISO 8601 format. */ $updatedAt: string; /** - * Minimum value to enforce for new documents. + * Backup archive ID. */ - min?: number; + archiveId: string; /** - * Maximum value to enforce for new documents. + * Backup policy ID. */ - max?: number; + policyId: string; /** - * Default value for attribute when not provided. Cannot be set when attribute is required. + * The status of the restoration. Possible values: pending, downloading, processing, completed, failed. */ - default?: number; + status: string; + /** + * The backup start time. + */ + startedAt: string; + /** + * Migration ID. + */ + migrationId: string; + /** + * The services that are backed up by this policy. + */ + services: string[]; + /** + * The resources that are backed up by this policy. + */ + resources: string[]; + /** + * Optional data in key-value object. + */ + options: string; } /** - * AttributeBoolean + * Backup restoration list */ - export type AttributeBoolean = { + export type BackupRestorationList = { /** - * Attribute Key. + * Total number of restorations that matched your query. */ - key: string; + total: number; /** - * Attribute type. + * List of restorations. */ - type: string; + restorations: BackupRestoration[]; + } + + /** + * Databases List + */ + export type DatabaseList = { /** - * Attribute status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` + * Total number of databases that matched your query. */ - status: AttributeStatus; + total: number; /** - * Error message. Displays error generated on failure of creating or deleting an attribute. + * List of databases. */ - error: string; + databases: Database[]; + } + + /** + * Database + */ + export type Database = { /** - * Is attribute required? + * Database ID. */ - required: boolean; + $id: string; /** - * Is attribute an array? + * Database name. */ - array?: boolean; + name: string; /** - * Attribute creation date in ISO 8601 format. + * Database creation date in ISO 8601 format. */ $createdAt: string; /** - * Attribute update date in ISO 8601 format. + * Database update date in ISO 8601 format. */ $updatedAt: string; /** - * Default value for attribute when not provided. Cannot be set when attribute is required. + * If database is enabled. Can be 'enabled' or 'disabled'. When disabled, the database is inaccessible to users, but remains accessible to Server SDKs using API keys. */ - default?: boolean; + enabled: boolean; + /** + * Database type. + */ + type: DatabaseType; + /** + * Database backup policies. + */ + policies: Index[]; + /** + * Database backup archives. + */ + archives: Collection[]; } /** - * AttributeEmail + * Transaction List */ - export type AttributeEmail = { + export type TransactionList = { /** - * Attribute Key. + * Total number of transactions that matched your query. */ - key: string; + total: number; /** - * Attribute type. + * List of transactions. */ - type: string; + transactions: Transaction[]; + } + + /** + * Transaction + */ + export type Transaction = { /** - * Attribute status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` + * Transaction ID. */ - status: AttributeStatus; + $id: string; /** - * Error message. Displays error generated on failure of creating or deleting an attribute. + * Transaction creation time in ISO 8601 format. */ - error: string; + $createdAt: string; /** - * Is attribute required? + * Transaction update date in ISO 8601 format. */ - required: boolean; + $updatedAt: string; /** - * Is attribute an array? + * Current status of the transaction. One of: pending, committing, committed, rolled_back, failed. */ - array?: boolean; + status: string; /** - * Attribute creation date in ISO 8601 format. + * Number of operations in the transaction. */ - $createdAt: string; + operations: number; /** - * Attribute update date in ISO 8601 format. + * Expiration time in ISO 8601 format. */ - $updatedAt: string; + expiresAt: string; + } + + /** + * Collections List + */ + export type CollectionList = { /** - * String format. + * Total number of collections that matched your query. */ - format: string; + total: number; /** - * Default value for attribute when not provided. Cannot be set when attribute is required. + * List of collections. */ - default?: string; + collections: Collection[]; } /** - * AttributeEnum + * Collection */ - export type AttributeEnum = { + export type Collection = { /** - * Attribute Key. + * Collection ID. */ - key: string; + $id: string; /** - * Attribute type. + * Collection creation date in ISO 8601 format. */ - type: string; + $createdAt: string; /** - * Attribute status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` + * Collection update date in ISO 8601 format. */ - status: AttributeStatus; + $updatedAt: string; /** - * Error message. Displays error generated on failure of creating or deleting an attribute. + * Collection permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). */ - error: string; + $permissions: string[]; /** - * Is attribute required? + * Database ID. */ - required: boolean; + databaseId: string; /** - * Is attribute an array? + * Collection name. */ - array?: boolean; + name: string; /** - * Attribute creation date in ISO 8601 format. + * Collection enabled. Can be 'enabled' or 'disabled'. When disabled, the collection is inaccessible to users, but remains accessible to Server SDKs using API keys. */ - $createdAt: string; + enabled: boolean; /** - * Attribute update date in ISO 8601 format. + * Whether document-level permissions are enabled. [Learn more about permissions](https://appwrite.io/docs/permissions). */ - $updatedAt: string; + documentSecurity: boolean; /** - * Array of elements in enumerated type. + * Collection attributes. */ - elements: string[]; + attributes: (Models.AttributeBoolean | Models.AttributeInteger | Models.AttributeFloat | Models.AttributeEmail | Models.AttributeEnum | Models.AttributeUrl | Models.AttributeIp | Models.AttributeDatetime | Models.AttributeRelationship | Models.AttributePoint | Models.AttributeLine | Models.AttributePolygon | Models.AttributeVarchar | Models.AttributeText | Models.AttributeMediumtext | Models.AttributeLongtext | Models.AttributeString)[]; /** - * String format. + * Collection indexes. */ - format: string; + indexes: Index[]; /** - * Default value for attribute when not provided. Cannot be set when attribute is required. + * Maximum document size in bytes. Returns 0 when no limit applies. */ - default?: string; + bytesMax: number; + /** + * Currently used document size in bytes based on defined attributes. + */ + bytesUsed: number; } /** - * AttributeIP + * Attributes List */ - export type AttributeIp = { + export type AttributeList = { + /** + * Total number of attributes in the given collection. + */ + total: number; + /** + * List of attributes. + */ + attributes: (Models.AttributeBoolean | Models.AttributeInteger | Models.AttributeFloat | Models.AttributeEmail | Models.AttributeEnum | Models.AttributeUrl | Models.AttributeIp | Models.AttributeDatetime | Models.AttributeRelationship | Models.AttributePoint | Models.AttributeLine | Models.AttributePolygon | Models.AttributeVarchar | Models.AttributeText | Models.AttributeMediumtext | Models.AttributeLongtext | Models.AttributeString)[]; + } + + /** + * AttributeBoolean + */ + export type AttributeBoolean = { /** * Attribute Key. */ @@ -1028,20 +947,16 @@ export namespace Models { * Attribute update date in ISO 8601 format. */ $updatedAt: string; - /** - * String format. - */ - format: string; /** * Default value for attribute when not provided. Cannot be set when attribute is required. */ - default?: string; + default?: boolean; } /** - * AttributeURL + * AttributeDatetime */ - export type AttributeUrl = { + export type AttributeDatetime = { /** * Attribute Key. */ @@ -1075,19 +990,19 @@ export namespace Models { */ $updatedAt: string; /** - * String format. + * ISO 8601 format. */ format: string; /** - * Default value for attribute when not provided. Cannot be set when attribute is required. + * Default value for attribute when not provided. Only null is optional */ default?: string; } /** - * AttributeDatetime + * AttributeEmail */ - export type AttributeDatetime = { + export type AttributeEmail = { /** * Attribute Key. */ @@ -1121,19 +1036,19 @@ export namespace Models { */ $updatedAt: string; /** - * ISO 8601 format. + * String format. */ format: string; /** - * Default value for attribute when not provided. Only null is optional + * Default value for attribute when not provided. Cannot be set when attribute is required. */ default?: string; } /** - * AttributeRelationship + * AttributeEnum */ - export type AttributeRelationship = { + export type AttributeEnum = { /** * Attribute Key. */ @@ -1167,35 +1082,73 @@ export namespace Models { */ $updatedAt: string; /** - * The ID of the related collection. + * Array of elements in enumerated type. */ - relatedCollection: string; + elements: string[]; /** - * The type of the relationship. + * String format. */ - relationType: string; + format: string; /** - * Is the relationship two-way? + * Default value for attribute when not provided. Cannot be set when attribute is required. */ - twoWay: boolean; + default?: string; + } + + /** + * AttributeFloat + */ + export type AttributeFloat = { /** - * The key of the two-way relationship. + * Attribute Key. */ - twoWayKey: string; + key: string; /** - * How deleting the parent document will propagate to child documents. + * Attribute type. */ - onDelete: string; + type: string; /** - * Whether this is the parent or child side of the relationship + * Attribute status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` */ - side: string; + status: AttributeStatus; + /** + * Error message. Displays error generated on failure of creating or deleting an attribute. + */ + error: string; + /** + * Is attribute required? + */ + required: boolean; + /** + * Is attribute an array? + */ + array?: boolean; + /** + * Attribute creation date in ISO 8601 format. + */ + $createdAt: string; + /** + * Attribute update date in ISO 8601 format. + */ + $updatedAt: string; + /** + * Minimum value to enforce for new documents. + */ + min?: number; + /** + * Maximum value to enforce for new documents. + */ + max?: number; + /** + * Default value for attribute when not provided. Cannot be set when attribute is required. + */ + default?: number; } /** - * AttributePoint + * AttributeInteger */ - export type AttributePoint = { + export type AttributeInteger = { /** * Attribute Key. */ @@ -1228,16 +1181,24 @@ export namespace Models { * Attribute update date in ISO 8601 format. */ $updatedAt: string; + /** + * Minimum value to enforce for new documents. + */ + min?: number | bigint; + /** + * Maximum value to enforce for new documents. + */ + max?: number | bigint; /** * Default value for attribute when not provided. Cannot be set when attribute is required. */ - default?: any[]; + default?: number; } /** - * AttributeLine + * AttributeIP */ - export type AttributeLine = { + export type AttributeIp = { /** * Attribute Key. */ @@ -1270,16 +1231,20 @@ export namespace Models { * Attribute update date in ISO 8601 format. */ $updatedAt: string; + /** + * String format. + */ + format: string; /** * Default value for attribute when not provided. Cannot be set when attribute is required. */ - default?: any[]; + default?: string; } /** - * AttributePolygon + * AttributeLine */ - export type AttributePolygon = { + export type AttributeLine = { /** * Attribute Key. */ @@ -1319,9 +1284,9 @@ export namespace Models { } /** - * AttributeVarchar + * AttributeLongtext */ - export type AttributeVarchar = { + export type AttributeLongtext = { /** * Attribute Key. */ @@ -1354,10 +1319,6 @@ export namespace Models { * Attribute update date in ISO 8601 format. */ $updatedAt: string; - /** - * Attribute size. - */ - size: number; /** * Default value for attribute when not provided. Cannot be set when attribute is required. */ @@ -1369,9 +1330,9 @@ export namespace Models { } /** - * AttributeText + * AttributeMediumtext */ - export type AttributeText = { + export type AttributeMediumtext = { /** * Attribute Key. */ @@ -1415,9 +1376,9 @@ export namespace Models { } /** - * AttributeMediumtext + * AttributePoint */ - export type AttributeMediumtext = { + export type AttributePoint = { /** * Attribute Key. */ @@ -1453,17 +1414,13 @@ export namespace Models { /** * Default value for attribute when not provided. Cannot be set when attribute is required. */ - default?: string; - /** - * Defines whether this attribute is encrypted or not. - */ - encrypt?: boolean; + default?: any[]; } /** - * AttributeLongtext + * AttributePolygon */ - export type AttributeLongtext = { + export type AttributePolygon = { /** * Attribute Key. */ @@ -1499,75 +1456,75 @@ export namespace Models { /** * Default value for attribute when not provided. Cannot be set when attribute is required. */ - default?: string; - /** - * Defines whether this attribute is encrypted or not. - */ - encrypt?: boolean; + default?: any[]; } /** - * VectorsDB Collection + * AttributeRelationship */ - export type VectorsdbCollection = { + export type AttributeRelationship = { /** - * Collection ID. + * Attribute Key. */ - $id: string; + key: string; /** - * Collection creation date in ISO 8601 format. + * Attribute type. */ - $createdAt: string; + type: string; /** - * Collection update date in ISO 8601 format. + * Attribute status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` */ - $updatedAt: string; + status: AttributeStatus; /** - * Collection permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). + * Error message. Displays error generated on failure of creating or deleting an attribute. */ - $permissions: string[]; + error: string; /** - * Database ID. + * Is attribute required? */ - databaseId: string; + required: boolean; /** - * Collection name. + * Is attribute an array? */ - name: string; + array?: boolean; /** - * Collection enabled. Can be 'enabled' or 'disabled'. When disabled, the collection is inaccessible to users, but remains accessible to Server SDKs using API keys. + * Attribute creation date in ISO 8601 format. */ - enabled: boolean; + $createdAt: string; /** - * Whether document-level permissions are enabled. [Learn more about permissions](https://appwrite.io/docs/permissions). + * Attribute update date in ISO 8601 format. */ - documentSecurity: boolean; + $updatedAt: string; /** - * Collection attributes. + * The ID of the related collection. */ - attributes: (Models.AttributeObject | Models.AttributeVector)[]; + relatedCollection: string; /** - * Collection indexes. + * The type of the relationship. */ - indexes: Index[]; + relationType: string; /** - * Maximum document size in bytes. Returns 0 when no limit applies. + * Is the relationship two-way? */ - bytesMax: number; + twoWay: boolean; /** - * Currently used document size in bytes based on defined attributes. + * The key of the two-way relationship. */ - bytesUsed: number; + twoWayKey: string; + /** + * How deleting the parent document will propagate to child documents. + */ + onDelete: string; /** - * Embedding dimension. + * Whether this is the parent or child side of the relationship */ - dimension: number; + side: string; } /** - * AttributeObject + * AttributeString */ - export type AttributeObject = { + export type AttributeString = { /** * Attribute Key. */ @@ -1600,12 +1557,24 @@ export namespace Models { * Attribute update date in ISO 8601 format. */ $updatedAt: string; + /** + * Attribute size. + */ + size: number; + /** + * Default value for attribute when not provided. Cannot be set when attribute is required. + */ + default?: string; + /** + * Defines whether this attribute is encrypted or not. + */ + encrypt?: boolean; } /** - * AttributeVector + * AttributeText */ - export type AttributeVector = { + export type AttributeText = { /** * Attribute Key. */ @@ -1639,1606 +1608,1386 @@ export namespace Models { */ $updatedAt: string; /** - * Vector dimensions. + * Default value for attribute when not provided. Cannot be set when attribute is required. */ - size: number; + default?: string; + /** + * Defines whether this attribute is encrypted or not. + */ + encrypt?: boolean; } /** - * Table + * AttributeURL */ - export type Table = { + export type AttributeUrl = { /** - * Table ID. + * Attribute Key. */ - $id: string; + key: string; /** - * Table creation date in ISO 8601 format. + * Attribute type. */ - $createdAt: string; + type: string; /** - * Table update date in ISO 8601 format. + * Attribute status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` */ - $updatedAt: string; + status: AttributeStatus; /** - * Table permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). + * Error message. Displays error generated on failure of creating or deleting an attribute. */ - $permissions: string[]; + error: string; /** - * Database ID. + * Is attribute required? */ - databaseId: string; + required: boolean; /** - * Table name. + * Is attribute an array? */ - name: string; + array?: boolean; /** - * Table enabled. Can be 'enabled' or 'disabled'. When disabled, the table is inaccessible to users, but remains accessible to Server SDKs using API keys. + * Attribute creation date in ISO 8601 format. */ - enabled: boolean; + $createdAt: string; /** - * Whether row-level permissions are enabled. [Learn more about permissions](https://appwrite.io/docs/permissions). + * Attribute update date in ISO 8601 format. */ - rowSecurity: boolean; + $updatedAt: string; /** - * Table columns. + * String format. */ - columns: (Models.ColumnBoolean | Models.ColumnInteger | Models.ColumnFloat | Models.ColumnEmail | Models.ColumnEnum | Models.ColumnUrl | Models.ColumnIp | Models.ColumnDatetime | Models.ColumnRelationship | Models.ColumnPoint | Models.ColumnLine | Models.ColumnPolygon | Models.ColumnVarchar | Models.ColumnText | Models.ColumnMediumtext | Models.ColumnLongtext | Models.ColumnString)[]; - /** - * Table indexes. - */ - indexes: ColumnIndex[]; - /** - * Maximum row size in bytes. Returns 0 when no limit applies. - */ - bytesMax: number; - /** - * Currently used row size in bytes based on defined columns. - */ - bytesUsed: number; - } - - /** - * Columns List - */ - export type ColumnList = { - /** - * Total number of columns in the given table. - */ - total: number; + format: string; /** - * List of columns. + * Default value for attribute when not provided. Cannot be set when attribute is required. */ - columns: (Models.ColumnBoolean | Models.ColumnInteger | Models.ColumnFloat | Models.ColumnEmail | Models.ColumnEnum | Models.ColumnUrl | Models.ColumnIp | Models.ColumnDatetime | Models.ColumnRelationship | Models.ColumnPoint | Models.ColumnLine | Models.ColumnPolygon | Models.ColumnVarchar | Models.ColumnText | Models.ColumnMediumtext | Models.ColumnLongtext | Models.ColumnString)[]; + default?: string; } /** - * ColumnString + * AttributeVarchar */ - export type ColumnString = { + export type AttributeVarchar = { /** - * Column Key. + * Attribute Key. */ key: string; /** - * Column type. + * Attribute type. */ type: string; /** - * Column status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` + * Attribute status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` */ - status: ColumnStatus; + status: AttributeStatus; /** - * Error message. Displays error generated on failure of creating or deleting an column. + * Error message. Displays error generated on failure of creating or deleting an attribute. */ error: string; /** - * Is column required? + * Is attribute required? */ required: boolean; /** - * Is column an array? + * Is attribute an array? */ array?: boolean; /** - * Column creation date in ISO 8601 format. + * Attribute creation date in ISO 8601 format. */ $createdAt: string; /** - * Column update date in ISO 8601 format. + * Attribute update date in ISO 8601 format. */ $updatedAt: string; /** - * Column size. + * Attribute size. */ size: number; /** - * Default value for column when not provided. Cannot be set when column is required. + * Default value for attribute when not provided. Cannot be set when attribute is required. */ default?: string; /** - * Defines whether this column is encrypted or not. + * Defines whether this attribute is encrypted or not. */ encrypt?: boolean; } /** - * ColumnInteger + * Documents List */ - export type ColumnInteger = { + export type DocumentList = { /** - * Column Key. + * Total number of documents that matched your query. */ - key: string; + total: number; /** - * Column type. + * List of documents. */ - type: string; + documents: Document[]; + } + + /** + * Document + */ + export type Document = { /** - * Column status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` + * Document ID. */ - status: ColumnStatus; + $id: string; /** - * Error message. Displays error generated on failure of creating or deleting an column. + * Document sequence ID. */ - error: string; + $sequence: string; /** - * Is column required? + * Collection ID. */ - required: boolean; + $collectionId: string; /** - * Is column an array? + * Database ID. */ - array?: boolean; + $databaseId: string; /** - * Column creation date in ISO 8601 format. + * Document creation date in ISO 8601 format. */ $createdAt: string; /** - * Column update date in ISO 8601 format. + * Document update date in ISO 8601 format. */ $updatedAt: string; /** - * Minimum value to enforce for new documents. + * Document permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). */ - min?: number | bigint; + $permissions: string[]; + } + + export type DefaultDocument = Document & { + [key: string]: any; + [__default]: true; + }; + + /** + * Indexes List + */ + export type IndexList = { /** - * Maximum value to enforce for new documents. + * Total number of indexes that matched your query. */ - max?: number | bigint; + total: number; /** - * Default value for column when not provided. Cannot be set when column is required. + * List of indexes. */ - default?: number; + indexes: Index[]; } /** - * ColumnFloat + * Index */ - export type ColumnFloat = { - /** - * Column Key. - */ - key: string; + export type Index = { /** - * Column type. + * Index ID. */ - type: string; + $id: string; /** - * Column status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` + * Index creation date in ISO 8601 format. */ - status: ColumnStatus; + $createdAt: string; /** - * Error message. Displays error generated on failure of creating or deleting an column. + * Index update date in ISO 8601 format. */ - error: string; + $updatedAt: string; /** - * Is column required? + * Index key. */ - required: boolean; + key: string; /** - * Is column an array? + * Index type. */ - array?: boolean; + type: string; /** - * Column creation date in ISO 8601 format. + * Index status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` */ - $createdAt: string; + status: IndexStatus; /** - * Column update date in ISO 8601 format. + * Error message. Displays error generated on failure of creating or deleting an index. */ - $updatedAt: string; + error: string; /** - * Minimum value to enforce for new documents. + * Index attributes. */ - min?: number; + attributes: string[]; /** - * Maximum value to enforce for new documents. + * Index attributes length. */ - max?: number; + lengths: number[]; /** - * Default value for column when not provided. Cannot be set when column is required. + * Index orders. */ - default?: number; + orders?: string[]; } /** - * ColumnBoolean + * Functions List */ - export type ColumnBoolean = { + export type FunctionList = { /** - * Column Key. + * Total number of functions that matched your query. */ - key: string; + total: number; /** - * Column type. + * List of functions. */ - type: string; + functions: Function[]; + } + + /** + * Function + */ + export type Function = { /** - * Column status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` + * Function ID. */ - status: ColumnStatus; + $id: string; /** - * Error message. Displays error generated on failure of creating or deleting an column. + * Function creation date in ISO 8601 format. */ - error: string; + $createdAt: string; /** - * Is column required? + * Function update date in ISO 8601 format. */ - required: boolean; + $updatedAt: string; /** - * Is column an array? + * Execution permissions. */ - array?: boolean; + execute: string[]; /** - * Column creation date in ISO 8601 format. + * Function name. */ - $createdAt: string; + name: string; /** - * Column update date in ISO 8601 format. + * Function enabled. */ - $updatedAt: string; + enabled: boolean; /** - * Default value for column when not provided. Cannot be set when column is required. + * Is the function deployed with the latest configuration? This is set to false if you've changed an environment variables, entrypoint, commands, or other settings that needs redeploy to be applied. When the value is false, redeploy the function to update it with the latest configuration. */ - default?: boolean; - } - - /** - * ColumnEmail - */ - export type ColumnEmail = { + live: boolean; /** - * Column Key. + * When disabled, executions will exclude logs and errors, and will be slightly faster. */ - key: string; + logging: boolean; /** - * Column type. + * Function execution and build runtime. */ - type: string; + runtime: string; /** - * Column status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` + * How many days to keep the non-active deployments before they will be automatically deleted. */ - status: ColumnStatus; + deploymentRetention: number; /** - * Error message. Displays error generated on failure of creating or deleting an column. + * Function's active deployment ID. */ - error: string; + deploymentId: string; /** - * Is column required? + * Active deployment creation date in ISO 8601 format. */ - required: boolean; + deploymentCreatedAt: string; /** - * Is column an array? + * Function's latest deployment ID. */ - array?: boolean; + latestDeploymentId: string; /** - * Column creation date in ISO 8601 format. + * Latest deployment creation date in ISO 8601 format. */ - $createdAt: string; + latestDeploymentCreatedAt: string; /** - * Column update date in ISO 8601 format. + * Status of latest deployment. Possible values are "waiting", "processing", "building", "ready", and "failed". */ - $updatedAt: string; + latestDeploymentStatus: string; /** - * String format. + * Allowed permission scopes. */ - format: string; + scopes: string[]; /** - * Default value for column when not provided. Cannot be set when column is required. + * Function variables. */ - default?: string; - } - - /** - * ColumnEnum - */ - export type ColumnEnum = { + vars: Variable[]; /** - * Column Key. + * Function trigger events. */ - key: string; + events: string[]; /** - * Column type. + * Function execution schedule in CRON format. */ - type: string; + schedule: string; /** - * Column status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` + * Function execution timeout in seconds. */ - status: ColumnStatus; + timeout: number; /** - * Error message. Displays error generated on failure of creating or deleting an column. + * The entrypoint file used to execute the deployment. */ - error: string; + entrypoint: string; /** - * Is column required? + * The build command used to build the deployment. */ - required: boolean; + commands: string; /** - * Is column an array? + * Version of Open Runtimes used for the function. */ - array?: boolean; + version: string; /** - * Column creation date in ISO 8601 format. + * Function VCS (Version Control System) installation id. */ - $createdAt: string; + installationId: string; /** - * Column update date in ISO 8601 format. + * VCS (Version Control System) Repository ID */ - $updatedAt: string; + providerRepositoryId: string; /** - * Array of elements in enumerated type. + * VCS (Version Control System) branch name */ - elements: string[]; + providerBranch: string; /** - * String format. + * Path to function in VCS (Version Control System) repository */ - format: string; + providerRootDirectory: string; /** - * Default value for column when not provided. Cannot be set when column is required. + * Is VCS (Version Control System) connection is in silent mode? When in silence mode, no comments will be posted on the repository pull or merge requests */ - default?: string; + providerSilentMode: boolean; + /** + * Machine specification for deployment builds. + */ + buildSpecification: string; + /** + * Machine specification for executions. + */ + runtimeSpecification: string; } /** - * ColumnIP + * Runtimes List */ - export type ColumnIp = { + export type RuntimeList = { /** - * Column Key. + * Total number of runtimes that matched your query. */ - key: string; + total: number; /** - * Column type. + * List of runtimes. */ - type: string; + runtimes: Runtime[]; + } + + /** + * Specifications List + */ + export type SpecificationList = { /** - * Column status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` + * Total number of specifications that matched your query. */ - status: ColumnStatus; + total: number; /** - * Error message. Displays error generated on failure of creating or deleting an column. + * List of specifications. */ - error: string; + specifications: Specification[]; + } + + /** + * Deployments List + */ + export type DeploymentList = { /** - * Is column required? + * Total number of deployments that matched your query. */ - required: boolean; + total: number; /** - * Is column an array? + * List of deployments. */ - array?: boolean; + deployments: Deployment[]; + } + + /** + * Deployment + */ + export type Deployment = { /** - * Column creation date in ISO 8601 format. + * Deployment ID. + */ + $id: string; + /** + * Deployment creation date in ISO 8601 format. */ $createdAt: string; /** - * Column update date in ISO 8601 format. + * Deployment update date in ISO 8601 format. */ $updatedAt: string; /** - * String format. + * Type of deployment. */ - format: string; + type: string; /** - * Default value for column when not provided. Cannot be set when column is required. + * Resource ID. */ - default?: string; - } - - /** - * ColumnURL - */ - export type ColumnUrl = { + resourceId: string; /** - * Column Key. + * Resource type. */ - key: string; + resourceType: string; /** - * Column type. + * The entrypoint file to use to execute the deployment code. */ - type: string; + entrypoint: string; /** - * Column status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` + * The code size in bytes. */ - status: ColumnStatus; + sourceSize: number; /** - * Error message. Displays error generated on failure of creating or deleting an column. + * The build output size in bytes. */ - error: string; + buildSize: number; /** - * Is column required? + * The total size in bytes (source and build output). */ - required: boolean; + totalSize: number; /** - * Is column an array? + * The current build ID. */ - array?: boolean; + buildId: string; /** - * Column creation date in ISO 8601 format. + * Whether the deployment should be automatically activated. */ - $createdAt: string; + activate: boolean; /** - * Column update date in ISO 8601 format. + * Screenshot with light theme preference file ID. */ - $updatedAt: string; + screenshotLight: string; /** - * String format. + * Screenshot with dark theme preference file ID. */ - format: string; + screenshotDark: string; /** - * Default value for column when not provided. Cannot be set when column is required. + * The deployment status. Possible values are "waiting", "processing", "building", "ready", "canceled" and "failed". */ - default?: string; - } - - /** - * ColumnDatetime - */ - export type ColumnDatetime = { + status: DeploymentStatus; /** - * Column Key. + * The build logs. */ - key: string; + buildLogs: string; /** - * Column type. + * The current build time in seconds. */ - type: string; + buildDuration: number; /** - * Column status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` + * The name of the vcs provider repository */ - status: ColumnStatus; + providerRepositoryName: string; /** - * Error message. Displays error generated on failure of creating or deleting an column. + * The name of the vcs provider repository owner */ - error: string; + providerRepositoryOwner: string; /** - * Is column required? + * The url of the vcs provider repository */ - required: boolean; + providerRepositoryUrl: string; /** - * Is column an array? + * The commit hash of the vcs commit */ - array?: boolean; + providerCommitHash: string; /** - * Column creation date in ISO 8601 format. + * The url of vcs commit author */ - $createdAt: string; + providerCommitAuthorUrl: string; /** - * Column update date in ISO 8601 format. + * The name of vcs commit author */ - $updatedAt: string; + providerCommitAuthor: string; /** - * ISO 8601 format. + * The commit message */ - format: string; + providerCommitMessage: string; /** - * Default value for column when not provided. Only null is optional + * The url of the vcs commit */ - default?: string; + providerCommitUrl: string; + /** + * The branch of the vcs repository + */ + providerBranch: string; + /** + * The branch of the vcs repository + */ + providerBranchUrl: string; } /** - * ColumnRelationship + * Executions List */ - export type ColumnRelationship = { + export type ExecutionList = { /** - * Column Key. + * Total number of executions that matched your query. */ - key: string; + total: number; /** - * Column type. + * List of executions. */ - type: string; + executions: Execution[]; + } + + /** + * Execution + */ + export type Execution = { /** - * Column status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` + * Execution ID. */ - status: ColumnStatus; + $id: string; /** - * Error message. Displays error generated on failure of creating or deleting an column. + * Execution creation date in ISO 8601 format. */ - error: string; + $createdAt: string; /** - * Is column required? + * Execution update date in ISO 8601 format. */ - required: boolean; + $updatedAt: string; /** - * Is column an array? + * Execution roles. */ - array?: boolean; + $permissions: string[]; /** - * Column creation date in ISO 8601 format. - */ - $createdAt: string; - /** - * Column update date in ISO 8601 format. + * Function ID. */ - $updatedAt: string; + functionId: string; /** - * The ID of the related table. + * Function's deployment ID used to create the execution. */ - relatedTable: string; + deploymentId: string; /** - * The type of the relationship. + * The trigger that caused the function to execute. Possible values can be: `http`, `schedule`, or `event`. */ - relationType: string; + trigger: ExecutionTrigger; /** - * Is the relationship two-way? + * The status of the function execution. Possible values can be: `waiting`, `processing`, `completed`, `failed`, or `scheduled`. */ - twoWay: boolean; + status: ExecutionStatus; /** - * The key of the two-way relationship. + * HTTP request method type. */ - twoWayKey: string; + requestMethod: string; /** - * How deleting the parent document will propagate to child documents. + * HTTP request path and query. */ - onDelete: string; + requestPath: string; /** - * Whether this is the parent or child side of the relationship + * HTTP request headers as a key-value object. This will return only whitelisted headers. All headers are returned if execution is created as synchronous. */ - side: string; - } - - /** - * ColumnPoint - */ - export type ColumnPoint = { + requestHeaders: Headers[]; /** - * Column Key. + * HTTP response status code. */ - key: string; + responseStatusCode: number; /** - * Column type. + * HTTP response body. This will return empty unless execution is created as synchronous. */ - type: string; + responseBody: string; /** - * Column status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` + * HTTP response headers as a key-value object. This will return only whitelisted headers. All headers are returned if execution is created as synchronous. */ - status: ColumnStatus; + responseHeaders: Headers[]; /** - * Error message. Displays error generated on failure of creating or deleting an column. + * Function logs. Includes the last 4,000 characters. This will return an empty string unless the response is returned using an API key or as part of a webhook payload. */ - error: string; + logs: string; /** - * Is column required? + * Function errors. Includes the last 4,000 characters. This will return an empty string unless the response is returned using an API key or as part of a webhook payload. */ - required: boolean; + errors: string; /** - * Is column an array? + * Resource(function/site) execution duration in seconds. */ - array?: boolean; + duration: number; /** - * Column creation date in ISO 8601 format. + * The scheduled time for execution. If left empty, execution will be queued immediately. */ - $createdAt: string; + scheduledAt?: string; + } + + /** + * Variables List + */ + export type VariableList = { /** - * Column update date in ISO 8601 format. + * Total number of variables that matched your query. */ - $updatedAt: string; + total: number; /** - * Default value for column when not provided. Cannot be set when column is required. + * List of variables. */ - default?: any[]; + variables: Variable[]; } /** - * ColumnLine + * Variable */ - export type ColumnLine = { - /** - * Column Key. - */ - key: string; + export type Variable = { /** - * Column type. + * Variable ID. */ - type: string; + $id: string; /** - * Column status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` + * Variable creation date in ISO 8601 format. */ - status: ColumnStatus; + $createdAt: string; /** - * Error message. Displays error generated on failure of creating or deleting an column. + * Variable creation date in ISO 8601 format. */ - error: string; + $updatedAt: string; /** - * Is column required? + * Variable key. */ - required: boolean; + key: string; /** - * Is column an array? + * Variable value. */ - array?: boolean; + value: string; /** - * Column creation date in ISO 8601 format. + * Variable secret flag. Secret variables can only be updated or deleted, but never read. */ - $createdAt: string; + secret: boolean; /** - * Column update date in ISO 8601 format. + * Service to which the variable belongs. Possible values are "project", "function" */ - $updatedAt: string; + resourceType: string; /** - * Default value for column when not provided. Cannot be set when column is required. + * ID of resource to which the variable belongs. If resourceType is "project", it is empty. If resourceType is "function", it is ID of the function. */ - default?: any[]; + resourceId: string; } /** - * ColumnPolygon + * Health Status */ - export type ColumnPolygon = { - /** - * Column Key. - */ - key: string; - /** - * Column type. - */ - type: string; + export type HealthStatus = { /** - * Column status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` + * Name of the service. */ - status: ColumnStatus; + name: string; /** - * Error message. Displays error generated on failure of creating or deleting an column. + * Duration in milliseconds how long the health check took. */ - error: string; + ping: number; /** - * Is column required? + * Service status. Possible values are: `pass`, `fail` */ - required: boolean; + status: HealthCheckStatus; + } + + /** + * Health Antivirus + */ + export type HealthAntivirus = { /** - * Is column an array? + * Antivirus version. */ - array?: boolean; + version: string; /** - * Column creation date in ISO 8601 format. + * Antivirus status. Possible values are: `disabled`, `offline`, `online` */ - $createdAt: string; + status: HealthAntivirusStatus; + } + + /** + * Status List + */ + export type HealthStatusList = { /** - * Column update date in ISO 8601 format. + * Total number of statuses that matched your query. */ - $updatedAt: string; + total: number; /** - * Default value for column when not provided. Cannot be set when column is required. + * List of statuses. */ - default?: any[]; + statuses: HealthStatus[]; } /** - * ColumnVarchar + * Health Certificate */ - export type ColumnVarchar = { - /** - * Column Key. - */ - key: string; + export type HealthCertificate = { /** - * Column type. + * Certificate name */ - type: string; + name: string; /** - * Column status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` + * Subject SN */ - status: ColumnStatus; + subjectSN: string; /** - * Error message. Displays error generated on failure of creating or deleting an column. + * Issuer organisation */ - error: string; + issuerOrganisation: string; /** - * Is column required? + * Valid from */ - required: boolean; + validFrom: string; /** - * Is column an array? + * Valid to */ - array?: boolean; + validTo: string; /** - * Column creation date in ISO 8601 format. + * Signature type SN */ - $createdAt: string; + signatureTypeSN: string; + } + + /** + * Health Queue + */ + export type HealthQueue = { /** - * Column update date in ISO 8601 format. + * Amount of actions in the queue. */ - $updatedAt: string; + size: number; + } + + /** + * Health Time + */ + export type HealthTime = { /** - * Column size. + * Current unix timestamp on trustful remote server. */ - size: number; + remoteTime: number; /** - * Default value for column when not provided. Cannot be set when column is required. + * Current unix timestamp of local server where Appwrite runs. */ - default?: string; + localTime: number; /** - * Defines whether this column is encrypted or not. + * Difference of unix remote and local timestamps in milliseconds. */ - encrypt?: boolean; + diff: number; } /** - * ColumnText + * Locale */ - export type ColumnText = { + export type Locale = { /** - * Column Key. + * User IP address. */ - key: string; + ip: string; /** - * Column type. + * Country code in [ISO 3166-1](http://en.wikipedia.org/wiki/ISO_3166-1) two-character format */ - type: string; + countryCode: string; /** - * Column status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` + * Country name. This field support localization. */ - status: ColumnStatus; + country: string; /** - * Error message. Displays error generated on failure of creating or deleting an column. + * Continent code. A two character continent code "AF" for Africa, "AN" for Antarctica, "AS" for Asia, "EU" for Europe, "NA" for North America, "OC" for Oceania, and "SA" for South America. */ - error: string; + continentCode: string; /** - * Is column required? + * Continent name. This field support localization. */ - required: boolean; + continent: string; /** - * Is column an array? - */ - array?: boolean; - /** - * Column creation date in ISO 8601 format. + * True if country is part of the European Union. */ - $createdAt: string; + eu: boolean; /** - * Column update date in ISO 8601 format. + * Currency code in [ISO 4217-1](http://en.wikipedia.org/wiki/ISO_4217) three-character format */ - $updatedAt: string; + currency: string; + } + + /** + * Locale codes list + */ + export type LocaleCodeList = { /** - * Default value for column when not provided. Cannot be set when column is required. + * Total number of localeCodes that matched your query. */ - default?: string; + total: number; /** - * Defines whether this column is encrypted or not. + * List of localeCodes. */ - encrypt?: boolean; + localeCodes: LocaleCode[]; } /** - * ColumnMediumtext + * Continents List */ - export type ColumnMediumtext = { + export type ContinentList = { /** - * Column Key. + * Total number of continents that matched your query. */ - key: string; + total: number; /** - * Column type. + * List of continents. */ - type: string; + continents: Continent[]; + } + + /** + * Countries List + */ + export type CountryList = { /** - * Column status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` + * Total number of countries that matched your query. */ - status: ColumnStatus; + total: number; /** - * Error message. Displays error generated on failure of creating or deleting an column. + * List of countries. */ - error: string; + countries: Country[]; + } + + /** + * Phones List + */ + export type PhoneList = { /** - * Is column required? + * Total number of phones that matched your query. */ - required: boolean; + total: number; /** - * Is column an array? + * List of phones. */ - array?: boolean; + phones: Phone[]; + } + + /** + * Currencies List + */ + export type CurrencyList = { /** - * Column creation date in ISO 8601 format. + * Total number of currencies that matched your query. */ - $createdAt: string; + total: number; /** - * Column update date in ISO 8601 format. + * List of currencies. */ - $updatedAt: string; + currencies: Currency[]; + } + + /** + * Languages List + */ + export type LanguageList = { /** - * Default value for column when not provided. Cannot be set when column is required. + * Total number of languages that matched your query. */ - default?: string; + total: number; /** - * Defines whether this column is encrypted or not. + * List of languages. */ - encrypt?: boolean; + languages: Language[]; } /** - * ColumnLongtext + * Message list */ - export type ColumnLongtext = { - /** - * Column Key. - */ - key: string; + export type MessageList = { /** - * Column type. + * Total number of messages that matched your query. */ - type: string; + total: number; /** - * Column status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` + * List of messages. */ - status: ColumnStatus; + messages: Message[]; + } + + /** + * Message + */ + export type Message = { /** - * Error message. Displays error generated on failure of creating or deleting an column. + * Message ID. */ - error: string; + $id: string; /** - * Is column required? + * Message creation time in ISO 8601 format. */ - required: boolean; + $createdAt: string; /** - * Is column an array? + * Message update date in ISO 8601 format. */ - array?: boolean; + $updatedAt: string; /** - * Column creation date in ISO 8601 format. + * Message provider type. */ - $createdAt: string; + providerType: string; /** - * Column update date in ISO 8601 format. + * Topic IDs set as recipients. */ - $updatedAt: string; + topics: string[]; /** - * Default value for column when not provided. Cannot be set when column is required. + * User IDs set as recipients. */ - default?: string; + users: string[]; /** - * Defines whether this column is encrypted or not. + * Target IDs set as recipients. */ - encrypt?: boolean; - } - - /** - * Index - */ - export type Index = { + targets: string[]; /** - * Index ID. + * The scheduled time for message. */ - $id: string; + scheduledAt?: string; /** - * Index creation date in ISO 8601 format. + * The time when the message was delivered. */ - $createdAt: string; + deliveredAt?: string; /** - * Index update date in ISO 8601 format. + * Delivery errors if any. */ - $updatedAt: string; + deliveryErrors?: string[]; /** - * Index key. + * Number of recipients the message was delivered to. */ - key: string; + deliveredTotal: number; /** - * Index type. + * Data of the message. */ - type: string; + data: object; /** - * Index status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` + * Status of delivery. */ - status: IndexStatus; + status: MessageStatus; + } + + /** + * Target list + */ + export type TargetList = { /** - * Error message. Displays error generated on failure of creating or deleting an index. + * Total number of targets that matched your query. */ - error: string; + total: number; /** - * Index attributes. + * List of targets. */ - attributes: string[]; + targets: Target[]; + } + + /** + * Provider list + */ + export type ProviderList = { /** - * Index attributes length. + * Total number of providers that matched your query. */ - lengths: number[]; + total: number; /** - * Index orders. + * List of providers. */ - orders?: string[]; + providers: Provider[]; } /** - * Index + * Provider */ - export type ColumnIndex = { + export type Provider = { /** - * Index ID. + * Provider ID. */ $id: string; /** - * Index creation date in ISO 8601 format. + * Provider creation time in ISO 8601 format. */ $createdAt: string; /** - * Index update date in ISO 8601 format. + * Provider update date in ISO 8601 format. */ $updatedAt: string; /** - * Index Key. + * The name for the provider instance. */ - key: string; + name: string; /** - * Index type. + * The name of the provider service. */ - type: string; + provider: string; /** - * Index status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` + * Is provider enabled? */ - status: string; + enabled: boolean; /** - * Error message. Displays error generated on failure of creating or deleting an index. + * Type of provider. */ - error: string; + type: string; /** - * Index columns. + * Provider credentials. */ - columns: string[]; + credentials: object; /** - * Index columns length. + * Provider options. */ - lengths: number[]; + options?: object; + } + + /** + * Topic list + */ + export type TopicList = { /** - * Index orders. + * Total number of topics that matched your query. */ - orders?: string[]; + total: number; + /** + * List of topics. + */ + topics: Topic[]; } /** - * Row + * Topic */ - export type Row = { + export type Topic = { /** - * Row ID. + * Topic ID. */ $id: string; /** - * Row sequence ID. - */ - $sequence: string; - /** - * Table ID. - */ - $tableId: string; - /** - * Database ID. - */ - $databaseId: string; - /** - * Row creation date in ISO 8601 format. + * Topic creation time in ISO 8601 format. */ $createdAt: string; /** - * Row update date in ISO 8601 format. + * Topic update date in ISO 8601 format. */ $updatedAt: string; /** - * Row permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). - */ - $permissions: string[]; - } - - export type DefaultRow = Row & { - [key: string]: any; - [__default]: true; - }; - - /** - * Document - */ - export type Document = { - /** - * Document ID. - */ - $id: string; - /** - * Document sequence ID. - */ - $sequence: string; - /** - * Collection ID. + * The name of the topic. */ - $collectionId: string; + name: string; /** - * Database ID. + * Total count of email subscribers subscribed to the topic. */ - $databaseId: string; + emailTotal: number; /** - * Document creation date in ISO 8601 format. + * Total count of SMS subscribers subscribed to the topic. */ - $createdAt: string; + smsTotal: number; /** - * Document update date in ISO 8601 format. + * Total count of push subscribers subscribed to the topic. */ - $updatedAt: string; + pushTotal: number; /** - * Document permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). + * Subscribe permissions. */ - $permissions: string[]; + subscribe: string[]; } - export type DefaultDocument = Document & { - [key: string]: any; - [__default]: true; - }; - /** - * Log + * Subscriber list */ - export type Log = { - /** - * Event name. - */ - event: string; - /** - * User ID of the actor recorded for this log. During impersonation, this is the original impersonator, not the impersonated target user. - */ - userId: string; - /** - * User email of the actor recorded for this log. During impersonation, this is the original impersonator. - */ - userEmail: string; - /** - * User name of the actor recorded for this log. During impersonation, this is the original impersonator. - */ - userName: string; - /** - * API mode when event triggered. - */ - mode: string; - /** - * IP session in use when the session was created. - */ - ip: string; - /** - * Log creation date in ISO 8601 format. - */ - time: string; - /** - * Operating system code name. View list of [available options](https://github.com/appwrite/appwrite/blob/master/docs/lists/os.json). - */ - osCode: string; - /** - * Operating system name. - */ - osName: string; - /** - * Operating system version. - */ - osVersion: string; - /** - * Client type. - */ - clientType: string; - /** - * Client code name. View list of [available options](https://github.com/appwrite/appwrite/blob/master/docs/lists/clients.json). - */ - clientCode: string; - /** - * Client name. - */ - clientName: string; - /** - * Client version. - */ - clientVersion: string; - /** - * Client engine name. - */ - clientEngine: string; - /** - * Client engine name. - */ - clientEngineVersion: string; - /** - * Device name. - */ - deviceName: string; - /** - * Device brand name. - */ - deviceBrand: string; - /** - * Device model name. - */ - deviceModel: string; + export type SubscriberList = { /** - * Country two-character ISO 3166-1 alpha code. + * Total number of subscribers that matched your query. */ - countryCode: string; + total: number; /** - * Country name. + * List of subscribers. */ - countryName: string; + subscribers: Subscriber[]; } /** - * User + * Subscriber */ - export type User = { + export type Subscriber = { /** - * User ID. + * Subscriber ID. */ $id: string; /** - * User creation date in ISO 8601 format. + * Subscriber creation time in ISO 8601 format. */ $createdAt: string; /** - * User update date in ISO 8601 format. + * Subscriber update date in ISO 8601 format. */ $updatedAt: string; /** - * User name. - */ - name: string; - /** - * Hashed user password. - */ - password?: string; - /** - * Password hashing algorithm. - */ - hash?: string; - /** - * Password hashing algorithm configuration. - */ - hashOptions?: object; - /** - * User registration date in ISO 8601 format. - */ - registration: string; - /** - * User status. Pass `true` for enabled and `false` for disabled. - */ - status: boolean; - /** - * Labels for the user. - */ - labels: string[]; - /** - * Password update time in ISO 8601 format. - */ - passwordUpdate: string; - /** - * User email address. - */ - email: string; - /** - * User phone number in E.164 format. - */ - phone: string; - /** - * Email verification status. - */ - emailVerification: boolean; - /** - * Phone verification status. - */ - phoneVerification: boolean; - /** - * Multi factor authentication status. - */ - mfa: boolean; - /** - * User preferences as a key-value object - */ - prefs: Preferences; - /** - * A user-owned message receiver. A single user may have multiple e.g. emails, phones, and a browser. Each target is registered with a single provider. - */ - targets: Target[]; - /** - * Most recent access date in ISO 8601 format. This attribute is only updated again after 24 hours. - */ - accessedAt: string; - /** - * Whether the user can impersonate other users. - */ - impersonator?: boolean; - /** - * ID of the original actor performing the impersonation. Present only when the current request is impersonating another user. Internal audit logs attribute the action to this user, while the impersonated target is recorded only in internal audit payload data. - */ - impersonatorUserId?: string; - } - - /** - * AlgoMD5 - */ - export type AlgoMd5 = { - /** - * Algo type. - */ - type: string; - } - - /** - * AlgoSHA - */ - export type AlgoSha = { - /** - * Algo type. - */ - type: string; - } - - /** - * AlgoPHPass - */ - export type AlgoPhpass = { - /** - * Algo type. - */ - type: string; - } - - /** - * AlgoBcrypt - */ - export type AlgoBcrypt = { - /** - * Algo type. - */ - type: string; - } - - /** - * AlgoScrypt - */ - export type AlgoScrypt = { - /** - * Algo type. - */ - type: string; - /** - * CPU complexity of computed hash. - */ - costCpu: number; - /** - * Memory complexity of computed hash. - */ - costMemory: number; - /** - * Parallelization of computed hash. - */ - costParallel: number; - /** - * Length used to compute hash. - */ - length: number; - } - - /** - * AlgoScryptModified - */ - export type AlgoScryptModified = { - /** - * Algo type. - */ - type: string; - /** - * Salt used to compute hash. - */ - salt: string; - /** - * Separator used to compute hash. + * Target ID. */ - saltSeparator: string; + targetId: string; /** - * Key used to compute hash. - */ - signerKey: string; - } - - /** - * AlgoArgon2 - */ - export type AlgoArgon2 = { + * Target. + */ + target: Target; /** - * Algo type. + * Topic ID. */ - type: string; + userId: string; /** - * Memory used to compute hash. + * User Name. */ - memoryCost: number; + userName: string; /** - * Amount of time consumed to compute hash + * Topic ID. */ - timeCost: number; + topicId: string; /** - * Number of threads used to compute hash. + * The target provider type. Can be one of the following: `email`, `sms` or `push`. */ - threads: number; + providerType: string; } /** - * Preferences + * Sites List */ - export type Preferences = { + export type SiteList = { + /** + * Total number of sites that matched your query. + */ + total: number; + /** + * List of sites. + */ + sites: Site[]; } - export type DefaultPreferences = Preferences & { - [key: string]: any; - [__default]: true; - }; - /** - * Session + * Site */ - export type Session = { + export type Site = { /** - * Session ID. + * Site ID. */ $id: string; /** - * Session creation date in ISO 8601 format. + * Site creation date in ISO 8601 format. */ $createdAt: string; /** - * Session update date in ISO 8601 format. + * Site update date in ISO 8601 format. */ $updatedAt: string; /** - * User ID. - */ - userId: string; - /** - * Session expiration date in ISO 8601 format. - */ - expire: string; - /** - * Session Provider. - */ - provider: string; - /** - * Session Provider User ID. + * Site name. */ - providerUid: string; + name: string; /** - * Session Provider Access Token. + * Site enabled. */ - providerAccessToken: string; + enabled: boolean; /** - * The date of when the access token expires in ISO 8601 format. + * Is the site deployed with the latest configuration? This is set to false if you've changed an environment variables, entrypoint, commands, or other settings that needs redeploy to be applied. When the value is false, redeploy the site to update it with the latest configuration. */ - providerAccessTokenExpiry: string; + live: boolean; /** - * Session Provider Refresh Token. + * When disabled, request logs will exclude logs and errors, and site responses will be slightly faster. */ - providerRefreshToken: string; + logging: boolean; /** - * IP in use when the session was created. + * Site framework. */ - ip: string; + framework: string; /** - * Operating system code name. View list of [available options](https://github.com/appwrite/appwrite/blob/master/docs/lists/os.json). + * How many days to keep the non-active deployments before they will be automatically deleted. */ - osCode: string; + deploymentRetention: number; /** - * Operating system name. + * Site's active deployment ID. */ - osName: string; + deploymentId: string; /** - * Operating system version. + * Active deployment creation date in ISO 8601 format. */ - osVersion: string; + deploymentCreatedAt: string; /** - * Client type. + * Screenshot of active deployment with light theme preference file ID. */ - clientType: string; + deploymentScreenshotLight: string; /** - * Client code name. View list of [available options](https://github.com/appwrite/appwrite/blob/master/docs/lists/clients.json). + * Screenshot of active deployment with dark theme preference file ID. */ - clientCode: string; + deploymentScreenshotDark: string; /** - * Client name. + * Site's latest deployment ID. */ - clientName: string; + latestDeploymentId: string; /** - * Client version. + * Latest deployment creation date in ISO 8601 format. */ - clientVersion: string; + latestDeploymentCreatedAt: string; /** - * Client engine name. + * Status of latest deployment. Possible values are "waiting", "processing", "building", "ready", and "failed". */ - clientEngine: string; + latestDeploymentStatus: string; /** - * Client engine name. + * Site variables. */ - clientEngineVersion: string; + vars: Variable[]; /** - * Device name. + * Site request timeout in seconds. */ - deviceName: string; + timeout: number; /** - * Device brand name. + * The install command used to install the site dependencies. */ - deviceBrand: string; + installCommand: string; /** - * Device model name. + * The build command used to build the site. */ - deviceModel: string; + buildCommand: string; /** - * Country two-character ISO 3166-1 alpha code. + * Custom command to use when starting site runtime. */ - countryCode: string; + startCommand: string; /** - * Country name. + * The directory where the site build output is located. */ - countryName: string; + outputDirectory: string; /** - * Returns true if this the current user session. + * Site VCS (Version Control System) installation id. */ - current: boolean; + installationId: string; /** - * Returns a list of active session factors. + * VCS (Version Control System) Repository ID */ - factors: string[]; + providerRepositoryId: string; /** - * Secret used to authenticate the user. Only included if the request was made with an API key + * VCS (Version Control System) branch name */ - secret: string; + providerBranch: string; /** - * Most recent date in ISO 8601 format when the session successfully passed MFA challenge. + * Path to site in VCS (Version Control System) repository */ - mfaUpdatedAt: string; - } - - /** - * Identity - */ - export type Identity = { + providerRootDirectory: string; /** - * Identity ID. + * Is VCS (Version Control System) connection is in silent mode? When in silence mode, no comments will be posted on the repository pull or merge requests */ - $id: string; + providerSilentMode: boolean; /** - * Identity creation date in ISO 8601 format. + * Machine specification for deployment builds. */ - $createdAt: string; + buildSpecification: string; /** - * Identity update date in ISO 8601 format. + * Machine specification for SSR executions. */ - $updatedAt: string; + runtimeSpecification: string; /** - * User ID. + * Site build runtime. */ - userId: string; + buildRuntime: string; /** - * Identity Provider. + * Site framework adapter. */ - provider: string; + adapter: string; /** - * ID of the User in the Identity Provider. + * Name of fallback file to use instead of 404 page. If null, Appwrite 404 page will be displayed. */ - providerUid: string; + fallbackFile: string; + } + + /** + * Frameworks List + */ + export type FrameworkList = { /** - * Email of the User in the Identity Provider. + * Total number of frameworks that matched your query. */ - providerEmail: string; + total: number; /** - * Identity Provider Access Token. + * List of frameworks. */ - providerAccessToken: string; + frameworks: Framework[]; + } + + /** + * Buckets List + */ + export type BucketList = { /** - * The date of when the access token expires in ISO 8601 format. + * Total number of buckets that matched your query. */ - providerAccessTokenExpiry: string; + total: number; /** - * Identity Provider Refresh Token. + * List of buckets. */ - providerRefreshToken: string; + buckets: Bucket[]; } /** - * Token + * Bucket */ - export type Token = { + export type Bucket = { /** - * Token ID. + * Bucket ID. */ $id: string; /** - * Token creation date in ISO 8601 format. + * Bucket creation time in ISO 8601 format. */ $createdAt: string; /** - * User ID. + * Bucket update date in ISO 8601 format. */ - userId: string; + $updatedAt: string; /** - * Token secret key. This will return an empty string unless the response is returned using an API key or as part of a webhook payload. + * Bucket permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). */ - secret: string; + $permissions: string[]; /** - * Token expiration date in ISO 8601 format. + * Whether file-level security is enabled. [Learn more about permissions](https://appwrite.io/docs/permissions). */ - expire: string; + fileSecurity: boolean; /** - * Security phrase of a token. Empty if security phrase was not requested when creating a token. It includes randomly generated phrase which is also sent in the external resource such as email. + * Bucket name. */ - phrase: string; - } - - /** - * JWT - */ - export type Jwt = { + name: string; /** - * JWT encoded string. + * Bucket enabled. */ - jwt: string; - } - - /** - * Locale - */ - export type Locale = { + enabled: boolean; /** - * User IP address. + * Maximum file size supported. */ - ip: string; + maximumFileSize: number; /** - * Country code in [ISO 3166-1](http://en.wikipedia.org/wiki/ISO_3166-1) two-character format + * Allowed file extensions. */ - countryCode: string; + allowedFileExtensions: string[]; /** - * Country name. This field support localization. + * Compression algorithm chosen for compression. Will be one of none, [gzip](https://en.wikipedia.org/wiki/Gzip), or [zstd](https://en.wikipedia.org/wiki/Zstd). */ - country: string; + compression: string; /** - * Continent code. A two character continent code "AF" for Africa, "AN" for Antarctica, "AS" for Asia, "EU" for Europe, "NA" for North America, "OC" for Oceania, and "SA" for South America. + * Bucket is encrypted. */ - continentCode: string; + encryption: boolean; /** - * Continent name. This field support localization. + * Virus scanning is enabled. */ - continent: string; + antivirus: boolean; /** - * True if country is part of the European Union. + * Image transformations are enabled. */ - eu: boolean; + transformations: boolean; /** - * Currency code in [ISO 4217-1](http://en.wikipedia.org/wiki/ISO_4217) three-character format + * Total size of this bucket in bytes. */ - currency: string; + totalSize: number; } /** - * LocaleCode + * Files List */ - export type LocaleCode = { + export type FileList = { /** - * Locale codes in [ISO 639-1](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes) + * Total number of files that matched your query. */ - code: string; + total: number; /** - * Locale name + * List of files. */ - name: string; + files: File[]; } /** @@ -3300,1447 +3049,1482 @@ export namespace Models { } /** - * Bucket + * Tables List */ - export type Bucket = { + export type TableList = { /** - * Bucket ID. + * Total number of tables that matched your query. + */ + total: number; + /** + * List of tables. + */ + tables: Table[]; + } + + /** + * Table + */ + export type Table = { + /** + * Table ID. */ $id: string; /** - * Bucket creation time in ISO 8601 format. + * Table creation date in ISO 8601 format. */ $createdAt: string; /** - * Bucket update date in ISO 8601 format. + * Table update date in ISO 8601 format. */ $updatedAt: string; /** - * Bucket permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). + * Table permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). */ $permissions: string[]; /** - * Whether file-level security is enabled. [Learn more about permissions](https://appwrite.io/docs/permissions). + * Database ID. */ - fileSecurity: boolean; + databaseId: string; /** - * Bucket name. + * Table name. */ name: string; /** - * Bucket enabled. + * Table enabled. Can be 'enabled' or 'disabled'. When disabled, the table is inaccessible to users, but remains accessible to Server SDKs using API keys. */ enabled: boolean; /** - * Maximum file size supported. + * Whether row-level permissions are enabled. [Learn more about permissions](https://appwrite.io/docs/permissions). */ - maximumFileSize: number; + rowSecurity: boolean; /** - * Allowed file extensions. + * Table columns. */ - allowedFileExtensions: string[]; + columns: (Models.ColumnBoolean | Models.ColumnInteger | Models.ColumnFloat | Models.ColumnEmail | Models.ColumnEnum | Models.ColumnUrl | Models.ColumnIp | Models.ColumnDatetime | Models.ColumnRelationship | Models.ColumnPoint | Models.ColumnLine | Models.ColumnPolygon | Models.ColumnVarchar | Models.ColumnText | Models.ColumnMediumtext | Models.ColumnLongtext | Models.ColumnString)[]; /** - * Compression algorithm chosen for compression. Will be one of none, [gzip](https://en.wikipedia.org/wiki/Gzip), or [zstd](https://en.wikipedia.org/wiki/Zstd). + * Table indexes. */ - compression: string; + indexes: ColumnIndex[]; /** - * Bucket is encrypted. + * Maximum row size in bytes. Returns 0 when no limit applies. */ - encryption: boolean; + bytesMax: number; /** - * Virus scanning is enabled. + * Currently used row size in bytes based on defined columns. */ - antivirus: boolean; + bytesUsed: number; + } + + /** + * Columns List + */ + export type ColumnList = { /** - * Image transformations are enabled. + * Total number of columns in the given table. */ - transformations: boolean; + total: number; /** - * Total size of this bucket in bytes. + * List of columns. */ - totalSize: number; + columns: (Models.ColumnBoolean | Models.ColumnInteger | Models.ColumnFloat | Models.ColumnEmail | Models.ColumnEnum | Models.ColumnUrl | Models.ColumnIp | Models.ColumnDatetime | Models.ColumnRelationship | Models.ColumnPoint | Models.ColumnLine | Models.ColumnPolygon | Models.ColumnVarchar | Models.ColumnText | Models.ColumnMediumtext | Models.ColumnLongtext | Models.ColumnString)[]; } /** - * ResourceToken + * ColumnBoolean */ - export type ResourceToken = { + export type ColumnBoolean = { /** - * Token ID. + * Column Key. */ - $id: string; + key: string; /** - * Token creation date in ISO 8601 format. + * Column type. */ - $createdAt: string; + type: string; /** - * Resource ID. + * Column status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` */ - resourceId: string; + status: ColumnStatus; /** - * Resource type. + * Error message. Displays error generated on failure of creating or deleting an column. */ - resourceType: string; + error: string; /** - * Token expiration date in ISO 8601 format. + * Is column required? */ - expire: string; + required: boolean; /** - * JWT encoded string. + * Is column an array? */ - secret: string; + array?: boolean; /** - * Most recent access date in ISO 8601 format. This attribute is only updated again after 24 hours. + * Column creation date in ISO 8601 format. */ - accessedAt: string; + $createdAt: string; + /** + * Column update date in ISO 8601 format. + */ + $updatedAt: string; + /** + * Default value for column when not provided. Cannot be set when column is required. + */ + default?: boolean; } /** - * Team + * ColumnDatetime */ - export type Team = { - /** - * Team ID. - */ - $id: string; + export type ColumnDatetime = { /** - * Team creation date in ISO 8601 format. + * Column Key. */ - $createdAt: string; + key: string; /** - * Team update date in ISO 8601 format. + * Column type. */ - $updatedAt: string; + type: string; /** - * Team name. + * Column status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` */ - name: string; + status: ColumnStatus; /** - * Total number of team members. + * Error message. Displays error generated on failure of creating or deleting an column. */ - total: number; + error: string; /** - * Team preferences as a key-value object + * Is column required? */ - prefs: Preferences; - } - - /** - * Membership - */ - export type Membership = { + required: boolean; /** - * Membership ID. + * Is column an array? */ - $id: string; + array?: boolean; /** - * Membership creation date in ISO 8601 format. + * Column creation date in ISO 8601 format. */ $createdAt: string; /** - * Membership update date in ISO 8601 format. + * Column update date in ISO 8601 format. */ $updatedAt: string; /** - * User ID. + * ISO 8601 format. */ - userId: string; + format: string; /** - * User name. Hide this attribute by toggling membership privacy in the Console. + * Default value for column when not provided. Only null is optional */ - userName: string; + default?: string; + } + + /** + * ColumnEmail + */ + export type ColumnEmail = { /** - * User email address. Hide this attribute by toggling membership privacy in the Console. + * Column Key. */ - userEmail: string; + key: string; /** - * Team ID. + * Column type. */ - teamId: string; + type: string; /** - * Team name. + * Column status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` */ - teamName: string; + status: ColumnStatus; /** - * Date, the user has been invited to join the team in ISO 8601 format. + * Error message. Displays error generated on failure of creating or deleting an column. */ - invited: string; + error: string; /** - * Date, the user has accepted the invitation to join the team in ISO 8601 format. + * Is column required? */ - joined: string; + required: boolean; /** - * User confirmation status, true if the user has joined the team or false otherwise. + * Is column an array? */ - confirm: boolean; + array?: boolean; /** - * Multi factor authentication status, true if the user has MFA enabled or false otherwise. Hide this attribute by toggling membership privacy in the Console. + * Column creation date in ISO 8601 format. */ - mfa: boolean; + $createdAt: string; /** - * User list of roles + * Column update date in ISO 8601 format. */ - roles: string[]; + $updatedAt: string; + /** + * String format. + */ + format: string; + /** + * Default value for column when not provided. Cannot be set when column is required. + */ + default?: string; } /** - * Site + * ColumnEnum */ - export type Site = { + export type ColumnEnum = { /** - * Site ID. + * Column Key. */ - $id: string; + key: string; /** - * Site creation date in ISO 8601 format. + * Column type. */ - $createdAt: string; + type: string; /** - * Site update date in ISO 8601 format. + * Column status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` */ - $updatedAt: string; + status: ColumnStatus; /** - * Site name. + * Error message. Displays error generated on failure of creating or deleting an column. + */ + error: string; + /** + * Is column required? */ - name: string; + required: boolean; /** - * Site enabled. + * Is column an array? */ - enabled: boolean; + array?: boolean; /** - * Is the site deployed with the latest configuration? This is set to false if you've changed an environment variables, entrypoint, commands, or other settings that needs redeploy to be applied. When the value is false, redeploy the site to update it with the latest configuration. + * Column creation date in ISO 8601 format. */ - live: boolean; + $createdAt: string; /** - * When disabled, request logs will exclude logs and errors, and site responses will be slightly faster. + * Column update date in ISO 8601 format. */ - logging: boolean; + $updatedAt: string; /** - * Site framework. + * Array of elements in enumerated type. */ - framework: string; + elements: string[]; /** - * How many days to keep the non-active deployments before they will be automatically deleted. + * String format. */ - deploymentRetention: number; + format: string; /** - * Site's active deployment ID. + * Default value for column when not provided. Cannot be set when column is required. */ - deploymentId: string; + default?: string; + } + + /** + * ColumnFloat + */ + export type ColumnFloat = { /** - * Active deployment creation date in ISO 8601 format. + * Column Key. */ - deploymentCreatedAt: string; + key: string; /** - * Screenshot of active deployment with light theme preference file ID. + * Column type. */ - deploymentScreenshotLight: string; + type: string; /** - * Screenshot of active deployment with dark theme preference file ID. + * Column status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` */ - deploymentScreenshotDark: string; + status: ColumnStatus; /** - * Site's latest deployment ID. + * Error message. Displays error generated on failure of creating or deleting an column. */ - latestDeploymentId: string; + error: string; /** - * Latest deployment creation date in ISO 8601 format. + * Is column required? */ - latestDeploymentCreatedAt: string; + required: boolean; /** - * Status of latest deployment. Possible values are "waiting", "processing", "building", "ready", and "failed". + * Is column an array? */ - latestDeploymentStatus: string; + array?: boolean; /** - * Site variables. + * Column creation date in ISO 8601 format. */ - vars: Variable[]; + $createdAt: string; /** - * Site request timeout in seconds. + * Column update date in ISO 8601 format. */ - timeout: number; + $updatedAt: string; /** - * The install command used to install the site dependencies. + * Minimum value to enforce for new documents. */ - installCommand: string; + min?: number; /** - * The build command used to build the site. + * Maximum value to enforce for new documents. */ - buildCommand: string; + max?: number; /** - * Custom command to use when starting site runtime. + * Default value for column when not provided. Cannot be set when column is required. */ - startCommand: string; + default?: number; + } + + /** + * ColumnInteger + */ + export type ColumnInteger = { /** - * The directory where the site build output is located. + * Column Key. */ - outputDirectory: string; + key: string; /** - * Site VCS (Version Control System) installation id. + * Column type. */ - installationId: string; + type: string; /** - * VCS (Version Control System) Repository ID + * Column status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` */ - providerRepositoryId: string; + status: ColumnStatus; /** - * VCS (Version Control System) branch name + * Error message. Displays error generated on failure of creating or deleting an column. */ - providerBranch: string; + error: string; /** - * Path to site in VCS (Version Control System) repository + * Is column required? */ - providerRootDirectory: string; + required: boolean; /** - * Is VCS (Version Control System) connection is in silent mode? When in silence mode, no comments will be posted on the repository pull or merge requests + * Is column an array? */ - providerSilentMode: boolean; + array?: boolean; /** - * Machine specification for deployment builds. + * Column creation date in ISO 8601 format. */ - buildSpecification: string; + $createdAt: string; /** - * Machine specification for SSR executions. + * Column update date in ISO 8601 format. */ - runtimeSpecification: string; + $updatedAt: string; /** - * Site build runtime. + * Minimum value to enforce for new documents. */ - buildRuntime: string; + min?: number | bigint; /** - * Site framework adapter. + * Maximum value to enforce for new documents. */ - adapter: string; + max?: number | bigint; /** - * Name of fallback file to use instead of 404 page. If null, Appwrite 404 page will be displayed. + * Default value for column when not provided. Cannot be set when column is required. */ - fallbackFile: string; + default?: number; } /** - * Function + * ColumnIP */ - export type Function = { - /** - * Function ID. - */ - $id: string; + export type ColumnIp = { /** - * Function creation date in ISO 8601 format. + * Column Key. */ - $createdAt: string; + key: string; /** - * Function update date in ISO 8601 format. + * Column type. */ - $updatedAt: string; + type: string; /** - * Execution permissions. + * Column status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` */ - execute: string[]; + status: ColumnStatus; /** - * Function name. + * Error message. Displays error generated on failure of creating or deleting an column. */ - name: string; + error: string; /** - * Function enabled. + * Is column required? */ - enabled: boolean; + required: boolean; /** - * Is the function deployed with the latest configuration? This is set to false if you've changed an environment variables, entrypoint, commands, or other settings that needs redeploy to be applied. When the value is false, redeploy the function to update it with the latest configuration. + * Is column an array? */ - live: boolean; + array?: boolean; /** - * When disabled, executions will exclude logs and errors, and will be slightly faster. + * Column creation date in ISO 8601 format. */ - logging: boolean; + $createdAt: string; /** - * Function execution and build runtime. + * Column update date in ISO 8601 format. */ - runtime: string; + $updatedAt: string; /** - * How many days to keep the non-active deployments before they will be automatically deleted. + * String format. */ - deploymentRetention: number; + format: string; /** - * Function's active deployment ID. + * Default value for column when not provided. Cannot be set when column is required. */ - deploymentId: string; + default?: string; + } + + /** + * ColumnLine + */ + export type ColumnLine = { /** - * Active deployment creation date in ISO 8601 format. + * Column Key. */ - deploymentCreatedAt: string; + key: string; /** - * Function's latest deployment ID. + * Column type. */ - latestDeploymentId: string; + type: string; /** - * Latest deployment creation date in ISO 8601 format. + * Column status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` */ - latestDeploymentCreatedAt: string; + status: ColumnStatus; /** - * Status of latest deployment. Possible values are "waiting", "processing", "building", "ready", and "failed". + * Error message. Displays error generated on failure of creating or deleting an column. */ - latestDeploymentStatus: string; + error: string; /** - * Allowed permission scopes. + * Is column required? */ - scopes: string[]; + required: boolean; /** - * Function variables. + * Is column an array? */ - vars: Variable[]; + array?: boolean; /** - * Function trigger events. + * Column creation date in ISO 8601 format. */ - events: string[]; + $createdAt: string; /** - * Function execution schedule in CRON format. + * Column update date in ISO 8601 format. */ - schedule: string; + $updatedAt: string; /** - * Function execution timeout in seconds. + * Default value for column when not provided. Cannot be set when column is required. */ - timeout: number; + default?: any[]; + } + + /** + * ColumnLongtext + */ + export type ColumnLongtext = { /** - * The entrypoint file used to execute the deployment. + * Column Key. */ - entrypoint: string; + key: string; /** - * The build command used to build the deployment. + * Column type. */ - commands: string; + type: string; /** - * Version of Open Runtimes used for the function. + * Column status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` */ - version: string; + status: ColumnStatus; /** - * Function VCS (Version Control System) installation id. + * Error message. Displays error generated on failure of creating or deleting an column. */ - installationId: string; + error: string; /** - * VCS (Version Control System) Repository ID + * Is column required? */ - providerRepositoryId: string; + required: boolean; /** - * VCS (Version Control System) branch name + * Is column an array? */ - providerBranch: string; + array?: boolean; /** - * Path to function in VCS (Version Control System) repository + * Column creation date in ISO 8601 format. */ - providerRootDirectory: string; + $createdAt: string; /** - * Is VCS (Version Control System) connection is in silent mode? When in silence mode, no comments will be posted on the repository pull or merge requests + * Column update date in ISO 8601 format. */ - providerSilentMode: boolean; + $updatedAt: string; /** - * Machine specification for deployment builds. + * Default value for column when not provided. Cannot be set when column is required. */ - buildSpecification: string; + default?: string; /** - * Machine specification for executions. + * Defines whether this column is encrypted or not. */ - runtimeSpecification: string; + encrypt?: boolean; } /** - * Runtime + * ColumnMediumtext */ - export type Runtime = { - /** - * Runtime ID. - */ - $id: string; + export type ColumnMediumtext = { /** - * Parent runtime key. + * Column Key. */ key: string; /** - * Runtime Name. - */ - name: string; - /** - * Runtime version. - */ - version: string; - /** - * Base Docker image used to build the runtime. + * Column type. */ - base: string; + type: string; /** - * Image name of Docker Hub. + * Column status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` */ - image: string; + status: ColumnStatus; /** - * Name of the logo image. + * Error message. Displays error generated on failure of creating or deleting an column. */ - logo: string; + error: string; /** - * List of supported architectures. + * Is column required? */ - supports: string[]; - } - - /** - * Framework - */ - export type Framework = { + required: boolean; /** - * Framework key. + * Is column an array? */ - key: string; + array?: boolean; /** - * Framework Name. + * Column creation date in ISO 8601 format. */ - name: string; + $createdAt: string; /** - * Default runtime version. + * Column update date in ISO 8601 format. */ - buildRuntime: string; + $updatedAt: string; /** - * List of supported runtime versions. + * Default value for column when not provided. Cannot be set when column is required. */ - runtimes: string[]; + default?: string; /** - * List of supported adapters. + * Defines whether this column is encrypted or not. */ - adapters: FrameworkAdapter[]; + encrypt?: boolean; } /** - * Framework Adapter + * ColumnPoint */ - export type FrameworkAdapter = { + export type ColumnPoint = { /** - * Adapter key. + * Column Key. */ key: string; /** - * Default command to download dependencies. + * Column type. */ - installCommand: string; + type: string; /** - * Default command to build site into output directory. + * Column status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` */ - buildCommand: string; + status: ColumnStatus; /** - * Default output directory of build. + * Error message. Displays error generated on failure of creating or deleting an column. */ - outputDirectory: string; + error: string; /** - * Name of fallback file to use instead of 404 page. If null, Appwrite 404 page will be displayed. + * Is column required? */ - fallbackFile: string; - } - - /** - * Deployment - */ - export type Deployment = { + required: boolean; /** - * Deployment ID. + * Is column an array? */ - $id: string; + array?: boolean; /** - * Deployment creation date in ISO 8601 format. + * Column creation date in ISO 8601 format. */ $createdAt: string; /** - * Deployment update date in ISO 8601 format. + * Column update date in ISO 8601 format. */ $updatedAt: string; /** - * Type of deployment. + * Default value for column when not provided. Cannot be set when column is required. */ - type: string; + default?: any[]; + } + + /** + * ColumnPolygon + */ + export type ColumnPolygon = { /** - * Resource ID. + * Column Key. */ - resourceId: string; + key: string; /** - * Resource type. + * Column type. */ - resourceType: string; + type: string; /** - * The entrypoint file to use to execute the deployment code. + * Column status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` */ - entrypoint: string; + status: ColumnStatus; /** - * The code size in bytes. + * Error message. Displays error generated on failure of creating or deleting an column. */ - sourceSize: number; + error: string; /** - * The build output size in bytes. + * Is column required? */ - buildSize: number; + required: boolean; /** - * The total size in bytes (source and build output). + * Is column an array? */ - totalSize: number; + array?: boolean; /** - * The current build ID. + * Column creation date in ISO 8601 format. */ - buildId: string; + $createdAt: string; /** - * Whether the deployment should be automatically activated. + * Column update date in ISO 8601 format. */ - activate: boolean; + $updatedAt: string; /** - * Screenshot with light theme preference file ID. + * Default value for column when not provided. Cannot be set when column is required. */ - screenshotLight: string; + default?: any[]; + } + + /** + * ColumnRelationship + */ + export type ColumnRelationship = { /** - * Screenshot with dark theme preference file ID. + * Column Key. */ - screenshotDark: string; + key: string; /** - * The deployment status. Possible values are "waiting", "processing", "building", "ready", "canceled" and "failed". + * Column type. */ - status: DeploymentStatus; + type: string; /** - * The build logs. + * Column status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` */ - buildLogs: string; + status: ColumnStatus; /** - * The current build time in seconds. + * Error message. Displays error generated on failure of creating or deleting an column. */ - buildDuration: number; + error: string; /** - * The name of the vcs provider repository + * Is column required? */ - providerRepositoryName: string; + required: boolean; /** - * The name of the vcs provider repository owner + * Is column an array? */ - providerRepositoryOwner: string; + array?: boolean; /** - * The url of the vcs provider repository + * Column creation date in ISO 8601 format. */ - providerRepositoryUrl: string; + $createdAt: string; /** - * The commit hash of the vcs commit + * Column update date in ISO 8601 format. */ - providerCommitHash: string; + $updatedAt: string; /** - * The url of vcs commit author + * The ID of the related table. */ - providerCommitAuthorUrl: string; + relatedTable: string; /** - * The name of vcs commit author + * The type of the relationship. */ - providerCommitAuthor: string; + relationType: string; /** - * The commit message + * Is the relationship two-way? */ - providerCommitMessage: string; + twoWay: boolean; /** - * The url of the vcs commit + * The key of the two-way relationship. */ - providerCommitUrl: string; + twoWayKey: string; /** - * The branch of the vcs repository + * How deleting the parent document will propagate to child documents. */ - providerBranch: string; + onDelete: string; /** - * The branch of the vcs repository + * Whether this is the parent or child side of the relationship */ - providerBranchUrl: string; + side: string; } /** - * Execution + * ColumnString */ - export type Execution = { + export type ColumnString = { /** - * Execution ID. + * Column Key. */ - $id: string; + key: string; /** - * Execution creation date in ISO 8601 format. + * Column type. */ - $createdAt: string; + type: string; /** - * Execution update date in ISO 8601 format. + * Column status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` */ - $updatedAt: string; + status: ColumnStatus; /** - * Execution roles. + * Error message. Displays error generated on failure of creating or deleting an column. */ - $permissions: string[]; + error: string; /** - * Function ID. + * Is column required? */ - functionId: string; + required: boolean; /** - * Function's deployment ID used to create the execution. + * Is column an array? */ - deploymentId: string; + array?: boolean; /** - * The trigger that caused the function to execute. Possible values can be: `http`, `schedule`, or `event`. + * Column creation date in ISO 8601 format. */ - trigger: ExecutionTrigger; + $createdAt: string; /** - * The status of the function execution. Possible values can be: `waiting`, `processing`, `completed`, `failed`, or `scheduled`. + * Column update date in ISO 8601 format. + */ + $updatedAt: string; + /** + * Column size. + */ + size: number; + /** + * Default value for column when not provided. Cannot be set when column is required. + */ + default?: string; + /** + * Defines whether this column is encrypted or not. */ - status: ExecutionStatus; + encrypt?: boolean; + } + + /** + * ColumnText + */ + export type ColumnText = { /** - * HTTP request method type. + * Column Key. */ - requestMethod: string; + key: string; /** - * HTTP request path and query. + * Column type. */ - requestPath: string; + type: string; /** - * HTTP request headers as a key-value object. This will return only whitelisted headers. All headers are returned if execution is created as synchronous. + * Column status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` */ - requestHeaders: Headers[]; + status: ColumnStatus; /** - * HTTP response status code. + * Error message. Displays error generated on failure of creating or deleting an column. */ - responseStatusCode: number; + error: string; /** - * HTTP response body. This will return empty unless execution is created as synchronous. + * Is column required? */ - responseBody: string; + required: boolean; /** - * HTTP response headers as a key-value object. This will return only whitelisted headers. All headers are returned if execution is created as synchronous. + * Is column an array? */ - responseHeaders: Headers[]; + array?: boolean; /** - * Function logs. Includes the last 4,000 characters. This will return an empty string unless the response is returned using an API key or as part of a webhook payload. + * Column creation date in ISO 8601 format. */ - logs: string; + $createdAt: string; /** - * Function errors. Includes the last 4,000 characters. This will return an empty string unless the response is returned using an API key or as part of a webhook payload. + * Column update date in ISO 8601 format. */ - errors: string; + $updatedAt: string; /** - * Resource(function/site) execution duration in seconds. + * Default value for column when not provided. Cannot be set when column is required. */ - duration: number; + default?: string; /** - * The scheduled time for execution. If left empty, execution will be queued immediately. + * Defines whether this column is encrypted or not. */ - scheduledAt?: string; + encrypt?: boolean; } /** - * Webhook + * ColumnURL */ - export type Webhook = { - /** - * Webhook ID. - */ - $id: string; - /** - * Webhook creation date in ISO 8601 format. - */ - $createdAt: string; - /** - * Webhook update date in ISO 8601 format. - */ - $updatedAt: string; + export type ColumnUrl = { /** - * Webhook name. + * Column Key. */ - name: string; + key: string; /** - * Webhook URL endpoint. + * Column type. */ - url: string; + type: string; /** - * Webhook trigger events. + * Column status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` */ - events: string[]; + status: ColumnStatus; /** - * Indicated if SSL / TLS Certificate verification is enabled. + * Error message. Displays error generated on failure of creating or deleting an column. */ - security: boolean; + error: string; /** - * HTTP basic authentication username. + * Is column required? */ - httpUser: string; + required: boolean; /** - * HTTP basic authentication password. + * Is column an array? */ - httpPass: string; + array?: boolean; /** - * Signature key which can be used to validated incoming + * Column creation date in ISO 8601 format. */ - signatureKey: string; + $createdAt: string; /** - * Indicates if this webhook is enabled. + * Column update date in ISO 8601 format. */ - enabled: boolean; + $updatedAt: string; /** - * Webhook error logs from the most recent failure. + * String format. */ - logs: string; + format: string; /** - * Number of consecutive failed webhook attempts. + * Default value for column when not provided. Cannot be set when column is required. */ - attempts: number; + default?: string; } /** - * Variable + * ColumnVarchar */ - export type Variable = { + export type ColumnVarchar = { /** - * Variable ID. + * Column Key. */ - $id: string; + key: string; /** - * Variable creation date in ISO 8601 format. + * Column type. */ - $createdAt: string; + type: string; /** - * Variable creation date in ISO 8601 format. + * Column status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` */ - $updatedAt: string; + status: ColumnStatus; /** - * Variable key. + * Error message. Displays error generated on failure of creating or deleting an column. */ - key: string; + error: string; /** - * Variable value. + * Is column required? */ - value: string; + required: boolean; /** - * Variable secret flag. Secret variables can only be updated or deleted, but never read. + * Is column an array? */ - secret: boolean; + array?: boolean; /** - * Service to which the variable belongs. Possible values are "project", "function" + * Column creation date in ISO 8601 format. */ - resourceType: string; + $createdAt: string; /** - * ID of resource to which the variable belongs. If resourceType is "project", it is empty. If resourceType is "function", it is ID of the function. + * Column update date in ISO 8601 format. */ - resourceId: string; - } - - /** - * Country - */ - export type Country = { + $updatedAt: string; /** - * Country name. + * Column size. */ - name: string; + size: number; /** - * Country two-character ISO 3166-1 alpha code. + * Default value for column when not provided. Cannot be set when column is required. */ - code: string; + default?: string; + /** + * Defines whether this column is encrypted or not. + */ + encrypt?: boolean; } /** - * Continent + * Column Indexes List */ - export type Continent = { + export type ColumnIndexList = { /** - * Continent name. + * Total number of indexes that matched your query. */ - name: string; + total: number; /** - * Continent two letter code. + * List of indexes. */ - code: string; + indexes: ColumnIndex[]; } /** - * Language + * Index */ - export type Language = { + export type ColumnIndex = { /** - * Language name. + * Index ID. */ - name: string; + $id: string; /** - * Language two-character ISO 639-1 codes. + * Index creation date in ISO 8601 format. */ - code: string; + $createdAt: string; /** - * Language native name. + * Index update date in ISO 8601 format. */ - nativeName: string; - } - - /** - * Currency - */ - export type Currency = { + $updatedAt: string; /** - * Currency symbol. + * Index Key. */ - symbol: string; + key: string; /** - * Currency name. + * Index type. */ - name: string; + type: string; /** - * Currency native symbol. + * Index status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` */ - symbolNative: string; + status: string; /** - * Number of decimal digits. + * Error message. Displays error generated on failure of creating or deleting an index. */ - decimalDigits: number; + error: string; /** - * Currency digit rounding. + * Index columns. */ - rounding: number; + columns: string[]; /** - * Currency code in [ISO 4217-1](http://en.wikipedia.org/wiki/ISO_4217) three-character format. + * Index columns length. */ - code: string; + lengths: number[]; /** - * Currency plural name + * Index orders. */ - namePlural: string; + orders?: string[]; } /** - * Phone + * Rows List */ - export type Phone = { - /** - * Phone code. - */ - code: string; + export type RowList = { /** - * Country two-character ISO 3166-1 alpha code. + * Total number of rows that matched your query. */ - countryCode: string; + total: number; /** - * Country name. + * List of rows. */ - countryName: string; + rows: Row[]; } /** - * Health Antivirus + * Row */ - export type HealthAntivirus = { + export type Row = { + /** + * Row ID. + */ + $id: string; + /** + * Row sequence ID. + */ + $sequence: string; + /** + * Table ID. + */ + $tableId: string; + /** + * Database ID. + */ + $databaseId: string; /** - * Antivirus version. + * Row creation date in ISO 8601 format. */ - version: string; + $createdAt: string; /** - * Antivirus status. Possible values are: `disabled`, `offline`, `online` + * Row update date in ISO 8601 format. */ - status: HealthAntivirusStatus; - } - - /** - * Health Queue - */ - export type HealthQueue = { + $updatedAt: string; /** - * Amount of actions in the queue. + * Row permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). */ - size: number; + $permissions: string[]; } + export type DefaultRow = Row & { + [key: string]: any; + [__default]: true; + }; + /** - * Health Status + * Teams List */ - export type HealthStatus = { - /** - * Name of the service. - */ - name: string; + export type TeamList = { /** - * Duration in milliseconds how long the health check took. + * Total number of teams that matched your query. */ - ping: number; + total: number; /** - * Service status. Possible values are: `pass`, `fail` + * List of teams. */ - status: HealthCheckStatus; + teams: Team[]; } /** - * Health Certificate + * Team */ - export type HealthCertificate = { + export type Team = { /** - * Certificate name + * Team ID. */ - name: string; + $id: string; /** - * Subject SN + * Team creation date in ISO 8601 format. */ - subjectSN: string; + $createdAt: string; /** - * Issuer organisation + * Team update date in ISO 8601 format. */ - issuerOrganisation: string; + $updatedAt: string; /** - * Valid from + * Team name. */ - validFrom: string; + name: string; /** - * Valid to + * Total number of team members. */ - validTo: string; + total: number; /** - * Signature type SN + * Team preferences as a key-value object */ - signatureTypeSN: string; + prefs: Preferences; } /** - * Health Time + * Memberships List */ - export type HealthTime = { - /** - * Current unix timestamp on trustful remote server. - */ - remoteTime: number; + export type MembershipList = { /** - * Current unix timestamp of local server where Appwrite runs. + * Total number of memberships that matched your query. */ - localTime: number; + total: number; /** - * Difference of unix remote and local timestamps in milliseconds. + * List of memberships. */ - diff: number; + memberships: Membership[]; } /** - * Headers + * Membership */ - export type Headers = { + export type Membership = { /** - * Header name. + * Membership ID. */ - name: string; + $id: string; /** - * Header value. + * Membership creation date in ISO 8601 format. */ - value: string; - } - - /** - * Specification - */ - export type Specification = { + $createdAt: string; /** - * Memory size in MB. + * Membership update date in ISO 8601 format. */ - memory: number; + $updatedAt: string; /** - * Number of CPUs. + * User ID. */ - cpus: number; + userId: string; /** - * Is size enabled. + * User name. Hide this attribute by toggling membership privacy in the Console. */ - enabled: boolean; + userName: string; /** - * Size slug. + * User email address. Hide this attribute by toggling membership privacy in the Console. */ - slug: string; - } - - /** - * MFA Challenge - */ - export type MfaChallenge = { + userEmail: string; /** - * Token ID. + * Team ID. */ - $id: string; + teamId: string; /** - * Token creation date in ISO 8601 format. + * Team name. */ - $createdAt: string; + teamName: string; /** - * User ID. + * Date, the user has been invited to join the team in ISO 8601 format. */ - userId: string; + invited: string; /** - * Token expiration date in ISO 8601 format. + * Date, the user has accepted the invitation to join the team in ISO 8601 format. */ - expire: string; - } - - /** - * MFA Recovery Codes - */ - export type MfaRecoveryCodes = { + joined: string; /** - * Recovery codes. + * User confirmation status, true if the user has joined the team or false otherwise. */ - recoveryCodes: string[]; - } - - /** - * MFAType - */ - export type MfaType = { + confirm: boolean; /** - * Secret token used for TOTP factor. + * Multi factor authentication status, true if the user has MFA enabled or false otherwise. Hide this attribute by toggling membership privacy in the Console. */ - secret: string; + mfa: boolean; /** - * URI for authenticator apps. + * User list of roles */ - uri: string; + roles: string[]; } /** - * MFAFactors + * Resource Tokens List */ - export type MfaFactors = { - /** - * Can TOTP be used for MFA challenge for this account. - */ - totp: boolean; - /** - * Can phone (SMS) be used for MFA challenge for this account. - */ - phone: boolean; + export type ResourceTokenList = { /** - * Can email be used for MFA challenge for this account. + * Total number of tokens that matched your query. */ - email: boolean; + total: number; /** - * Can recovery code be used for MFA challenge for this account. + * List of tokens. */ - recoveryCode: boolean; + tokens: ResourceToken[]; } /** - * Provider + * ResourceToken */ - export type Provider = { + export type ResourceToken = { /** - * Provider ID. + * Token ID. */ $id: string; /** - * Provider creation time in ISO 8601 format. + * Token creation date in ISO 8601 format. */ $createdAt: string; /** - * Provider update date in ISO 8601 format. + * Resource ID. */ - $updatedAt: string; + resourceId: string; /** - * The name for the provider instance. + * Resource type. */ - name: string; + resourceType: string; /** - * The name of the provider service. + * Token expiration date in ISO 8601 format. */ - provider: string; + expire: string; /** - * Is provider enabled? + * JWT encoded string. */ - enabled: boolean; + secret: string; /** - * Type of provider. + * Most recent access date in ISO 8601 format. This attribute is only updated again after 24 hours. */ - type: string; + accessedAt: string; + } + + /** + * Users List + */ + export type UserList = { /** - * Provider credentials. + * Total number of users that matched your query. */ - credentials: object; + total: number; /** - * Provider options. + * List of users. */ - options?: object; + users: User[]; } /** - * Message + * Target */ - export type Message = { + export type Target = { /** - * Message ID. + * Target ID. */ $id: string; /** - * Message creation time in ISO 8601 format. + * Target creation time in ISO 8601 format. */ $createdAt: string; /** - * Message update date in ISO 8601 format. + * Target update date in ISO 8601 format. */ $updatedAt: string; /** - * Message provider type. - */ - providerType: string; - /** - * Topic IDs set as recipients. - */ - topics: string[]; - /** - * User IDs set as recipients. + * Target Name. */ - users: string[]; + name: string; /** - * Target IDs set as recipients. + * User ID. */ - targets: string[]; + userId: string; /** - * The scheduled time for message. + * Provider ID. */ - scheduledAt?: string; + providerId?: string; /** - * The time when the message was delivered. + * The target provider type. Can be one of the following: `email`, `sms` or `push`. */ - deliveredAt?: string; + providerType: string; /** - * Delivery errors if any. + * The target identifier. */ - deliveryErrors?: string[]; + identifier: string; /** - * Number of recipients the message was delivered to. + * Is the target expired. */ - deliveredTotal: number; + expired: boolean; + } + + /** + * Webhooks List + */ + export type WebhookList = { /** - * Data of the message. + * Total number of webhooks that matched your query. */ - data: object; + total: number; /** - * Status of delivery. + * List of webhooks. */ - status: MessageStatus; + webhooks: Webhook[]; } /** - * Topic + * Webhook */ - export type Topic = { + export type Webhook = { /** - * Topic ID. + * Webhook ID. */ $id: string; /** - * Topic creation time in ISO 8601 format. + * Webhook creation date in ISO 8601 format. */ $createdAt: string; /** - * Topic update date in ISO 8601 format. + * Webhook update date in ISO 8601 format. */ $updatedAt: string; /** - * The name of the topic. + * Webhook name. */ name: string; /** - * Total count of email subscribers subscribed to the topic. - */ - emailTotal: number; - /** - * Total count of SMS subscribers subscribed to the topic. + * Webhook URL endpoint. */ - smsTotal: number; + url: string; /** - * Total count of push subscribers subscribed to the topic. + * Webhook trigger events. */ - pushTotal: number; + events: string[]; /** - * Subscribe permissions. + * Indicated if SSL / TLS Certificate verification is enabled. */ - subscribe: string[]; - } - - /** - * Transaction - */ - export type Transaction = { + security: boolean; /** - * Transaction ID. + * HTTP basic authentication username. */ - $id: string; + httpUser: string; /** - * Transaction creation time in ISO 8601 format. + * HTTP basic authentication password. */ - $createdAt: string; + httpPass: string; /** - * Transaction update date in ISO 8601 format. + * Signature key which can be used to validated incoming */ - $updatedAt: string; + signatureKey: string; /** - * Current status of the transaction. One of: pending, committing, committed, rolled_back, failed. + * Indicates if this webhook is enabled. */ - status: string; + enabled: boolean; /** - * Number of operations in the transaction. + * Webhook error logs from the most recent failure. */ - operations: number; + logs: string; /** - * Expiration time in ISO 8601 format. + * Number of consecutive failed webhook attempts. */ - expiresAt: string; + attempts: number; } /** - * Subscriber + * AlgoArgon2 */ - export type Subscriber = { + export type AlgoArgon2 = { /** - * Subscriber ID. + * Algo type. */ - $id: string; + type: string; /** - * Subscriber creation time in ISO 8601 format. + * Memory used to compute hash. */ - $createdAt: string; + memoryCost: number; /** - * Subscriber update date in ISO 8601 format. + * Amount of time consumed to compute hash */ - $updatedAt: string; + timeCost: number; /** - * Target ID. + * Number of threads used to compute hash. */ - targetId: string; + threads: number; + } + + /** + * AlgoScrypt + */ + export type AlgoScrypt = { /** - * Target. + * Algo type. */ - target: Target; + type: string; /** - * Topic ID. + * CPU complexity of computed hash. */ - userId: string; + costCpu: number; /** - * User Name. + * Memory complexity of computed hash. */ - userName: string; + costMemory: number; /** - * Topic ID. + * Parallelization of computed hash. */ - topicId: string; + costParallel: number; /** - * The target provider type. Can be one of the following: `email`, `sms` or `push`. + * Length used to compute hash. */ - providerType: string; + length: number; } /** - * Target + * AlgoScryptModified */ - export type Target = { - /** - * Target ID. - */ - $id: string; + export type AlgoScryptModified = { /** - * Target creation time in ISO 8601 format. + * Algo type. */ - $createdAt: string; + type: string; /** - * Target update date in ISO 8601 format. + * Salt used to compute hash. */ - $updatedAt: string; + salt: string; /** - * Target Name. + * Separator used to compute hash. */ - name: string; + saltSeparator: string; /** - * User ID. + * Key used to compute hash. */ - userId: string; + signerKey: string; + } + + /** + * AlgoBcrypt + */ + export type AlgoBcrypt = { /** - * Provider ID. + * Algo type. */ - providerId?: string; + type: string; + } + + /** + * AlgoPHPass + */ + export type AlgoPhpass = { /** - * The target provider type. Can be one of the following: `email`, `sms` or `push`. + * Algo type. */ - providerType: string; + type: string; + } + + /** + * AlgoSHA + */ + export type AlgoSha = { /** - * The target identifier. + * Algo type. */ - identifier: string; + type: string; + } + + /** + * AlgoMD5 + */ + export type AlgoMd5 = { /** - * Is the target expired. + * Algo type. */ - expired: boolean; + type: string; } /** - * ActivityEvent + * Identity */ - export type ActivityEvent = { + export type Identity = { /** - * Event ID. + * Identity ID. */ $id: string; /** - * User type. + * Identity creation date in ISO 8601 format. */ - userType: string; + $createdAt: string; + /** + * Identity update date in ISO 8601 format. + */ + $updatedAt: string; /** * User ID. */ userId: string; /** - * User Email. + * Identity Provider. */ - userEmail: string; + provider: string; /** - * User Name. + * ID of the User in the Identity Provider. */ - userName: string; + providerUid: string; /** - * Resource parent. + * Email of the User in the Identity Provider. */ - resourceParent: string; + providerEmail: string; /** - * Resource type. + * Identity Provider Access Token. */ - resourceType: string; + providerAccessToken: string; /** - * Resource ID. + * The date of when the access token expires in ISO 8601 format. */ - resourceId: string; + providerAccessTokenExpiry: string; /** - * Resource. + * Identity Provider Refresh Token. */ - resource: string; + providerRefreshToken: string; + } + + /** + * Log + */ + export type Log = { /** * Event name. */ event: string; /** - * User agent. - */ - userAgent: string; - /** - * IP address. - */ - ip: string; - /** - * API mode when event triggered. + * User ID of the actor recorded for this log. During impersonation, this is the original impersonator, not the impersonated target user. */ - mode: string; + userId: string; /** - * Location. + * User email of the actor recorded for this log. During impersonation, this is the original impersonator. */ - country: string; + userEmail: string; /** - * Log creation date in ISO 8601 format. + * User name of the actor recorded for this log. During impersonation, this is the original impersonator. */ - time: string; + userName: string; /** - * Project ID. + * API mode when event triggered. */ - projectId: string; + mode: string; /** - * Team ID. + * IP session in use when the session was created. */ - teamId: string; + ip: string; /** - * Hostname. + * Log creation date in ISO 8601 format. */ - hostname: string; + time: string; /** * Operating system code name. View list of [available options](https://github.com/appwrite/appwrite/blob/master/docs/lists/os.json). */ @@ -4800,212 +4584,240 @@ export namespace Models { } /** - * Archive + * Runtime */ - export type BackupArchive = { + export type Runtime = { /** - * Archive ID. + * Runtime ID. */ $id: string; /** - * Archive creation time in ISO 8601 format. + * Parent runtime key. */ - $createdAt: string; + key: string; /** - * Archive update date in ISO 8601 format. + * Runtime Name. */ - $updatedAt: string; + name: string; /** - * Archive policy ID. + * Runtime version. */ - policyId: string; + version: string; /** - * Archive size in bytes. + * Base Docker image used to build the runtime. */ - size: number; + base: string; /** - * The status of the archive creation. Possible values: pending, processing, uploading, completed, failed. + * Image name of Docker Hub. */ - status: string; + image: string; /** - * The backup start time. + * Name of the logo image. */ - startedAt: string; + logo: string; /** - * Migration ID. + * List of supported architectures. */ - migrationId: string; + supports: string[]; + } + + /** + * Specification + */ + export type Specification = { /** - * The services that are backed up by this archive. + * Memory size in MB. */ - services: string[]; + memory: number; /** - * The resources that are backed up by this archive. + * Number of CPUs. */ - resources: string[]; + cpus: number; /** - * The resource ID to backup. Set only if this archive should backup a single resource. + * Is size enabled. */ - resourceId?: string; + enabled: boolean; /** - * The resource type to backup. Set only if this archive should backup a single resource. + * Size slug. */ - resourceType?: string; + slug: string; } /** - * backup + * Headers */ - export type BackupPolicy = { + export type Headers = { /** - * Backup policy ID. + * Header name. */ - $id: string; + name: string; /** - * Backup policy name. + * Header value. */ - name: string; + value: string; + } + + /** + * LocaleCode + */ + export type LocaleCode = { /** - * Policy creation date in ISO 8601 format. + * Locale codes in [ISO 639-1](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes) */ - $createdAt: string; + code: string; /** - * Policy update date in ISO 8601 format. + * Locale name */ - $updatedAt: string; + name: string; + } + + /** + * Continent + */ + export type Continent = { /** - * The services that are backed up by this policy. + * Continent name. */ - services: string[]; + name: string; /** - * The resources that are backed up by this policy. + * Continent two letter code. */ - resources: string[]; + code: string; + } + + /** + * Country + */ + export type Country = { /** - * The resource ID to backup. Set only if this policy should backup a single resource. + * Country name. */ - resourceId?: string; + name: string; /** - * The resource type to backup. Set only if this policy should backup a single resource. + * Country two-character ISO 3166-1 alpha code. */ - resourceType?: string; + code: string; + } + + /** + * Phone + */ + export type Phone = { /** - * How many days to keep the backup before it will be automatically deleted. + * Phone code. */ - retention: number; + code: string; /** - * Policy backup schedule in CRON format. + * Country two-character ISO 3166-1 alpha code. */ - schedule: string; + countryCode: string; /** - * Is this policy enabled. + * Country name. */ - enabled: boolean; + countryName: string; } /** - * Restoration + * Currency */ - export type BackupRestoration = { - /** - * Restoration ID. - */ - $id: string; + export type Currency = { /** - * Restoration creation time in ISO 8601 format. + * Currency symbol. */ - $createdAt: string; + symbol: string; /** - * Restoration update date in ISO 8601 format. + * Currency name. */ - $updatedAt: string; + name: string; /** - * Backup archive ID. + * Currency native symbol. */ - archiveId: string; + symbolNative: string; /** - * Backup policy ID. + * Number of decimal digits. */ - policyId: string; + decimalDigits: number; /** - * The status of the restoration. Possible values: pending, downloading, processing, completed, failed. + * Currency digit rounding. */ - status: string; + rounding: number; /** - * The backup start time. + * Currency code in [ISO 4217-1](http://en.wikipedia.org/wiki/ISO_4217) three-character format. */ - startedAt: string; + code: string; /** - * Migration ID. + * Currency plural name */ - migrationId: string; + namePlural: string; + } + + /** + * Language + */ + export type Language = { /** - * The services that are backed up by this policy. + * Language name. */ - services: string[]; + name: string; /** - * The resources that are backed up by this policy. + * Language two-character ISO 639-1 codes. */ - resources: string[]; + code: string; /** - * Optional data in key-value object. + * Language native name. */ - options: string; + nativeName: string; } /** - * Activity event list + * Framework */ - export type ActivityEventList = { + export type Framework = { /** - * Total number of events that matched your query. + * Framework key. */ - total: number; + key: string; /** - * List of events. + * Framework Name. */ - events: ActivityEvent[]; - } - - /** - * Backup archive list - */ - export type BackupArchiveList = { + name: string; /** - * Total number of archives that matched your query. + * Default runtime version. */ - total: number; + buildRuntime: string; /** - * List of archives. + * List of supported runtime versions. */ - archives: BackupArchive[]; + runtimes: string[]; + /** + * List of supported adapters. + */ + adapters: FrameworkAdapter[]; } /** - * Backup policy list + * Framework Adapter */ - export type BackupPolicyList = { + export type FrameworkAdapter = { /** - * Total number of policies that matched your query. + * Adapter key. */ - total: number; + key: string; /** - * List of policies. + * Default command to download dependencies. */ - policies: BackupPolicy[]; - } - - /** - * Backup restoration list - */ - export type BackupRestorationList = { + installCommand: string; /** - * Total number of restorations that matched your query. + * Default command to build site into output directory. */ - total: number; + buildCommand: string; /** - * List of restorations. + * Default output directory of build. */ - restorations: BackupRestoration[]; + outputDirectory: string; + /** + * Name of fallback file to use instead of 404 page. If null, Appwrite 404 page will be displayed. + */ + fallbackFile: string; } } diff --git a/src/services/health.ts b/src/services/health.ts index e3d724c3..14111566 100644 --- a/src/services/health.ts +++ b/src/services/health.ts @@ -288,108 +288,6 @@ export class Health { ); } - /** - * Get billing project aggregation queue. - * - * @param {number} params.threshold - Queue size threshold. When hit (equal or higher), endpoint returns server error. Default value is 5000. - * @throws {AppwriteException} - * @returns {Promise} - */ - getQueueBillingProjectAggregation(params?: { threshold?: number }): Promise; - /** - * Get billing project aggregation queue. - * - * @param {number} threshold - Queue size threshold. When hit (equal or higher), endpoint returns server error. Default value is 5000. - * @throws {AppwriteException} - * @returns {Promise} - * @deprecated Use the object parameter style method for a better developer experience. - */ - getQueueBillingProjectAggregation(threshold?: number): Promise; - getQueueBillingProjectAggregation( - paramsOrFirst?: { threshold?: number } | number - ): Promise { - let params: { threshold?: number }; - - if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { threshold?: number }; - } else { - params = { - threshold: paramsOrFirst as number - }; - } - - const threshold = params.threshold; - - - const apiPath = '/health/queue/billing-project-aggregation'; - const payload: Payload = {}; - if (typeof threshold !== 'undefined') { - payload['threshold'] = threshold; - } - const uri = new URL(this.client.config.endpoint + apiPath); - - const apiHeaders: { [header: string]: string } = { - } - - return this.client.call( - 'get', - uri, - apiHeaders, - payload, - ); - } - - /** - * Get billing team aggregation queue. - * - * @param {number} params.threshold - Queue size threshold. When hit (equal or higher), endpoint returns server error. Default value is 5000. - * @throws {AppwriteException} - * @returns {Promise} - */ - getQueueBillingTeamAggregation(params?: { threshold?: number }): Promise; - /** - * Get billing team aggregation queue. - * - * @param {number} threshold - Queue size threshold. When hit (equal or higher), endpoint returns server error. Default value is 5000. - * @throws {AppwriteException} - * @returns {Promise} - * @deprecated Use the object parameter style method for a better developer experience. - */ - getQueueBillingTeamAggregation(threshold?: number): Promise; - getQueueBillingTeamAggregation( - paramsOrFirst?: { threshold?: number } | number - ): Promise { - let params: { threshold?: number }; - - if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { threshold?: number }; - } else { - params = { - threshold: paramsOrFirst as number - }; - } - - const threshold = params.threshold; - - - const apiPath = '/health/queue/billing-team-aggregation'; - const payload: Payload = {}; - if (typeof threshold !== 'undefined') { - payload['threshold'] = threshold; - } - const uri = new URL(this.client.config.endpoint + apiPath); - - const apiHeaders: { [header: string]: string } = { - } - - return this.client.call( - 'get', - uri, - apiHeaders, - payload, - ); - } - /** * Get the number of builds that are waiting to be processed in the Appwrite internal queue server. * @@ -441,57 +339,6 @@ export class Health { ); } - /** - * Get the priority builds queue size. - * - * @param {number} params.threshold - Queue size threshold. When hit (equal or higher), endpoint returns server error. Default value is 500. - * @throws {AppwriteException} - * @returns {Promise} - */ - getQueuePriorityBuilds(params?: { threshold?: number }): Promise; - /** - * Get the priority builds queue size. - * - * @param {number} threshold - Queue size threshold. When hit (equal or higher), endpoint returns server error. Default value is 500. - * @throws {AppwriteException} - * @returns {Promise} - * @deprecated Use the object parameter style method for a better developer experience. - */ - getQueuePriorityBuilds(threshold?: number): Promise; - getQueuePriorityBuilds( - paramsOrFirst?: { threshold?: number } | number - ): Promise { - let params: { threshold?: number }; - - if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { threshold?: number }; - } else { - params = { - threshold: paramsOrFirst as number - }; - } - - const threshold = params.threshold; - - - const apiPath = '/health/queue/builds-priority'; - const payload: Payload = {}; - if (typeof threshold !== 'undefined') { - payload['threshold'] = threshold; - } - const uri = new URL(this.client.config.endpoint + apiPath); - - const apiHeaders: { [header: string]: string } = { - } - - return this.client.call( - 'get', - uri, - apiHeaders, - payload, - ); - } - /** * Get the number of certificates that are waiting to be issued against [Letsencrypt](https://letsencrypt.org/) in the Appwrite internal queue server. * @@ -969,57 +816,6 @@ export class Health { ); } - /** - * Get region manager queue. - * - * @param {number} params.threshold - Queue size threshold. When hit (equal or higher), endpoint returns server error. Default value is 100. - * @throws {AppwriteException} - * @returns {Promise} - */ - getQueueRegionManager(params?: { threshold?: number }): Promise; - /** - * Get region manager queue. - * - * @param {number} threshold - Queue size threshold. When hit (equal or higher), endpoint returns server error. Default value is 100. - * @throws {AppwriteException} - * @returns {Promise} - * @deprecated Use the object parameter style method for a better developer experience. - */ - getQueueRegionManager(threshold?: number): Promise; - getQueueRegionManager( - paramsOrFirst?: { threshold?: number } | number - ): Promise { - let params: { threshold?: number }; - - if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { threshold?: number }; - } else { - params = { - threshold: paramsOrFirst as number - }; - } - - const threshold = params.threshold; - - - const apiPath = '/health/queue/region-manager'; - const payload: Payload = {}; - if (typeof threshold !== 'undefined') { - payload['threshold'] = threshold; - } - const uri = new URL(this.client.config.endpoint + apiPath); - - const apiHeaders: { [header: string]: string } = { - } - - return this.client.call( - 'get', - uri, - apiHeaders, - payload, - ); - } - /** * Get the number of metrics that are waiting to be processed in the Appwrite stats resources queue. * @@ -1122,57 +918,6 @@ export class Health { ); } - /** - * Get threats queue. - * - * @param {number} params.threshold - Queue size threshold. When hit (equal or higher), endpoint returns server error. Default value is 100. - * @throws {AppwriteException} - * @returns {Promise} - */ - getQueueThreats(params?: { threshold?: number }): Promise; - /** - * Get threats queue. - * - * @param {number} threshold - Queue size threshold. When hit (equal or higher), endpoint returns server error. Default value is 100. - * @throws {AppwriteException} - * @returns {Promise} - * @deprecated Use the object parameter style method for a better developer experience. - */ - getQueueThreats(threshold?: number): Promise; - getQueueThreats( - paramsOrFirst?: { threshold?: number } | number - ): Promise { - let params: { threshold?: number }; - - if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { threshold?: number }; - } else { - params = { - threshold: paramsOrFirst as number - }; - } - - const threshold = params.threshold; - - - const apiPath = '/health/queue/threats'; - const payload: Payload = {}; - if (typeof threshold !== 'undefined') { - payload['threshold'] = threshold; - } - const uri = new URL(this.client.config.endpoint + apiPath); - - const apiHeaders: { [header: string]: string } = { - } - - return this.client.call( - 'get', - uri, - apiHeaders, - payload, - ); - } - /** * Get the number of webhooks that are waiting to be processed in the Appwrite internal queue server. * diff --git a/test/services/health.test.js b/test/services/health.test.js index 3c1bfddb..75178b52 100644 --- a/test/services/health.test.js +++ b/test/services/health.test.js @@ -135,34 +135,6 @@ describe('Health', () => { expect(response).toEqual(data); }); - test('test method getQueueBillingProjectAggregation()', async () => { - const data = { - 'size': 8,}; - mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await health.getQueueBillingProjectAggregation( - ); - - // Remove custom toString method on the objects to allow for clean data comparison. - delete response.toString; - - expect(response).toEqual(data); - }); - - test('test method getQueueBillingTeamAggregation()', async () => { - const data = { - 'size': 8,}; - mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await health.getQueueBillingTeamAggregation( - ); - - // Remove custom toString method on the objects to allow for clean data comparison. - delete response.toString; - - expect(response).toEqual(data); - }); - test('test method getQueueBuilds()', async () => { const data = { 'size': 8,}; @@ -177,20 +149,6 @@ describe('Health', () => { expect(response).toEqual(data); }); - test('test method getQueuePriorityBuilds()', async () => { - const data = { - 'size': 8,}; - mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await health.getQueuePriorityBuilds( - ); - - // Remove custom toString method on the objects to allow for clean data comparison. - delete response.toString; - - expect(response).toEqual(data); - }); - test('test method getQueueCertificates()', async () => { const data = { 'size': 8,}; @@ -318,20 +276,6 @@ describe('Health', () => { expect(response).toEqual(data); }); - test('test method getQueueRegionManager()', async () => { - const data = { - 'size': 8,}; - mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await health.getQueueRegionManager( - ); - - // Remove custom toString method on the objects to allow for clean data comparison. - delete response.toString; - - expect(response).toEqual(data); - }); - test('test method getQueueStatsResources()', async () => { const data = { 'size': 8,}; @@ -360,20 +304,6 @@ describe('Health', () => { expect(response).toEqual(data); }); - test('test method getQueueThreats()', async () => { - const data = { - 'size': 8,}; - mockedFetch.mockImplementation(() => Response.json(data)); - - const response = await health.getQueueThreats( - ); - - // Remove custom toString method on the objects to allow for clean data comparison. - delete response.toString; - - expect(response).toEqual(data); - }); - test('test method getQueueWebhooks()', async () => { const data = { 'size': 8,}; From e63db6ca94057c1d4634a8a6b124b5dc5caafbad Mon Sep 17 00:00:00 2001 From: root Date: Wed, 25 Mar 2026 07:03:27 +0000 Subject: [PATCH 5/9] chore: update Node.js SDK to 23.0.0 --- src/index.ts | 4 +- src/models.ts | 4556 ++++++++++++++++++++++++------------------------- 2 files changed, 2280 insertions(+), 2280 deletions(-) diff --git a/src/index.ts b/src/index.ts index f6c5c05b..99e694ad 100644 --- a/src/index.ts +++ b/src/index.ts @@ -57,11 +57,11 @@ export { PasswordHash } from './enums/password-hash'; export { MessagingProviderType } from './enums/messaging-provider-type'; export { DatabaseType } from './enums/database-type'; export { AttributeStatus } from './enums/attribute-status'; +export { ColumnStatus } from './enums/column-status'; export { IndexStatus } from './enums/index-status'; export { DeploymentStatus } from './enums/deployment-status'; export { ExecutionTrigger } from './enums/execution-trigger'; export { ExecutionStatus } from './enums/execution-status'; -export { HealthCheckStatus } from './enums/health-check-status'; export { HealthAntivirusStatus } from './enums/health-antivirus-status'; +export { HealthCheckStatus } from './enums/health-check-status'; export { MessageStatus } from './enums/message-status'; -export { ColumnStatus } from './enums/column-status'; diff --git a/src/models.ts b/src/models.ts index 049b933a..37c65933 100644 --- a/src/models.ts +++ b/src/models.ts @@ -1,13 +1,13 @@ import { DatabaseType } from "./enums/database-type" import { AttributeStatus } from "./enums/attribute-status" +import { ColumnStatus } from "./enums/column-status" import { IndexStatus } from "./enums/index-status" import { DeploymentStatus } from "./enums/deployment-status" import { ExecutionTrigger } from "./enums/execution-trigger" import { ExecutionStatus } from "./enums/execution-status" -import { HealthCheckStatus } from "./enums/health-check-status" import { HealthAntivirusStatus } from "./enums/health-antivirus-status" +import { HealthCheckStatus } from "./enums/health-check-status" import { MessageStatus } from "./enums/message-status" -import { ColumnStatus } from "./enums/column-status" /** * Appwrite Models @@ -17,93 +17,129 @@ export namespace Models { declare const __default: unique symbol; /** - * User + * Rows List */ - export type User = { - /** - * User ID. - */ - $id: string; - /** - * User creation date in ISO 8601 format. - */ - $createdAt: string; - /** - * User update date in ISO 8601 format. - */ - $updatedAt: string; + export type RowList = { /** - * User name. + * Total number of rows that matched your query. */ - name: string; + total: number; /** - * Hashed user password. + * List of rows. */ - password?: string; + rows: Row[]; + } + + /** + * Documents List + */ + export type DocumentList = { /** - * Password hashing algorithm. + * Total number of documents that matched your query. */ - hash?: string; + total: number; /** - * Password hashing algorithm configuration. + * List of documents. */ - hashOptions?: object; + documents: Document[]; + } + + /** + * Tables List + */ + export type TableList = { /** - * User registration date in ISO 8601 format. + * Total number of tables that matched your query. */ - registration: string; + total: number; /** - * User status. Pass `true` for enabled and `false` for disabled. + * List of tables. */ - status: boolean; + tables: Table[]; + } + + /** + * Collections List + */ + export type CollectionList = { /** - * Labels for the user. + * Total number of collections that matched your query. */ - labels: string[]; + total: number; /** - * Password update time in ISO 8601 format. + * List of collections. */ - passwordUpdate: string; + collections: Collection[]; + } + + /** + * Databases List + */ + export type DatabaseList = { /** - * User email address. + * Total number of databases that matched your query. */ - email: string; + total: number; /** - * User phone number in E.164 format. + * List of databases. */ - phone: string; + databases: Database[]; + } + + /** + * Indexes List + */ + export type IndexList = { /** - * Email verification status. + * Total number of indexes that matched your query. */ - emailVerification: boolean; + total: number; /** - * Phone verification status. + * List of indexes. */ - phoneVerification: boolean; + indexes: Index[]; + } + + /** + * Column Indexes List + */ + export type ColumnIndexList = { /** - * Multi factor authentication status. + * Total number of indexes that matched your query. */ - mfa: boolean; + total: number; /** - * User preferences as a key-value object + * List of indexes. */ - prefs: Preferences; + indexes: ColumnIndex[]; + } + + /** + * Users List + */ + export type UserList = { /** - * A user-owned message receiver. A single user may have multiple e.g. emails, phones, and a browser. Each target is registered with a single provider. + * Total number of users that matched your query. */ - targets: Target[]; + total: number; /** - * Most recent access date in ISO 8601 format. This attribute is only updated again after 24 hours. + * List of users. */ - accessedAt: string; + users: User[]; + } + + /** + * Sessions List + */ + export type SessionList = { /** - * Whether the user can impersonate other users. + * Total number of sessions that matched your query. */ - impersonator?: boolean; + total: number; /** - * ID of the original actor performing the impersonation. Present only when the current request is impersonating another user. Internal audit logs attribute the action to this user, while the impersonated target is recorded only in internal audit payload data. + * List of sessions. */ - impersonatorUserId?: string; + sessions: Session[]; } /** @@ -120,16 +156,6 @@ export namespace Models { identities: Identity[]; } - /** - * JWT - */ - export type Jwt = { - /** - * JWT encoded string. - */ - jwt: string; - } - /** * Logs List */ @@ -145,776 +171,781 @@ export namespace Models { } /** - * MFAType + * Files List */ - export type MfaType = { + export type FileList = { /** - * Secret token used for TOTP factor. + * Total number of files that matched your query. */ - secret: string; + total: number; /** - * URI for authenticator apps. + * List of files. */ - uri: string; + files: File[]; } /** - * MFA Challenge + * Buckets List */ - export type MfaChallenge = { + export type BucketList = { /** - * Token ID. + * Total number of buckets that matched your query. */ - $id: string; + total: number; /** - * Token creation date in ISO 8601 format. + * List of buckets. */ - $createdAt: string; + buckets: Bucket[]; + } + + /** + * Resource Tokens List + */ + export type ResourceTokenList = { /** - * User ID. + * Total number of tokens that matched your query. */ - userId: string; + total: number; /** - * Token expiration date in ISO 8601 format. + * List of tokens. */ - expire: string; + tokens: ResourceToken[]; } /** - * Session + * Teams List */ - export type Session = { + export type TeamList = { /** - * Session ID. + * Total number of teams that matched your query. */ - $id: string; + total: number; /** - * Session creation date in ISO 8601 format. + * List of teams. */ - $createdAt: string; + teams: Team[]; + } + + /** + * Memberships List + */ + export type MembershipList = { /** - * Session update date in ISO 8601 format. + * Total number of memberships that matched your query. */ - $updatedAt: string; + total: number; /** - * User ID. + * List of memberships. */ - userId: string; + memberships: Membership[]; + } + + /** + * Sites List + */ + export type SiteList = { /** - * Session expiration date in ISO 8601 format. + * Total number of sites that matched your query. */ - expire: string; + total: number; /** - * Session Provider. + * List of sites. */ - provider: string; + sites: Site[]; + } + + /** + * Functions List + */ + export type FunctionList = { /** - * Session Provider User ID. + * Total number of functions that matched your query. */ - providerUid: string; + total: number; /** - * Session Provider Access Token. + * List of functions. */ - providerAccessToken: string; + functions: Function[]; + } + + /** + * Frameworks List + */ + export type FrameworkList = { /** - * The date of when the access token expires in ISO 8601 format. + * Total number of frameworks that matched your query. */ - providerAccessTokenExpiry: string; + total: number; /** - * Session Provider Refresh Token. + * List of frameworks. */ - providerRefreshToken: string; - /** - * IP in use when the session was created. - */ - ip: string; + frameworks: Framework[]; + } + + /** + * Runtimes List + */ + export type RuntimeList = { /** - * Operating system code name. View list of [available options](https://github.com/appwrite/appwrite/blob/master/docs/lists/os.json). + * Total number of runtimes that matched your query. */ - osCode: string; + total: number; /** - * Operating system name. + * List of runtimes. */ - osName: string; + runtimes: Runtime[]; + } + + /** + * Deployments List + */ + export type DeploymentList = { /** - * Operating system version. + * Total number of deployments that matched your query. */ - osVersion: string; + total: number; /** - * Client type. + * List of deployments. */ - clientType: string; + deployments: Deployment[]; + } + + /** + * Executions List + */ + export type ExecutionList = { /** - * Client code name. View list of [available options](https://github.com/appwrite/appwrite/blob/master/docs/lists/clients.json). + * Total number of executions that matched your query. */ - clientCode: string; + total: number; /** - * Client name. + * List of executions. */ - clientName: string; + executions: Execution[]; + } + + /** + * Webhooks List + */ + export type WebhookList = { /** - * Client version. + * Total number of webhooks that matched your query. */ - clientVersion: string; + total: number; /** - * Client engine name. + * List of webhooks. */ - clientEngine: string; + webhooks: Webhook[]; + } + + /** + * Countries List + */ + export type CountryList = { /** - * Client engine name. + * Total number of countries that matched your query. */ - clientEngineVersion: string; + total: number; /** - * Device name. + * List of countries. */ - deviceName: string; + countries: Country[]; + } + + /** + * Continents List + */ + export type ContinentList = { /** - * Device brand name. + * Total number of continents that matched your query. */ - deviceBrand: string; + total: number; /** - * Device model name. + * List of continents. */ - deviceModel: string; + continents: Continent[]; + } + + /** + * Languages List + */ + export type LanguageList = { /** - * Country two-character ISO 3166-1 alpha code. + * Total number of languages that matched your query. */ - countryCode: string; + total: number; /** - * Country name. + * List of languages. */ - countryName: string; + languages: Language[]; + } + + /** + * Currencies List + */ + export type CurrencyList = { /** - * Returns true if this the current user session. + * Total number of currencies that matched your query. */ - current: boolean; + total: number; /** - * Returns a list of active session factors. + * List of currencies. */ - factors: string[]; + currencies: Currency[]; + } + + /** + * Phones List + */ + export type PhoneList = { /** - * Secret used to authenticate the user. Only included if the request was made with an API key + * Total number of phones that matched your query. */ - secret: string; + total: number; /** - * Most recent date in ISO 8601 format when the session successfully passed MFA challenge. + * List of phones. */ - mfaUpdatedAt: string; + phones: Phone[]; } /** - * MFAFactors + * Variables List */ - export type MfaFactors = { + export type VariableList = { /** - * Can TOTP be used for MFA challenge for this account. + * Total number of variables that matched your query. */ - totp: boolean; + total: number; /** - * Can phone (SMS) be used for MFA challenge for this account. + * List of variables. */ - phone: boolean; + variables: Variable[]; + } + + /** + * Status List + */ + export type HealthStatusList = { /** - * Can email be used for MFA challenge for this account. + * Total number of statuses that matched your query. */ - email: boolean; + total: number; /** - * Can recovery code be used for MFA challenge for this account. + * List of statuses. */ - recoveryCode: boolean; + statuses: HealthStatus[]; } /** - * MFA Recovery Codes + * Locale codes list */ - export type MfaRecoveryCodes = { + export type LocaleCodeList = { /** - * Recovery codes. + * Total number of localeCodes that matched your query. */ - recoveryCodes: string[]; + total: number; + /** + * List of localeCodes. + */ + localeCodes: LocaleCode[]; } /** - * Preferences + * Provider list */ - export type Preferences = { + export type ProviderList = { + /** + * Total number of providers that matched your query. + */ + total: number; + /** + * List of providers. + */ + providers: Provider[]; } - export type DefaultPreferences = Preferences & { - [key: string]: any; - [__default]: true; - }; - /** - * Token + * Message list */ - export type Token = { + export type MessageList = { /** - * Token ID. + * Total number of messages that matched your query. */ - $id: string; + total: number; /** - * Token creation date in ISO 8601 format. + * List of messages. */ - $createdAt: string; + messages: Message[]; + } + + /** + * Topic list + */ + export type TopicList = { /** - * User ID. + * Total number of topics that matched your query. */ - userId: string; + total: number; /** - * Token secret key. This will return an empty string unless the response is returned using an API key or as part of a webhook payload. + * List of topics. */ - secret: string; + topics: Topic[]; + } + + /** + * Subscriber list + */ + export type SubscriberList = { /** - * Token expiration date in ISO 8601 format. + * Total number of subscribers that matched your query. */ - expire: string; + total: number; /** - * Security phrase of a token. Empty if security phrase was not requested when creating a token. It includes randomly generated phrase which is also sent in the external resource such as email. + * List of subscribers. */ - phrase: string; + subscribers: Subscriber[]; } /** - * Sessions List + * Target list */ - export type SessionList = { + export type TargetList = { /** - * Total number of sessions that matched your query. + * Total number of targets that matched your query. */ total: number; /** - * List of sessions. + * List of targets. */ - sessions: Session[]; + targets: Target[]; } /** - * Activity event list + * Transaction List */ - export type ActivityEventList = { + export type TransactionList = { /** - * Total number of events that matched your query. + * Total number of transactions that matched your query. */ total: number; /** - * List of events. + * List of transactions. */ - events: ActivityEvent[]; + transactions: Transaction[]; } /** - * ActivityEvent + * Specifications List */ - export type ActivityEvent = { + export type SpecificationList = { /** - * Event ID. + * Total number of specifications that matched your query. */ - $id: string; + total: number; /** - * User type. + * List of specifications. */ - userType: string; + specifications: Specification[]; + } + + /** + * Database + */ + export type Database = { /** - * User ID. + * Database ID. */ - userId: string; + $id: string; /** - * User Email. + * Database name. */ - userEmail: string; + name: string; /** - * User Name. + * Database creation date in ISO 8601 format. */ - userName: string; + $createdAt: string; /** - * Resource parent. + * Database update date in ISO 8601 format. */ - resourceParent: string; + $updatedAt: string; /** - * Resource type. + * If database is enabled. Can be 'enabled' or 'disabled'. When disabled, the database is inaccessible to users, but remains accessible to Server SDKs using API keys. */ - resourceType: string; + enabled: boolean; /** - * Resource ID. + * Database type. */ - resourceId: string; + type: DatabaseType; /** - * Resource. + * Database backup policies. */ - resource: string; + policies: Index[]; /** - * Event name. + * Database backup archives. */ - event: string; + archives: Collection[]; + } + + /** + * Collection + */ + export type Collection = { /** - * User agent. + * Collection ID. */ - userAgent: string; + $id: string; /** - * IP address. + * Collection creation date in ISO 8601 format. */ - ip: string; + $createdAt: string; /** - * API mode when event triggered. + * Collection update date in ISO 8601 format. */ - mode: string; + $updatedAt: string; /** - * Location. + * Collection permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). */ - country: string; + $permissions: string[]; /** - * Log creation date in ISO 8601 format. + * Database ID. */ - time: string; + databaseId: string; /** - * Project ID. + * Collection name. */ - projectId: string; + name: string; /** - * Team ID. + * Collection enabled. Can be 'enabled' or 'disabled'. When disabled, the collection is inaccessible to users, but remains accessible to Server SDKs using API keys. */ - teamId: string; + enabled: boolean; /** - * Hostname. + * Whether document-level permissions are enabled. [Learn more about permissions](https://appwrite.io/docs/permissions). */ - hostname: string; + documentSecurity: boolean; /** - * Operating system code name. View list of [available options](https://github.com/appwrite/appwrite/blob/master/docs/lists/os.json). + * Collection attributes. */ - osCode: string; + attributes: (Models.AttributeBoolean | Models.AttributeInteger | Models.AttributeFloat | Models.AttributeEmail | Models.AttributeEnum | Models.AttributeUrl | Models.AttributeIp | Models.AttributeDatetime | Models.AttributeRelationship | Models.AttributePoint | Models.AttributeLine | Models.AttributePolygon | Models.AttributeVarchar | Models.AttributeText | Models.AttributeMediumtext | Models.AttributeLongtext | Models.AttributeString)[]; /** - * Operating system name. + * Collection indexes. */ - osName: string; + indexes: Index[]; /** - * Operating system version. + * Maximum document size in bytes. Returns 0 when no limit applies. */ - osVersion: string; + bytesMax: number; /** - * Client type. + * Currently used document size in bytes based on defined attributes. */ - clientType: string; + bytesUsed: number; + } + + /** + * Attributes List + */ + export type AttributeList = { /** - * Client code name. View list of [available options](https://github.com/appwrite/appwrite/blob/master/docs/lists/clients.json). + * Total number of attributes in the given collection. */ - clientCode: string; + total: number; /** - * Client name. + * List of attributes. */ - clientName: string; + attributes: (Models.AttributeBoolean | Models.AttributeInteger | Models.AttributeFloat | Models.AttributeEmail | Models.AttributeEnum | Models.AttributeUrl | Models.AttributeIp | Models.AttributeDatetime | Models.AttributeRelationship | Models.AttributePoint | Models.AttributeLine | Models.AttributePolygon | Models.AttributeVarchar | Models.AttributeText | Models.AttributeMediumtext | Models.AttributeLongtext | Models.AttributeString)[]; + } + + /** + * AttributeString + */ + export type AttributeString = { /** - * Client version. + * Attribute Key. */ - clientVersion: string; + key: string; /** - * Client engine name. + * Attribute type. */ - clientEngine: string; + type: string; /** - * Client engine name. + * Attribute status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` */ - clientEngineVersion: string; + status: AttributeStatus; /** - * Device name. + * Error message. Displays error generated on failure of creating or deleting an attribute. */ - deviceName: string; + error: string; /** - * Device brand name. + * Is attribute required? */ - deviceBrand: string; + required: boolean; /** - * Device model name. + * Is attribute an array? */ - deviceModel: string; + array?: boolean; /** - * Country two-character ISO 3166-1 alpha code. + * Attribute creation date in ISO 8601 format. */ - countryCode: string; + $createdAt: string; /** - * Country name. + * Attribute update date in ISO 8601 format. */ - countryName: string; - } - - /** - * Backup archive list - */ - export type BackupArchiveList = { + $updatedAt: string; /** - * Total number of archives that matched your query. + * Attribute size. */ - total: number; + size: number; /** - * List of archives. + * Default value for attribute when not provided. Cannot be set when attribute is required. */ - archives: BackupArchive[]; + default?: string; + /** + * Defines whether this attribute is encrypted or not. + */ + encrypt?: boolean; } /** - * Archive + * AttributeInteger */ - export type BackupArchive = { - /** - * Archive ID. - */ - $id: string; + export type AttributeInteger = { /** - * Archive creation time in ISO 8601 format. + * Attribute Key. */ - $createdAt: string; + key: string; /** - * Archive update date in ISO 8601 format. + * Attribute type. */ - $updatedAt: string; + type: string; /** - * Archive policy ID. + * Attribute status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` */ - policyId: string; + status: AttributeStatus; /** - * Archive size in bytes. + * Error message. Displays error generated on failure of creating or deleting an attribute. */ - size: number; + error: string; /** - * The status of the archive creation. Possible values: pending, processing, uploading, completed, failed. + * Is attribute required? */ - status: string; + required: boolean; /** - * The backup start time. + * Is attribute an array? */ - startedAt: string; + array?: boolean; /** - * Migration ID. + * Attribute creation date in ISO 8601 format. */ - migrationId: string; + $createdAt: string; /** - * The services that are backed up by this archive. + * Attribute update date in ISO 8601 format. */ - services: string[]; + $updatedAt: string; /** - * The resources that are backed up by this archive. + * Minimum value to enforce for new documents. */ - resources: string[]; + min?: number | bigint; /** - * The resource ID to backup. Set only if this archive should backup a single resource. + * Maximum value to enforce for new documents. */ - resourceId?: string; + max?: number | bigint; /** - * The resource type to backup. Set only if this archive should backup a single resource. + * Default value for attribute when not provided. Cannot be set when attribute is required. */ - resourceType?: string; + default?: number; } /** - * Backup policy list + * AttributeFloat */ - export type BackupPolicyList = { + export type AttributeFloat = { /** - * Total number of policies that matched your query. + * Attribute Key. */ - total: number; + key: string; /** - * List of policies. + * Attribute type. */ - policies: BackupPolicy[]; - } - - /** - * backup - */ - export type BackupPolicy = { + type: string; /** - * Backup policy ID. + * Attribute status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` */ - $id: string; + status: AttributeStatus; /** - * Backup policy name. + * Error message. Displays error generated on failure of creating or deleting an attribute. */ - name: string; + error: string; /** - * Policy creation date in ISO 8601 format. + * Is attribute required? */ - $createdAt: string; + required: boolean; /** - * Policy update date in ISO 8601 format. + * Is attribute an array? */ - $updatedAt: string; + array?: boolean; /** - * The services that are backed up by this policy. + * Attribute creation date in ISO 8601 format. */ - services: string[]; + $createdAt: string; /** - * The resources that are backed up by this policy. + * Attribute update date in ISO 8601 format. */ - resources: string[]; - /** - * The resource ID to backup. Set only if this policy should backup a single resource. - */ - resourceId?: string; - /** - * The resource type to backup. Set only if this policy should backup a single resource. - */ - resourceType?: string; + $updatedAt: string; /** - * How many days to keep the backup before it will be automatically deleted. + * Minimum value to enforce for new documents. */ - retention: number; + min?: number; /** - * Policy backup schedule in CRON format. + * Maximum value to enforce for new documents. */ - schedule: string; + max?: number; /** - * Is this policy enabled. + * Default value for attribute when not provided. Cannot be set when attribute is required. */ - enabled: boolean; + default?: number; } /** - * Restoration + * AttributeBoolean */ - export type BackupRestoration = { - /** - * Restoration ID. - */ - $id: string; - /** - * Restoration creation time in ISO 8601 format. - */ - $createdAt: string; + export type AttributeBoolean = { /** - * Restoration update date in ISO 8601 format. + * Attribute Key. */ - $updatedAt: string; + key: string; /** - * Backup archive ID. + * Attribute type. */ - archiveId: string; + type: string; /** - * Backup policy ID. + * Attribute status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` */ - policyId: string; + status: AttributeStatus; /** - * The status of the restoration. Possible values: pending, downloading, processing, completed, failed. + * Error message. Displays error generated on failure of creating or deleting an attribute. */ - status: string; + error: string; /** - * The backup start time. + * Is attribute required? */ - startedAt: string; + required: boolean; /** - * Migration ID. + * Is attribute an array? */ - migrationId: string; + array?: boolean; /** - * The services that are backed up by this policy. + * Attribute creation date in ISO 8601 format. */ - services: string[]; + $createdAt: string; /** - * The resources that are backed up by this policy. + * Attribute update date in ISO 8601 format. */ - resources: string[]; + $updatedAt: string; /** - * Optional data in key-value object. + * Default value for attribute when not provided. Cannot be set when attribute is required. */ - options: string; + default?: boolean; } /** - * Backup restoration list + * AttributeEmail */ - export type BackupRestorationList = { + export type AttributeEmail = { /** - * Total number of restorations that matched your query. + * Attribute Key. */ - total: number; + key: string; /** - * List of restorations. + * Attribute type. */ - restorations: BackupRestoration[]; - } - - /** - * Databases List - */ - export type DatabaseList = { + type: string; /** - * Total number of databases that matched your query. + * Attribute status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` */ - total: number; + status: AttributeStatus; /** - * List of databases. + * Error message. Displays error generated on failure of creating or deleting an attribute. */ - databases: Database[]; - } - - /** - * Database - */ - export type Database = { + error: string; /** - * Database ID. + * Is attribute required? */ - $id: string; + required: boolean; /** - * Database name. + * Is attribute an array? */ - name: string; + array?: boolean; /** - * Database creation date in ISO 8601 format. + * Attribute creation date in ISO 8601 format. */ $createdAt: string; /** - * Database update date in ISO 8601 format. + * Attribute update date in ISO 8601 format. */ $updatedAt: string; /** - * If database is enabled. Can be 'enabled' or 'disabled'. When disabled, the database is inaccessible to users, but remains accessible to Server SDKs using API keys. - */ - enabled: boolean; - /** - * Database type. - */ - type: DatabaseType; - /** - * Database backup policies. - */ - policies: Index[]; - /** - * Database backup archives. - */ - archives: Collection[]; - } - - /** - * Transaction List - */ - export type TransactionList = { - /** - * Total number of transactions that matched your query. + * String format. */ - total: number; + format: string; /** - * List of transactions. + * Default value for attribute when not provided. Cannot be set when attribute is required. */ - transactions: Transaction[]; + default?: string; } /** - * Transaction + * AttributeEnum */ - export type Transaction = { - /** - * Transaction ID. - */ - $id: string; - /** - * Transaction creation time in ISO 8601 format. - */ - $createdAt: string; - /** - * Transaction update date in ISO 8601 format. - */ - $updatedAt: string; + export type AttributeEnum = { /** - * Current status of the transaction. One of: pending, committing, committed, rolled_back, failed. + * Attribute Key. */ - status: string; + key: string; /** - * Number of operations in the transaction. + * Attribute type. */ - operations: number; + type: string; /** - * Expiration time in ISO 8601 format. + * Attribute status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` */ - expiresAt: string; - } - - /** - * Collections List - */ - export type CollectionList = { + status: AttributeStatus; /** - * Total number of collections that matched your query. + * Error message. Displays error generated on failure of creating or deleting an attribute. */ - total: number; + error: string; /** - * List of collections. + * Is attribute required? */ - collections: Collection[]; - } - - /** - * Collection - */ - export type Collection = { + required: boolean; /** - * Collection ID. + * Is attribute an array? */ - $id: string; + array?: boolean; /** - * Collection creation date in ISO 8601 format. + * Attribute creation date in ISO 8601 format. */ $createdAt: string; /** - * Collection update date in ISO 8601 format. + * Attribute update date in ISO 8601 format. */ $updatedAt: string; /** - * Collection permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). - */ - $permissions: string[]; - /** - * Database ID. - */ - databaseId: string; - /** - * Collection name. - */ - name: string; - /** - * Collection enabled. Can be 'enabled' or 'disabled'. When disabled, the collection is inaccessible to users, but remains accessible to Server SDKs using API keys. - */ - enabled: boolean; - /** - * Whether document-level permissions are enabled. [Learn more about permissions](https://appwrite.io/docs/permissions). - */ - documentSecurity: boolean; - /** - * Collection attributes. - */ - attributes: (Models.AttributeBoolean | Models.AttributeInteger | Models.AttributeFloat | Models.AttributeEmail | Models.AttributeEnum | Models.AttributeUrl | Models.AttributeIp | Models.AttributeDatetime | Models.AttributeRelationship | Models.AttributePoint | Models.AttributeLine | Models.AttributePolygon | Models.AttributeVarchar | Models.AttributeText | Models.AttributeMediumtext | Models.AttributeLongtext | Models.AttributeString)[]; - /** - * Collection indexes. - */ - indexes: Index[]; - /** - * Maximum document size in bytes. Returns 0 when no limit applies. - */ - bytesMax: number; - /** - * Currently used document size in bytes based on defined attributes. + * Array of elements in enumerated type. */ - bytesUsed: number; - } - - /** - * Attributes List - */ - export type AttributeList = { + elements: string[]; /** - * Total number of attributes in the given collection. + * String format. */ - total: number; + format: string; /** - * List of attributes. + * Default value for attribute when not provided. Cannot be set when attribute is required. */ - attributes: (Models.AttributeBoolean | Models.AttributeInteger | Models.AttributeFloat | Models.AttributeEmail | Models.AttributeEnum | Models.AttributeUrl | Models.AttributeIp | Models.AttributeDatetime | Models.AttributeRelationship | Models.AttributePoint | Models.AttributeLine | Models.AttributePolygon | Models.AttributeVarchar | Models.AttributeText | Models.AttributeMediumtext | Models.AttributeLongtext | Models.AttributeString)[]; + default?: string; } /** - * AttributeBoolean + * AttributeIP */ - export type AttributeBoolean = { + export type AttributeIp = { /** * Attribute Key. */ @@ -948,61 +979,19 @@ export namespace Models { */ $updatedAt: string; /** - * Default value for attribute when not provided. Cannot be set when attribute is required. - */ - default?: boolean; - } - - /** - * AttributeDatetime - */ - export type AttributeDatetime = { - /** - * Attribute Key. - */ - key: string; - /** - * Attribute type. - */ - type: string; - /** - * Attribute status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` - */ - status: AttributeStatus; - /** - * Error message. Displays error generated on failure of creating or deleting an attribute. - */ - error: string; - /** - * Is attribute required? - */ - required: boolean; - /** - * Is attribute an array? - */ - array?: boolean; - /** - * Attribute creation date in ISO 8601 format. - */ - $createdAt: string; - /** - * Attribute update date in ISO 8601 format. - */ - $updatedAt: string; - /** - * ISO 8601 format. + * String format. */ format: string; /** - * Default value for attribute when not provided. Only null is optional + * Default value for attribute when not provided. Cannot be set when attribute is required. */ default?: string; } /** - * AttributeEmail + * AttributeURL */ - export type AttributeEmail = { + export type AttributeUrl = { /** * Attribute Key. */ @@ -1046,9 +1035,9 @@ export namespace Models { } /** - * AttributeEnum + * AttributeDatetime */ - export type AttributeEnum = { + export type AttributeDatetime = { /** * Attribute Key. */ @@ -1082,23 +1071,19 @@ export namespace Models { */ $updatedAt: string; /** - * Array of elements in enumerated type. - */ - elements: string[]; - /** - * String format. + * ISO 8601 format. */ format: string; /** - * Default value for attribute when not provided. Cannot be set when attribute is required. + * Default value for attribute when not provided. Only null is optional */ default?: string; } /** - * AttributeFloat + * AttributeRelationship */ - export type AttributeFloat = { + export type AttributeRelationship = { /** * Attribute Key. */ @@ -1132,23 +1117,35 @@ export namespace Models { */ $updatedAt: string; /** - * Minimum value to enforce for new documents. + * The ID of the related collection. */ - min?: number; + relatedCollection: string; /** - * Maximum value to enforce for new documents. + * The type of the relationship. */ - max?: number; + relationType: string; /** - * Default value for attribute when not provided. Cannot be set when attribute is required. + * Is the relationship two-way? */ - default?: number; + twoWay: boolean; + /** + * The key of the two-way relationship. + */ + twoWayKey: string; + /** + * How deleting the parent document will propagate to child documents. + */ + onDelete: string; + /** + * Whether this is the parent or child side of the relationship + */ + side: string; } /** - * AttributeInteger + * AttributePoint */ - export type AttributeInteger = { + export type AttributePoint = { /** * Attribute Key. */ @@ -1181,24 +1178,16 @@ export namespace Models { * Attribute update date in ISO 8601 format. */ $updatedAt: string; - /** - * Minimum value to enforce for new documents. - */ - min?: number | bigint; - /** - * Maximum value to enforce for new documents. - */ - max?: number | bigint; /** * Default value for attribute when not provided. Cannot be set when attribute is required. */ - default?: number; + default?: any[]; } /** - * AttributeIP + * AttributeLine */ - export type AttributeIp = { + export type AttributeLine = { /** * Attribute Key. */ @@ -1231,20 +1220,16 @@ export namespace Models { * Attribute update date in ISO 8601 format. */ $updatedAt: string; - /** - * String format. - */ - format: string; /** * Default value for attribute when not provided. Cannot be set when attribute is required. */ - default?: string; + default?: any[]; } /** - * AttributeLine + * AttributePolygon */ - export type AttributeLine = { + export type AttributePolygon = { /** * Attribute Key. */ @@ -1284,9 +1269,9 @@ export namespace Models { } /** - * AttributeLongtext + * AttributeVarchar */ - export type AttributeLongtext = { + export type AttributeVarchar = { /** * Attribute Key. */ @@ -1319,6 +1304,10 @@ export namespace Models { * Attribute update date in ISO 8601 format. */ $updatedAt: string; + /** + * Attribute size. + */ + size: number; /** * Default value for attribute when not provided. Cannot be set when attribute is required. */ @@ -1330,9 +1319,9 @@ export namespace Models { } /** - * AttributeMediumtext + * AttributeText */ - export type AttributeMediumtext = { + export type AttributeText = { /** * Attribute Key. */ @@ -1376,9 +1365,9 @@ export namespace Models { } /** - * AttributePoint + * AttributeMediumtext */ - export type AttributePoint = { + export type AttributeMediumtext = { /** * Attribute Key. */ @@ -1414,13 +1403,17 @@ export namespace Models { /** * Default value for attribute when not provided. Cannot be set when attribute is required. */ - default?: any[]; + default?: string; + /** + * Defines whether this attribute is encrypted or not. + */ + encrypt?: boolean; } /** - * AttributePolygon + * AttributeLongtext */ - export type AttributePolygon = { + export type AttributeLongtext = { /** * Attribute Key. */ @@ -1456,1538 +1449,1608 @@ export namespace Models { /** * Default value for attribute when not provided. Cannot be set when attribute is required. */ - default?: any[]; + default?: string; + /** + * Defines whether this attribute is encrypted or not. + */ + encrypt?: boolean; } /** - * AttributeRelationship + * Table */ - export type AttributeRelationship = { + export type Table = { /** - * Attribute Key. + * Table ID. */ - key: string; + $id: string; /** - * Attribute type. + * Table creation date in ISO 8601 format. */ - type: string; + $createdAt: string; /** - * Attribute status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` + * Table update date in ISO 8601 format. */ - status: AttributeStatus; + $updatedAt: string; /** - * Error message. Displays error generated on failure of creating or deleting an attribute. + * Table permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). */ - error: string; + $permissions: string[]; /** - * Is attribute required? + * Database ID. */ - required: boolean; + databaseId: string; /** - * Is attribute an array? + * Table name. */ - array?: boolean; + name: string; /** - * Attribute creation date in ISO 8601 format. + * Table enabled. Can be 'enabled' or 'disabled'. When disabled, the table is inaccessible to users, but remains accessible to Server SDKs using API keys. */ - $createdAt: string; + enabled: boolean; /** - * Attribute update date in ISO 8601 format. + * Whether row-level permissions are enabled. [Learn more about permissions](https://appwrite.io/docs/permissions). */ - $updatedAt: string; + rowSecurity: boolean; /** - * The ID of the related collection. + * Table columns. */ - relatedCollection: string; + columns: (Models.ColumnBoolean | Models.ColumnInteger | Models.ColumnFloat | Models.ColumnEmail | Models.ColumnEnum | Models.ColumnUrl | Models.ColumnIp | Models.ColumnDatetime | Models.ColumnRelationship | Models.ColumnPoint | Models.ColumnLine | Models.ColumnPolygon | Models.ColumnVarchar | Models.ColumnText | Models.ColumnMediumtext | Models.ColumnLongtext | Models.ColumnString)[]; /** - * The type of the relationship. + * Table indexes. */ - relationType: string; + indexes: ColumnIndex[]; /** - * Is the relationship two-way? + * Maximum row size in bytes. Returns 0 when no limit applies. */ - twoWay: boolean; + bytesMax: number; /** - * The key of the two-way relationship. + * Currently used row size in bytes based on defined columns. */ - twoWayKey: string; + bytesUsed: number; + } + + /** + * Columns List + */ + export type ColumnList = { /** - * How deleting the parent document will propagate to child documents. + * Total number of columns in the given table. */ - onDelete: string; + total: number; /** - * Whether this is the parent or child side of the relationship + * List of columns. */ - side: string; + columns: (Models.ColumnBoolean | Models.ColumnInteger | Models.ColumnFloat | Models.ColumnEmail | Models.ColumnEnum | Models.ColumnUrl | Models.ColumnIp | Models.ColumnDatetime | Models.ColumnRelationship | Models.ColumnPoint | Models.ColumnLine | Models.ColumnPolygon | Models.ColumnVarchar | Models.ColumnText | Models.ColumnMediumtext | Models.ColumnLongtext | Models.ColumnString)[]; } /** - * AttributeString + * ColumnString */ - export type AttributeString = { + export type ColumnString = { /** - * Attribute Key. + * Column Key. */ key: string; /** - * Attribute type. + * Column type. */ type: string; /** - * Attribute status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` + * Column status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` */ - status: AttributeStatus; + status: ColumnStatus; /** - * Error message. Displays error generated on failure of creating or deleting an attribute. + * Error message. Displays error generated on failure of creating or deleting an column. */ error: string; /** - * Is attribute required? + * Is column required? */ required: boolean; /** - * Is attribute an array? + * Is column an array? */ array?: boolean; /** - * Attribute creation date in ISO 8601 format. + * Column creation date in ISO 8601 format. */ $createdAt: string; /** - * Attribute update date in ISO 8601 format. + * Column update date in ISO 8601 format. */ $updatedAt: string; /** - * Attribute size. + * Column size. */ size: number; /** - * Default value for attribute when not provided. Cannot be set when attribute is required. + * Default value for column when not provided. Cannot be set when column is required. */ default?: string; /** - * Defines whether this attribute is encrypted or not. + * Defines whether this column is encrypted or not. */ encrypt?: boolean; } /** - * AttributeText + * ColumnInteger */ - export type AttributeText = { + export type ColumnInteger = { /** - * Attribute Key. + * Column Key. */ key: string; /** - * Attribute type. + * Column type. */ type: string; /** - * Attribute status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` + * Column status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` */ - status: AttributeStatus; + status: ColumnStatus; /** - * Error message. Displays error generated on failure of creating or deleting an attribute. + * Error message. Displays error generated on failure of creating or deleting an column. */ error: string; /** - * Is attribute required? + * Is column required? */ required: boolean; /** - * Is attribute an array? + * Is column an array? */ array?: boolean; /** - * Attribute creation date in ISO 8601 format. + * Column creation date in ISO 8601 format. */ $createdAt: string; /** - * Attribute update date in ISO 8601 format. + * Column update date in ISO 8601 format. */ $updatedAt: string; /** - * Default value for attribute when not provided. Cannot be set when attribute is required. + * Minimum value to enforce for new documents. */ - default?: string; + min?: number | bigint; /** - * Defines whether this attribute is encrypted or not. + * Maximum value to enforce for new documents. */ - encrypt?: boolean; + max?: number | bigint; + /** + * Default value for column when not provided. Cannot be set when column is required. + */ + default?: number; } /** - * AttributeURL + * ColumnFloat */ - export type AttributeUrl = { + export type ColumnFloat = { /** - * Attribute Key. + * Column Key. */ key: string; /** - * Attribute type. + * Column type. */ type: string; /** - * Attribute status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` + * Column status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` */ - status: AttributeStatus; + status: ColumnStatus; /** - * Error message. Displays error generated on failure of creating or deleting an attribute. + * Error message. Displays error generated on failure of creating or deleting an column. */ error: string; /** - * Is attribute required? + * Is column required? */ required: boolean; /** - * Is attribute an array? + * Is column an array? */ array?: boolean; /** - * Attribute creation date in ISO 8601 format. + * Column creation date in ISO 8601 format. */ $createdAt: string; /** - * Attribute update date in ISO 8601 format. + * Column update date in ISO 8601 format. */ $updatedAt: string; /** - * String format. + * Minimum value to enforce for new documents. */ - format: string; + min?: number; /** - * Default value for attribute when not provided. Cannot be set when attribute is required. + * Maximum value to enforce for new documents. */ - default?: string; + max?: number; + /** + * Default value for column when not provided. Cannot be set when column is required. + */ + default?: number; } /** - * AttributeVarchar + * ColumnBoolean */ - export type AttributeVarchar = { + export type ColumnBoolean = { /** - * Attribute Key. + * Column Key. */ key: string; /** - * Attribute type. + * Column type. */ type: string; /** - * Attribute status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` + * Column status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` */ - status: AttributeStatus; + status: ColumnStatus; /** - * Error message. Displays error generated on failure of creating or deleting an attribute. + * Error message. Displays error generated on failure of creating or deleting an column. */ error: string; /** - * Is attribute required? + * Is column required? */ required: boolean; /** - * Is attribute an array? + * Is column an array? */ array?: boolean; /** - * Attribute creation date in ISO 8601 format. + * Column creation date in ISO 8601 format. */ $createdAt: string; /** - * Attribute update date in ISO 8601 format. + * Column update date in ISO 8601 format. */ $updatedAt: string; /** - * Attribute size. - */ - size: number; - /** - * Default value for attribute when not provided. Cannot be set when attribute is required. - */ - default?: string; - /** - * Defines whether this attribute is encrypted or not. + * Default value for column when not provided. Cannot be set when column is required. */ - encrypt?: boolean; + default?: boolean; } /** - * Documents List + * ColumnEmail */ - export type DocumentList = { + export type ColumnEmail = { /** - * Total number of documents that matched your query. + * Column Key. */ - total: number; + key: string; /** - * List of documents. + * Column type. */ - documents: Document[]; - } - - /** - * Document - */ - export type Document = { + type: string; /** - * Document ID. + * Column status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` */ - $id: string; + status: ColumnStatus; /** - * Document sequence ID. + * Error message. Displays error generated on failure of creating or deleting an column. */ - $sequence: string; + error: string; /** - * Collection ID. + * Is column required? */ - $collectionId: string; + required: boolean; /** - * Database ID. + * Is column an array? */ - $databaseId: string; + array?: boolean; /** - * Document creation date in ISO 8601 format. + * Column creation date in ISO 8601 format. */ $createdAt: string; /** - * Document update date in ISO 8601 format. + * Column update date in ISO 8601 format. */ $updatedAt: string; /** - * Document permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). - */ - $permissions: string[]; - } - - export type DefaultDocument = Document & { - [key: string]: any; - [__default]: true; - }; - - /** - * Indexes List - */ - export type IndexList = { - /** - * Total number of indexes that matched your query. + * String format. */ - total: number; + format: string; /** - * List of indexes. + * Default value for column when not provided. Cannot be set when column is required. */ - indexes: Index[]; + default?: string; } /** - * Index + * ColumnEnum */ - export type Index = { - /** - * Index ID. - */ - $id: string; + export type ColumnEnum = { /** - * Index creation date in ISO 8601 format. + * Column Key. */ - $createdAt: string; + key: string; /** - * Index update date in ISO 8601 format. + * Column type. */ - $updatedAt: string; + type: string; /** - * Index key. + * Column status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` */ - key: string; + status: ColumnStatus; /** - * Index type. + * Error message. Displays error generated on failure of creating or deleting an column. */ - type: string; + error: string; /** - * Index status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` + * Is column required? */ - status: IndexStatus; + required: boolean; /** - * Error message. Displays error generated on failure of creating or deleting an index. + * Is column an array? */ - error: string; + array?: boolean; /** - * Index attributes. + * Column creation date in ISO 8601 format. */ - attributes: string[]; + $createdAt: string; /** - * Index attributes length. + * Column update date in ISO 8601 format. */ - lengths: number[]; + $updatedAt: string; /** - * Index orders. + * Array of elements in enumerated type. */ - orders?: string[]; - } - - /** - * Functions List - */ - export type FunctionList = { + elements: string[]; /** - * Total number of functions that matched your query. + * String format. */ - total: number; + format: string; /** - * List of functions. + * Default value for column when not provided. Cannot be set when column is required. */ - functions: Function[]; + default?: string; } /** - * Function + * ColumnIP */ - export type Function = { + export type ColumnIp = { /** - * Function ID. + * Column Key. */ - $id: string; + key: string; /** - * Function creation date in ISO 8601 format. + * Column type. */ - $createdAt: string; + type: string; /** - * Function update date in ISO 8601 format. + * Column status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` */ - $updatedAt: string; + status: ColumnStatus; /** - * Execution permissions. + * Error message. Displays error generated on failure of creating or deleting an column. */ - execute: string[]; + error: string; /** - * Function name. + * Is column required? */ - name: string; + required: boolean; /** - * Function enabled. + * Is column an array? */ - enabled: boolean; + array?: boolean; /** - * Is the function deployed with the latest configuration? This is set to false if you've changed an environment variables, entrypoint, commands, or other settings that needs redeploy to be applied. When the value is false, redeploy the function to update it with the latest configuration. + * Column creation date in ISO 8601 format. */ - live: boolean; + $createdAt: string; /** - * When disabled, executions will exclude logs and errors, and will be slightly faster. + * Column update date in ISO 8601 format. */ - logging: boolean; + $updatedAt: string; /** - * Function execution and build runtime. + * String format. */ - runtime: string; + format: string; /** - * How many days to keep the non-active deployments before they will be automatically deleted. + * Default value for column when not provided. Cannot be set when column is required. */ - deploymentRetention: number; + default?: string; + } + + /** + * ColumnURL + */ + export type ColumnUrl = { /** - * Function's active deployment ID. + * Column Key. */ - deploymentId: string; + key: string; /** - * Active deployment creation date in ISO 8601 format. + * Column type. */ - deploymentCreatedAt: string; + type: string; /** - * Function's latest deployment ID. + * Column status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` */ - latestDeploymentId: string; + status: ColumnStatus; /** - * Latest deployment creation date in ISO 8601 format. + * Error message. Displays error generated on failure of creating or deleting an column. */ - latestDeploymentCreatedAt: string; + error: string; /** - * Status of latest deployment. Possible values are "waiting", "processing", "building", "ready", and "failed". + * Is column required? */ - latestDeploymentStatus: string; + required: boolean; /** - * Allowed permission scopes. + * Is column an array? */ - scopes: string[]; + array?: boolean; /** - * Function variables. + * Column creation date in ISO 8601 format. */ - vars: Variable[]; + $createdAt: string; /** - * Function trigger events. + * Column update date in ISO 8601 format. */ - events: string[]; + $updatedAt: string; /** - * Function execution schedule in CRON format. + * String format. */ - schedule: string; + format: string; /** - * Function execution timeout in seconds. + * Default value for column when not provided. Cannot be set when column is required. */ - timeout: number; + default?: string; + } + + /** + * ColumnDatetime + */ + export type ColumnDatetime = { /** - * The entrypoint file used to execute the deployment. + * Column Key. */ - entrypoint: string; + key: string; /** - * The build command used to build the deployment. + * Column type. */ - commands: string; + type: string; /** - * Version of Open Runtimes used for the function. + * Column status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` */ - version: string; + status: ColumnStatus; /** - * Function VCS (Version Control System) installation id. + * Error message. Displays error generated on failure of creating or deleting an column. */ - installationId: string; + error: string; /** - * VCS (Version Control System) Repository ID + * Is column required? */ - providerRepositoryId: string; + required: boolean; /** - * VCS (Version Control System) branch name + * Is column an array? */ - providerBranch: string; + array?: boolean; /** - * Path to function in VCS (Version Control System) repository + * Column creation date in ISO 8601 format. */ - providerRootDirectory: string; + $createdAt: string; /** - * Is VCS (Version Control System) connection is in silent mode? When in silence mode, no comments will be posted on the repository pull or merge requests + * Column update date in ISO 8601 format. */ - providerSilentMode: boolean; + $updatedAt: string; /** - * Machine specification for deployment builds. + * ISO 8601 format. */ - buildSpecification: string; + format: string; /** - * Machine specification for executions. + * Default value for column when not provided. Only null is optional */ - runtimeSpecification: string; + default?: string; } /** - * Runtimes List + * ColumnRelationship */ - export type RuntimeList = { - /** - * Total number of runtimes that matched your query. - */ - total: number; + export type ColumnRelationship = { /** - * List of runtimes. + * Column Key. */ - runtimes: Runtime[]; - } - - /** - * Specifications List - */ - export type SpecificationList = { + key: string; /** - * Total number of specifications that matched your query. + * Column type. */ - total: number; + type: string; /** - * List of specifications. + * Column status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` */ - specifications: Specification[]; - } - - /** - * Deployments List - */ - export type DeploymentList = { + status: ColumnStatus; /** - * Total number of deployments that matched your query. + * Error message. Displays error generated on failure of creating or deleting an column. */ - total: number; + error: string; /** - * List of deployments. + * Is column required? */ - deployments: Deployment[]; - } - - /** - * Deployment - */ - export type Deployment = { + required: boolean; /** - * Deployment ID. + * Is column an array? */ - $id: string; + array?: boolean; /** - * Deployment creation date in ISO 8601 format. + * Column creation date in ISO 8601 format. */ $createdAt: string; /** - * Deployment update date in ISO 8601 format. + * Column update date in ISO 8601 format. */ $updatedAt: string; /** - * Type of deployment. + * The ID of the related table. */ - type: string; + relatedTable: string; /** - * Resource ID. + * The type of the relationship. */ - resourceId: string; + relationType: string; /** - * Resource type. + * Is the relationship two-way? */ - resourceType: string; + twoWay: boolean; /** - * The entrypoint file to use to execute the deployment code. + * The key of the two-way relationship. */ - entrypoint: string; + twoWayKey: string; /** - * The code size in bytes. + * How deleting the parent document will propagate to child documents. */ - sourceSize: number; + onDelete: string; /** - * The build output size in bytes. + * Whether this is the parent or child side of the relationship */ - buildSize: number; + side: string; + } + + /** + * ColumnPoint + */ + export type ColumnPoint = { /** - * The total size in bytes (source and build output). + * Column Key. */ - totalSize: number; + key: string; /** - * The current build ID. + * Column type. */ - buildId: string; + type: string; /** - * Whether the deployment should be automatically activated. + * Column status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` */ - activate: boolean; + status: ColumnStatus; /** - * Screenshot with light theme preference file ID. + * Error message. Displays error generated on failure of creating or deleting an column. */ - screenshotLight: string; + error: string; /** - * Screenshot with dark theme preference file ID. + * Is column required? */ - screenshotDark: string; + required: boolean; /** - * The deployment status. Possible values are "waiting", "processing", "building", "ready", "canceled" and "failed". + * Is column an array? */ - status: DeploymentStatus; + array?: boolean; /** - * The build logs. + * Column creation date in ISO 8601 format. */ - buildLogs: string; + $createdAt: string; /** - * The current build time in seconds. + * Column update date in ISO 8601 format. */ - buildDuration: number; + $updatedAt: string; /** - * The name of the vcs provider repository + * Default value for column when not provided. Cannot be set when column is required. */ - providerRepositoryName: string; + default?: any[]; + } + + /** + * ColumnLine + */ + export type ColumnLine = { /** - * The name of the vcs provider repository owner + * Column Key. */ - providerRepositoryOwner: string; + key: string; /** - * The url of the vcs provider repository + * Column type. */ - providerRepositoryUrl: string; + type: string; /** - * The commit hash of the vcs commit + * Column status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` */ - providerCommitHash: string; + status: ColumnStatus; /** - * The url of vcs commit author + * Error message. Displays error generated on failure of creating or deleting an column. */ - providerCommitAuthorUrl: string; + error: string; /** - * The name of vcs commit author + * Is column required? */ - providerCommitAuthor: string; + required: boolean; /** - * The commit message + * Is column an array? */ - providerCommitMessage: string; + array?: boolean; /** - * The url of the vcs commit + * Column creation date in ISO 8601 format. */ - providerCommitUrl: string; + $createdAt: string; /** - * The branch of the vcs repository + * Column update date in ISO 8601 format. */ - providerBranch: string; + $updatedAt: string; /** - * The branch of the vcs repository + * Default value for column when not provided. Cannot be set when column is required. */ - providerBranchUrl: string; + default?: any[]; } /** - * Executions List + * ColumnPolygon */ - export type ExecutionList = { + export type ColumnPolygon = { /** - * Total number of executions that matched your query. + * Column Key. */ - total: number; + key: string; /** - * List of executions. + * Column type. */ - executions: Execution[]; - } - - /** - * Execution - */ - export type Execution = { + type: string; /** - * Execution ID. + * Column status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` */ - $id: string; + status: ColumnStatus; /** - * Execution creation date in ISO 8601 format. + * Error message. Displays error generated on failure of creating or deleting an column. */ - $createdAt: string; + error: string; /** - * Execution update date in ISO 8601 format. + * Is column required? */ - $updatedAt: string; + required: boolean; /** - * Execution roles. + * Is column an array? */ - $permissions: string[]; + array?: boolean; /** - * Function ID. + * Column creation date in ISO 8601 format. */ - functionId: string; + $createdAt: string; /** - * Function's deployment ID used to create the execution. + * Column update date in ISO 8601 format. */ - deploymentId: string; + $updatedAt: string; /** - * The trigger that caused the function to execute. Possible values can be: `http`, `schedule`, or `event`. + * Default value for column when not provided. Cannot be set when column is required. */ - trigger: ExecutionTrigger; + default?: any[]; + } + + /** + * ColumnVarchar + */ + export type ColumnVarchar = { /** - * The status of the function execution. Possible values can be: `waiting`, `processing`, `completed`, `failed`, or `scheduled`. + * Column Key. */ - status: ExecutionStatus; + key: string; /** - * HTTP request method type. + * Column type. */ - requestMethod: string; + type: string; /** - * HTTP request path and query. + * Column status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` */ - requestPath: string; + status: ColumnStatus; /** - * HTTP request headers as a key-value object. This will return only whitelisted headers. All headers are returned if execution is created as synchronous. + * Error message. Displays error generated on failure of creating or deleting an column. */ - requestHeaders: Headers[]; + error: string; /** - * HTTP response status code. + * Is column required? */ - responseStatusCode: number; + required: boolean; /** - * HTTP response body. This will return empty unless execution is created as synchronous. + * Is column an array? */ - responseBody: string; + array?: boolean; /** - * HTTP response headers as a key-value object. This will return only whitelisted headers. All headers are returned if execution is created as synchronous. + * Column creation date in ISO 8601 format. */ - responseHeaders: Headers[]; + $createdAt: string; /** - * Function logs. Includes the last 4,000 characters. This will return an empty string unless the response is returned using an API key or as part of a webhook payload. + * Column update date in ISO 8601 format. */ - logs: string; + $updatedAt: string; /** - * Function errors. Includes the last 4,000 characters. This will return an empty string unless the response is returned using an API key or as part of a webhook payload. + * Column size. */ - errors: string; + size: number; /** - * Resource(function/site) execution duration in seconds. + * Default value for column when not provided. Cannot be set when column is required. */ - duration: number; + default?: string; /** - * The scheduled time for execution. If left empty, execution will be queued immediately. + * Defines whether this column is encrypted or not. */ - scheduledAt?: string; + encrypt?: boolean; } /** - * Variables List + * ColumnText */ - export type VariableList = { + export type ColumnText = { /** - * Total number of variables that matched your query. + * Column Key. */ - total: number; + key: string; /** - * List of variables. + * Column type. */ - variables: Variable[]; - } - - /** - * Variable - */ - export type Variable = { + type: string; /** - * Variable ID. + * Column status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` */ - $id: string; + status: ColumnStatus; /** - * Variable creation date in ISO 8601 format. + * Error message. Displays error generated on failure of creating or deleting an column. */ - $createdAt: string; + error: string; /** - * Variable creation date in ISO 8601 format. + * Is column required? */ - $updatedAt: string; + required: boolean; /** - * Variable key. + * Is column an array? */ - key: string; + array?: boolean; /** - * Variable value. + * Column creation date in ISO 8601 format. */ - value: string; + $createdAt: string; /** - * Variable secret flag. Secret variables can only be updated or deleted, but never read. + * Column update date in ISO 8601 format. */ - secret: boolean; + $updatedAt: string; /** - * Service to which the variable belongs. Possible values are "project", "function" + * Default value for column when not provided. Cannot be set when column is required. */ - resourceType: string; + default?: string; /** - * ID of resource to which the variable belongs. If resourceType is "project", it is empty. If resourceType is "function", it is ID of the function. + * Defines whether this column is encrypted or not. */ - resourceId: string; + encrypt?: boolean; } /** - * Health Status + * ColumnMediumtext */ - export type HealthStatus = { + export type ColumnMediumtext = { /** - * Name of the service. + * Column Key. */ - name: string; + key: string; /** - * Duration in milliseconds how long the health check took. + * Column type. */ - ping: number; + type: string; /** - * Service status. Possible values are: `pass`, `fail` + * Column status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` */ - status: HealthCheckStatus; - } - - /** - * Health Antivirus - */ - export type HealthAntivirus = { + status: ColumnStatus; /** - * Antivirus version. + * Error message. Displays error generated on failure of creating or deleting an column. */ - version: string; + error: string; /** - * Antivirus status. Possible values are: `disabled`, `offline`, `online` + * Is column required? */ - status: HealthAntivirusStatus; - } - - /** - * Status List - */ - export type HealthStatusList = { + required: boolean; /** - * Total number of statuses that matched your query. + * Is column an array? */ - total: number; + array?: boolean; /** - * List of statuses. + * Column creation date in ISO 8601 format. */ - statuses: HealthStatus[]; + $createdAt: string; + /** + * Column update date in ISO 8601 format. + */ + $updatedAt: string; + /** + * Default value for column when not provided. Cannot be set when column is required. + */ + default?: string; + /** + * Defines whether this column is encrypted or not. + */ + encrypt?: boolean; } /** - * Health Certificate + * ColumnLongtext */ - export type HealthCertificate = { + export type ColumnLongtext = { /** - * Certificate name + * Column Key. */ - name: string; + key: string; /** - * Subject SN + * Column type. */ - subjectSN: string; + type: string; /** - * Issuer organisation + * Column status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` */ - issuerOrganisation: string; + status: ColumnStatus; /** - * Valid from + * Error message. Displays error generated on failure of creating or deleting an column. */ - validFrom: string; + error: string; /** - * Valid to + * Is column required? */ - validTo: string; + required: boolean; /** - * Signature type SN + * Is column an array? */ - signatureTypeSN: string; - } - - /** - * Health Queue - */ - export type HealthQueue = { + array?: boolean; /** - * Amount of actions in the queue. + * Column creation date in ISO 8601 format. */ - size: number; - } - - /** - * Health Time - */ - export type HealthTime = { + $createdAt: string; /** - * Current unix timestamp on trustful remote server. + * Column update date in ISO 8601 format. */ - remoteTime: number; + $updatedAt: string; /** - * Current unix timestamp of local server where Appwrite runs. + * Default value for column when not provided. Cannot be set when column is required. */ - localTime: number; + default?: string; /** - * Difference of unix remote and local timestamps in milliseconds. + * Defines whether this column is encrypted or not. */ - diff: number; + encrypt?: boolean; } /** - * Locale + * Index */ - export type Locale = { + export type Index = { /** - * User IP address. + * Index ID. */ - ip: string; + $id: string; /** - * Country code in [ISO 3166-1](http://en.wikipedia.org/wiki/ISO_3166-1) two-character format + * Index creation date in ISO 8601 format. */ - countryCode: string; + $createdAt: string; /** - * Country name. This field support localization. + * Index update date in ISO 8601 format. */ - country: string; + $updatedAt: string; /** - * Continent code. A two character continent code "AF" for Africa, "AN" for Antarctica, "AS" for Asia, "EU" for Europe, "NA" for North America, "OC" for Oceania, and "SA" for South America. + * Index key. */ - continentCode: string; + key: string; /** - * Continent name. This field support localization. + * Index type. */ - continent: string; + type: string; /** - * True if country is part of the European Union. + * Index status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` */ - eu: boolean; + status: IndexStatus; /** - * Currency code in [ISO 4217-1](http://en.wikipedia.org/wiki/ISO_4217) three-character format + * Error message. Displays error generated on failure of creating or deleting an index. */ - currency: string; - } - - /** - * Locale codes list - */ - export type LocaleCodeList = { + error: string; /** - * Total number of localeCodes that matched your query. + * Index attributes. */ - total: number; + attributes: string[]; /** - * List of localeCodes. + * Index attributes length. */ - localeCodes: LocaleCode[]; + lengths: number[]; + /** + * Index orders. + */ + orders?: string[]; } /** - * Continents List + * Index */ - export type ContinentList = { + export type ColumnIndex = { /** - * Total number of continents that matched your query. + * Index ID. */ - total: number; + $id: string; /** - * List of continents. + * Index creation date in ISO 8601 format. */ - continents: Continent[]; - } - - /** - * Countries List - */ - export type CountryList = { + $createdAt: string; /** - * Total number of countries that matched your query. + * Index update date in ISO 8601 format. */ - total: number; + $updatedAt: string; /** - * List of countries. + * Index Key. */ - countries: Country[]; - } - - /** - * Phones List - */ - export type PhoneList = { + key: string; /** - * Total number of phones that matched your query. + * Index type. */ - total: number; + type: string; /** - * List of phones. + * Index status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` */ - phones: Phone[]; - } - - /** - * Currencies List - */ - export type CurrencyList = { + status: string; /** - * Total number of currencies that matched your query. + * Error message. Displays error generated on failure of creating or deleting an index. */ - total: number; + error: string; /** - * List of currencies. + * Index columns. */ - currencies: Currency[]; + columns: string[]; + /** + * Index columns length. + */ + lengths: number[]; + /** + * Index orders. + */ + orders?: string[]; } /** - * Languages List + * Row */ - export type LanguageList = { + export type Row = { /** - * Total number of languages that matched your query. + * Row ID. */ - total: number; + $id: string; /** - * List of languages. + * Row sequence ID. */ - languages: Language[]; + $sequence: string; + /** + * Table ID. + */ + $tableId: string; + /** + * Database ID. + */ + $databaseId: string; + /** + * Row creation date in ISO 8601 format. + */ + $createdAt: string; + /** + * Row update date in ISO 8601 format. + */ + $updatedAt: string; + /** + * Row permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). + */ + $permissions: string[]; } + export type DefaultRow = Row & { + [key: string]: any; + [__default]: true; + }; + /** - * Message list + * Document */ - export type MessageList = { + export type Document = { /** - * Total number of messages that matched your query. + * Document ID. */ - total: number; + $id: string; /** - * List of messages. + * Document sequence ID. */ - messages: Message[]; + $sequence: string; + /** + * Collection ID. + */ + $collectionId: string; + /** + * Database ID. + */ + $databaseId: string; + /** + * Document creation date in ISO 8601 format. + */ + $createdAt: string; + /** + * Document update date in ISO 8601 format. + */ + $updatedAt: string; + /** + * Document permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). + */ + $permissions: string[]; } + export type DefaultDocument = Document & { + [key: string]: any; + [__default]: true; + }; + /** - * Message + * Log */ - export type Message = { + export type Log = { /** - * Message ID. + * Event name. */ - $id: string; + event: string; + /** + * User ID of the actor recorded for this log. During impersonation, this is the original impersonator, not the impersonated target user. + */ + userId: string; + /** + * User email of the actor recorded for this log. During impersonation, this is the original impersonator. + */ + userEmail: string; + /** + * User name of the actor recorded for this log. During impersonation, this is the original impersonator. + */ + userName: string; + /** + * API mode when event triggered. + */ + mode: string; /** - * Message creation time in ISO 8601 format. + * IP session in use when the session was created. */ - $createdAt: string; + ip: string; /** - * Message update date in ISO 8601 format. + * Log creation date in ISO 8601 format. */ - $updatedAt: string; + time: string; /** - * Message provider type. + * Operating system code name. View list of [available options](https://github.com/appwrite/appwrite/blob/master/docs/lists/os.json). */ - providerType: string; + osCode: string; /** - * Topic IDs set as recipients. + * Operating system name. */ - topics: string[]; + osName: string; /** - * User IDs set as recipients. + * Operating system version. */ - users: string[]; + osVersion: string; /** - * Target IDs set as recipients. + * Client type. */ - targets: string[]; + clientType: string; /** - * The scheduled time for message. + * Client code name. View list of [available options](https://github.com/appwrite/appwrite/blob/master/docs/lists/clients.json). */ - scheduledAt?: string; + clientCode: string; /** - * The time when the message was delivered. + * Client name. */ - deliveredAt?: string; + clientName: string; /** - * Delivery errors if any. + * Client version. */ - deliveryErrors?: string[]; + clientVersion: string; /** - * Number of recipients the message was delivered to. + * Client engine name. */ - deliveredTotal: number; + clientEngine: string; /** - * Data of the message. + * Client engine name. */ - data: object; + clientEngineVersion: string; /** - * Status of delivery. + * Device name. */ - status: MessageStatus; - } - - /** - * Target list - */ - export type TargetList = { + deviceName: string; /** - * Total number of targets that matched your query. + * Device brand name. */ - total: number; + deviceBrand: string; /** - * List of targets. + * Device model name. */ - targets: Target[]; - } - - /** - * Provider list - */ - export type ProviderList = { + deviceModel: string; /** - * Total number of providers that matched your query. + * Country two-character ISO 3166-1 alpha code. */ - total: number; + countryCode: string; /** - * List of providers. + * Country name. */ - providers: Provider[]; + countryName: string; } /** - * Provider + * User */ - export type Provider = { + export type User = { /** - * Provider ID. + * User ID. */ $id: string; /** - * Provider creation time in ISO 8601 format. + * User creation date in ISO 8601 format. */ $createdAt: string; /** - * Provider update date in ISO 8601 format. + * User update date in ISO 8601 format. */ $updatedAt: string; /** - * The name for the provider instance. + * User name. */ name: string; /** - * The name of the provider service. + * Hashed user password. */ - provider: string; + password?: string; /** - * Is provider enabled? + * Password hashing algorithm. */ - enabled: boolean; + hash?: string; /** - * Type of provider. + * Password hashing algorithm configuration. */ - type: string; + hashOptions?: object; /** - * Provider credentials. + * User registration date in ISO 8601 format. */ - credentials: object; + registration: string; /** - * Provider options. + * User status. Pass `true` for enabled and `false` for disabled. */ - options?: object; - } - - /** - * Topic list - */ - export type TopicList = { + status: boolean; /** - * Total number of topics that matched your query. + * Labels for the user. */ - total: number; + labels: string[]; /** - * List of topics. + * Password update time in ISO 8601 format. */ - topics: Topic[]; - } - - /** - * Topic - */ - export type Topic = { + passwordUpdate: string; /** - * Topic ID. + * User email address. */ - $id: string; + email: string; /** - * Topic creation time in ISO 8601 format. + * User phone number in E.164 format. */ - $createdAt: string; + phone: string; /** - * Topic update date in ISO 8601 format. + * Email verification status. */ - $updatedAt: string; + emailVerification: boolean; /** - * The name of the topic. + * Phone verification status. */ - name: string; + phoneVerification: boolean; /** - * Total count of email subscribers subscribed to the topic. + * Multi factor authentication status. */ - emailTotal: number; + mfa: boolean; /** - * Total count of SMS subscribers subscribed to the topic. + * User preferences as a key-value object */ - smsTotal: number; + prefs: Preferences; /** - * Total count of push subscribers subscribed to the topic. + * A user-owned message receiver. A single user may have multiple e.g. emails, phones, and a browser. Each target is registered with a single provider. */ - pushTotal: number; + targets: Target[]; /** - * Subscribe permissions. + * Most recent access date in ISO 8601 format. This attribute is only updated again after 24 hours. */ - subscribe: string[]; + accessedAt: string; + /** + * Whether the user can impersonate other users. + */ + impersonator?: boolean; + /** + * ID of the original actor performing the impersonation. Present only when the current request is impersonating another user. Internal audit logs attribute the action to this user, while the impersonated target is recorded only in internal audit payload data. + */ + impersonatorUserId?: string; } /** - * Subscriber list + * AlgoMD5 */ - export type SubscriberList = { + export type AlgoMd5 = { /** - * Total number of subscribers that matched your query. + * Algo type. */ - total: number; + type: string; + } + + /** + * AlgoSHA + */ + export type AlgoSha = { /** - * List of subscribers. + * Algo type. */ - subscribers: Subscriber[]; + type: string; } /** - * Subscriber + * AlgoPHPass */ - export type Subscriber = { + export type AlgoPhpass = { /** - * Subscriber ID. + * Algo type. */ - $id: string; + type: string; + } + + /** + * AlgoBcrypt + */ + export type AlgoBcrypt = { /** - * Subscriber creation time in ISO 8601 format. + * Algo type. */ - $createdAt: string; + type: string; + } + + /** + * AlgoScrypt + */ + export type AlgoScrypt = { /** - * Subscriber update date in ISO 8601 format. + * Algo type. */ - $updatedAt: string; + type: string; /** - * Target ID. + * CPU complexity of computed hash. */ - targetId: string; + costCpu: number; /** - * Target. + * Memory complexity of computed hash. */ - target: Target; + costMemory: number; + /** + * Parallelization of computed hash. + */ + costParallel: number; + /** + * Length used to compute hash. + */ + length: number; + } + + /** + * AlgoScryptModified + */ + export type AlgoScryptModified = { + /** + * Algo type. + */ + type: string; + /** + * Salt used to compute hash. + */ + salt: string; + /** + * Separator used to compute hash. + */ + saltSeparator: string; + /** + * Key used to compute hash. + */ + signerKey: string; + } + + /** + * AlgoArgon2 + */ + export type AlgoArgon2 = { /** - * Topic ID. + * Algo type. */ - userId: string; + type: string; /** - * User Name. + * Memory used to compute hash. */ - userName: string; + memoryCost: number; /** - * Topic ID. + * Amount of time consumed to compute hash */ - topicId: string; + timeCost: number; /** - * The target provider type. Can be one of the following: `email`, `sms` or `push`. + * Number of threads used to compute hash. */ - providerType: string; + threads: number; } /** - * Sites List + * Preferences */ - export type SiteList = { - /** - * Total number of sites that matched your query. - */ - total: number; - /** - * List of sites. - */ - sites: Site[]; + export type Preferences = { } + export type DefaultPreferences = Preferences & { + [key: string]: any; + [__default]: true; + }; + /** - * Site + * Session */ - export type Site = { + export type Session = { /** - * Site ID. + * Session ID. */ $id: string; /** - * Site creation date in ISO 8601 format. + * Session creation date in ISO 8601 format. */ $createdAt: string; /** - * Site update date in ISO 8601 format. + * Session update date in ISO 8601 format. */ $updatedAt: string; /** - * Site name. + * User ID. */ - name: string; + userId: string; /** - * Site enabled. + * Session expiration date in ISO 8601 format. */ - enabled: boolean; + expire: string; /** - * Is the site deployed with the latest configuration? This is set to false if you've changed an environment variables, entrypoint, commands, or other settings that needs redeploy to be applied. When the value is false, redeploy the site to update it with the latest configuration. + * Session Provider. */ - live: boolean; + provider: string; /** - * When disabled, request logs will exclude logs and errors, and site responses will be slightly faster. + * Session Provider User ID. */ - logging: boolean; + providerUid: string; /** - * Site framework. + * Session Provider Access Token. */ - framework: string; + providerAccessToken: string; /** - * How many days to keep the non-active deployments before they will be automatically deleted. + * The date of when the access token expires in ISO 8601 format. */ - deploymentRetention: number; + providerAccessTokenExpiry: string; /** - * Site's active deployment ID. + * Session Provider Refresh Token. */ - deploymentId: string; + providerRefreshToken: string; /** - * Active deployment creation date in ISO 8601 format. + * IP in use when the session was created. */ - deploymentCreatedAt: string; + ip: string; /** - * Screenshot of active deployment with light theme preference file ID. + * Operating system code name. View list of [available options](https://github.com/appwrite/appwrite/blob/master/docs/lists/os.json). */ - deploymentScreenshotLight: string; + osCode: string; /** - * Screenshot of active deployment with dark theme preference file ID. + * Operating system name. */ - deploymentScreenshotDark: string; + osName: string; /** - * Site's latest deployment ID. + * Operating system version. */ - latestDeploymentId: string; + osVersion: string; /** - * Latest deployment creation date in ISO 8601 format. + * Client type. */ - latestDeploymentCreatedAt: string; + clientType: string; /** - * Status of latest deployment. Possible values are "waiting", "processing", "building", "ready", and "failed". + * Client code name. View list of [available options](https://github.com/appwrite/appwrite/blob/master/docs/lists/clients.json). */ - latestDeploymentStatus: string; + clientCode: string; /** - * Site variables. + * Client name. */ - vars: Variable[]; + clientName: string; /** - * Site request timeout in seconds. + * Client version. */ - timeout: number; + clientVersion: string; /** - * The install command used to install the site dependencies. + * Client engine name. */ - installCommand: string; + clientEngine: string; /** - * The build command used to build the site. + * Client engine name. */ - buildCommand: string; + clientEngineVersion: string; /** - * Custom command to use when starting site runtime. + * Device name. */ - startCommand: string; + deviceName: string; /** - * The directory where the site build output is located. + * Device brand name. */ - outputDirectory: string; + deviceBrand: string; /** - * Site VCS (Version Control System) installation id. + * Device model name. */ - installationId: string; + deviceModel: string; /** - * VCS (Version Control System) Repository ID + * Country two-character ISO 3166-1 alpha code. */ - providerRepositoryId: string; + countryCode: string; /** - * VCS (Version Control System) branch name + * Country name. */ - providerBranch: string; + countryName: string; /** - * Path to site in VCS (Version Control System) repository + * Returns true if this the current user session. */ - providerRootDirectory: string; + current: boolean; /** - * Is VCS (Version Control System) connection is in silent mode? When in silence mode, no comments will be posted on the repository pull or merge requests + * Returns a list of active session factors. */ - providerSilentMode: boolean; + factors: string[]; /** - * Machine specification for deployment builds. + * Secret used to authenticate the user. Only included if the request was made with an API key */ - buildSpecification: string; + secret: string; /** - * Machine specification for SSR executions. + * Most recent date in ISO 8601 format when the session successfully passed MFA challenge. */ - runtimeSpecification: string; + mfaUpdatedAt: string; + } + + /** + * Identity + */ + export type Identity = { /** - * Site build runtime. + * Identity ID. */ - buildRuntime: string; + $id: string; /** - * Site framework adapter. + * Identity creation date in ISO 8601 format. */ - adapter: string; + $createdAt: string; /** - * Name of fallback file to use instead of 404 page. If null, Appwrite 404 page will be displayed. + * Identity update date in ISO 8601 format. */ - fallbackFile: string; - } - - /** - * Frameworks List - */ - export type FrameworkList = { + $updatedAt: string; /** - * Total number of frameworks that matched your query. + * User ID. */ - total: number; + userId: string; /** - * List of frameworks. + * Identity Provider. */ - frameworks: Framework[]; - } - - /** - * Buckets List - */ - export type BucketList = { + provider: string; /** - * Total number of buckets that matched your query. + * ID of the User in the Identity Provider. */ - total: number; + providerUid: string; /** - * List of buckets. + * Email of the User in the Identity Provider. */ - buckets: Bucket[]; + providerEmail: string; + /** + * Identity Provider Access Token. + */ + providerAccessToken: string; + /** + * The date of when the access token expires in ISO 8601 format. + */ + providerAccessTokenExpiry: string; + /** + * Identity Provider Refresh Token. + */ + providerRefreshToken: string; } /** - * Bucket + * Token */ - export type Bucket = { + export type Token = { /** - * Bucket ID. + * Token ID. */ $id: string; /** - * Bucket creation time in ISO 8601 format. + * Token creation date in ISO 8601 format. */ $createdAt: string; /** - * Bucket update date in ISO 8601 format. + * User ID. */ - $updatedAt: string; + userId: string; /** - * Bucket permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). + * Token secret key. This will return an empty string unless the response is returned using an API key or as part of a webhook payload. */ - $permissions: string[]; + secret: string; /** - * Whether file-level security is enabled. [Learn more about permissions](https://appwrite.io/docs/permissions). + * Token expiration date in ISO 8601 format. */ - fileSecurity: boolean; + expire: string; /** - * Bucket name. + * Security phrase of a token. Empty if security phrase was not requested when creating a token. It includes randomly generated phrase which is also sent in the external resource such as email. */ - name: string; + phrase: string; + } + + /** + * JWT + */ + export type Jwt = { /** - * Bucket enabled. + * JWT encoded string. */ - enabled: boolean; + jwt: string; + } + + /** + * Locale + */ + export type Locale = { /** - * Maximum file size supported. + * User IP address. */ - maximumFileSize: number; + ip: string; /** - * Allowed file extensions. + * Country code in [ISO 3166-1](http://en.wikipedia.org/wiki/ISO_3166-1) two-character format */ - allowedFileExtensions: string[]; + countryCode: string; /** - * Compression algorithm chosen for compression. Will be one of none, [gzip](https://en.wikipedia.org/wiki/Gzip), or [zstd](https://en.wikipedia.org/wiki/Zstd). + * Country name. This field support localization. */ - compression: string; + country: string; /** - * Bucket is encrypted. + * Continent code. A two character continent code "AF" for Africa, "AN" for Antarctica, "AS" for Asia, "EU" for Europe, "NA" for North America, "OC" for Oceania, and "SA" for South America. */ - encryption: boolean; + continentCode: string; /** - * Virus scanning is enabled. + * Continent name. This field support localization. */ - antivirus: boolean; + continent: string; /** - * Image transformations are enabled. + * True if country is part of the European Union. */ - transformations: boolean; + eu: boolean; /** - * Total size of this bucket in bytes. + * Currency code in [ISO 4217-1](http://en.wikipedia.org/wiki/ISO_4217) three-character format */ - totalSize: number; + currency: string; } /** - * Files List + * LocaleCode */ - export type FileList = { + export type LocaleCode = { /** - * Total number of files that matched your query. + * Locale codes in [ISO 639-1](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes) */ - total: number; + code: string; /** - * List of files. + * Locale name */ - files: File[]; + name: string; } /** @@ -3049,1482 +3112,1447 @@ export namespace Models { } /** - * Tables List - */ - export type TableList = { - /** - * Total number of tables that matched your query. - */ - total: number; - /** - * List of tables. - */ - tables: Table[]; - } - - /** - * Table + * Bucket */ - export type Table = { + export type Bucket = { /** - * Table ID. + * Bucket ID. */ $id: string; /** - * Table creation date in ISO 8601 format. + * Bucket creation time in ISO 8601 format. */ $createdAt: string; /** - * Table update date in ISO 8601 format. + * Bucket update date in ISO 8601 format. */ $updatedAt: string; /** - * Table permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). + * Bucket permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). */ $permissions: string[]; /** - * Database ID. + * Whether file-level security is enabled. [Learn more about permissions](https://appwrite.io/docs/permissions). */ - databaseId: string; + fileSecurity: boolean; /** - * Table name. + * Bucket name. */ name: string; /** - * Table enabled. Can be 'enabled' or 'disabled'. When disabled, the table is inaccessible to users, but remains accessible to Server SDKs using API keys. + * Bucket enabled. */ enabled: boolean; /** - * Whether row-level permissions are enabled. [Learn more about permissions](https://appwrite.io/docs/permissions). + * Maximum file size supported. */ - rowSecurity: boolean; + maximumFileSize: number; /** - * Table columns. + * Allowed file extensions. */ - columns: (Models.ColumnBoolean | Models.ColumnInteger | Models.ColumnFloat | Models.ColumnEmail | Models.ColumnEnum | Models.ColumnUrl | Models.ColumnIp | Models.ColumnDatetime | Models.ColumnRelationship | Models.ColumnPoint | Models.ColumnLine | Models.ColumnPolygon | Models.ColumnVarchar | Models.ColumnText | Models.ColumnMediumtext | Models.ColumnLongtext | Models.ColumnString)[]; + allowedFileExtensions: string[]; /** - * Table indexes. + * Compression algorithm chosen for compression. Will be one of none, [gzip](https://en.wikipedia.org/wiki/Gzip), or [zstd](https://en.wikipedia.org/wiki/Zstd). */ - indexes: ColumnIndex[]; + compression: string; /** - * Maximum row size in bytes. Returns 0 when no limit applies. + * Bucket is encrypted. */ - bytesMax: number; + encryption: boolean; /** - * Currently used row size in bytes based on defined columns. + * Virus scanning is enabled. */ - bytesUsed: number; - } - - /** - * Columns List - */ - export type ColumnList = { + antivirus: boolean; /** - * Total number of columns in the given table. + * Image transformations are enabled. */ - total: number; + transformations: boolean; /** - * List of columns. + * Total size of this bucket in bytes. */ - columns: (Models.ColumnBoolean | Models.ColumnInteger | Models.ColumnFloat | Models.ColumnEmail | Models.ColumnEnum | Models.ColumnUrl | Models.ColumnIp | Models.ColumnDatetime | Models.ColumnRelationship | Models.ColumnPoint | Models.ColumnLine | Models.ColumnPolygon | Models.ColumnVarchar | Models.ColumnText | Models.ColumnMediumtext | Models.ColumnLongtext | Models.ColumnString)[]; + totalSize: number; } /** - * ColumnBoolean + * ResourceToken */ - export type ColumnBoolean = { - /** - * Column Key. - */ - key: string; - /** - * Column type. - */ - type: string; + export type ResourceToken = { /** - * Column status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` + * Token ID. */ - status: ColumnStatus; + $id: string; /** - * Error message. Displays error generated on failure of creating or deleting an column. + * Token creation date in ISO 8601 format. */ - error: string; + $createdAt: string; /** - * Is column required? + * Resource ID. */ - required: boolean; + resourceId: string; /** - * Is column an array? + * Resource type. */ - array?: boolean; + resourceType: string; /** - * Column creation date in ISO 8601 format. + * Token expiration date in ISO 8601 format. */ - $createdAt: string; + expire: string; /** - * Column update date in ISO 8601 format. + * JWT encoded string. */ - $updatedAt: string; + secret: string; /** - * Default value for column when not provided. Cannot be set when column is required. + * Most recent access date in ISO 8601 format. This attribute is only updated again after 24 hours. */ - default?: boolean; + accessedAt: string; } /** - * ColumnDatetime + * Team */ - export type ColumnDatetime = { - /** - * Column Key. - */ - key: string; + export type Team = { /** - * Column type. + * Team ID. */ - type: string; + $id: string; /** - * Column status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` + * Team creation date in ISO 8601 format. */ - status: ColumnStatus; + $createdAt: string; /** - * Error message. Displays error generated on failure of creating or deleting an column. + * Team update date in ISO 8601 format. */ - error: string; + $updatedAt: string; /** - * Is column required? + * Team name. */ - required: boolean; + name: string; /** - * Is column an array? + * Total number of team members. */ - array?: boolean; + total: number; /** - * Column creation date in ISO 8601 format. + * Team preferences as a key-value object */ - $createdAt: string; + prefs: Preferences; + } + + /** + * Membership + */ + export type Membership = { /** - * Column update date in ISO 8601 format. + * Membership ID. */ - $updatedAt: string; + $id: string; /** - * ISO 8601 format. + * Membership creation date in ISO 8601 format. */ - format: string; + $createdAt: string; /** - * Default value for column when not provided. Only null is optional + * Membership update date in ISO 8601 format. */ - default?: string; - } - - /** - * ColumnEmail - */ - export type ColumnEmail = { + $updatedAt: string; /** - * Column Key. + * User ID. */ - key: string; + userId: string; /** - * Column type. + * User name. Hide this attribute by toggling membership privacy in the Console. */ - type: string; + userName: string; /** - * Column status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` + * User email address. Hide this attribute by toggling membership privacy in the Console. */ - status: ColumnStatus; + userEmail: string; /** - * Error message. Displays error generated on failure of creating or deleting an column. + * Team ID. */ - error: string; + teamId: string; /** - * Is column required? + * Team name. */ - required: boolean; + teamName: string; /** - * Is column an array? + * Date, the user has been invited to join the team in ISO 8601 format. */ - array?: boolean; + invited: string; /** - * Column creation date in ISO 8601 format. + * Date, the user has accepted the invitation to join the team in ISO 8601 format. */ - $createdAt: string; + joined: string; /** - * Column update date in ISO 8601 format. + * User confirmation status, true if the user has joined the team or false otherwise. */ - $updatedAt: string; + confirm: boolean; /** - * String format. + * Multi factor authentication status, true if the user has MFA enabled or false otherwise. Hide this attribute by toggling membership privacy in the Console. */ - format: string; + mfa: boolean; /** - * Default value for column when not provided. Cannot be set when column is required. + * User list of roles */ - default?: string; + roles: string[]; } /** - * ColumnEnum + * Site */ - export type ColumnEnum = { - /** - * Column Key. - */ - key: string; + export type Site = { /** - * Column type. + * Site ID. */ - type: string; + $id: string; /** - * Column status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` + * Site creation date in ISO 8601 format. */ - status: ColumnStatus; + $createdAt: string; /** - * Error message. Displays error generated on failure of creating or deleting an column. + * Site update date in ISO 8601 format. */ - error: string; + $updatedAt: string; /** - * Is column required? + * Site name. */ - required: boolean; + name: string; /** - * Is column an array? + * Site enabled. */ - array?: boolean; + enabled: boolean; /** - * Column creation date in ISO 8601 format. + * Is the site deployed with the latest configuration? This is set to false if you've changed an environment variables, entrypoint, commands, or other settings that needs redeploy to be applied. When the value is false, redeploy the site to update it with the latest configuration. */ - $createdAt: string; + live: boolean; /** - * Column update date in ISO 8601 format. + * When disabled, request logs will exclude logs and errors, and site responses will be slightly faster. */ - $updatedAt: string; + logging: boolean; /** - * Array of elements in enumerated type. + * Site framework. */ - elements: string[]; + framework: string; /** - * String format. + * How many days to keep the non-active deployments before they will be automatically deleted. */ - format: string; + deploymentRetention: number; /** - * Default value for column when not provided. Cannot be set when column is required. + * Site's active deployment ID. */ - default?: string; - } - - /** - * ColumnFloat - */ - export type ColumnFloat = { + deploymentId: string; /** - * Column Key. + * Active deployment creation date in ISO 8601 format. */ - key: string; + deploymentCreatedAt: string; /** - * Column type. + * Screenshot of active deployment with light theme preference file ID. */ - type: string; + deploymentScreenshotLight: string; /** - * Column status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` + * Screenshot of active deployment with dark theme preference file ID. */ - status: ColumnStatus; + deploymentScreenshotDark: string; /** - * Error message. Displays error generated on failure of creating or deleting an column. + * Site's latest deployment ID. */ - error: string; + latestDeploymentId: string; /** - * Is column required? + * Latest deployment creation date in ISO 8601 format. */ - required: boolean; + latestDeploymentCreatedAt: string; /** - * Is column an array? + * Status of latest deployment. Possible values are "waiting", "processing", "building", "ready", and "failed". */ - array?: boolean; + latestDeploymentStatus: string; /** - * Column creation date in ISO 8601 format. + * Site variables. */ - $createdAt: string; + vars: Variable[]; /** - * Column update date in ISO 8601 format. + * Site request timeout in seconds. */ - $updatedAt: string; + timeout: number; /** - * Minimum value to enforce for new documents. + * The install command used to install the site dependencies. */ - min?: number; + installCommand: string; /** - * Maximum value to enforce for new documents. + * The build command used to build the site. */ - max?: number; + buildCommand: string; /** - * Default value for column when not provided. Cannot be set when column is required. + * Custom command to use when starting site runtime. */ - default?: number; - } - - /** - * ColumnInteger - */ - export type ColumnInteger = { + startCommand: string; /** - * Column Key. + * The directory where the site build output is located. */ - key: string; + outputDirectory: string; /** - * Column type. + * Site VCS (Version Control System) installation id. */ - type: string; + installationId: string; /** - * Column status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` + * VCS (Version Control System) Repository ID */ - status: ColumnStatus; + providerRepositoryId: string; /** - * Error message. Displays error generated on failure of creating or deleting an column. + * VCS (Version Control System) branch name */ - error: string; + providerBranch: string; /** - * Is column required? + * Path to site in VCS (Version Control System) repository */ - required: boolean; + providerRootDirectory: string; /** - * Is column an array? + * Is VCS (Version Control System) connection is in silent mode? When in silence mode, no comments will be posted on the repository pull or merge requests */ - array?: boolean; + providerSilentMode: boolean; /** - * Column creation date in ISO 8601 format. + * Machine specification for deployment builds. */ - $createdAt: string; + buildSpecification: string; /** - * Column update date in ISO 8601 format. + * Machine specification for SSR executions. */ - $updatedAt: string; + runtimeSpecification: string; /** - * Minimum value to enforce for new documents. + * Site build runtime. */ - min?: number | bigint; + buildRuntime: string; /** - * Maximum value to enforce for new documents. + * Site framework adapter. */ - max?: number | bigint; + adapter: string; /** - * Default value for column when not provided. Cannot be set when column is required. + * Name of fallback file to use instead of 404 page. If null, Appwrite 404 page will be displayed. */ - default?: number; + fallbackFile: string; } /** - * ColumnIP + * Function */ - export type ColumnIp = { + export type Function = { /** - * Column Key. + * Function ID. */ - key: string; + $id: string; /** - * Column type. + * Function creation date in ISO 8601 format. */ - type: string; + $createdAt: string; /** - * Column status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` + * Function update date in ISO 8601 format. */ - status: ColumnStatus; + $updatedAt: string; /** - * Error message. Displays error generated on failure of creating or deleting an column. + * Execution permissions. */ - error: string; + execute: string[]; /** - * Is column required? + * Function name. */ - required: boolean; + name: string; /** - * Is column an array? + * Function enabled. */ - array?: boolean; + enabled: boolean; /** - * Column creation date in ISO 8601 format. + * Is the function deployed with the latest configuration? This is set to false if you've changed an environment variables, entrypoint, commands, or other settings that needs redeploy to be applied. When the value is false, redeploy the function to update it with the latest configuration. */ - $createdAt: string; + live: boolean; /** - * Column update date in ISO 8601 format. + * When disabled, executions will exclude logs and errors, and will be slightly faster. */ - $updatedAt: string; + logging: boolean; /** - * String format. + * Function execution and build runtime. */ - format: string; + runtime: string; /** - * Default value for column when not provided. Cannot be set when column is required. + * How many days to keep the non-active deployments before they will be automatically deleted. */ - default?: string; - } - - /** - * ColumnLine - */ - export type ColumnLine = { + deploymentRetention: number; /** - * Column Key. + * Function's active deployment ID. */ - key: string; + deploymentId: string; /** - * Column type. + * Active deployment creation date in ISO 8601 format. */ - type: string; + deploymentCreatedAt: string; /** - * Column status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` + * Function's latest deployment ID. */ - status: ColumnStatus; + latestDeploymentId: string; /** - * Error message. Displays error generated on failure of creating or deleting an column. + * Latest deployment creation date in ISO 8601 format. */ - error: string; + latestDeploymentCreatedAt: string; /** - * Is column required? + * Status of latest deployment. Possible values are "waiting", "processing", "building", "ready", and "failed". */ - required: boolean; + latestDeploymentStatus: string; /** - * Is column an array? + * Allowed permission scopes. */ - array?: boolean; + scopes: string[]; /** - * Column creation date in ISO 8601 format. + * Function variables. */ - $createdAt: string; + vars: Variable[]; /** - * Column update date in ISO 8601 format. + * Function trigger events. */ - $updatedAt: string; + events: string[]; /** - * Default value for column when not provided. Cannot be set when column is required. + * Function execution schedule in CRON format. */ - default?: any[]; - } - - /** - * ColumnLongtext - */ - export type ColumnLongtext = { + schedule: string; /** - * Column Key. + * Function execution timeout in seconds. */ - key: string; + timeout: number; /** - * Column type. + * The entrypoint file used to execute the deployment. */ - type: string; + entrypoint: string; /** - * Column status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` + * The build command used to build the deployment. */ - status: ColumnStatus; + commands: string; /** - * Error message. Displays error generated on failure of creating or deleting an column. + * Version of Open Runtimes used for the function. */ - error: string; + version: string; /** - * Is column required? + * Function VCS (Version Control System) installation id. */ - required: boolean; + installationId: string; /** - * Is column an array? + * VCS (Version Control System) Repository ID */ - array?: boolean; + providerRepositoryId: string; /** - * Column creation date in ISO 8601 format. + * VCS (Version Control System) branch name */ - $createdAt: string; + providerBranch: string; /** - * Column update date in ISO 8601 format. + * Path to function in VCS (Version Control System) repository */ - $updatedAt: string; + providerRootDirectory: string; /** - * Default value for column when not provided. Cannot be set when column is required. + * Is VCS (Version Control System) connection is in silent mode? When in silence mode, no comments will be posted on the repository pull or merge requests + */ + providerSilentMode: boolean; + /** + * Machine specification for deployment builds. */ - default?: string; + buildSpecification: string; /** - * Defines whether this column is encrypted or not. + * Machine specification for executions. */ - encrypt?: boolean; + runtimeSpecification: string; } /** - * ColumnMediumtext + * Runtime */ - export type ColumnMediumtext = { + export type Runtime = { /** - * Column Key. + * Runtime ID. + */ + $id: string; + /** + * Parent runtime key. */ key: string; /** - * Column type. + * Runtime Name. */ - type: string; + name: string; /** - * Column status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` + * Runtime version. */ - status: ColumnStatus; + version: string; /** - * Error message. Displays error generated on failure of creating or deleting an column. + * Base Docker image used to build the runtime. */ - error: string; + base: string; /** - * Is column required? + * Image name of Docker Hub. */ - required: boolean; + image: string; /** - * Is column an array? + * Name of the logo image. */ - array?: boolean; + logo: string; /** - * Column creation date in ISO 8601 format. + * List of supported architectures. */ - $createdAt: string; + supports: string[]; + } + + /** + * Framework + */ + export type Framework = { /** - * Column update date in ISO 8601 format. + * Framework key. */ - $updatedAt: string; + key: string; /** - * Default value for column when not provided. Cannot be set when column is required. + * Framework Name. */ - default?: string; + name: string; /** - * Defines whether this column is encrypted or not. + * Default runtime version. */ - encrypt?: boolean; + buildRuntime: string; + /** + * List of supported runtime versions. + */ + runtimes: string[]; + /** + * List of supported adapters. + */ + adapters: FrameworkAdapter[]; } /** - * ColumnPoint + * Framework Adapter */ - export type ColumnPoint = { + export type FrameworkAdapter = { /** - * Column Key. + * Adapter key. */ key: string; /** - * Column type. + * Default command to download dependencies. */ - type: string; + installCommand: string; /** - * Column status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` + * Default command to build site into output directory. */ - status: ColumnStatus; + buildCommand: string; /** - * Error message. Displays error generated on failure of creating or deleting an column. + * Default output directory of build. */ - error: string; + outputDirectory: string; /** - * Is column required? + * Name of fallback file to use instead of 404 page. If null, Appwrite 404 page will be displayed. */ - required: boolean; + fallbackFile: string; + } + + /** + * Deployment + */ + export type Deployment = { /** - * Is column an array? + * Deployment ID. */ - array?: boolean; + $id: string; /** - * Column creation date in ISO 8601 format. + * Deployment creation date in ISO 8601 format. */ $createdAt: string; /** - * Column update date in ISO 8601 format. + * Deployment update date in ISO 8601 format. */ $updatedAt: string; /** - * Default value for column when not provided. Cannot be set when column is required. + * Type of deployment. */ - default?: any[]; - } - - /** - * ColumnPolygon - */ - export type ColumnPolygon = { + type: string; /** - * Column Key. + * Resource ID. */ - key: string; + resourceId: string; /** - * Column type. + * Resource type. */ - type: string; + resourceType: string; /** - * Column status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` + * The entrypoint file to use to execute the deployment code. */ - status: ColumnStatus; + entrypoint: string; /** - * Error message. Displays error generated on failure of creating or deleting an column. + * The code size in bytes. */ - error: string; + sourceSize: number; /** - * Is column required? + * The build output size in bytes. */ - required: boolean; + buildSize: number; /** - * Is column an array? + * The total size in bytes (source and build output). */ - array?: boolean; + totalSize: number; /** - * Column creation date in ISO 8601 format. + * The current build ID. */ - $createdAt: string; + buildId: string; /** - * Column update date in ISO 8601 format. + * Whether the deployment should be automatically activated. */ - $updatedAt: string; + activate: boolean; /** - * Default value for column when not provided. Cannot be set when column is required. + * Screenshot with light theme preference file ID. */ - default?: any[]; - } - - /** - * ColumnRelationship - */ - export type ColumnRelationship = { + screenshotLight: string; /** - * Column Key. + * Screenshot with dark theme preference file ID. */ - key: string; + screenshotDark: string; /** - * Column type. + * The deployment status. Possible values are "waiting", "processing", "building", "ready", "canceled" and "failed". */ - type: string; + status: DeploymentStatus; /** - * Column status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` + * The build logs. */ - status: ColumnStatus; + buildLogs: string; /** - * Error message. Displays error generated on failure of creating or deleting an column. + * The current build time in seconds. */ - error: string; + buildDuration: number; /** - * Is column required? + * The name of the vcs provider repository */ - required: boolean; + providerRepositoryName: string; /** - * Is column an array? + * The name of the vcs provider repository owner */ - array?: boolean; + providerRepositoryOwner: string; /** - * Column creation date in ISO 8601 format. + * The url of the vcs provider repository */ - $createdAt: string; + providerRepositoryUrl: string; /** - * Column update date in ISO 8601 format. + * The commit hash of the vcs commit */ - $updatedAt: string; + providerCommitHash: string; /** - * The ID of the related table. + * The url of vcs commit author */ - relatedTable: string; + providerCommitAuthorUrl: string; /** - * The type of the relationship. + * The name of vcs commit author */ - relationType: string; + providerCommitAuthor: string; /** - * Is the relationship two-way? + * The commit message */ - twoWay: boolean; + providerCommitMessage: string; /** - * The key of the two-way relationship. + * The url of the vcs commit */ - twoWayKey: string; + providerCommitUrl: string; /** - * How deleting the parent document will propagate to child documents. + * The branch of the vcs repository */ - onDelete: string; + providerBranch: string; /** - * Whether this is the parent or child side of the relationship + * The branch of the vcs repository */ - side: string; + providerBranchUrl: string; } /** - * ColumnString + * Execution */ - export type ColumnString = { - /** - * Column Key. - */ - key: string; - /** - * Column type. - */ - type: string; - /** - * Column status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` - */ - status: ColumnStatus; + export type Execution = { /** - * Error message. Displays error generated on failure of creating or deleting an column. + * Execution ID. */ - error: string; + $id: string; /** - * Is column required? + * Execution creation date in ISO 8601 format. */ - required: boolean; + $createdAt: string; /** - * Is column an array? + * Execution update date in ISO 8601 format. */ - array?: boolean; + $updatedAt: string; /** - * Column creation date in ISO 8601 format. + * Execution roles. */ - $createdAt: string; + $permissions: string[]; /** - * Column update date in ISO 8601 format. + * Function ID. */ - $updatedAt: string; + functionId: string; /** - * Column size. + * Function's deployment ID used to create the execution. */ - size: number; + deploymentId: string; /** - * Default value for column when not provided. Cannot be set when column is required. + * The trigger that caused the function to execute. Possible values can be: `http`, `schedule`, or `event`. */ - default?: string; + trigger: ExecutionTrigger; /** - * Defines whether this column is encrypted or not. + * The status of the function execution. Possible values can be: `waiting`, `processing`, `completed`, `failed`, or `scheduled`. */ - encrypt?: boolean; - } - - /** - * ColumnText - */ - export type ColumnText = { + status: ExecutionStatus; /** - * Column Key. + * HTTP request method type. */ - key: string; + requestMethod: string; /** - * Column type. + * HTTP request path and query. */ - type: string; + requestPath: string; /** - * Column status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` + * HTTP request headers as a key-value object. This will return only whitelisted headers. All headers are returned if execution is created as synchronous. */ - status: ColumnStatus; + requestHeaders: Headers[]; /** - * Error message. Displays error generated on failure of creating or deleting an column. + * HTTP response status code. */ - error: string; + responseStatusCode: number; /** - * Is column required? + * HTTP response body. This will return empty unless execution is created as synchronous. */ - required: boolean; + responseBody: string; /** - * Is column an array? + * HTTP response headers as a key-value object. This will return only whitelisted headers. All headers are returned if execution is created as synchronous. */ - array?: boolean; + responseHeaders: Headers[]; /** - * Column creation date in ISO 8601 format. + * Function logs. Includes the last 4,000 characters. This will return an empty string unless the response is returned using an API key or as part of a webhook payload. */ - $createdAt: string; + logs: string; /** - * Column update date in ISO 8601 format. + * Function errors. Includes the last 4,000 characters. This will return an empty string unless the response is returned using an API key or as part of a webhook payload. */ - $updatedAt: string; + errors: string; /** - * Default value for column when not provided. Cannot be set when column is required. + * Resource(function/site) execution duration in seconds. */ - default?: string; + duration: number; /** - * Defines whether this column is encrypted or not. + * The scheduled time for execution. If left empty, execution will be queued immediately. */ - encrypt?: boolean; + scheduledAt?: string; } /** - * ColumnURL + * Webhook */ - export type ColumnUrl = { + export type Webhook = { /** - * Column Key. + * Webhook ID. */ - key: string; + $id: string; /** - * Column type. + * Webhook creation date in ISO 8601 format. */ - type: string; + $createdAt: string; /** - * Column status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` + * Webhook update date in ISO 8601 format. */ - status: ColumnStatus; + $updatedAt: string; /** - * Error message. Displays error generated on failure of creating or deleting an column. + * Webhook name. */ - error: string; + name: string; /** - * Is column required? + * Webhook URL endpoint. */ - required: boolean; + url: string; /** - * Is column an array? + * Webhook trigger events. */ - array?: boolean; + events: string[]; /** - * Column creation date in ISO 8601 format. + * Indicated if SSL / TLS Certificate verification is enabled. */ - $createdAt: string; + security: boolean; /** - * Column update date in ISO 8601 format. + * HTTP basic authentication username. */ - $updatedAt: string; + httpUser: string; /** - * String format. + * HTTP basic authentication password. */ - format: string; + httpPass: string; /** - * Default value for column when not provided. Cannot be set when column is required. + * Signature key which can be used to validated incoming */ - default?: string; - } - - /** - * ColumnVarchar - */ - export type ColumnVarchar = { + signatureKey: string; /** - * Column Key. + * Indicates if this webhook is enabled. */ - key: string; + enabled: boolean; /** - * Column type. + * Webhook error logs from the most recent failure. */ - type: string; + logs: string; /** - * Column status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` + * Number of consecutive failed webhook attempts. */ - status: ColumnStatus; + attempts: number; + } + + /** + * Variable + */ + export type Variable = { /** - * Error message. Displays error generated on failure of creating or deleting an column. + * Variable ID. */ - error: string; + $id: string; /** - * Is column required? + * Variable creation date in ISO 8601 format. */ - required: boolean; + $createdAt: string; /** - * Is column an array? + * Variable creation date in ISO 8601 format. */ - array?: boolean; + $updatedAt: string; /** - * Column creation date in ISO 8601 format. + * Variable key. */ - $createdAt: string; + key: string; /** - * Column update date in ISO 8601 format. + * Variable value. */ - $updatedAt: string; + value: string; /** - * Column size. + * Variable secret flag. Secret variables can only be updated or deleted, but never read. */ - size: number; + secret: boolean; /** - * Default value for column when not provided. Cannot be set when column is required. + * Service to which the variable belongs. Possible values are "project", "function" */ - default?: string; + resourceType: string; /** - * Defines whether this column is encrypted or not. + * ID of resource to which the variable belongs. If resourceType is "project", it is empty. If resourceType is "function", it is ID of the function. */ - encrypt?: boolean; + resourceId: string; } /** - * Column Indexes List + * Country */ - export type ColumnIndexList = { + export type Country = { /** - * Total number of indexes that matched your query. + * Country name. */ - total: number; + name: string; /** - * List of indexes. + * Country two-character ISO 3166-1 alpha code. */ - indexes: ColumnIndex[]; + code: string; } /** - * Index + * Continent */ - export type ColumnIndex = { + export type Continent = { /** - * Index ID. + * Continent name. */ - $id: string; + name: string; /** - * Index creation date in ISO 8601 format. + * Continent two letter code. */ - $createdAt: string; + code: string; + } + + /** + * Language + */ + export type Language = { /** - * Index update date in ISO 8601 format. + * Language name. */ - $updatedAt: string; + name: string; /** - * Index Key. + * Language two-character ISO 639-1 codes. */ - key: string; + code: string; /** - * Index type. + * Language native name. */ - type: string; + nativeName: string; + } + + /** + * Currency + */ + export type Currency = { /** - * Index status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` + * Currency symbol. */ - status: string; + symbol: string; /** - * Error message. Displays error generated on failure of creating or deleting an index. + * Currency name. */ - error: string; + name: string; /** - * Index columns. + * Currency native symbol. */ - columns: string[]; + symbolNative: string; /** - * Index columns length. + * Number of decimal digits. */ - lengths: number[]; + decimalDigits: number; /** - * Index orders. + * Currency digit rounding. */ - orders?: string[]; - } - - /** - * Rows List - */ - export type RowList = { + rounding: number; /** - * Total number of rows that matched your query. + * Currency code in [ISO 4217-1](http://en.wikipedia.org/wiki/ISO_4217) three-character format. */ - total: number; + code: string; /** - * List of rows. + * Currency plural name */ - rows: Row[]; + namePlural: string; } /** - * Row + * Phone */ - export type Row = { - /** - * Row ID. - */ - $id: string; + export type Phone = { /** - * Row sequence ID. + * Phone code. */ - $sequence: string; + code: string; /** - * Table ID. + * Country two-character ISO 3166-1 alpha code. */ - $tableId: string; + countryCode: string; /** - * Database ID. + * Country name. */ - $databaseId: string; + countryName: string; + } + + /** + * Health Antivirus + */ + export type HealthAntivirus = { /** - * Row creation date in ISO 8601 format. + * Antivirus version. */ - $createdAt: string; + version: string; /** - * Row update date in ISO 8601 format. + * Antivirus status. Possible values are: `disabled`, `offline`, `online` */ - $updatedAt: string; + status: HealthAntivirusStatus; + } + + /** + * Health Queue + */ + export type HealthQueue = { /** - * Row permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). + * Amount of actions in the queue. */ - $permissions: string[]; + size: number; } - export type DefaultRow = Row & { - [key: string]: any; - [__default]: true; - }; - /** - * Teams List + * Health Status */ - export type TeamList = { + export type HealthStatus = { /** - * Total number of teams that matched your query. + * Name of the service. */ - total: number; + name: string; /** - * List of teams. + * Duration in milliseconds how long the health check took. */ - teams: Team[]; + ping: number; + /** + * Service status. Possible values are: `pass`, `fail` + */ + status: HealthCheckStatus; } /** - * Team + * Health Certificate */ - export type Team = { + export type HealthCertificate = { /** - * Team ID. + * Certificate name */ - $id: string; + name: string; /** - * Team creation date in ISO 8601 format. + * Subject SN */ - $createdAt: string; + subjectSN: string; /** - * Team update date in ISO 8601 format. + * Issuer organisation */ - $updatedAt: string; + issuerOrganisation: string; /** - * Team name. + * Valid from */ - name: string; + validFrom: string; /** - * Total number of team members. + * Valid to */ - total: number; + validTo: string; /** - * Team preferences as a key-value object + * Signature type SN */ - prefs: Preferences; + signatureTypeSN: string; } /** - * Memberships List + * Health Time */ - export type MembershipList = { + export type HealthTime = { /** - * Total number of memberships that matched your query. + * Current unix timestamp on trustful remote server. */ - total: number; + remoteTime: number; /** - * List of memberships. + * Current unix timestamp of local server where Appwrite runs. */ - memberships: Membership[]; + localTime: number; + /** + * Difference of unix remote and local timestamps in milliseconds. + */ + diff: number; } /** - * Membership + * Headers */ - export type Membership = { + export type Headers = { /** - * Membership ID. + * Header name. */ - $id: string; + name: string; /** - * Membership creation date in ISO 8601 format. + * Header value. */ - $createdAt: string; + value: string; + } + + /** + * Specification + */ + export type Specification = { /** - * Membership update date in ISO 8601 format. + * Memory size in MB. */ - $updatedAt: string; + memory: number; /** - * User ID. + * Number of CPUs. */ - userId: string; + cpus: number; /** - * User name. Hide this attribute by toggling membership privacy in the Console. + * Is size enabled. */ - userName: string; + enabled: boolean; /** - * User email address. Hide this attribute by toggling membership privacy in the Console. + * Size slug. */ - userEmail: string; + slug: string; + } + + /** + * MFA Challenge + */ + export type MfaChallenge = { /** - * Team ID. + * Token ID. */ - teamId: string; + $id: string; /** - * Team name. + * Token creation date in ISO 8601 format. */ - teamName: string; + $createdAt: string; /** - * Date, the user has been invited to join the team in ISO 8601 format. + * User ID. */ - invited: string; + userId: string; /** - * Date, the user has accepted the invitation to join the team in ISO 8601 format. + * Token expiration date in ISO 8601 format. */ - joined: string; + expire: string; + } + + /** + * MFA Recovery Codes + */ + export type MfaRecoveryCodes = { /** - * User confirmation status, true if the user has joined the team or false otherwise. + * Recovery codes. */ - confirm: boolean; + recoveryCodes: string[]; + } + + /** + * MFAType + */ + export type MfaType = { /** - * Multi factor authentication status, true if the user has MFA enabled or false otherwise. Hide this attribute by toggling membership privacy in the Console. + * Secret token used for TOTP factor. */ - mfa: boolean; + secret: string; /** - * User list of roles + * URI for authenticator apps. */ - roles: string[]; + uri: string; } /** - * Resource Tokens List + * MFAFactors */ - export type ResourceTokenList = { + export type MfaFactors = { /** - * Total number of tokens that matched your query. + * Can TOTP be used for MFA challenge for this account. */ - total: number; + totp: boolean; /** - * List of tokens. + * Can phone (SMS) be used for MFA challenge for this account. */ - tokens: ResourceToken[]; + phone: boolean; + /** + * Can email be used for MFA challenge for this account. + */ + email: boolean; + /** + * Can recovery code be used for MFA challenge for this account. + */ + recoveryCode: boolean; } /** - * ResourceToken + * Provider */ - export type ResourceToken = { + export type Provider = { /** - * Token ID. + * Provider ID. */ $id: string; /** - * Token creation date in ISO 8601 format. + * Provider creation time in ISO 8601 format. */ $createdAt: string; /** - * Resource ID. + * Provider update date in ISO 8601 format. */ - resourceId: string; + $updatedAt: string; /** - * Resource type. + * The name for the provider instance. */ - resourceType: string; + name: string; /** - * Token expiration date in ISO 8601 format. + * The name of the provider service. */ - expire: string; + provider: string; /** - * JWT encoded string. + * Is provider enabled? */ - secret: string; + enabled: boolean; /** - * Most recent access date in ISO 8601 format. This attribute is only updated again after 24 hours. + * Type of provider. */ - accessedAt: string; - } - - /** - * Users List - */ - export type UserList = { + type: string; /** - * Total number of users that matched your query. + * Provider credentials. */ - total: number; + credentials: object; /** - * List of users. + * Provider options. */ - users: User[]; + options?: object; } /** - * Target + * Message */ - export type Target = { + export type Message = { /** - * Target ID. + * Message ID. */ $id: string; /** - * Target creation time in ISO 8601 format. + * Message creation time in ISO 8601 format. */ $createdAt: string; /** - * Target update date in ISO 8601 format. + * Message update date in ISO 8601 format. */ $updatedAt: string; /** - * Target Name. + * Message provider type. */ - name: string; + providerType: string; /** - * User ID. + * Topic IDs set as recipients. */ - userId: string; + topics: string[]; /** - * Provider ID. + * User IDs set as recipients. */ - providerId?: string; + users: string[]; + /** + * Target IDs set as recipients. + */ + targets: string[]; + /** + * The scheduled time for message. + */ + scheduledAt?: string; /** - * The target provider type. Can be one of the following: `email`, `sms` or `push`. + * The time when the message was delivered. */ - providerType: string; + deliveredAt?: string; /** - * The target identifier. + * Delivery errors if any. */ - identifier: string; + deliveryErrors?: string[]; /** - * Is the target expired. + * Number of recipients the message was delivered to. */ - expired: boolean; - } - - /** - * Webhooks List - */ - export type WebhookList = { + deliveredTotal: number; /** - * Total number of webhooks that matched your query. + * Data of the message. */ - total: number; + data: object; /** - * List of webhooks. + * Status of delivery. */ - webhooks: Webhook[]; + status: MessageStatus; } /** - * Webhook + * Topic */ - export type Webhook = { + export type Topic = { /** - * Webhook ID. + * Topic ID. */ $id: string; /** - * Webhook creation date in ISO 8601 format. + * Topic creation time in ISO 8601 format. */ $createdAt: string; /** - * Webhook update date in ISO 8601 format. + * Topic update date in ISO 8601 format. */ $updatedAt: string; /** - * Webhook name. + * The name of the topic. */ name: string; /** - * Webhook URL endpoint. + * Total count of email subscribers subscribed to the topic. */ - url: string; + emailTotal: number; /** - * Webhook trigger events. + * Total count of SMS subscribers subscribed to the topic. */ - events: string[]; + smsTotal: number; /** - * Indicated if SSL / TLS Certificate verification is enabled. + * Total count of push subscribers subscribed to the topic. */ - security: boolean; + pushTotal: number; /** - * HTTP basic authentication username. + * Subscribe permissions. */ - httpUser: string; + subscribe: string[]; + } + + /** + * Transaction + */ + export type Transaction = { /** - * HTTP basic authentication password. + * Transaction ID. */ - httpPass: string; + $id: string; /** - * Signature key which can be used to validated incoming + * Transaction creation time in ISO 8601 format. */ - signatureKey: string; + $createdAt: string; /** - * Indicates if this webhook is enabled. + * Transaction update date in ISO 8601 format. */ - enabled: boolean; + $updatedAt: string; /** - * Webhook error logs from the most recent failure. + * Current status of the transaction. One of: pending, committing, committed, rolled_back, failed. */ - logs: string; + status: string; /** - * Number of consecutive failed webhook attempts. + * Number of operations in the transaction. */ - attempts: number; + operations: number; + /** + * Expiration time in ISO 8601 format. + */ + expiresAt: string; } /** - * AlgoArgon2 + * Subscriber */ - export type AlgoArgon2 = { + export type Subscriber = { /** - * Algo type. + * Subscriber ID. */ - type: string; + $id: string; /** - * Memory used to compute hash. + * Subscriber creation time in ISO 8601 format. */ - memoryCost: number; + $createdAt: string; /** - * Amount of time consumed to compute hash + * Subscriber update date in ISO 8601 format. */ - timeCost: number; + $updatedAt: string; /** - * Number of threads used to compute hash. + * Target ID. */ - threads: number; - } - - /** - * AlgoScrypt - */ - export type AlgoScrypt = { + targetId: string; /** - * Algo type. + * Target. */ - type: string; + target: Target; /** - * CPU complexity of computed hash. + * Topic ID. */ - costCpu: number; + userId: string; /** - * Memory complexity of computed hash. + * User Name. */ - costMemory: number; + userName: string; /** - * Parallelization of computed hash. + * Topic ID. */ - costParallel: number; + topicId: string; /** - * Length used to compute hash. + * The target provider type. Can be one of the following: `email`, `sms` or `push`. */ - length: number; + providerType: string; } /** - * AlgoScryptModified + * Target */ - export type AlgoScryptModified = { + export type Target = { /** - * Algo type. + * Target ID. */ - type: string; + $id: string; /** - * Salt used to compute hash. + * Target creation time in ISO 8601 format. */ - salt: string; + $createdAt: string; /** - * Separator used to compute hash. + * Target update date in ISO 8601 format. */ - saltSeparator: string; + $updatedAt: string; /** - * Key used to compute hash. + * Target Name. */ - signerKey: string; - } - - /** - * AlgoBcrypt - */ - export type AlgoBcrypt = { + name: string; /** - * Algo type. + * User ID. */ - type: string; - } - - /** - * AlgoPHPass - */ - export type AlgoPhpass = { + userId: string; /** - * Algo type. + * Provider ID. */ - type: string; - } - - /** - * AlgoSHA - */ - export type AlgoSha = { + providerId?: string; /** - * Algo type. + * The target provider type. Can be one of the following: `email`, `sms` or `push`. */ - type: string; - } - - /** - * AlgoMD5 - */ - export type AlgoMd5 = { + providerType: string; /** - * Algo type. + * The target identifier. */ - type: string; + identifier: string; + /** + * Is the target expired. + */ + expired: boolean; } /** - * Identity + * ActivityEvent */ - export type Identity = { + export type ActivityEvent = { /** - * Identity ID. + * Event ID. */ $id: string; /** - * Identity creation date in ISO 8601 format. - */ - $createdAt: string; - /** - * Identity update date in ISO 8601 format. + * User type. */ - $updatedAt: string; + userType: string; /** * User ID. */ userId: string; /** - * Identity Provider. + * User Email. */ - provider: string; + userEmail: string; /** - * ID of the User in the Identity Provider. + * User Name. */ - providerUid: string; + userName: string; /** - * Email of the User in the Identity Provider. + * Resource parent. */ - providerEmail: string; + resourceParent: string; /** - * Identity Provider Access Token. + * Resource type. */ - providerAccessToken: string; + resourceType: string; /** - * The date of when the access token expires in ISO 8601 format. + * Resource ID. */ - providerAccessTokenExpiry: string; + resourceId: string; /** - * Identity Provider Refresh Token. + * Resource. */ - providerRefreshToken: string; - } - - /** - * Log - */ - export type Log = { + resource: string; /** * Event name. */ event: string; /** - * User ID of the actor recorded for this log. During impersonation, this is the original impersonator, not the impersonated target user. + * User agent. */ - userId: string; + userAgent: string; /** - * User email of the actor recorded for this log. During impersonation, this is the original impersonator. + * IP address. */ - userEmail: string; + ip: string; /** - * User name of the actor recorded for this log. During impersonation, this is the original impersonator. + * API mode when event triggered. + */ + mode: string; + /** + * Location. + */ + country: string; + /** + * Log creation date in ISO 8601 format. */ - userName: string; + time: string; /** - * API mode when event triggered. + * Project ID. */ - mode: string; + projectId: string; /** - * IP session in use when the session was created. + * Team ID. */ - ip: string; + teamId: string; /** - * Log creation date in ISO 8601 format. + * Hostname. */ - time: string; + hostname: string; /** * Operating system code name. View list of [available options](https://github.com/appwrite/appwrite/blob/master/docs/lists/os.json). */ @@ -4584,240 +4612,212 @@ export namespace Models { } /** - * Runtime + * Archive */ - export type Runtime = { + export type BackupArchive = { /** - * Runtime ID. + * Archive ID. */ $id: string; /** - * Parent runtime key. + * Archive creation time in ISO 8601 format. */ - key: string; + $createdAt: string; /** - * Runtime Name. + * Archive update date in ISO 8601 format. */ - name: string; + $updatedAt: string; /** - * Runtime version. + * Archive policy ID. */ - version: string; + policyId: string; /** - * Base Docker image used to build the runtime. + * Archive size in bytes. */ - base: string; + size: number; /** - * Image name of Docker Hub. + * The status of the archive creation. Possible values: pending, processing, uploading, completed, failed. */ - image: string; + status: string; /** - * Name of the logo image. + * The backup start time. */ - logo: string; + startedAt: string; /** - * List of supported architectures. + * Migration ID. */ - supports: string[]; - } - - /** - * Specification - */ - export type Specification = { + migrationId: string; /** - * Memory size in MB. + * The services that are backed up by this archive. */ - memory: number; + services: string[]; /** - * Number of CPUs. + * The resources that are backed up by this archive. */ - cpus: number; + resources: string[]; /** - * Is size enabled. + * The resource ID to backup. Set only if this archive should backup a single resource. */ - enabled: boolean; + resourceId?: string; /** - * Size slug. + * The resource type to backup. Set only if this archive should backup a single resource. */ - slug: string; + resourceType?: string; } /** - * Headers + * backup */ - export type Headers = { + export type BackupPolicy = { /** - * Header name. + * Backup policy ID. */ - name: string; + $id: string; /** - * Header value. + * Backup policy name. */ - value: string; - } - - /** - * LocaleCode - */ - export type LocaleCode = { + name: string; /** - * Locale codes in [ISO 639-1](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes) + * Policy creation date in ISO 8601 format. */ - code: string; + $createdAt: string; /** - * Locale name + * Policy update date in ISO 8601 format. */ - name: string; - } - - /** - * Continent - */ - export type Continent = { + $updatedAt: string; /** - * Continent name. + * The services that are backed up by this policy. */ - name: string; + services: string[]; /** - * Continent two letter code. + * The resources that are backed up by this policy. */ - code: string; - } - - /** - * Country - */ - export type Country = { + resources: string[]; /** - * Country name. + * The resource ID to backup. Set only if this policy should backup a single resource. */ - name: string; + resourceId?: string; /** - * Country two-character ISO 3166-1 alpha code. + * The resource type to backup. Set only if this policy should backup a single resource. */ - code: string; - } - - /** - * Phone - */ - export type Phone = { + resourceType?: string; /** - * Phone code. + * How many days to keep the backup before it will be automatically deleted. */ - code: string; + retention: number; /** - * Country two-character ISO 3166-1 alpha code. + * Policy backup schedule in CRON format. */ - countryCode: string; + schedule: string; /** - * Country name. + * Is this policy enabled. */ - countryName: string; + enabled: boolean; } /** - * Currency + * Restoration */ - export type Currency = { + export type BackupRestoration = { /** - * Currency symbol. + * Restoration ID. */ - symbol: string; + $id: string; /** - * Currency name. + * Restoration creation time in ISO 8601 format. */ - name: string; + $createdAt: string; /** - * Currency native symbol. + * Restoration update date in ISO 8601 format. */ - symbolNative: string; + $updatedAt: string; /** - * Number of decimal digits. + * Backup archive ID. */ - decimalDigits: number; + archiveId: string; /** - * Currency digit rounding. + * Backup policy ID. */ - rounding: number; + policyId: string; /** - * Currency code in [ISO 4217-1](http://en.wikipedia.org/wiki/ISO_4217) three-character format. + * The status of the restoration. Possible values: pending, downloading, processing, completed, failed. */ - code: string; + status: string; /** - * Currency plural name + * The backup start time. */ - namePlural: string; - } - - /** - * Language - */ - export type Language = { + startedAt: string; /** - * Language name. + * Migration ID. */ - name: string; + migrationId: string; /** - * Language two-character ISO 639-1 codes. + * The services that are backed up by this policy. */ - code: string; + services: string[]; /** - * Language native name. + * The resources that are backed up by this policy. */ - nativeName: string; + resources: string[]; + /** + * Optional data in key-value object. + */ + options: string; } /** - * Framework + * Activity event list */ - export type Framework = { - /** - * Framework key. - */ - key: string; + export type ActivityEventList = { /** - * Framework Name. + * Total number of events that matched your query. */ - name: string; + total: number; /** - * Default runtime version. + * List of events. */ - buildRuntime: string; + events: ActivityEvent[]; + } + + /** + * Backup archive list + */ + export type BackupArchiveList = { /** - * List of supported runtime versions. + * Total number of archives that matched your query. */ - runtimes: string[]; + total: number; /** - * List of supported adapters. + * List of archives. */ - adapters: FrameworkAdapter[]; + archives: BackupArchive[]; } /** - * Framework Adapter + * Backup policy list */ - export type FrameworkAdapter = { - /** - * Adapter key. - */ - key: string; + export type BackupPolicyList = { /** - * Default command to download dependencies. + * Total number of policies that matched your query. */ - installCommand: string; + total: number; /** - * Default command to build site into output directory. + * List of policies. */ - buildCommand: string; + policies: BackupPolicy[]; + } + + /** + * Backup restoration list + */ + export type BackupRestorationList = { /** - * Default output directory of build. + * Total number of restorations that matched your query. */ - outputDirectory: string; + total: number; /** - * Name of fallback file to use instead of 404 page. If null, Appwrite 404 page will be displayed. + * List of restorations. */ - fallbackFile: string; + restorations: BackupRestoration[]; } } From c48f8faa5971408b0d315ac123ad3d787798e721 Mon Sep 17 00:00:00 2001 From: root Date: Wed, 25 Mar 2026 07:19:14 +0000 Subject: [PATCH 6/9] chore: update Node.js SDK to 23.0.0 --- src/enums/vcs-reference-type.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/enums/vcs-reference-type.ts b/src/enums/vcs-reference-type.ts index 5bbae171..cb5270f5 100644 --- a/src/enums/vcs-reference-type.ts +++ b/src/enums/vcs-reference-type.ts @@ -1,4 +1,5 @@ export enum VCSReferenceType { Branch = 'branch', Commit = 'commit', + Tag = 'tag', } \ No newline at end of file From 566f8489f1a205f1b4331b3ca577a1984851241f Mon Sep 17 00:00:00 2001 From: root Date: Thu, 26 Mar 2026 04:21:45 +0000 Subject: [PATCH 7/9] chore: update Node.js SDK to 23.0.0 --- src/enums/build-runtime.ts | 86 -------------------------------------- src/enums/runtime.ts | 86 -------------------------------------- 2 files changed, 172 deletions(-) diff --git a/src/enums/build-runtime.ts b/src/enums/build-runtime.ts index be56a9f4..3f85913f 100644 --- a/src/enums/build-runtime.ts +++ b/src/enums/build-runtime.ts @@ -85,90 +85,4 @@ export enum BuildRuntime { Flutter332 = 'flutter-3.32', Flutter335 = 'flutter-3.35', Flutter338 = 'flutter-3.38', - Node145rc = 'node-14.5-rc', - Node160rc = 'node-16.0-rc', - Node180rc = 'node-18.0-rc', - Node190rc = 'node-19.0-rc', - Node200rc = 'node-20.0-rc', - Node210rc = 'node-21.0-rc', - Node22rc = 'node-22-rc', - Node23rc = 'node-23-rc', - Node24rc = 'node-24-rc', - Node25rc = 'node-25-rc', - Php80rc = 'php-8.0-rc', - Php81rc = 'php-8.1-rc', - Php82rc = 'php-8.2-rc', - Php83rc = 'php-8.3-rc', - Php84rc = 'php-8.4-rc', - Ruby30rc = 'ruby-3.0-rc', - Ruby31rc = 'ruby-3.1-rc', - Ruby32rc = 'ruby-3.2-rc', - Ruby33rc = 'ruby-3.3-rc', - Ruby34rc = 'ruby-3.4-rc', - Ruby40rc = 'ruby-4.0-rc', - Python38rc = 'python-3.8-rc', - Python39rc = 'python-3.9-rc', - Python310rc = 'python-3.10-rc', - Python311rc = 'python-3.11-rc', - Python312rc = 'python-3.12-rc', - Python313rc = 'python-3.13-rc', - Python314rc = 'python-3.14-rc', - Pythonml311rc = 'python-ml-3.11-rc', - Pythonml312rc = 'python-ml-3.12-rc', - Pythonml313rc = 'python-ml-3.13-rc', - Deno140rc = 'deno-1.40-rc', - Deno146rc = 'deno-1.46-rc', - Deno20rc = 'deno-2.0-rc', - Deno25rc = 'deno-2.5-rc', - Deno26rc = 'deno-2.6-rc', - Dart215rc = 'dart-2.15-rc', - Dart216rc = 'dart-2.16-rc', - Dart217rc = 'dart-2.17-rc', - Dart218rc = 'dart-2.18-rc', - Dart219rc = 'dart-2.19-rc', - Dart30rc = 'dart-3.0-rc', - Dart31rc = 'dart-3.1-rc', - Dart33rc = 'dart-3.3-rc', - Dart35rc = 'dart-3.5-rc', - Dart38rc = 'dart-3.8-rc', - Dart39rc = 'dart-3.9-rc', - Dart310rc = 'dart-3.10-rc', - Dotnet60rc = 'dotnet-6.0-rc', - Dotnet70rc = 'dotnet-7.0-rc', - Dotnet80rc = 'dotnet-8.0-rc', - Dotnet10rc = 'dotnet-10-rc', - Java80rc = 'java-8.0-rc', - Java110rc = 'java-11.0-rc', - Java170rc = 'java-17.0-rc', - Java180rc = 'java-18.0-rc', - Java210rc = 'java-21.0-rc', - Java22rc = 'java-22-rc', - Java25rc = 'java-25-rc', - Swift55rc = 'swift-5.5-rc', - Swift58rc = 'swift-5.8-rc', - Swift59rc = 'swift-5.9-rc', - Swift510rc = 'swift-5.10-rc', - Swift62rc = 'swift-6.2-rc', - Kotlin16rc = 'kotlin-1.6-rc', - Kotlin18rc = 'kotlin-1.8-rc', - Kotlin19rc = 'kotlin-1.9-rc', - Kotlin20rc = 'kotlin-2.0-rc', - Kotlin23rc = 'kotlin-2.3-rc', - Cpp17rc = 'cpp-17-rc', - Cpp20rc = 'cpp-20-rc', - Bun10rc = 'bun-1.0-rc', - Bun11rc = 'bun-1.1-rc', - Bun12rc = 'bun-1.2-rc', - Bun13rc = 'bun-1.3-rc', - Go123rc = 'go-1.23-rc', - Go124rc = 'go-1.24-rc', - Go125rc = 'go-1.25-rc', - Go126rc = 'go-1.26-rc', - Static1rc = 'static-1-rc', - Flutter324rc = 'flutter-3.24-rc', - Flutter327rc = 'flutter-3.27-rc', - Flutter329rc = 'flutter-3.29-rc', - Flutter332rc = 'flutter-3.32-rc', - Flutter335rc = 'flutter-3.35-rc', - Flutter338rc = 'flutter-3.38-rc', } \ No newline at end of file diff --git a/src/enums/runtime.ts b/src/enums/runtime.ts index cfd4a735..fda3bab3 100644 --- a/src/enums/runtime.ts +++ b/src/enums/runtime.ts @@ -85,90 +85,4 @@ export enum Runtime { Flutter332 = 'flutter-3.32', Flutter335 = 'flutter-3.35', Flutter338 = 'flutter-3.38', - Node145rc = 'node-14.5-rc', - Node160rc = 'node-16.0-rc', - Node180rc = 'node-18.0-rc', - Node190rc = 'node-19.0-rc', - Node200rc = 'node-20.0-rc', - Node210rc = 'node-21.0-rc', - Node22rc = 'node-22-rc', - Node23rc = 'node-23-rc', - Node24rc = 'node-24-rc', - Node25rc = 'node-25-rc', - Php80rc = 'php-8.0-rc', - Php81rc = 'php-8.1-rc', - Php82rc = 'php-8.2-rc', - Php83rc = 'php-8.3-rc', - Php84rc = 'php-8.4-rc', - Ruby30rc = 'ruby-3.0-rc', - Ruby31rc = 'ruby-3.1-rc', - Ruby32rc = 'ruby-3.2-rc', - Ruby33rc = 'ruby-3.3-rc', - Ruby34rc = 'ruby-3.4-rc', - Ruby40rc = 'ruby-4.0-rc', - Python38rc = 'python-3.8-rc', - Python39rc = 'python-3.9-rc', - Python310rc = 'python-3.10-rc', - Python311rc = 'python-3.11-rc', - Python312rc = 'python-3.12-rc', - Python313rc = 'python-3.13-rc', - Python314rc = 'python-3.14-rc', - Pythonml311rc = 'python-ml-3.11-rc', - Pythonml312rc = 'python-ml-3.12-rc', - Pythonml313rc = 'python-ml-3.13-rc', - Deno140rc = 'deno-1.40-rc', - Deno146rc = 'deno-1.46-rc', - Deno20rc = 'deno-2.0-rc', - Deno25rc = 'deno-2.5-rc', - Deno26rc = 'deno-2.6-rc', - Dart215rc = 'dart-2.15-rc', - Dart216rc = 'dart-2.16-rc', - Dart217rc = 'dart-2.17-rc', - Dart218rc = 'dart-2.18-rc', - Dart219rc = 'dart-2.19-rc', - Dart30rc = 'dart-3.0-rc', - Dart31rc = 'dart-3.1-rc', - Dart33rc = 'dart-3.3-rc', - Dart35rc = 'dart-3.5-rc', - Dart38rc = 'dart-3.8-rc', - Dart39rc = 'dart-3.9-rc', - Dart310rc = 'dart-3.10-rc', - Dotnet60rc = 'dotnet-6.0-rc', - Dotnet70rc = 'dotnet-7.0-rc', - Dotnet80rc = 'dotnet-8.0-rc', - Dotnet10rc = 'dotnet-10-rc', - Java80rc = 'java-8.0-rc', - Java110rc = 'java-11.0-rc', - Java170rc = 'java-17.0-rc', - Java180rc = 'java-18.0-rc', - Java210rc = 'java-21.0-rc', - Java22rc = 'java-22-rc', - Java25rc = 'java-25-rc', - Swift55rc = 'swift-5.5-rc', - Swift58rc = 'swift-5.8-rc', - Swift59rc = 'swift-5.9-rc', - Swift510rc = 'swift-5.10-rc', - Swift62rc = 'swift-6.2-rc', - Kotlin16rc = 'kotlin-1.6-rc', - Kotlin18rc = 'kotlin-1.8-rc', - Kotlin19rc = 'kotlin-1.9-rc', - Kotlin20rc = 'kotlin-2.0-rc', - Kotlin23rc = 'kotlin-2.3-rc', - Cpp17rc = 'cpp-17-rc', - Cpp20rc = 'cpp-20-rc', - Bun10rc = 'bun-1.0-rc', - Bun11rc = 'bun-1.1-rc', - Bun12rc = 'bun-1.2-rc', - Bun13rc = 'bun-1.3-rc', - Go123rc = 'go-1.23-rc', - Go124rc = 'go-1.24-rc', - Go125rc = 'go-1.25-rc', - Go126rc = 'go-1.26-rc', - Static1rc = 'static-1-rc', - Flutter324rc = 'flutter-3.24-rc', - Flutter327rc = 'flutter-3.27-rc', - Flutter329rc = 'flutter-3.29-rc', - Flutter332rc = 'flutter-3.32-rc', - Flutter335rc = 'flutter-3.35-rc', - Flutter338rc = 'flutter-3.38-rc', } \ No newline at end of file From 1ca645e5c2800873fde0c5f8e3cffca52cc952fa Mon Sep 17 00:00:00 2001 From: root Date: Thu, 26 Mar 2026 05:05:59 +0000 Subject: [PATCH 8/9] chore: update Node.js SDK to 23.0.0 --- docs/examples/databases/upsert-documents.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/examples/databases/upsert-documents.md b/docs/examples/databases/upsert-documents.md index 73caa593..2a304924 100644 --- a/docs/examples/databases/upsert-documents.md +++ b/docs/examples/databases/upsert-documents.md @@ -4,7 +4,7 @@ const sdk = require('node-appwrite'); const client = new sdk.Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint .setProject('') // Your project ID - .setSession(''); // The user session to authenticate with + .setKey(''); // Your secret API key const databases = new sdk.Databases(client); From b9a56849394f7ec41bf34b826044b618048bbe89 Mon Sep 17 00:00:00 2001 From: root Date: Thu, 26 Mar 2026 05:17:49 +0000 Subject: [PATCH 9/9] chore: update Node.js SDK to 23.0.0 --- CHANGELOG.md | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 43308acd..f4df186a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,8 +2,23 @@ ## 23.0.0 -* [BREAKING] Changed `$sequence` type from `int` to `string` for rows and documents -* Updated `DatabasesIndexType` usage; bumped API version badge to 1.9.0 +* [BREAKING] Changed `$sequence` type from `number` to `string` for `Row` and `Document` models +* [BREAKING] Renamed `IndexType` enum: split into `DatabasesIndexType` (with new `Spatial` value) and `TablesDBIndexType` +* [BREAKING] Replaced `specification` parameter with `buildSpecification` and `runtimeSpecification` in `Functions.create()`, `Functions.update()`, `Sites.create()`, `Sites.update()` +* Added new `Project` service with full CRUD for project-level environment variables +* Added new `Webhooks` service with full CRUD for project webhooks (including `updateSignature`) +* Added `Users.updateImpersonator()` method for enabling/disabling user impersonation +* Added impersonation support: `setImpersonateUserId()`, `setImpersonateUserEmail()`, `setImpersonateUserPhone()` on `Client` +* Added `impersonator` and `impersonatorUserId` optional fields to `User` model +* Added `deploymentRetention` parameter to Functions and Sites create/update +* Added `startCommand` parameter to Sites create/update +* Added `Webhook` and `WebhookList` models +* Added `Documentsdb`, `Vectorsdb` values to `BackupServices` and `DatabaseType` enums +* Added `WebhooksRead`, `WebhooksWrite`, `ProjectRead`, `ProjectWrite` scopes +* Added custom `toString()` on response data using `JSONbig.stringify` for BigInt support +* Removed `getQueueBillingProjectAggregation`, `getQueueBillingTeamAggregation`, `getQueuePriorityBuilds`, `getQueueRegionManager`, `getQueueThreats` from `Health` service +* Updated `Log` model field descriptions to clarify impersonation behavior +* Updated `X-Appwrite-Response-Format` header to `1.9.0` ## 22.1.2