From 286fa579b60bfd190fc4cfbdf4c607de11275deb Mon Sep 17 00:00:00 2001 From: root Date: Tue, 24 Mar 2026 12:59:42 +0000 Subject: [PATCH 1/5] feat: update React Native SDK to 0.24.2 * Updated API version badge to `1.9.0` * Updated compatibility note to Appwrite server version `1.8.x` * Added new documentation examples for `DocumentsDB` and `VectorsDB` --- README.md | 4 +- docs/examples/databases/upsert-documents.md | 18 + docs/examples/documentsdb/create-document.md | 25 + docs/examples/documentsdb/create-documents.md | 17 + .../examples/documentsdb/create-operations.md | 26 + .../documentsdb/create-transaction.md | 15 + .../decrement-document-attribute.md | 21 + docs/examples/documentsdb/delete-document.md | 18 + .../documentsdb/delete-transaction.md | 15 + docs/examples/documentsdb/get-document.md | 19 + docs/examples/documentsdb/get-transaction.md | 15 + .../increment-document-attribute.md | 21 + docs/examples/documentsdb/list-documents.md | 20 + .../examples/documentsdb/list-transactions.md | 15 + docs/examples/documentsdb/update-document.md | 20 + .../documentsdb/update-transaction.md | 17 + docs/examples/documentsdb/upsert-document.md | 20 + docs/examples/vectorsdb/create-document.md | 29 + docs/examples/vectorsdb/create-operations.md | 26 + docs/examples/vectorsdb/create-transaction.md | 15 + docs/examples/vectorsdb/delete-document.md | 18 + docs/examples/vectorsdb/delete-transaction.md | 15 + docs/examples/vectorsdb/get-document.md | 19 + docs/examples/vectorsdb/get-transaction.md | 15 + docs/examples/vectorsdb/list-documents.md | 20 + docs/examples/vectorsdb/list-transactions.md | 15 + docs/examples/vectorsdb/update-document.md | 20 + docs/examples/vectorsdb/update-transaction.md | 17 + docs/examples/vectorsdb/upsert-document.md | 20 + package.json | 10 +- rollup.config.js | 3 +- src/client.ts | 74 +- src/index.ts | 2 + src/models.ts | 18 +- src/services/databases.ts | 77 ++ src/services/documents-db.ts | 1041 +++++++++++++++++ src/services/vectors-db.ts | 775 ++++++++++++ 37 files changed, 2520 insertions(+), 15 deletions(-) create mode 100644 docs/examples/databases/upsert-documents.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-operations.md create mode 100644 docs/examples/documentsdb/create-transaction.md create mode 100644 docs/examples/documentsdb/decrement-document-attribute.md create mode 100644 docs/examples/documentsdb/delete-document.md create mode 100644 docs/examples/documentsdb/delete-transaction.md create mode 100644 docs/examples/documentsdb/get-document.md create mode 100644 docs/examples/documentsdb/get-transaction.md create mode 100644 docs/examples/documentsdb/increment-document-attribute.md create mode 100644 docs/examples/documentsdb/list-documents.md create mode 100644 docs/examples/documentsdb/list-transactions.md create mode 100644 docs/examples/documentsdb/update-document.md create mode 100644 docs/examples/documentsdb/update-transaction.md create mode 100644 docs/examples/documentsdb/upsert-document.md create mode 100644 docs/examples/vectorsdb/create-document.md create mode 100644 docs/examples/vectorsdb/create-operations.md create mode 100644 docs/examples/vectorsdb/create-transaction.md create mode 100644 docs/examples/vectorsdb/delete-document.md create mode 100644 docs/examples/vectorsdb/delete-transaction.md create mode 100644 docs/examples/vectorsdb/get-document.md create mode 100644 docs/examples/vectorsdb/get-transaction.md create mode 100644 docs/examples/vectorsdb/list-documents.md create mode 100644 docs/examples/vectorsdb/list-transactions.md create mode 100644 docs/examples/vectorsdb/update-document.md create mode 100644 docs/examples/vectorsdb/update-transaction.md create mode 100644 docs/examples/vectorsdb/upsert-document.md create mode 100644 src/services/documents-db.ts create mode 100644 src/services/vectors-db.ts diff --git a/README.md b/README.md index 5452c01f..939dd95d 100644 --- a/README.md +++ b/README.md @@ -1,12 +1,12 @@ # Appwrite React Native SDK ![License](https://img.shields.io/github/license/appwrite/sdk-for-react-native.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) -**This SDK is compatible with Appwrite server version latest. For older versions, please check [previous releases](https://github.com/appwrite/sdk-for-react-native/releases).** +**This SDK is compatible with Appwrite server version 1.8.x. For older versions, please check [previous releases](https://github.com/appwrite/sdk-for-react-native/releases).** Appwrite is an open-source backend as a service server that abstracts and simplifies complex and repetitive development tasks behind a very simple to use REST API. Appwrite aims to help you develop your apps faster and in a more secure way. Use the React Native SDK to integrate your app with the Appwrite server to easily start interacting with all of Appwrite backend APIs and tools. For full API documentation and tutorials go to [https://appwrite.io/docs](https://appwrite.io/docs) diff --git a/docs/examples/databases/upsert-documents.md b/docs/examples/databases/upsert-documents.md new file mode 100644 index 00000000..8a3b45a6 --- /dev/null +++ b/docs/examples/databases/upsert-documents.md @@ -0,0 +1,18 @@ +```javascript +import { Client, Databases } from "react-native-appwrite"; + +const client = new Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject(''); // Your project ID + +const databases = new Databases(client); + +const result = await databases.upsertDocuments({ + databaseId: '', + collectionId: '', + documents: [], + transactionId: '' // optional +}); + +console.log(result); +``` diff --git a/docs/examples/documentsdb/create-document.md b/docs/examples/documentsdb/create-document.md new file mode 100644 index 00000000..cbb11795 --- /dev/null +++ b/docs/examples/documentsdb/create-document.md @@ -0,0 +1,25 @@ +```javascript +import { Client, DocumentsDB, Permission, Role } from "react-native-appwrite"; + +const client = new Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject(''); // Your project ID + +const documentsDB = new 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: ["read("any")"] // optional +}); + +console.log(result); +``` diff --git a/docs/examples/documentsdb/create-documents.md b/docs/examples/documentsdb/create-documents.md new file mode 100644 index 00000000..de91fae0 --- /dev/null +++ b/docs/examples/documentsdb/create-documents.md @@ -0,0 +1,17 @@ +```javascript +import { Client, DocumentsDB } from "react-native-appwrite"; + +const client = new Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject(''); // Your project ID + +const documentsDB = new DocumentsDB(client); + +const result = await documentsDB.createDocuments({ + databaseId: '', + collectionId: '', + documents: [] +}); + +console.log(result); +``` diff --git a/docs/examples/documentsdb/create-operations.md b/docs/examples/documentsdb/create-operations.md new file mode 100644 index 00000000..fefe87f0 --- /dev/null +++ b/docs/examples/documentsdb/create-operations.md @@ -0,0 +1,26 @@ +```javascript +import { Client, DocumentsDB } from "react-native-appwrite"; + +const client = new Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject(''); // Your project ID + +const documentsDB = new DocumentsDB(client); + +const result = await documentsDB.createOperations({ + transactionId: '', + operations: [ + { + "action": "create", + "databaseId": "", + "collectionId": "", + "documentId": "", + "data": { + "name": "Walter O'Brien" + } + } + ] // optional +}); + +console.log(result); +``` diff --git a/docs/examples/documentsdb/create-transaction.md b/docs/examples/documentsdb/create-transaction.md new file mode 100644 index 00000000..92efb795 --- /dev/null +++ b/docs/examples/documentsdb/create-transaction.md @@ -0,0 +1,15 @@ +```javascript +import { Client, DocumentsDB } from "react-native-appwrite"; + +const client = new Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject(''); // Your project ID + +const documentsDB = new DocumentsDB(client); + +const result = await documentsDB.createTransaction({ + ttl: 60 // optional +}); + +console.log(result); +``` diff --git a/docs/examples/documentsdb/decrement-document-attribute.md b/docs/examples/documentsdb/decrement-document-attribute.md new file mode 100644 index 00000000..69dc5c34 --- /dev/null +++ b/docs/examples/documentsdb/decrement-document-attribute.md @@ -0,0 +1,21 @@ +```javascript +import { Client, DocumentsDB } from "react-native-appwrite"; + +const client = new Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject(''); // Your project ID + +const documentsDB = new DocumentsDB(client); + +const result = await documentsDB.decrementDocumentAttribute({ + databaseId: '', + collectionId: '', + documentId: '', + attribute: '', + value: 0, // optional + min: 0, // optional + transactionId: '' // optional +}); + +console.log(result); +``` diff --git a/docs/examples/documentsdb/delete-document.md b/docs/examples/documentsdb/delete-document.md new file mode 100644 index 00000000..dee5d605 --- /dev/null +++ b/docs/examples/documentsdb/delete-document.md @@ -0,0 +1,18 @@ +```javascript +import { Client, DocumentsDB } from "react-native-appwrite"; + +const client = new Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject(''); // Your project ID + +const documentsDB = new DocumentsDB(client); + +const result = await documentsDB.deleteDocument({ + databaseId: '', + collectionId: '', + documentId: '', + transactionId: '' // optional +}); + +console.log(result); +``` diff --git a/docs/examples/documentsdb/delete-transaction.md b/docs/examples/documentsdb/delete-transaction.md new file mode 100644 index 00000000..e3282e38 --- /dev/null +++ b/docs/examples/documentsdb/delete-transaction.md @@ -0,0 +1,15 @@ +```javascript +import { Client, DocumentsDB } from "react-native-appwrite"; + +const client = new Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject(''); // Your project ID + +const documentsDB = new DocumentsDB(client); + +const result = await documentsDB.deleteTransaction({ + transactionId: '' +}); + +console.log(result); +``` diff --git a/docs/examples/documentsdb/get-document.md b/docs/examples/documentsdb/get-document.md new file mode 100644 index 00000000..5be89277 --- /dev/null +++ b/docs/examples/documentsdb/get-document.md @@ -0,0 +1,19 @@ +```javascript +import { Client, DocumentsDB } from "react-native-appwrite"; + +const client = new Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject(''); // Your project ID + +const documentsDB = new DocumentsDB(client); + +const result = await documentsDB.getDocument({ + databaseId: '', + collectionId: '', + documentId: '', + queries: [], // optional + transactionId: '' // optional +}); + +console.log(result); +``` diff --git a/docs/examples/documentsdb/get-transaction.md b/docs/examples/documentsdb/get-transaction.md new file mode 100644 index 00000000..32cdd766 --- /dev/null +++ b/docs/examples/documentsdb/get-transaction.md @@ -0,0 +1,15 @@ +```javascript +import { Client, DocumentsDB } from "react-native-appwrite"; + +const client = new Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject(''); // Your project ID + +const documentsDB = new DocumentsDB(client); + +const result = await documentsDB.getTransaction({ + transactionId: '' +}); + +console.log(result); +``` diff --git a/docs/examples/documentsdb/increment-document-attribute.md b/docs/examples/documentsdb/increment-document-attribute.md new file mode 100644 index 00000000..758a40b3 --- /dev/null +++ b/docs/examples/documentsdb/increment-document-attribute.md @@ -0,0 +1,21 @@ +```javascript +import { Client, DocumentsDB } from "react-native-appwrite"; + +const client = new Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject(''); // Your project ID + +const documentsDB = new DocumentsDB(client); + +const result = await documentsDB.incrementDocumentAttribute({ + databaseId: '', + collectionId: '', + documentId: '', + attribute: '', + value: 0, // optional + max: 0, // optional + transactionId: '' // optional +}); + +console.log(result); +``` diff --git a/docs/examples/documentsdb/list-documents.md b/docs/examples/documentsdb/list-documents.md new file mode 100644 index 00000000..6e6cc4dd --- /dev/null +++ b/docs/examples/documentsdb/list-documents.md @@ -0,0 +1,20 @@ +```javascript +import { Client, DocumentsDB } from "react-native-appwrite"; + +const client = new Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject(''); // Your project ID + +const documentsDB = new DocumentsDB(client); + +const result = await documentsDB.listDocuments({ + databaseId: '', + collectionId: '', + queries: [], // optional + transactionId: '', // optional + total: false, // optional + ttl: 0 // optional +}); + +console.log(result); +``` diff --git a/docs/examples/documentsdb/list-transactions.md b/docs/examples/documentsdb/list-transactions.md new file mode 100644 index 00000000..3d946b38 --- /dev/null +++ b/docs/examples/documentsdb/list-transactions.md @@ -0,0 +1,15 @@ +```javascript +import { Client, DocumentsDB } from "react-native-appwrite"; + +const client = new Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject(''); // Your project ID + +const documentsDB = new DocumentsDB(client); + +const result = await documentsDB.listTransactions({ + queries: [] // optional +}); + +console.log(result); +``` diff --git a/docs/examples/documentsdb/update-document.md b/docs/examples/documentsdb/update-document.md new file mode 100644 index 00000000..28e34e8f --- /dev/null +++ b/docs/examples/documentsdb/update-document.md @@ -0,0 +1,20 @@ +```javascript +import { Client, DocumentsDB, Permission, Role } from "react-native-appwrite"; + +const client = new Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject(''); // Your project ID + +const documentsDB = new DocumentsDB(client); + +const result = await documentsDB.updateDocument({ + databaseId: '', + collectionId: '', + documentId: '', + data: {}, // optional + permissions: ["read("any")"], // optional + transactionId: '' // optional +}); + +console.log(result); +``` diff --git a/docs/examples/documentsdb/update-transaction.md b/docs/examples/documentsdb/update-transaction.md new file mode 100644 index 00000000..8e76cdcf --- /dev/null +++ b/docs/examples/documentsdb/update-transaction.md @@ -0,0 +1,17 @@ +```javascript +import { Client, DocumentsDB } from "react-native-appwrite"; + +const client = new Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject(''); // Your project ID + +const documentsDB = new DocumentsDB(client); + +const result = await documentsDB.updateTransaction({ + transactionId: '', + commit: false, // optional + rollback: false // optional +}); + +console.log(result); +``` diff --git a/docs/examples/documentsdb/upsert-document.md b/docs/examples/documentsdb/upsert-document.md new file mode 100644 index 00000000..b3fce531 --- /dev/null +++ b/docs/examples/documentsdb/upsert-document.md @@ -0,0 +1,20 @@ +```javascript +import { Client, DocumentsDB, Permission, Role } from "react-native-appwrite"; + +const client = new Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject(''); // Your project ID + +const documentsDB = new DocumentsDB(client); + +const result = await documentsDB.upsertDocument({ + databaseId: '', + collectionId: '', + documentId: '', + data: {}, // optional + permissions: ["read("any")"], // optional + transactionId: '' // optional +}); + +console.log(result); +``` diff --git a/docs/examples/vectorsdb/create-document.md b/docs/examples/vectorsdb/create-document.md new file mode 100644 index 00000000..72620eec --- /dev/null +++ b/docs/examples/vectorsdb/create-document.md @@ -0,0 +1,29 @@ +```javascript +import { Client, VectorsDB, Permission, Role } from "react-native-appwrite"; + +const client = new Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject(''); // Your project ID + +const vectorsDB = new VectorsDB(client); + +const result = await vectorsDB.createDocument({ + databaseId: '', + collectionId: '', + documentId: '', + data: { + "embeddings": [ + 0.12, + -0.55, + 0.88, + 1.02 + ], + "metadata": { + "key": "value" + } + }, + permissions: ["read("any")"] // optional +}); + +console.log(result); +``` diff --git a/docs/examples/vectorsdb/create-operations.md b/docs/examples/vectorsdb/create-operations.md new file mode 100644 index 00000000..81429751 --- /dev/null +++ b/docs/examples/vectorsdb/create-operations.md @@ -0,0 +1,26 @@ +```javascript +import { Client, VectorsDB } from "react-native-appwrite"; + +const client = new Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject(''); // Your project ID + +const vectorsDB = new VectorsDB(client); + +const result = await vectorsDB.createOperations({ + transactionId: '', + operations: [ + { + "action": "create", + "databaseId": "", + "collectionId": "", + "documentId": "", + "data": { + "name": "Walter O'Brien" + } + } + ] // optional +}); + +console.log(result); +``` diff --git a/docs/examples/vectorsdb/create-transaction.md b/docs/examples/vectorsdb/create-transaction.md new file mode 100644 index 00000000..ae07efbd --- /dev/null +++ b/docs/examples/vectorsdb/create-transaction.md @@ -0,0 +1,15 @@ +```javascript +import { Client, VectorsDB } from "react-native-appwrite"; + +const client = new Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject(''); // Your project ID + +const vectorsDB = new VectorsDB(client); + +const result = await vectorsDB.createTransaction({ + ttl: 60 // optional +}); + +console.log(result); +``` diff --git a/docs/examples/vectorsdb/delete-document.md b/docs/examples/vectorsdb/delete-document.md new file mode 100644 index 00000000..6eee6695 --- /dev/null +++ b/docs/examples/vectorsdb/delete-document.md @@ -0,0 +1,18 @@ +```javascript +import { Client, VectorsDB } from "react-native-appwrite"; + +const client = new Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject(''); // Your project ID + +const vectorsDB = new VectorsDB(client); + +const result = await vectorsDB.deleteDocument({ + databaseId: '', + collectionId: '', + documentId: '', + transactionId: '' // optional +}); + +console.log(result); +``` diff --git a/docs/examples/vectorsdb/delete-transaction.md b/docs/examples/vectorsdb/delete-transaction.md new file mode 100644 index 00000000..10fe8423 --- /dev/null +++ b/docs/examples/vectorsdb/delete-transaction.md @@ -0,0 +1,15 @@ +```javascript +import { Client, VectorsDB } from "react-native-appwrite"; + +const client = new Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject(''); // Your project ID + +const vectorsDB = new VectorsDB(client); + +const result = await vectorsDB.deleteTransaction({ + transactionId: '' +}); + +console.log(result); +``` diff --git a/docs/examples/vectorsdb/get-document.md b/docs/examples/vectorsdb/get-document.md new file mode 100644 index 00000000..2ad29dcc --- /dev/null +++ b/docs/examples/vectorsdb/get-document.md @@ -0,0 +1,19 @@ +```javascript +import { Client, VectorsDB } from "react-native-appwrite"; + +const client = new Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject(''); // Your project ID + +const vectorsDB = new VectorsDB(client); + +const result = await vectorsDB.getDocument({ + databaseId: '', + collectionId: '', + documentId: '', + queries: [], // optional + transactionId: '' // optional +}); + +console.log(result); +``` diff --git a/docs/examples/vectorsdb/get-transaction.md b/docs/examples/vectorsdb/get-transaction.md new file mode 100644 index 00000000..41599da0 --- /dev/null +++ b/docs/examples/vectorsdb/get-transaction.md @@ -0,0 +1,15 @@ +```javascript +import { Client, VectorsDB } from "react-native-appwrite"; + +const client = new Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject(''); // Your project ID + +const vectorsDB = new VectorsDB(client); + +const result = await vectorsDB.getTransaction({ + transactionId: '' +}); + +console.log(result); +``` diff --git a/docs/examples/vectorsdb/list-documents.md b/docs/examples/vectorsdb/list-documents.md new file mode 100644 index 00000000..fb42061f --- /dev/null +++ b/docs/examples/vectorsdb/list-documents.md @@ -0,0 +1,20 @@ +```javascript +import { Client, VectorsDB } from "react-native-appwrite"; + +const client = new Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject(''); // Your project ID + +const vectorsDB = new VectorsDB(client); + +const result = await vectorsDB.listDocuments({ + databaseId: '', + collectionId: '', + queries: [], // optional + transactionId: '', // optional + total: false, // optional + ttl: 0 // optional +}); + +console.log(result); +``` diff --git a/docs/examples/vectorsdb/list-transactions.md b/docs/examples/vectorsdb/list-transactions.md new file mode 100644 index 00000000..179017c0 --- /dev/null +++ b/docs/examples/vectorsdb/list-transactions.md @@ -0,0 +1,15 @@ +```javascript +import { Client, VectorsDB } from "react-native-appwrite"; + +const client = new Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject(''); // Your project ID + +const vectorsDB = new VectorsDB(client); + +const result = await vectorsDB.listTransactions({ + queries: [] // optional +}); + +console.log(result); +``` diff --git a/docs/examples/vectorsdb/update-document.md b/docs/examples/vectorsdb/update-document.md new file mode 100644 index 00000000..c9a8c7ab --- /dev/null +++ b/docs/examples/vectorsdb/update-document.md @@ -0,0 +1,20 @@ +```javascript +import { Client, VectorsDB, Permission, Role } from "react-native-appwrite"; + +const client = new Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject(''); // Your project ID + +const vectorsDB = new VectorsDB(client); + +const result = await vectorsDB.updateDocument({ + databaseId: '', + collectionId: '', + documentId: '', + data: {}, // optional + permissions: ["read("any")"], // optional + transactionId: '' // optional +}); + +console.log(result); +``` diff --git a/docs/examples/vectorsdb/update-transaction.md b/docs/examples/vectorsdb/update-transaction.md new file mode 100644 index 00000000..29a999e6 --- /dev/null +++ b/docs/examples/vectorsdb/update-transaction.md @@ -0,0 +1,17 @@ +```javascript +import { Client, VectorsDB } from "react-native-appwrite"; + +const client = new Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject(''); // Your project ID + +const vectorsDB = new VectorsDB(client); + +const result = await vectorsDB.updateTransaction({ + transactionId: '', + commit: false, // optional + rollback: false // optional +}); + +console.log(result); +``` diff --git a/docs/examples/vectorsdb/upsert-document.md b/docs/examples/vectorsdb/upsert-document.md new file mode 100644 index 00000000..d1f33b32 --- /dev/null +++ b/docs/examples/vectorsdb/upsert-document.md @@ -0,0 +1,20 @@ +```javascript +import { Client, VectorsDB, Permission, Role } from "react-native-appwrite"; + +const client = new Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject(''); // Your project ID + +const vectorsDB = new VectorsDB(client); + +const result = await vectorsDB.upsertDocument({ + databaseId: '', + collectionId: '', + documentId: '', + data: {}, // optional + permissions: ["read("any")"], // optional + transactionId: '' // optional +}); + +console.log(result); +``` diff --git a/package.json b/package.json index 53463dbc..33b21716 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "react-native-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": "0.25.0", + "version": "0.24.2", "license": "BSD-3-Clause", "main": "dist/cjs/sdk.js", "exports": { @@ -25,13 +25,13 @@ "build:libs": "rollup -c" }, "devDependencies": { - "@rollup/plugin-typescript": "8.3.2", + "@rollup/plugin-typescript": "11.1.6", "@types/json-bigint": "1.0.4", "playwright": "1.56.1", - "rollup": "2.75.4", + "rollup": "3.29.5", "serve-handler": "6.1.0", - "tslib": "2.4.0", - "typescript": "^5.3.3" + "tslib": "2.8.1", + "typescript": "5.7.3" }, "dependencies": { "expo-file-system": "18.*.*", diff --git a/rollup.config.js b/rollup.config.js index cfcba7da..f01c4a64 100644 --- a/rollup.config.js +++ b/rollup.config.js @@ -1,4 +1,5 @@ -import pkg from "./package.json"; +import { readFileSync } from "fs"; +const pkg = JSON.parse(readFileSync("./package.json", "utf8")); import typescript from "@rollup/plugin-typescript"; const external = Object.keys(pkg.dependencies ?? {}); diff --git a/src/client.ts b/src/client.ts index d6bfc9fe..bf5bfa92 100644 --- a/src/client.ts +++ b/src/client.ts @@ -152,14 +152,17 @@ class Client { locale: '', session: '', devkey: '', + impersonateuserid: '', + impersonateuseremail: '', + impersonateuserphone: '', platform: '', }; headers: Headers = { 'x-sdk-name': 'React Native', 'x-sdk-platform': 'client', 'x-sdk-language': 'reactnative', - 'x-sdk-version': '0.25.0', - 'X-Appwrite-Response-Format': '1.8.0', + 'x-sdk-version': '0.24.2', + 'X-Appwrite-Response-Format': '1.9.0', }; /** @@ -293,6 +296,69 @@ class Client { 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; + } + private realtime: Realtime = { socket: undefined, @@ -588,6 +654,10 @@ class Client { window.localStorage.setItem('cookieFallback', cookieFallback); } + if (data && typeof data === 'object') { + data.toString = () => JSONbig.stringify(data); + } + return data; } catch (e) { if (e instanceof AppwriteException) { diff --git a/src/index.ts b/src/index.ts index f6d51fd5..ce905932 100644 --- a/src/index.ts +++ b/src/index.ts @@ -2,6 +2,7 @@ export { Client, AppwriteException } from './client'; export { Account } from './services/account'; export { Avatars } from './services/avatars'; export { Databases } from './services/databases'; +export { DocumentsDB } from './services/documents-db'; export { Functions } from './services/functions'; export { Graphql } from './services/graphql'; export { Locale } from './services/locale'; @@ -9,6 +10,7 @@ export { Messaging } from './services/messaging'; export { Storage } from './services/storage'; export { TablesDB } from './services/tables-db'; export { Teams } from './services/teams'; +export { VectorsDB } from './services/vectors-db'; export type { Models, Payload, RealtimeResponseEvent, UploadProgress } from './client'; export type { QueryTypes, QueryTypesList } from './query'; export { Query } from './query'; diff --git a/src/models.ts b/src/models.ts index 06c8d712..dc2e4ff7 100644 --- a/src/models.ts +++ b/src/models.ts @@ -240,7 +240,7 @@ export namespace Models { /** * Row sequence ID. */ - $sequence: number; + $sequence: string; /** * Table ID. */ @@ -279,7 +279,7 @@ export namespace Models { /** * Document sequence ID. */ - $sequence: number; + $sequence: string; /** * Collection ID. */ @@ -316,15 +316,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; /** @@ -477,6 +477,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; } /** diff --git a/src/services/databases.ts b/src/services/databases.ts index 92bae343..39edb06b 100644 --- a/src/services/databases.ts +++ b/src/services/databases.ts @@ -488,6 +488,83 @@ export class Databases extends Service { }, 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#databasesCreateCollection) 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} + * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.upsertRows` instead. + */ + 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#databasesCreateCollection) 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 = '/databases/{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); + return this.client.call('put', uri, { + 'content-type': 'application/json', + }, payload); + } + /** * Get a document by its unique ID. This endpoint response returns a JSON object with the document data. * diff --git a/src/services/documents-db.ts b/src/services/documents-db.ts new file mode 100644 index 00000000..97119f01 --- /dev/null +++ b/src/services/documents-db.ts @@ -0,0 +1,1041 @@ +import { Service } from '../service'; +import { AppwriteException, Client } from '../client'; +import type { Models } from '../models'; +import type { UploadProgress, Payload } from '../client'; +import * as FileSystem from 'expo-file-system'; +import { Platform } from 'react-native'; + + +export class DocumentsDB extends Service { + + constructor(client: Client) + { + super(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). + * @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); + return this.client.call('get', uri, { + }, 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); + return this.client.call('post', uri, { + 'content-type': 'application/json', + }, 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); + return this.client.call('get', uri, { + }, 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); + return this.client.call('patch', uri, { + 'content-type': 'application/json', + }, 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); + return this.client.call('delete', uri, { + 'content-type': 'application/json', + }, 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); + return this.client.call('post', uri, { + 'content-type': 'application/json', + }, 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); + return this.client.call('get', uri, { + }, 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); + return this.client.call('post', uri, { + 'content-type': 'application/json', + }, 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); + return this.client.call('post', uri, { + 'content-type': 'application/json', + }, 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); + return this.client.call('get', uri, { + }, 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); + return this.client.call('put', uri, { + 'content-type': 'application/json', + }, 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); + return this.client.call('patch', uri, { + 'content-type': 'application/json', + }, 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); + return this.client.call('delete', uri, { + 'content-type': 'application/json', + }, 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); + return this.client.call('patch', uri, { + 'content-type': 'application/json', + }, 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); + return this.client.call('patch', uri, { + 'content-type': 'application/json', + }, payload); + } +}; diff --git a/src/services/vectors-db.ts b/src/services/vectors-db.ts new file mode 100644 index 00000000..e4b04928 --- /dev/null +++ b/src/services/vectors-db.ts @@ -0,0 +1,775 @@ +import { Service } from '../service'; +import { AppwriteException, Client } from '../client'; +import type { Models } from '../models'; +import type { UploadProgress, Payload } from '../client'; +import * as FileSystem from 'expo-file-system'; +import { Platform } from 'react-native'; + + +export class VectorsDB extends Service { + + constructor(client: Client) + { + super(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). + * @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); + return this.client.call('get', uri, { + }, 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); + return this.client.call('post', uri, { + 'content-type': 'application/json', + }, 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); + return this.client.call('get', uri, { + }, 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); + return this.client.call('patch', uri, { + 'content-type': 'application/json', + }, 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); + return this.client.call('delete', uri, { + 'content-type': 'application/json', + }, 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); + return this.client.call('post', uri, { + 'content-type': 'application/json', + }, 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); + return this.client.call('get', uri, { + }, 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); + return this.client.call('post', uri, { + 'content-type': 'application/json', + }, 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); + return this.client.call('get', uri, { + }, 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); + return this.client.call('put', uri, { + 'content-type': 'application/json', + }, 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); + return this.client.call('patch', uri, { + 'content-type': 'application/json', + }, 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); + return this.client.call('delete', uri, { + 'content-type': 'application/json', + }, payload); + } +}; From 29db635b762d1d04540c14873a681ea1ff1f80d6 Mon Sep 17 00:00:00 2001 From: root Date: Wed, 25 Mar 2026 04:23:12 +0000 Subject: [PATCH 2/5] chore: update React Native SDK to 0.25.0 --- CHANGELOG.md | 4 ++++ README.md | 2 +- package.json | 2 +- src/client.ts | 2 +- 4 files changed, 7 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index fe74f4a8..9a893dda 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Change log +## 0.25.0 + +* [BREAKING] Changed `$sequence` type from `int` to `string` for rows and documents + ## 0.24.1 * Fix very large double values (for example 1.7976931348623157e+308) from being expanded into giant integer literals. diff --git a/README.md b/README.md index 939dd95d..da4140d5 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-react-native/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-react-native/releases).** Appwrite is an open-source backend as a service server that abstracts and simplifies complex and repetitive development tasks behind a very simple to use REST API. Appwrite aims to help you develop your apps faster and in a more secure way. Use the React Native SDK to integrate your app with the Appwrite server to easily start interacting with all of Appwrite backend APIs and tools. For full API documentation and tutorials go to [https://appwrite.io/docs](https://appwrite.io/docs) diff --git a/package.json b/package.json index 33b21716..4545f282 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "react-native-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": "0.24.2", + "version": "0.25.0", "license": "BSD-3-Clause", "main": "dist/cjs/sdk.js", "exports": { diff --git a/src/client.ts b/src/client.ts index bf5bfa92..e14516de 100644 --- a/src/client.ts +++ b/src/client.ts @@ -161,7 +161,7 @@ class Client { 'x-sdk-name': 'React Native', 'x-sdk-platform': 'client', 'x-sdk-language': 'reactnative', - 'x-sdk-version': '0.24.2', + 'x-sdk-version': '0.25.0', 'X-Appwrite-Response-Format': '1.9.0', }; From f80fe6122ae92a762686aed26b8f0606ddd2a9af Mon Sep 17 00:00:00 2001 From: root Date: Wed, 25 Mar 2026 05:25:19 +0000 Subject: [PATCH 3/5] chore: update React Native SDK to 0.25.0 --- docs/examples/documentsdb/create-document.md | 25 - docs/examples/documentsdb/create-documents.md | 17 - .../examples/documentsdb/create-operations.md | 26 - .../documentsdb/create-transaction.md | 15 - .../decrement-document-attribute.md | 21 - docs/examples/documentsdb/delete-document.md | 18 - .../documentsdb/delete-transaction.md | 15 - docs/examples/documentsdb/get-document.md | 19 - docs/examples/documentsdb/get-transaction.md | 15 - .../increment-document-attribute.md | 21 - docs/examples/documentsdb/list-documents.md | 20 - .../examples/documentsdb/list-transactions.md | 15 - docs/examples/documentsdb/update-document.md | 20 - .../documentsdb/update-transaction.md | 17 - docs/examples/documentsdb/upsert-document.md | 20 - docs/examples/vectorsdb/create-document.md | 29 - docs/examples/vectorsdb/create-operations.md | 26 - docs/examples/vectorsdb/create-transaction.md | 15 - docs/examples/vectorsdb/delete-document.md | 18 - docs/examples/vectorsdb/delete-transaction.md | 15 - docs/examples/vectorsdb/get-document.md | 19 - docs/examples/vectorsdb/get-transaction.md | 15 - docs/examples/vectorsdb/list-documents.md | 20 - docs/examples/vectorsdb/list-transactions.md | 15 - docs/examples/vectorsdb/update-document.md | 20 - docs/examples/vectorsdb/update-transaction.md | 17 - docs/examples/vectorsdb/upsert-document.md | 20 - src/index.ts | 2 - src/services/documents-db.ts | 1041 ----------------- src/services/vectors-db.ts | 775 ------------ 30 files changed, 2331 deletions(-) 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-operations.md delete mode 100644 docs/examples/documentsdb/create-transaction.md delete mode 100644 docs/examples/documentsdb/decrement-document-attribute.md delete mode 100644 docs/examples/documentsdb/delete-document.md delete mode 100644 docs/examples/documentsdb/delete-transaction.md delete mode 100644 docs/examples/documentsdb/get-document.md delete mode 100644 docs/examples/documentsdb/get-transaction.md delete mode 100644 docs/examples/documentsdb/increment-document-attribute.md delete mode 100644 docs/examples/documentsdb/list-documents.md delete mode 100644 docs/examples/documentsdb/list-transactions.md delete mode 100644 docs/examples/documentsdb/update-document.md delete mode 100644 docs/examples/documentsdb/update-transaction.md delete mode 100644 docs/examples/documentsdb/upsert-document.md delete mode 100644 docs/examples/vectorsdb/create-document.md delete mode 100644 docs/examples/vectorsdb/create-operations.md delete mode 100644 docs/examples/vectorsdb/create-transaction.md delete mode 100644 docs/examples/vectorsdb/delete-document.md delete mode 100644 docs/examples/vectorsdb/delete-transaction.md delete mode 100644 docs/examples/vectorsdb/get-document.md delete mode 100644 docs/examples/vectorsdb/get-transaction.md delete mode 100644 docs/examples/vectorsdb/list-documents.md delete mode 100644 docs/examples/vectorsdb/list-transactions.md delete mode 100644 docs/examples/vectorsdb/update-document.md delete mode 100644 docs/examples/vectorsdb/update-transaction.md delete mode 100644 docs/examples/vectorsdb/upsert-document.md delete mode 100644 src/services/documents-db.ts delete mode 100644 src/services/vectors-db.ts diff --git a/docs/examples/documentsdb/create-document.md b/docs/examples/documentsdb/create-document.md deleted file mode 100644 index cbb11795..00000000 --- a/docs/examples/documentsdb/create-document.md +++ /dev/null @@ -1,25 +0,0 @@ -```javascript -import { Client, DocumentsDB, Permission, Role } from "react-native-appwrite"; - -const client = new Client() - .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - .setProject(''); // Your project ID - -const documentsDB = new 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: ["read("any")"] // optional -}); - -console.log(result); -``` diff --git a/docs/examples/documentsdb/create-documents.md b/docs/examples/documentsdb/create-documents.md deleted file mode 100644 index de91fae0..00000000 --- a/docs/examples/documentsdb/create-documents.md +++ /dev/null @@ -1,17 +0,0 @@ -```javascript -import { Client, DocumentsDB } from "react-native-appwrite"; - -const client = new Client() - .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - .setProject(''); // Your project ID - -const documentsDB = new DocumentsDB(client); - -const result = await documentsDB.createDocuments({ - databaseId: '', - collectionId: '', - documents: [] -}); - -console.log(result); -``` diff --git a/docs/examples/documentsdb/create-operations.md b/docs/examples/documentsdb/create-operations.md deleted file mode 100644 index fefe87f0..00000000 --- a/docs/examples/documentsdb/create-operations.md +++ /dev/null @@ -1,26 +0,0 @@ -```javascript -import { Client, DocumentsDB } from "react-native-appwrite"; - -const client = new Client() - .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - .setProject(''); // Your project ID - -const documentsDB = new DocumentsDB(client); - -const result = await documentsDB.createOperations({ - transactionId: '', - operations: [ - { - "action": "create", - "databaseId": "", - "collectionId": "", - "documentId": "", - "data": { - "name": "Walter O'Brien" - } - } - ] // optional -}); - -console.log(result); -``` diff --git a/docs/examples/documentsdb/create-transaction.md b/docs/examples/documentsdb/create-transaction.md deleted file mode 100644 index 92efb795..00000000 --- a/docs/examples/documentsdb/create-transaction.md +++ /dev/null @@ -1,15 +0,0 @@ -```javascript -import { Client, DocumentsDB } from "react-native-appwrite"; - -const client = new Client() - .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - .setProject(''); // Your project ID - -const documentsDB = new DocumentsDB(client); - -const result = await documentsDB.createTransaction({ - ttl: 60 // optional -}); - -console.log(result); -``` diff --git a/docs/examples/documentsdb/decrement-document-attribute.md b/docs/examples/documentsdb/decrement-document-attribute.md deleted file mode 100644 index 69dc5c34..00000000 --- a/docs/examples/documentsdb/decrement-document-attribute.md +++ /dev/null @@ -1,21 +0,0 @@ -```javascript -import { Client, DocumentsDB } from "react-native-appwrite"; - -const client = new Client() - .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - .setProject(''); // Your project ID - -const documentsDB = new DocumentsDB(client); - -const result = await documentsDB.decrementDocumentAttribute({ - databaseId: '', - collectionId: '', - documentId: '', - attribute: '', - value: 0, // optional - min: 0, // optional - transactionId: '' // optional -}); - -console.log(result); -``` diff --git a/docs/examples/documentsdb/delete-document.md b/docs/examples/documentsdb/delete-document.md deleted file mode 100644 index dee5d605..00000000 --- a/docs/examples/documentsdb/delete-document.md +++ /dev/null @@ -1,18 +0,0 @@ -```javascript -import { Client, DocumentsDB } from "react-native-appwrite"; - -const client = new Client() - .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - .setProject(''); // Your project ID - -const documentsDB = new DocumentsDB(client); - -const result = await documentsDB.deleteDocument({ - databaseId: '', - collectionId: '', - documentId: '', - transactionId: '' // optional -}); - -console.log(result); -``` diff --git a/docs/examples/documentsdb/delete-transaction.md b/docs/examples/documentsdb/delete-transaction.md deleted file mode 100644 index e3282e38..00000000 --- a/docs/examples/documentsdb/delete-transaction.md +++ /dev/null @@ -1,15 +0,0 @@ -```javascript -import { Client, DocumentsDB } from "react-native-appwrite"; - -const client = new Client() - .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - .setProject(''); // Your project ID - -const documentsDB = new DocumentsDB(client); - -const result = await documentsDB.deleteTransaction({ - transactionId: '' -}); - -console.log(result); -``` diff --git a/docs/examples/documentsdb/get-document.md b/docs/examples/documentsdb/get-document.md deleted file mode 100644 index 5be89277..00000000 --- a/docs/examples/documentsdb/get-document.md +++ /dev/null @@ -1,19 +0,0 @@ -```javascript -import { Client, DocumentsDB } from "react-native-appwrite"; - -const client = new Client() - .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - .setProject(''); // Your project ID - -const documentsDB = new DocumentsDB(client); - -const result = await documentsDB.getDocument({ - databaseId: '', - collectionId: '', - documentId: '', - queries: [], // optional - transactionId: '' // optional -}); - -console.log(result); -``` diff --git a/docs/examples/documentsdb/get-transaction.md b/docs/examples/documentsdb/get-transaction.md deleted file mode 100644 index 32cdd766..00000000 --- a/docs/examples/documentsdb/get-transaction.md +++ /dev/null @@ -1,15 +0,0 @@ -```javascript -import { Client, DocumentsDB } from "react-native-appwrite"; - -const client = new Client() - .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - .setProject(''); // Your project ID - -const documentsDB = new DocumentsDB(client); - -const result = await documentsDB.getTransaction({ - transactionId: '' -}); - -console.log(result); -``` diff --git a/docs/examples/documentsdb/increment-document-attribute.md b/docs/examples/documentsdb/increment-document-attribute.md deleted file mode 100644 index 758a40b3..00000000 --- a/docs/examples/documentsdb/increment-document-attribute.md +++ /dev/null @@ -1,21 +0,0 @@ -```javascript -import { Client, DocumentsDB } from "react-native-appwrite"; - -const client = new Client() - .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - .setProject(''); // Your project ID - -const documentsDB = new DocumentsDB(client); - -const result = await documentsDB.incrementDocumentAttribute({ - databaseId: '', - collectionId: '', - documentId: '', - attribute: '', - value: 0, // optional - max: 0, // optional - transactionId: '' // optional -}); - -console.log(result); -``` diff --git a/docs/examples/documentsdb/list-documents.md b/docs/examples/documentsdb/list-documents.md deleted file mode 100644 index 6e6cc4dd..00000000 --- a/docs/examples/documentsdb/list-documents.md +++ /dev/null @@ -1,20 +0,0 @@ -```javascript -import { Client, DocumentsDB } from "react-native-appwrite"; - -const client = new Client() - .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - .setProject(''); // Your project ID - -const documentsDB = new DocumentsDB(client); - -const result = await documentsDB.listDocuments({ - databaseId: '', - collectionId: '', - queries: [], // optional - transactionId: '', // optional - total: false, // optional - ttl: 0 // optional -}); - -console.log(result); -``` diff --git a/docs/examples/documentsdb/list-transactions.md b/docs/examples/documentsdb/list-transactions.md deleted file mode 100644 index 3d946b38..00000000 --- a/docs/examples/documentsdb/list-transactions.md +++ /dev/null @@ -1,15 +0,0 @@ -```javascript -import { Client, DocumentsDB } from "react-native-appwrite"; - -const client = new Client() - .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - .setProject(''); // Your project ID - -const documentsDB = new DocumentsDB(client); - -const result = await documentsDB.listTransactions({ - queries: [] // optional -}); - -console.log(result); -``` diff --git a/docs/examples/documentsdb/update-document.md b/docs/examples/documentsdb/update-document.md deleted file mode 100644 index 28e34e8f..00000000 --- a/docs/examples/documentsdb/update-document.md +++ /dev/null @@ -1,20 +0,0 @@ -```javascript -import { Client, DocumentsDB, Permission, Role } from "react-native-appwrite"; - -const client = new Client() - .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - .setProject(''); // Your project ID - -const documentsDB = new DocumentsDB(client); - -const result = await documentsDB.updateDocument({ - databaseId: '', - collectionId: '', - documentId: '', - data: {}, // optional - permissions: ["read("any")"], // optional - transactionId: '' // optional -}); - -console.log(result); -``` diff --git a/docs/examples/documentsdb/update-transaction.md b/docs/examples/documentsdb/update-transaction.md deleted file mode 100644 index 8e76cdcf..00000000 --- a/docs/examples/documentsdb/update-transaction.md +++ /dev/null @@ -1,17 +0,0 @@ -```javascript -import { Client, DocumentsDB } from "react-native-appwrite"; - -const client = new Client() - .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - .setProject(''); // Your project ID - -const documentsDB = new DocumentsDB(client); - -const result = await documentsDB.updateTransaction({ - transactionId: '', - commit: false, // optional - rollback: false // optional -}); - -console.log(result); -``` diff --git a/docs/examples/documentsdb/upsert-document.md b/docs/examples/documentsdb/upsert-document.md deleted file mode 100644 index b3fce531..00000000 --- a/docs/examples/documentsdb/upsert-document.md +++ /dev/null @@ -1,20 +0,0 @@ -```javascript -import { Client, DocumentsDB, Permission, Role } from "react-native-appwrite"; - -const client = new Client() - .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - .setProject(''); // Your project ID - -const documentsDB = new DocumentsDB(client); - -const result = await documentsDB.upsertDocument({ - databaseId: '', - collectionId: '', - documentId: '', - data: {}, // optional - permissions: ["read("any")"], // optional - transactionId: '' // optional -}); - -console.log(result); -``` diff --git a/docs/examples/vectorsdb/create-document.md b/docs/examples/vectorsdb/create-document.md deleted file mode 100644 index 72620eec..00000000 --- a/docs/examples/vectorsdb/create-document.md +++ /dev/null @@ -1,29 +0,0 @@ -```javascript -import { Client, VectorsDB, Permission, Role } from "react-native-appwrite"; - -const client = new Client() - .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - .setProject(''); // Your project ID - -const vectorsDB = new VectorsDB(client); - -const result = await vectorsDB.createDocument({ - databaseId: '', - collectionId: '', - documentId: '', - data: { - "embeddings": [ - 0.12, - -0.55, - 0.88, - 1.02 - ], - "metadata": { - "key": "value" - } - }, - permissions: ["read("any")"] // optional -}); - -console.log(result); -``` diff --git a/docs/examples/vectorsdb/create-operations.md b/docs/examples/vectorsdb/create-operations.md deleted file mode 100644 index 81429751..00000000 --- a/docs/examples/vectorsdb/create-operations.md +++ /dev/null @@ -1,26 +0,0 @@ -```javascript -import { Client, VectorsDB } from "react-native-appwrite"; - -const client = new Client() - .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - .setProject(''); // Your project ID - -const vectorsDB = new VectorsDB(client); - -const result = await vectorsDB.createOperations({ - transactionId: '', - operations: [ - { - "action": "create", - "databaseId": "", - "collectionId": "", - "documentId": "", - "data": { - "name": "Walter O'Brien" - } - } - ] // optional -}); - -console.log(result); -``` diff --git a/docs/examples/vectorsdb/create-transaction.md b/docs/examples/vectorsdb/create-transaction.md deleted file mode 100644 index ae07efbd..00000000 --- a/docs/examples/vectorsdb/create-transaction.md +++ /dev/null @@ -1,15 +0,0 @@ -```javascript -import { Client, VectorsDB } from "react-native-appwrite"; - -const client = new Client() - .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - .setProject(''); // Your project ID - -const vectorsDB = new VectorsDB(client); - -const result = await vectorsDB.createTransaction({ - ttl: 60 // optional -}); - -console.log(result); -``` diff --git a/docs/examples/vectorsdb/delete-document.md b/docs/examples/vectorsdb/delete-document.md deleted file mode 100644 index 6eee6695..00000000 --- a/docs/examples/vectorsdb/delete-document.md +++ /dev/null @@ -1,18 +0,0 @@ -```javascript -import { Client, VectorsDB } from "react-native-appwrite"; - -const client = new Client() - .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - .setProject(''); // Your project ID - -const vectorsDB = new VectorsDB(client); - -const result = await vectorsDB.deleteDocument({ - databaseId: '', - collectionId: '', - documentId: '', - transactionId: '' // optional -}); - -console.log(result); -``` diff --git a/docs/examples/vectorsdb/delete-transaction.md b/docs/examples/vectorsdb/delete-transaction.md deleted file mode 100644 index 10fe8423..00000000 --- a/docs/examples/vectorsdb/delete-transaction.md +++ /dev/null @@ -1,15 +0,0 @@ -```javascript -import { Client, VectorsDB } from "react-native-appwrite"; - -const client = new Client() - .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - .setProject(''); // Your project ID - -const vectorsDB = new VectorsDB(client); - -const result = await vectorsDB.deleteTransaction({ - transactionId: '' -}); - -console.log(result); -``` diff --git a/docs/examples/vectorsdb/get-document.md b/docs/examples/vectorsdb/get-document.md deleted file mode 100644 index 2ad29dcc..00000000 --- a/docs/examples/vectorsdb/get-document.md +++ /dev/null @@ -1,19 +0,0 @@ -```javascript -import { Client, VectorsDB } from "react-native-appwrite"; - -const client = new Client() - .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - .setProject(''); // Your project ID - -const vectorsDB = new VectorsDB(client); - -const result = await vectorsDB.getDocument({ - databaseId: '', - collectionId: '', - documentId: '', - queries: [], // optional - transactionId: '' // optional -}); - -console.log(result); -``` diff --git a/docs/examples/vectorsdb/get-transaction.md b/docs/examples/vectorsdb/get-transaction.md deleted file mode 100644 index 41599da0..00000000 --- a/docs/examples/vectorsdb/get-transaction.md +++ /dev/null @@ -1,15 +0,0 @@ -```javascript -import { Client, VectorsDB } from "react-native-appwrite"; - -const client = new Client() - .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - .setProject(''); // Your project ID - -const vectorsDB = new VectorsDB(client); - -const result = await vectorsDB.getTransaction({ - transactionId: '' -}); - -console.log(result); -``` diff --git a/docs/examples/vectorsdb/list-documents.md b/docs/examples/vectorsdb/list-documents.md deleted file mode 100644 index fb42061f..00000000 --- a/docs/examples/vectorsdb/list-documents.md +++ /dev/null @@ -1,20 +0,0 @@ -```javascript -import { Client, VectorsDB } from "react-native-appwrite"; - -const client = new Client() - .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - .setProject(''); // Your project ID - -const vectorsDB = new VectorsDB(client); - -const result = await vectorsDB.listDocuments({ - databaseId: '', - collectionId: '', - queries: [], // optional - transactionId: '', // optional - total: false, // optional - ttl: 0 // optional -}); - -console.log(result); -``` diff --git a/docs/examples/vectorsdb/list-transactions.md b/docs/examples/vectorsdb/list-transactions.md deleted file mode 100644 index 179017c0..00000000 --- a/docs/examples/vectorsdb/list-transactions.md +++ /dev/null @@ -1,15 +0,0 @@ -```javascript -import { Client, VectorsDB } from "react-native-appwrite"; - -const client = new Client() - .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - .setProject(''); // Your project ID - -const vectorsDB = new VectorsDB(client); - -const result = await vectorsDB.listTransactions({ - queries: [] // optional -}); - -console.log(result); -``` diff --git a/docs/examples/vectorsdb/update-document.md b/docs/examples/vectorsdb/update-document.md deleted file mode 100644 index c9a8c7ab..00000000 --- a/docs/examples/vectorsdb/update-document.md +++ /dev/null @@ -1,20 +0,0 @@ -```javascript -import { Client, VectorsDB, Permission, Role } from "react-native-appwrite"; - -const client = new Client() - .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - .setProject(''); // Your project ID - -const vectorsDB = new VectorsDB(client); - -const result = await vectorsDB.updateDocument({ - databaseId: '', - collectionId: '', - documentId: '', - data: {}, // optional - permissions: ["read("any")"], // optional - transactionId: '' // optional -}); - -console.log(result); -``` diff --git a/docs/examples/vectorsdb/update-transaction.md b/docs/examples/vectorsdb/update-transaction.md deleted file mode 100644 index 29a999e6..00000000 --- a/docs/examples/vectorsdb/update-transaction.md +++ /dev/null @@ -1,17 +0,0 @@ -```javascript -import { Client, VectorsDB } from "react-native-appwrite"; - -const client = new Client() - .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - .setProject(''); // Your project ID - -const vectorsDB = new VectorsDB(client); - -const result = await vectorsDB.updateTransaction({ - transactionId: '', - commit: false, // optional - rollback: false // optional -}); - -console.log(result); -``` diff --git a/docs/examples/vectorsdb/upsert-document.md b/docs/examples/vectorsdb/upsert-document.md deleted file mode 100644 index d1f33b32..00000000 --- a/docs/examples/vectorsdb/upsert-document.md +++ /dev/null @@ -1,20 +0,0 @@ -```javascript -import { Client, VectorsDB, Permission, Role } from "react-native-appwrite"; - -const client = new Client() - .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - .setProject(''); // Your project ID - -const vectorsDB = new VectorsDB(client); - -const result = await vectorsDB.upsertDocument({ - databaseId: '', - collectionId: '', - documentId: '', - data: {}, // optional - permissions: ["read("any")"], // optional - transactionId: '' // optional -}); - -console.log(result); -``` diff --git a/src/index.ts b/src/index.ts index ce905932..f6d51fd5 100644 --- a/src/index.ts +++ b/src/index.ts @@ -2,7 +2,6 @@ export { Client, AppwriteException } from './client'; export { Account } from './services/account'; export { Avatars } from './services/avatars'; export { Databases } from './services/databases'; -export { DocumentsDB } from './services/documents-db'; export { Functions } from './services/functions'; export { Graphql } from './services/graphql'; export { Locale } from './services/locale'; @@ -10,7 +9,6 @@ export { Messaging } from './services/messaging'; export { Storage } from './services/storage'; export { TablesDB } from './services/tables-db'; export { Teams } from './services/teams'; -export { VectorsDB } from './services/vectors-db'; export type { Models, Payload, RealtimeResponseEvent, UploadProgress } from './client'; export type { QueryTypes, QueryTypesList } from './query'; export { Query } from './query'; diff --git a/src/services/documents-db.ts b/src/services/documents-db.ts deleted file mode 100644 index 97119f01..00000000 --- a/src/services/documents-db.ts +++ /dev/null @@ -1,1041 +0,0 @@ -import { Service } from '../service'; -import { AppwriteException, Client } from '../client'; -import type { Models } from '../models'; -import type { UploadProgress, Payload } from '../client'; -import * as FileSystem from 'expo-file-system'; -import { Platform } from 'react-native'; - - -export class DocumentsDB extends Service { - - constructor(client: Client) - { - super(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). - * @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); - return this.client.call('get', uri, { - }, 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); - return this.client.call('post', uri, { - 'content-type': 'application/json', - }, 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); - return this.client.call('get', uri, { - }, 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); - return this.client.call('patch', uri, { - 'content-type': 'application/json', - }, 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); - return this.client.call('delete', uri, { - 'content-type': 'application/json', - }, 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); - return this.client.call('post', uri, { - 'content-type': 'application/json', - }, 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); - return this.client.call('get', uri, { - }, 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); - return this.client.call('post', uri, { - 'content-type': 'application/json', - }, 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); - return this.client.call('post', uri, { - 'content-type': 'application/json', - }, 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); - return this.client.call('get', uri, { - }, 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); - return this.client.call('put', uri, { - 'content-type': 'application/json', - }, 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); - return this.client.call('patch', uri, { - 'content-type': 'application/json', - }, 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); - return this.client.call('delete', uri, { - 'content-type': 'application/json', - }, 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); - return this.client.call('patch', uri, { - 'content-type': 'application/json', - }, 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); - return this.client.call('patch', uri, { - 'content-type': 'application/json', - }, payload); - } -}; diff --git a/src/services/vectors-db.ts b/src/services/vectors-db.ts deleted file mode 100644 index e4b04928..00000000 --- a/src/services/vectors-db.ts +++ /dev/null @@ -1,775 +0,0 @@ -import { Service } from '../service'; -import { AppwriteException, Client } from '../client'; -import type { Models } from '../models'; -import type { UploadProgress, Payload } from '../client'; -import * as FileSystem from 'expo-file-system'; -import { Platform } from 'react-native'; - - -export class VectorsDB extends Service { - - constructor(client: Client) - { - super(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). - * @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); - return this.client.call('get', uri, { - }, 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); - return this.client.call('post', uri, { - 'content-type': 'application/json', - }, 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); - return this.client.call('get', uri, { - }, 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); - return this.client.call('patch', uri, { - 'content-type': 'application/json', - }, 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); - return this.client.call('delete', uri, { - 'content-type': 'application/json', - }, 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); - return this.client.call('post', uri, { - 'content-type': 'application/json', - }, 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); - return this.client.call('get', uri, { - }, 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); - return this.client.call('post', uri, { - 'content-type': 'application/json', - }, 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); - return this.client.call('get', uri, { - }, 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); - return this.client.call('put', uri, { - 'content-type': 'application/json', - }, 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); - return this.client.call('patch', uri, { - 'content-type': 'application/json', - }, 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); - return this.client.call('delete', uri, { - 'content-type': 'application/json', - }, payload); - } -}; From 360b5b48d7545bd7bbf18f71aeb71722e06b7677 Mon Sep 17 00:00:00 2001 From: root Date: Wed, 25 Mar 2026 06:41:23 +0000 Subject: [PATCH 4/5] chore: update React Native SDK to 0.25.0 --- src/models.ts | 1376 ++++++++++++++++++++++++------------------------- 1 file changed, 688 insertions(+), 688 deletions(-) diff --git a/src/models.ts b/src/models.ts index dc2e4ff7..c1a85a19 100644 --- a/src/models.ts +++ b/src/models.ts @@ -6,339 +6,217 @@ 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[]; - } - - /** - * Sessions List - */ - export type SessionList = { + name: string; /** - * Total number of sessions that matched your query. + * Hashed user password. */ - total: number; + password?: string; /** - * List of sessions. + * Password hashing algorithm. */ - sessions: Session[]; - } - - /** - * Identities List - */ - export type IdentityList = { + hash?: string; /** - * Total number of identities that matched your query. + * Password hashing algorithm configuration. */ - total: number; + hashOptions?: object; /** - * List of identities. + * User registration date in ISO 8601 format. */ - identities: Identity[]; - } - - /** - * Logs List - */ - export type LogList = { + registration: string; /** - * Total number of logs that matched your query. + * User status. Pass `true` for enabled and `false` for disabled. */ - total: number; + status: boolean; /** - * List of logs. + * Labels for the user. */ - logs: Log[]; - } - - /** - * Files List - */ - export type FileList = { + labels: string[]; /** - * Total number of files that matched your query. + * Password update time in ISO 8601 format. */ - total: number; + passwordUpdate: string; /** - * List of files. + * User email address. */ - files: File[]; - } - - /** - * Teams List - */ - export type TeamList = { + email: string; /** - * Total number of teams that matched your query. + * User phone number in E.164 format. */ - total: number; + phone: string; /** - * List of teams. + * Email verification status. */ - teams: Team[]; - } - - /** - * Memberships List - */ - export type MembershipList = { + emailVerification: boolean; /** - * Total number of memberships that matched your query. + * Phone verification status. */ - total: number; + phoneVerification: boolean; /** - * List of memberships. + * Multi factor authentication status. */ - memberships: Membership[]; - } - - /** - * Executions List - */ - export type ExecutionList = { + mfa: boolean; /** - * Total number of executions that matched your query. + * User preferences as a key-value object */ - total: number; + prefs: Preferences; /** - * List of executions. + * 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. */ - executions: Execution[]; - } - - /** - * Countries List - */ - export type CountryList = { + targets: Target[]; /** - * Total number of countries that matched your query. + * Most recent access date in ISO 8601 format. This attribute is only updated again after 24 hours. */ - total: number; + accessedAt: string; /** - * List of countries. + * Whether the user can impersonate other users. */ - countries: Country[]; + 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; } /** - * Continents List + * Identities List */ - export type ContinentList = { + export type IdentityList = { /** - * Total number of continents that matched your query. + * Total number of identities that matched your query. */ total: number; /** - * List of continents. + * List of identities. */ - continents: Continent[]; + identities: Identity[]; } /** - * Languages List + * JWT */ - export type LanguageList = { - /** - * Total number of languages that matched your query. - */ - total: number; + export type Jwt = { /** - * List of languages. + * JWT encoded string. */ - languages: Language[]; + jwt: string; } /** - * Currencies List + * Logs List */ - export type CurrencyList = { + export type LogList = { /** - * Total number of currencies that matched your query. + * Total number of logs that matched your query. */ total: number; /** - * List of currencies. + * List of logs. */ - currencies: Currency[]; + logs: Log[]; } /** - * Phones List + * MFAType */ - export type PhoneList = { + export type MfaType = { /** - * Total number of phones that matched your query. + * Secret token used for TOTP factor. */ - total: number; + secret: string; /** - * List of phones. + * URI for authenticator apps. */ - phones: Phone[]; + uri: string; } /** - * Locale codes list + * MFA Challenge */ - export type LocaleCodeList = { + export type MfaChallenge = { /** - * Total number of localeCodes that matched your query. + * Token ID. */ - total: number; + $id: string; /** - * List of localeCodes. + * Token creation date in ISO 8601 format. */ - localeCodes: LocaleCode[]; - } - - /** - * Transaction List - */ - export type TransactionList = { + $createdAt: string; /** - * Total number of transactions that matched your query. + * User ID. */ - total: number; + userId: string; /** - * List of transactions. + * Token expiration date in ISO 8601 format. */ - transactions: Transaction[]; + expire: string; } /** - * Row + * Session */ - export type Row = { + export type Session = { /** - * Row ID. + * Session ID. */ $id: string; /** - * Row sequence ID. + * Session creation date in ISO 8601 format. */ - $sequence: string; + $createdAt: string; /** - * Table ID. + * Session update date in ISO 8601 format. */ - $tableId: string; + $updatedAt: string; /** - * Database ID. + * User ID. */ - $databaseId: string; + userId: string; /** - * Row creation date in ISO 8601 format. + * Session expiration date in ISO 8601 format. */ - $createdAt: string; + expire: string; /** - * Row update date in ISO 8601 format. + * Session Provider. */ - $updatedAt: string; + provider: string; /** - * Row permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). + * Session Provider User ID. */ - $permissions: string[]; - } - - export type DefaultRow = Row & { - [key: string]: any; - [__default]: true; - }; - - /** - * Document - */ - export type Document = { + providerUid: string; /** - * Document ID. + * Session Provider Access Token. */ - $id: string; - /** - * Document sequence ID. - */ - $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; - }; - - /** - * Log - */ - 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; + providerAccessToken: string; /** - * User name of the actor recorded for this log. During impersonation, this is the original impersonator. + * The date of when the access token expires in ISO 8601 format. */ - userName: string; + providerAccessTokenExpiry: string; /** - * API mode when event triggered. + * Session Provider Refresh Token. */ - mode: string; + providerRefreshToken: string; /** - * IP session in use when the session was created. + * IP 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). */ @@ -395,473 +273,514 @@ export namespace Models { * Country name. */ countryName: string; + /** + * Returns true if this the current user session. + */ + current: boolean; + /** + * Returns a list of active session factors. + */ + factors: string[]; + /** + * Secret used to authenticate the user. Only included if the request was made with an API key + */ + secret: string; + /** + * Most recent date in ISO 8601 format when the session successfully passed MFA challenge. + */ + mfaUpdatedAt: string; } /** - * User + * MFAFactors */ - export type User = { + export type MfaFactors = { /** - * User ID. + * Can TOTP be used for MFA challenge for this account. */ - $id: string; + totp: boolean; /** - * User creation date in ISO 8601 format. + * Can phone (SMS) be used for MFA challenge for this account. */ - $createdAt: string; + phone: boolean; /** - * User update date in ISO 8601 format. + * Can email be used for MFA challenge for this account. */ - $updatedAt: string; + email: boolean; /** - * User name. + * Can recovery code be used for MFA challenge for this account. */ - name: string; + recoveryCode: boolean; + } + + /** + * MFA Recovery Codes + */ + export type MfaRecoveryCodes = { /** - * Hashed user password. + * Recovery codes. */ - password?: string; + recoveryCodes: string[]; + } + + /** + * Preferences + */ + export type Preferences = { + } + + export type DefaultPreferences = Preferences & { + [key: string]: any; + [__default]: true; + }; + + /** + * Token + */ + export type Token = { /** - * Password hashing algorithm. + * Token ID. */ - hash?: string; + $id: string; /** - * Password hashing algorithm configuration. + * Token creation date in ISO 8601 format. */ - hashOptions?: object; + $createdAt: string; /** - * User registration date in ISO 8601 format. + * User ID. */ - registration: string; + userId: string; /** - * User status. Pass `true` for enabled and `false` for disabled. + * 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. */ - status: boolean; + secret: string; /** - * Labels for the user. + * Token expiration date in ISO 8601 format. */ - labels: string[]; + expire: string; /** - * Password update time in ISO 8601 format. + * 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. */ - passwordUpdate: string; + phrase: string; + } + + /** + * Sessions List + */ + export type SessionList = { /** - * User email address. + * Total number of sessions that matched your query. */ - email: string; + total: number; /** - * User phone number in E.164 format. + * List of sessions. */ - phone: string; + sessions: Session[]; + } + + /** + * Target + */ + export type Target = { /** - * Email verification status. + * Target ID. */ - emailVerification: boolean; + $id: string; /** - * Phone verification status. + * Target creation time in ISO 8601 format. */ - phoneVerification: boolean; + $createdAt: string; /** - * Multi factor authentication status. + * Target update date in ISO 8601 format. */ - mfa: boolean; + $updatedAt: string; /** - * User preferences as a key-value object + * Target Name. */ - prefs: Preferences; + name: string; /** - * 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. + * User ID. */ - targets: Target[]; + userId: string; /** - * Most recent access date in ISO 8601 format. This attribute is only updated again after 24 hours. + * Provider ID. */ - accessedAt: string; + providerId?: string; /** - * Whether the user can impersonate other users. + * The target provider type. Can be one of the following: `email`, `sms` or `push`. */ - impersonator?: boolean; + providerType: string; /** - * 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. + * The target identifier. */ - impersonatorUserId?: string; - } - - /** - * AlgoMD5 - */ - export type AlgoMd5 = { + identifier: string; /** - * Algo type. + * Is the target expired. */ - type: string; + expired: boolean; } /** - * AlgoSHA + * Transaction List */ - export type AlgoSha = { + export type TransactionList = { /** - * Algo type. + * Total number of transactions that matched your query. */ - type: string; - } - - /** - * AlgoPHPass - */ - export type AlgoPhpass = { + total: number; /** - * Algo type. + * List of transactions. */ - type: string; + transactions: Transaction[]; } /** - * AlgoBcrypt + * Transaction */ - export type AlgoBcrypt = { + export type Transaction = { /** - * Algo type. + * Transaction ID. */ - type: string; - } - - /** - * AlgoScrypt - */ - export type AlgoScrypt = { + $id: string; /** - * Algo type. + * Transaction creation time in ISO 8601 format. */ - type: string; + $createdAt: string; /** - * CPU complexity of computed hash. + * Transaction update date in ISO 8601 format. */ - costCpu: number; + $updatedAt: string; /** - * Memory complexity of computed hash. + * Current status of the transaction. One of: pending, committing, committed, rolled_back, failed. */ - costMemory: number; + status: string; /** - * Parallelization of computed hash. + * Number of operations in the transaction. */ - costParallel: number; + operations: number; /** - * Length used to compute hash. + * Expiration time in ISO 8601 format. */ - length: number; + expiresAt: string; } /** - * AlgoScryptModified + * Documents List */ - export type AlgoScryptModified = { - /** - * Algo type. - */ - type: string; - /** - * Salt used to compute hash. - */ - salt: string; + export type DocumentList = { /** - * Separator used to compute hash. + * Total number of documents that matched your query. */ - saltSeparator: string; + total: number; /** - * Key used to compute hash. + * List of documents. */ - signerKey: string; + documents: Document[]; } /** - * AlgoArgon2 + * Document */ - export type AlgoArgon2 = { - /** - * Algo type. - */ - type: string; + export type Document = { /** - * Memory used to compute hash. + * Document ID. */ - memoryCost: number; + $id: string; /** - * Amount of time consumed to compute hash + * Document sequence ID. */ - timeCost: number; + $sequence: string; /** - * Number of threads used to compute hash. + * Collection ID. */ - threads: number; - } - - /** - * Preferences - */ - export type Preferences = { - } - - export type DefaultPreferences = Preferences & { - [key: string]: any; - [__default]: true; - }; - - /** - * Session - */ - export type Session = { + $collectionId: string; /** - * Session ID. + * Database ID. */ - $id: string; + $databaseId: string; /** - * Session creation date in ISO 8601 format. + * Document creation date in ISO 8601 format. */ $createdAt: string; /** - * Session update date in ISO 8601 format. + * Document 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. - */ - providerUid: string; - /** - * Session Provider Access Token. - */ - providerAccessToken: string; - /** - * The date of when the access token expires in ISO 8601 format. + * Document permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). */ - providerAccessTokenExpiry: string; + $permissions: string[]; + } + + export type DefaultDocument = Document & { + [key: string]: any; + [__default]: true; + }; + + /** + * Executions List + */ + export type ExecutionList = { /** - * Session Provider Refresh Token. + * Total number of executions that matched your query. */ - providerRefreshToken: string; + total: number; /** - * IP in use when the session was created. + * List of executions. */ - ip: string; + executions: Execution[]; + } + + /** + * Execution + */ + export type Execution = { /** - * Operating system code name. View list of [available options](https://github.com/appwrite/appwrite/blob/master/docs/lists/os.json). + * Execution ID. */ - osCode: string; + $id: string; /** - * Operating system name. + * Execution creation date in ISO 8601 format. */ - osName: string; + $createdAt: string; /** - * Operating system version. + * Execution update date in ISO 8601 format. */ - osVersion: string; + $updatedAt: string; /** - * Client type. + * Execution roles. */ - clientType: string; + $permissions: string[]; /** - * Client code name. View list of [available options](https://github.com/appwrite/appwrite/blob/master/docs/lists/clients.json). + * Function ID. */ - clientCode: string; + functionId: string; /** - * Client name. + * Function's deployment ID used to create the execution. */ - clientName: string; + deploymentId: string; /** - * Client version. + * The trigger that caused the function to execute. Possible values can be: `http`, `schedule`, or `event`. */ - clientVersion: string; + trigger: ExecutionTrigger; /** - * Client engine name. + * The status of the function execution. Possible values can be: `waiting`, `processing`, `completed`, `failed`, or `scheduled`. */ - clientEngine: string; + status: ExecutionStatus; /** - * Client engine name. + * HTTP request method type. */ - clientEngineVersion: string; + requestMethod: string; /** - * Device name. + * HTTP request path and query. */ - deviceName: string; + requestPath: string; /** - * Device brand name. + * HTTP request headers as a key-value object. This will return only whitelisted headers. All headers are returned if execution is created as synchronous. */ - deviceBrand: string; + requestHeaders: Headers[]; /** - * Device model name. + * HTTP response status code. */ - deviceModel: string; + responseStatusCode: number; /** - * Country two-character ISO 3166-1 alpha code. + * HTTP response body. This will return empty unless execution is created as synchronous. */ - countryCode: string; + responseBody: string; /** - * Country name. + * HTTP response headers as a key-value object. This will return only whitelisted headers. All headers are returned if execution is created as synchronous. */ - countryName: string; + responseHeaders: Headers[]; /** - * Returns true if this the current user session. + * 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. */ - current: boolean; + logs: string; /** - * Returns a list of active session factors. + * 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. */ - factors: string[]; + errors: string; /** - * Secret used to authenticate the user. Only included if the request was made with an API key + * Resource(function/site) execution duration in seconds. */ - secret: string; + duration: number; /** - * Most recent date in ISO 8601 format when the session successfully passed MFA challenge. + * The scheduled time for execution. If left empty, execution will be queued immediately. */ - mfaUpdatedAt: string; + scheduledAt?: string; } /** - * Identity + * Locale */ - export type Identity = { + export type Locale = { /** - * Identity ID. + * User IP address. */ - $id: string; + ip: string; /** - * Identity creation date in ISO 8601 format. + * Country code in [ISO 3166-1](http://en.wikipedia.org/wiki/ISO_3166-1) two-character format */ - $createdAt: string; + countryCode: string; /** - * Identity update date in ISO 8601 format. + * Country name. This field support localization. */ - $updatedAt: string; + country: string; /** - * User ID. + * 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. */ - userId: string; + continentCode: string; /** - * Identity Provider. + * Continent name. This field support localization. */ - provider: string; + continent: string; /** - * ID of the User in the Identity Provider. + * True if country is part of the European Union. */ - providerUid: string; + eu: boolean; /** - * Email of the User in the Identity Provider. + * Currency code in [ISO 4217-1](http://en.wikipedia.org/wiki/ISO_4217) three-character format */ - providerEmail: string; + currency: string; + } + + /** + * Locale codes list + */ + export type LocaleCodeList = { /** - * Identity Provider Access Token. + * Total number of localeCodes that matched your query. */ - providerAccessToken: string; + total: number; /** - * The date of when the access token expires in ISO 8601 format. + * List of localeCodes. */ - providerAccessTokenExpiry: string; + localeCodes: LocaleCode[]; + } + + /** + * Continents List + */ + export type ContinentList = { /** - * Identity Provider Refresh Token. + * Total number of continents that matched your query. */ - providerRefreshToken: string; + total: number; + /** + * List of continents. + */ + continents: Continent[]; } /** - * Token + * Countries List */ - export type Token = { + export type CountryList = { /** - * Token ID. + * Total number of countries that matched your query. */ - $id: string; + total: number; /** - * Token creation date in ISO 8601 format. + * List of countries. */ - $createdAt: string; + countries: Country[]; + } + + /** + * Phones List + */ + export type PhoneList = { /** - * User ID. + * Total number of phones 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 phones. */ - secret: string; + phones: Phone[]; + } + + /** + * Currencies List + */ + export type CurrencyList = { /** - * Token expiration date in ISO 8601 format. + * Total number of currencies 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 currencies. */ - phrase: string; + currencies: Currency[]; } /** - * JWT + * Languages List */ - export type Jwt = { + export type LanguageList = { /** - * JWT encoded string. + * Total number of languages that matched your query. */ - jwt: string; + total: number; + /** + * List of languages. + */ + languages: Language[]; } /** - * Locale + * Subscriber */ - export type Locale = { + export type Subscriber = { /** - * User IP address. + * Subscriber ID. */ - ip: string; + $id: string; /** - * Country code in [ISO 3166-1](http://en.wikipedia.org/wiki/ISO_3166-1) two-character format + * Subscriber creation time in ISO 8601 format. */ - countryCode: string; + $createdAt: string; /** - * Country name. This field support localization. + * Subscriber 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. + * Target ID. */ - continentCode: string; + targetId: string; /** - * Continent name. This field support localization. + * Target. */ - continent: string; + target: Target; /** - * True if country is part of the European Union. + * Topic ID. */ - eu: boolean; + userId: string; /** - * Currency code in [ISO 4217-1](http://en.wikipedia.org/wiki/ISO_4217) three-character format + * User Name. */ - currency: string; + userName: string; + /** + * Topic ID. + */ + topicId: string; + /** + * The target provider type. Can be one of the following: `email`, `sms` or `push`. + */ + providerType: string; } /** - * 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[]; } /** @@ -922,6 +841,73 @@ export namespace Models { compression: string; } + /** + * Rows List + */ + export type RowList = { + /** + * Total number of rows that matched your query. + */ + total: number; + /** + * List of rows. + */ + rows: Row[]; + } + + /** + * Row + */ + export type Row = { + /** + * Row ID. + */ + $id: string; + /** + * Row sequence ID. + */ + $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; + }; + + /** + * Teams List + */ + export type TeamList = { + /** + * Total number of teams that matched your query. + */ + total: number; + /** + * List of teams. + */ + teams: Team[]; + } + /** * Team */ @@ -952,6 +938,20 @@ export namespace Models { prefs: Preferences; } + /** + * Memberships List + */ + export type MembershipList = { + /** + * Total number of memberships that matched your query. + */ + total: number; + /** + * List of memberships. + */ + memberships: Membership[]; + } + /** * Membership */ @@ -1011,171 +1011,241 @@ export namespace Models { } /** - * Execution + * AlgoArgon2 */ - export type Execution = { + export type AlgoArgon2 = { /** - * Execution ID. + * Algo type. */ - $id: string; + type: string; /** - * Execution creation date in ISO 8601 format. + * Memory used to compute hash. */ - $createdAt: string; + memoryCost: number; /** - * Execution update date in ISO 8601 format. + * Amount of time consumed to compute hash */ - $updatedAt: string; + timeCost: number; /** - * Execution roles. + * Number of threads used to compute hash. */ - $permissions: string[]; + threads: number; + } + + /** + * AlgoScrypt + */ + export type AlgoScrypt = { /** - * Function ID. + * Algo type. */ - functionId: string; + type: string; /** - * Function's deployment ID used to create the execution. + * CPU complexity of computed hash. */ - deploymentId: string; + costCpu: number; /** - * The trigger that caused the function to execute. Possible values can be: `http`, `schedule`, or `event`. + * Memory complexity of computed hash. */ - trigger: ExecutionTrigger; + costMemory: number; /** - * The status of the function execution. Possible values can be: `waiting`, `processing`, `completed`, `failed`, or `scheduled`. + * Parallelization of computed hash. */ - status: ExecutionStatus; + costParallel: number; /** - * HTTP request method type. + * Length used to compute hash. */ - requestMethod: string; + length: number; + } + + /** + * AlgoScryptModified + */ + export type AlgoScryptModified = { /** - * HTTP request path and query. + * Algo 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. + * Salt used to compute hash. */ - requestHeaders: Headers[]; + salt: string; /** - * HTTP response status code. + * Separator used to compute hash. */ - responseStatusCode: number; + saltSeparator: string; /** - * HTTP response body. This will return empty unless execution is created as synchronous. + * Key used to compute hash. */ - responseBody: string; + signerKey: string; + } + + /** + * AlgoBcrypt + */ + export type AlgoBcrypt = { /** - * HTTP response headers as a key-value object. This will return only whitelisted headers. All headers are returned if execution is created as synchronous. + * Algo type. */ - responseHeaders: Headers[]; + type: string; + } + + /** + * AlgoPHPass + */ + export type AlgoPhpass = { /** - * 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. + * Algo type. */ - logs: string; + type: string; + } + + /** + * AlgoSHA + */ + export type AlgoSha = { /** - * 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. + * Algo type. */ - errors: string; + type: string; + } + + /** + * AlgoMD5 + */ + export type AlgoMd5 = { /** - * Resource(function/site) execution duration in seconds. + * Algo type. */ - duration: number; + type: string; + } + + /** + * Identity + */ + export type Identity = { /** - * The scheduled time for execution. If left empty, execution will be queued immediately. + * Identity ID. */ - scheduledAt?: string; + $id: string; + /** + * Identity creation date in ISO 8601 format. + */ + $createdAt: string; + /** + * Identity update date in ISO 8601 format. + */ + $updatedAt: string; + /** + * User ID. + */ + userId: string; + /** + * Identity Provider. + */ + provider: string; + /** + * ID of the User in the Identity Provider. + */ + providerUid: string; + /** + * Email of the User in the Identity Provider. + */ + 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; } /** - * Country + * Log */ - export type Country = { + 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; /** - * Country name. + * User name of the actor recorded for this log. During impersonation, this is the original impersonator. */ - name: string; + userName: string; /** - * Country two-character ISO 3166-1 alpha code. + * API mode when event triggered. */ - code: string; - } - - /** - * Continent - */ - export type Continent = { + mode: string; /** - * Continent name. + * IP session in use when the session was created. */ - name: string; + ip: string; /** - * Continent two letter code. + * Log creation date in ISO 8601 format. */ - code: string; - } - - /** - * Language - */ - export type Language = { + time: string; /** - * Language name. + * Operating system code name. View list of [available options](https://github.com/appwrite/appwrite/blob/master/docs/lists/os.json). */ - name: string; + osCode: string; /** - * Language two-character ISO 639-1 codes. + * Operating system name. */ - code: string; + osName: string; /** - * Language native name. + * Operating system version. */ - nativeName: string; - } - - /** - * Currency - */ - export type Currency = { + osVersion: string; /** - * Currency symbol. + * Client type. */ - symbol: string; + clientType: string; /** - * Currency name. + * Client code name. View list of [available options](https://github.com/appwrite/appwrite/blob/master/docs/lists/clients.json). */ - name: string; + clientCode: string; /** - * Currency native symbol. + * Client name. */ - symbolNative: string; + clientName: string; /** - * Number of decimal digits. + * Client version. */ - decimalDigits: number; + clientVersion: string; /** - * Currency digit rounding. + * Client engine name. */ - rounding: number; + clientEngine: string; /** - * Currency code in [ISO 4217-1](http://en.wikipedia.org/wiki/ISO_4217) three-character format. + * Client engine name. */ - code: string; + clientEngineVersion: string; /** - * Currency plural name + * Device name. */ - namePlural: string; - } - - /** - * Phone - */ - export type Phone = { + deviceName: string; /** - * Phone code. + * Device brand name. */ - code: string; + deviceBrand: string; + /** + * Device model name. + */ + deviceModel: string; /** * Country two-character ISO 3166-1 alpha code. */ @@ -1201,184 +1271,114 @@ export namespace Models { } /** - * MFA Challenge + * LocaleCode */ - export type MfaChallenge = { - /** - * Token ID. - */ - $id: string; - /** - * Token creation date in ISO 8601 format. - */ - $createdAt: string; - /** - * User ID. - */ - userId: string; + export type LocaleCode = { /** - * Token expiration date in ISO 8601 format. + * Locale codes in [ISO 639-1](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes) */ - expire: string; - } - - /** - * MFA Recovery Codes - */ - export type MfaRecoveryCodes = { + code: string; /** - * Recovery codes. + * Locale name */ - recoveryCodes: string[]; + name: string; } /** - * MFAType + * Continent */ - export type MfaType = { + export type Continent = { /** - * Secret token used for TOTP factor. + * Continent name. */ - secret: string; + name: string; /** - * URI for authenticator apps. + * Continent two letter code. */ - uri: string; + code: string; } /** - * MFAFactors + * Country */ - 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 Country = { /** - * Can email be used for MFA challenge for this account. + * Country name. */ - email: boolean; + name: string; /** - * Can recovery code be used for MFA challenge for this account. + * Country two-character ISO 3166-1 alpha code. */ - recoveryCode: boolean; + code: string; } /** - * Transaction + * Phone */ - 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 Phone = { /** - * Current status of the transaction. One of: pending, committing, committed, rolled_back, failed. + * Phone code. */ - status: string; + code: string; /** - * Number of operations in the transaction. + * Country two-character ISO 3166-1 alpha code. */ - operations: number; + countryCode: string; /** - * Expiration time in ISO 8601 format. + * Country name. */ - expiresAt: string; + countryName: string; } /** - * Subscriber + * Currency */ - export type Subscriber = { - /** - * Subscriber ID. - */ - $id: string; - /** - * Subscriber creation time in ISO 8601 format. - */ - $createdAt: string; + export type Currency = { /** - * Subscriber update date in ISO 8601 format. + * Currency symbol. */ - $updatedAt: string; + symbol: string; /** - * Target ID. + * Currency name. */ - targetId: string; + name: string; /** - * Target. + * Currency native symbol. */ - target: Target; + symbolNative: string; /** - * Topic ID. + * Number of decimal digits. */ - userId: string; + decimalDigits: number; /** - * User Name. + * Currency digit rounding. */ - userName: string; + rounding: number; /** - * Topic ID. + * Currency code in [ISO 4217-1](http://en.wikipedia.org/wiki/ISO_4217) three-character format. */ - topicId: string; + code: string; /** - * The target provider type. Can be one of the following: `email`, `sms` or `push`. + * Currency plural name */ - providerType: string; + namePlural: string; } /** - * Target + * Language */ - export type Target = { - /** - * Target ID. - */ - $id: string; - /** - * Target creation time in ISO 8601 format. - */ - $createdAt: string; - /** - * Target update date in ISO 8601 format. - */ - $updatedAt: string; + export type Language = { /** - * Target Name. + * Language name. */ name: string; /** - * User ID. - */ - userId: string; - /** - * Provider ID. - */ - providerId?: string; - /** - * The target provider type. Can be one of the following: `email`, `sms` or `push`. - */ - providerType: string; - /** - * The target identifier. + * Language two-character ISO 639-1 codes. */ - identifier: string; + code: string; /** - * Is the target expired. + * Language native name. */ - expired: boolean; + nativeName: string; } } From 75665f452298090cb0e9cac7363f6be88e619ad5 Mon Sep 17 00:00:00 2001 From: root Date: Wed, 25 Mar 2026 07:01:55 +0000 Subject: [PATCH 5/5] chore: update React Native SDK to 0.25.0 --- src/models.ts | 1380 ++++++++++++++++++++++++------------------------- 1 file changed, 690 insertions(+), 690 deletions(-) diff --git a/src/models.ts b/src/models.ts index c1a85a19..dc2e4ff7 100644 --- a/src/models.ts +++ b/src/models.ts @@ -6,217 +6,339 @@ export namespace Models { declare const __default: unique symbol; /** - * User + * Rows List */ - export type User = { - /** - * User ID. - */ - $id: string; + export type RowList = { /** - * User creation date in ISO 8601 format. + * Total number of rows that matched your query. */ - $createdAt: string; + total: number; /** - * User update date in ISO 8601 format. + * List of rows. */ - $updatedAt: string; + rows: Row[]; + } + + /** + * Documents List + */ + export type DocumentList = { /** - * User name. + * Total number of documents that matched your query. */ - name: string; + total: number; /** - * Hashed user password. + * List of documents. */ - password?: string; + documents: Document[]; + } + + /** + * Sessions List + */ + export type SessionList = { /** - * Password hashing algorithm. + * Total number of sessions that matched your query. */ - hash?: string; + total: number; /** - * Password hashing algorithm configuration. + * List of sessions. */ - hashOptions?: object; + sessions: Session[]; + } + + /** + * Identities List + */ + export type IdentityList = { /** - * User registration date in ISO 8601 format. + * Total number of identities that matched your query. */ - registration: string; + total: number; /** - * User status. Pass `true` for enabled and `false` for disabled. + * List of identities. */ - status: boolean; + identities: Identity[]; + } + + /** + * Logs List + */ + export type LogList = { /** - * Labels for the user. + * Total number of logs that matched your query. */ - labels: string[]; + total: number; /** - * Password update time in ISO 8601 format. + * List of logs. */ - passwordUpdate: string; + logs: Log[]; + } + + /** + * Files List + */ + export type FileList = { /** - * User email address. + * Total number of files that matched your query. */ - email: string; + total: number; /** - * User phone number in E.164 format. + * List of files. */ - phone: string; + files: File[]; + } + + /** + * Teams List + */ + export type TeamList = { /** - * Email verification status. + * Total number of teams that matched your query. */ - emailVerification: boolean; + total: number; /** - * Phone verification status. + * List of teams. */ - phoneVerification: boolean; + teams: Team[]; + } + + /** + * Memberships List + */ + export type MembershipList = { /** - * Multi factor authentication status. + * Total number of memberships that matched your query. */ - mfa: boolean; + total: number; /** - * User preferences as a key-value object + * List of memberships. */ - prefs: Preferences; + memberships: Membership[]; + } + + /** + * Executions List + */ + export type ExecutionList = { /** - * 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 executions 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 executions. */ - accessedAt: string; + executions: Execution[]; + } + + /** + * Countries List + */ + export type CountryList = { /** - * Whether the user can impersonate other users. + * Total number of countries 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 countries. */ - impersonatorUserId?: string; + countries: Country[]; } /** - * Identities List + * Continents List */ - export type IdentityList = { + export type ContinentList = { /** - * Total number of identities that matched your query. + * Total number of continents that matched your query. */ total: number; /** - * List of identities. + * List of continents. */ - identities: Identity[]; + continents: Continent[]; } /** - * JWT + * Languages List */ - export type Jwt = { + export type LanguageList = { /** - * JWT encoded string. + * Total number of languages that matched your query. */ - jwt: string; + total: number; + /** + * List of languages. + */ + languages: Language[]; } /** - * Logs List + * Currencies List */ - export type LogList = { + export type CurrencyList = { /** - * Total number of logs that matched your query. + * Total number of currencies that matched your query. */ total: number; /** - * List of logs. + * List of currencies. */ - logs: Log[]; + currencies: Currency[]; } /** - * MFAType + * Phones List */ - export type MfaType = { + export type PhoneList = { /** - * Secret token used for TOTP factor. + * Total number of phones that matched your query. */ - secret: string; + total: number; /** - * URI for authenticator apps. + * List of phones. */ - uri: string; + phones: Phone[]; } /** - * MFA Challenge + * Locale codes list */ - export type MfaChallenge = { + export type LocaleCodeList = { /** - * Token ID. + * Total number of localeCodes that matched your query. */ - $id: string; + total: number; /** - * Token creation date in ISO 8601 format. + * List of localeCodes. */ - $createdAt: string; + localeCodes: LocaleCode[]; + } + + /** + * Transaction List + */ + export type TransactionList = { /** - * User ID. + * Total number of transactions that matched your query. */ - userId: string; + total: number; /** - * Token expiration date in ISO 8601 format. + * List of transactions. */ - expire: string; + transactions: Transaction[]; } /** - * Session + * Row */ - export type Session = { + export type Row = { /** - * Session ID. + * Row ID. */ $id: string; /** - * Session creation date in ISO 8601 format. + * Row sequence ID. */ - $createdAt: string; + $sequence: string; /** - * Session update date in ISO 8601 format. + * Table ID. */ - $updatedAt: string; + $tableId: string; /** - * User ID. + * Database ID. */ - userId: string; + $databaseId: string; /** - * Session expiration date in ISO 8601 format. + * Row creation date in ISO 8601 format. */ - expire: string; + $createdAt: string; /** - * Session Provider. + * Row update date in ISO 8601 format. */ - provider: string; + $updatedAt: string; /** - * Session Provider User ID. + * Row permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). */ - providerUid: string; + $permissions: string[]; + } + + export type DefaultRow = Row & { + [key: string]: any; + [__default]: true; + }; + + /** + * Document + */ + export type Document = { /** - * Session Provider Access Token. + * Document ID. */ - providerAccessToken: string; + $id: string; /** - * The date of when the access token expires in ISO 8601 format. + * Document sequence ID. */ - providerAccessTokenExpiry: string; + $sequence: string; /** - * Session Provider Refresh Token. + * Collection ID. */ - providerRefreshToken: string; + $collectionId: string; /** - * IP in use when the session was created. + * 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; + }; + + /** + * Log + */ + 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). */ @@ -273,514 +395,473 @@ export namespace Models { * Country name. */ countryName: string; - /** - * Returns true if this the current user session. - */ - current: boolean; - /** - * Returns a list of active session factors. - */ - factors: string[]; - /** - * Secret used to authenticate the user. Only included if the request was made with an API key - */ - secret: string; - /** - * Most recent date in ISO 8601 format when the session successfully passed MFA challenge. - */ - mfaUpdatedAt: string; } /** - * MFAFactors + * User */ - export type MfaFactors = { + export type User = { /** - * Can TOTP be used for MFA challenge for this account. + * User ID. */ - totp: boolean; + $id: string; /** - * Can phone (SMS) be used for MFA challenge for this account. + * User creation date in ISO 8601 format. */ - phone: boolean; + $createdAt: string; /** - * Can email be used for MFA challenge for this account. + * User update date in ISO 8601 format. */ - email: boolean; + $updatedAt: string; /** - * Can recovery code be used for MFA challenge for this account. + * User name. */ - recoveryCode: boolean; - } - - /** - * MFA Recovery Codes - */ - export type MfaRecoveryCodes = { + name: string; /** - * Recovery codes. + * Hashed user password. */ - recoveryCodes: string[]; - } - - /** - * Preferences - */ - export type Preferences = { - } - - export type DefaultPreferences = Preferences & { - [key: string]: any; - [__default]: true; - }; - - /** - * Token - */ - export type Token = { + password?: string; /** - * Token ID. + * Password hashing algorithm. */ - $id: string; + hash?: string; /** - * Token creation date in ISO 8601 format. + * Password hashing algorithm configuration. */ - $createdAt: string; + hashOptions?: object; /** - * User ID. + * User registration date in ISO 8601 format. */ - userId: string; + registration: 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. + * User status. Pass `true` for enabled and `false` for disabled. */ - secret: string; + status: boolean; /** - * Token expiration date in ISO 8601 format. + * Labels for the user. */ - expire: string; + labels: string[]; /** - * 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. + * Password update time in ISO 8601 format. */ - phrase: string; - } - - /** - * Sessions List - */ - export type SessionList = { + passwordUpdate: string; /** - * Total number of sessions that matched your query. + * User email address. */ - total: number; + email: string; /** - * List of sessions. + * User phone number in E.164 format. */ - sessions: Session[]; - } - - /** - * Target - */ - export type Target = { + phone: string; /** - * Target ID. + * Email verification status. */ - $id: string; + emailVerification: boolean; /** - * Target creation time in ISO 8601 format. + * Phone verification status. */ - $createdAt: string; + phoneVerification: boolean; /** - * Target update date in ISO 8601 format. + * Multi factor authentication status. */ - $updatedAt: string; + mfa: boolean; /** - * Target Name. + * User preferences as a key-value object */ - name: string; + prefs: Preferences; /** - * User ID. + * 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. */ - userId: string; + targets: Target[]; /** - * Provider ID. + * Most recent access date in ISO 8601 format. This attribute is only updated again after 24 hours. */ - providerId?: string; + accessedAt: string; /** - * The target provider type. Can be one of the following: `email`, `sms` or `push`. + * Whether the user can impersonate other users. */ - providerType: string; + impersonator?: boolean; /** - * The target identifier. + * 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. */ - identifier: string; + impersonatorUserId?: string; + } + + /** + * AlgoMD5 + */ + export type AlgoMd5 = { /** - * Is the target expired. + * Algo type. */ - expired: boolean; + type: string; } /** - * Transaction List + * AlgoSHA */ - export type TransactionList = { + export type AlgoSha = { /** - * Total number of transactions that matched your query. + * Algo type. */ - total: number; + type: string; + } + + /** + * AlgoPHPass + */ + export type AlgoPhpass = { /** - * List of transactions. + * Algo type. */ - transactions: Transaction[]; + type: string; } /** - * Transaction + * AlgoBcrypt */ - export type Transaction = { + export type AlgoBcrypt = { /** - * Transaction ID. + * Algo type. */ - $id: string; + type: string; + } + + /** + * AlgoScrypt + */ + export type AlgoScrypt = { /** - * Transaction creation time in ISO 8601 format. + * Algo type. */ - $createdAt: string; + type: string; /** - * Transaction update date in ISO 8601 format. + * CPU complexity of computed hash. */ - $updatedAt: string; + costCpu: number; /** - * Current status of the transaction. One of: pending, committing, committed, rolled_back, failed. + * Memory complexity of computed hash. */ - status: string; + costMemory: number; /** - * Number of operations in the transaction. + * Parallelization of computed hash. */ - operations: number; + costParallel: number; /** - * Expiration time in ISO 8601 format. + * Length used to compute hash. */ - expiresAt: string; + length: number; } /** - * Documents List + * AlgoScryptModified */ - export type DocumentList = { - /** - * Total number of documents that matched your query. - */ - total: number; + export type AlgoScryptModified = { /** - * List of documents. + * Algo type. */ - documents: Document[]; - } - - /** - * Document - */ - export type Document = { + type: string; /** - * Document ID. + * Salt used to compute hash. */ - $id: string; + salt: string; /** - * Document sequence ID. + * Separator used to compute hash. */ - $sequence: string; + saltSeparator: string; /** - * Collection ID. + * Key used to compute hash. */ - $collectionId: string; + signerKey: string; + } + + /** + * AlgoArgon2 + */ + export type AlgoArgon2 = { /** - * Database ID. + * Algo type. */ - $databaseId: string; + type: string; /** - * Document creation date in ISO 8601 format. + * Memory used to compute hash. */ - $createdAt: string; + memoryCost: number; /** - * Document update date in ISO 8601 format. + * Amount of time consumed to compute hash */ - $updatedAt: string; + timeCost: number; /** - * Document permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). + * Number of threads used to compute hash. */ - $permissions: string[]; + threads: number; } - export type DefaultDocument = Document & { + /** + * Preferences + */ + export type Preferences = { + } + + export type DefaultPreferences = Preferences & { [key: string]: any; [__default]: true; }; /** - * Executions List + * Session */ - export type ExecutionList = { + export type Session = { + /** + * Session ID. + */ + $id: string; + /** + * Session creation date in ISO 8601 format. + */ + $createdAt: string; + /** + * Session 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. + */ + providerUid: string; + /** + * Session Provider Access Token. + */ + providerAccessToken: string; /** - * Total number of executions that matched your query. + * The date of when the access token expires in ISO 8601 format. */ - total: number; + providerAccessTokenExpiry: string; /** - * List of executions. + * Session Provider Refresh Token. */ - executions: Execution[]; - } - - /** - * Execution - */ - export type Execution = { + providerRefreshToken: string; /** - * Execution ID. + * IP in use when the session was created. */ - $id: string; + ip: string; /** - * Execution creation date in ISO 8601 format. + * Operating system code name. View list of [available options](https://github.com/appwrite/appwrite/blob/master/docs/lists/os.json). */ - $createdAt: string; + osCode: string; /** - * Execution update date in ISO 8601 format. + * Operating system name. */ - $updatedAt: string; + osName: string; /** - * Execution roles. + * Operating system version. */ - $permissions: string[]; + osVersion: string; /** - * Function ID. + * Client type. */ - functionId: string; + clientType: string; /** - * Function's deployment ID used to create the execution. + * Client code name. View list of [available options](https://github.com/appwrite/appwrite/blob/master/docs/lists/clients.json). */ - deploymentId: string; + clientCode: string; /** - * The trigger that caused the function to execute. Possible values can be: `http`, `schedule`, or `event`. + * Client name. */ - trigger: ExecutionTrigger; + clientName: string; /** - * The status of the function execution. Possible values can be: `waiting`, `processing`, `completed`, `failed`, or `scheduled`. + * Client version. */ - status: ExecutionStatus; + clientVersion: string; /** - * HTTP request method type. + * Client engine name. */ - requestMethod: string; + clientEngine: string; /** - * HTTP request path and query. + * Client engine name. */ - requestPath: string; + clientEngineVersion: 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. + * Device name. */ - requestHeaders: Headers[]; + deviceName: string; /** - * HTTP response status code. + * Device brand name. */ - responseStatusCode: number; + deviceBrand: string; /** - * HTTP response body. This will return empty unless execution is created as synchronous. + * Device model name. */ - responseBody: string; + deviceModel: string; /** - * HTTP response headers as a key-value object. This will return only whitelisted headers. All headers are returned if execution is created as synchronous. + * Country two-character ISO 3166-1 alpha code. */ - responseHeaders: Headers[]; + countryCode: 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. + * Country name. */ - logs: string; + countryName: 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. + * Returns true if this the current user session. */ - errors: string; + current: boolean; /** - * Resource(function/site) execution duration in seconds. + * Returns a list of active session factors. */ - duration: number; + factors: string[]; /** - * The scheduled time for execution. If left empty, execution will be queued immediately. + * Secret used to authenticate the user. Only included if the request was made with an API key */ - scheduledAt?: string; + secret: string; + /** + * Most recent date in ISO 8601 format when the session successfully passed MFA challenge. + */ + mfaUpdatedAt: string; } /** - * Locale + * Identity */ - export type Locale = { - /** - * User IP address. - */ - ip: string; + export type Identity = { /** - * Country code in [ISO 3166-1](http://en.wikipedia.org/wiki/ISO_3166-1) two-character format + * Identity ID. */ - countryCode: string; + $id: string; /** - * Country name. This field support localization. + * Identity creation date in ISO 8601 format. */ - country: string; + $createdAt: 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. + * Identity update date in ISO 8601 format. */ - continentCode: string; + $updatedAt: string; /** - * Continent name. This field support localization. + * User ID. */ - continent: string; + userId: string; /** - * True if country is part of the European Union. + * Identity Provider. */ - eu: boolean; + provider: string; /** - * Currency code in [ISO 4217-1](http://en.wikipedia.org/wiki/ISO_4217) three-character format + * ID of the User in the Identity Provider. */ - currency: string; - } - - /** - * Locale codes list - */ - export type LocaleCodeList = { + providerUid: string; /** - * Total number of localeCodes that matched your query. + * Email of the User in the Identity Provider. */ - total: number; + providerEmail: string; /** - * List of localeCodes. + * Identity Provider Access Token. */ - localeCodes: LocaleCode[]; - } - - /** - * Continents List - */ - export type ContinentList = { + providerAccessToken: string; /** - * Total number of continents that matched your query. + * The date of when the access token expires in ISO 8601 format. */ - total: number; + providerAccessTokenExpiry: string; /** - * List of continents. + * Identity Provider Refresh Token. */ - continents: Continent[]; + providerRefreshToken: string; } /** - * Countries List + * Token */ - export type CountryList = { + export type Token = { /** - * Total number of countries that matched your query. + * Token ID. */ - total: number; + $id: string; /** - * List of countries. + * Token creation date in ISO 8601 format. */ - countries: Country[]; - } - - /** - * Phones List - */ - export type PhoneList = { + $createdAt: string; /** - * Total number of phones that matched your query. + * User ID. */ - total: number; + userId: string; /** - * List of phones. + * 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. */ - phones: Phone[]; - } - - /** - * Currencies List - */ - export type CurrencyList = { + secret: string; /** - * Total number of currencies that matched your query. + * Token expiration date in ISO 8601 format. */ - total: number; + expire: string; /** - * List of currencies. + * 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. */ - currencies: Currency[]; + phrase: string; } /** - * Languages List + * JWT */ - export type LanguageList = { - /** - * Total number of languages that matched your query. - */ - total: number; + export type Jwt = { /** - * List of languages. + * JWT encoded string. */ - languages: Language[]; + jwt: string; } /** - * Subscriber + * Locale */ - export type Subscriber = { - /** - * Subscriber ID. - */ - $id: string; - /** - * Subscriber creation time in ISO 8601 format. - */ - $createdAt: string; + export type Locale = { /** - * Subscriber update date in ISO 8601 format. + * User IP address. */ - $updatedAt: string; + ip: string; /** - * Target ID. + * Country code in [ISO 3166-1](http://en.wikipedia.org/wiki/ISO_3166-1) two-character format */ - targetId: string; + countryCode: string; /** - * Target. + * Country name. This field support localization. */ - target: Target; + country: string; /** - * Topic ID. + * 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. */ - userId: string; + continentCode: string; /** - * User Name. + * Continent name. This field support localization. */ - userName: string; + continent: string; /** - * Topic ID. + * True if country is part of the European Union. */ - topicId: string; + eu: boolean; /** - * The target provider type. Can be one of the following: `email`, `sms` or `push`. + * Currency code in [ISO 4217-1](http://en.wikipedia.org/wiki/ISO_4217) three-character format */ - providerType: string; + 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; } /** @@ -841,73 +922,6 @@ export namespace Models { compression: string; } - /** - * Rows List - */ - export type RowList = { - /** - * Total number of rows that matched your query. - */ - total: number; - /** - * List of rows. - */ - rows: Row[]; - } - - /** - * Row - */ - export type Row = { - /** - * Row ID. - */ - $id: string; - /** - * Row sequence ID. - */ - $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; - }; - - /** - * Teams List - */ - export type TeamList = { - /** - * Total number of teams that matched your query. - */ - total: number; - /** - * List of teams. - */ - teams: Team[]; - } - /** * Team */ @@ -938,20 +952,6 @@ export namespace Models { prefs: Preferences; } - /** - * Memberships List - */ - export type MembershipList = { - /** - * Total number of memberships that matched your query. - */ - total: number; - /** - * List of memberships. - */ - memberships: Membership[]; - } - /** * Membership */ @@ -1011,241 +1011,171 @@ export namespace Models { } /** - * AlgoArgon2 - */ - export type AlgoArgon2 = { - /** - * Algo type. - */ - type: string; - /** - * Memory used to compute hash. - */ - memoryCost: number; - /** - * Amount of time consumed to compute hash - */ - timeCost: number; - /** - * Number of threads used to compute hash. - */ - threads: number; - } - - /** - * 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 + * Execution */ - export type AlgoScryptModified = { + export type Execution = { /** - * Algo type. + * Execution ID. */ - type: string; + $id: string; /** - * Salt used to compute hash. + * Execution creation date in ISO 8601 format. */ - salt: string; + $createdAt: string; /** - * Separator used to compute hash. + * Execution update date in ISO 8601 format. */ - saltSeparator: string; + $updatedAt: string; /** - * Key used to compute hash. + * Execution roles. */ - signerKey: string; - } - - /** - * AlgoBcrypt - */ - export type AlgoBcrypt = { + $permissions: string[]; /** - * Algo type. + * Function ID. */ - type: string; - } - - /** - * AlgoPHPass - */ - export type AlgoPhpass = { + functionId: string; /** - * Algo type. + * Function's deployment ID used to create the execution. */ - type: string; - } - - /** - * AlgoSHA - */ - export type AlgoSha = { + deploymentId: string; /** - * Algo type. + * The trigger that caused the function to execute. Possible values can be: `http`, `schedule`, or `event`. */ - type: string; - } - - /** - * AlgoMD5 - */ - export type AlgoMd5 = { + trigger: ExecutionTrigger; /** - * Algo type. + * The status of the function execution. Possible values can be: `waiting`, `processing`, `completed`, `failed`, or `scheduled`. */ - type: string; - } - - /** - * Identity - */ - export type Identity = { + status: ExecutionStatus; /** - * Identity ID. + * HTTP request method type. */ - $id: string; + requestMethod: string; /** - * Identity creation date in ISO 8601 format. + * HTTP request path and query. */ - $createdAt: string; + requestPath: string; /** - * Identity update date in ISO 8601 format. + * HTTP request headers as a key-value object. This will return only whitelisted headers. All headers are returned if execution is created as synchronous. */ - $updatedAt: string; + requestHeaders: Headers[]; /** - * User ID. + * HTTP response status code. */ - userId: string; + responseStatusCode: number; /** - * Identity Provider. + * HTTP response body. This will return empty unless execution is created as synchronous. */ - provider: string; + responseBody: string; /** - * ID of the User in the Identity Provider. + * HTTP response headers as a key-value object. This will return only whitelisted headers. All headers are returned if execution is created as synchronous. */ - providerUid: string; + responseHeaders: Headers[]; /** - * Email of the User in the Identity Provider. + * 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. */ - providerEmail: string; + logs: string; /** - * Identity Provider Access Token. + * 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. */ - providerAccessToken: string; + errors: string; /** - * The date of when the access token expires in ISO 8601 format. + * Resource(function/site) execution duration in seconds. */ - providerAccessTokenExpiry: string; + duration: number; /** - * Identity Provider Refresh Token. + * The scheduled time for execution. If left empty, execution will be queued immediately. */ - providerRefreshToken: string; + scheduledAt?: string; } - /** - * Log - */ - 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; + /** + * Country + */ + export type Country = { /** - * API mode when event triggered. + * Country name. */ - mode: string; + name: string; /** - * IP session in use when the session was created. + * Country two-character ISO 3166-1 alpha code. */ - ip: string; + code: string; + } + + /** + * Continent + */ + export type Continent = { /** - * Log creation date in ISO 8601 format. + * Continent name. */ - time: string; + name: string; /** - * Operating system code name. View list of [available options](https://github.com/appwrite/appwrite/blob/master/docs/lists/os.json). + * Continent two letter code. */ - osCode: string; + code: string; + } + + /** + * Language + */ + export type Language = { /** - * Operating system name. + * Language name. */ - osName: string; + name: string; /** - * Operating system version. + * Language two-character ISO 639-1 codes. */ - osVersion: string; + code: string; /** - * Client type. + * Language native name. */ - clientType: string; + nativeName: string; + } + + /** + * Currency + */ + export type Currency = { /** - * Client code name. View list of [available options](https://github.com/appwrite/appwrite/blob/master/docs/lists/clients.json). + * Currency symbol. */ - clientCode: string; + symbol: string; /** - * Client name. + * Currency name. */ - clientName: string; + name: string; /** - * Client version. + * Currency native symbol. */ - clientVersion: string; + symbolNative: string; /** - * Client engine name. + * Number of decimal digits. */ - clientEngine: string; + decimalDigits: number; /** - * Client engine name. + * Currency digit rounding. */ - clientEngineVersion: string; + rounding: number; /** - * Device name. + * Currency code in [ISO 4217-1](http://en.wikipedia.org/wiki/ISO_4217) three-character format. */ - deviceName: string; + code: string; /** - * Device brand name. + * Currency plural name */ - deviceBrand: string; + namePlural: string; + } + + /** + * Phone + */ + export type Phone = { /** - * Device model name. + * Phone code. */ - deviceModel: string; + code: string; /** * Country two-character ISO 3166-1 alpha code. */ @@ -1271,114 +1201,184 @@ export namespace Models { } /** - * LocaleCode + * MFA Challenge */ - export type LocaleCode = { + export type MfaChallenge = { /** - * Locale codes in [ISO 639-1](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes) + * Token ID. */ - code: string; + $id: string; /** - * Locale name + * Token creation date in ISO 8601 format. */ - name: string; + $createdAt: string; + /** + * User ID. + */ + userId: string; + /** + * Token expiration date in ISO 8601 format. + */ + expire: string; } /** - * Continent + * MFA Recovery Codes */ - export type Continent = { + export type MfaRecoveryCodes = { /** - * Continent name. + * Recovery codes. */ - name: string; + recoveryCodes: string[]; + } + + /** + * MFAType + */ + export type MfaType = { /** - * Continent two letter code. + * Secret token used for TOTP factor. */ - code: string; + secret: string; + /** + * URI for authenticator apps. + */ + uri: string; } /** - * Country + * MFAFactors */ - export type Country = { + export type MfaFactors = { /** - * Country name. + * Can TOTP be used for MFA challenge for this account. */ - name: string; + totp: boolean; /** - * Country two-character ISO 3166-1 alpha code. + * Can phone (SMS) be used for MFA challenge for this account. */ - code: string; + 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; } /** - * Phone + * Transaction */ - export type Phone = { + export type Transaction = { /** - * Phone code. + * Transaction ID. */ - code: string; + $id: string; /** - * Country two-character ISO 3166-1 alpha code. + * Transaction creation time in ISO 8601 format. */ - countryCode: string; + $createdAt: string; /** - * Country name. + * Transaction update date in ISO 8601 format. */ - countryName: string; + $updatedAt: string; + /** + * Current status of the transaction. One of: pending, committing, committed, rolled_back, failed. + */ + status: string; + /** + * Number of operations in the transaction. + */ + operations: number; + /** + * Expiration time in ISO 8601 format. + */ + expiresAt: string; } /** - * Currency + * Subscriber */ - export type Currency = { + export type Subscriber = { /** - * Currency symbol. + * Subscriber ID. */ - symbol: string; + $id: string; /** - * Currency name. + * Subscriber creation time in ISO 8601 format. */ - name: string; + $createdAt: string; /** - * Currency native symbol. + * Subscriber update date in ISO 8601 format. */ - symbolNative: string; + $updatedAt: string; /** - * Number of decimal digits. + * Target ID. */ - decimalDigits: number; + targetId: string; /** - * Currency digit rounding. + * Target. */ - rounding: number; + target: Target; /** - * Currency code in [ISO 4217-1](http://en.wikipedia.org/wiki/ISO_4217) three-character format. + * Topic ID. */ - code: string; + userId: string; /** - * Currency plural name + * User Name. */ - namePlural: string; + userName: string; + /** + * Topic ID. + */ + topicId: string; + /** + * The target provider type. Can be one of the following: `email`, `sms` or `push`. + */ + providerType: string; } /** - * Language + * Target */ - export type Language = { + export type Target = { /** - * Language name. + * Target ID. + */ + $id: string; + /** + * Target creation time in ISO 8601 format. + */ + $createdAt: string; + /** + * Target update date in ISO 8601 format. + */ + $updatedAt: string; + /** + * Target Name. */ name: string; /** - * Language two-character ISO 639-1 codes. + * User ID. */ - code: string; + userId: string; /** - * Language native name. + * Provider ID. */ - nativeName: string; + providerId?: string; + /** + * The target provider type. Can be one of the following: `email`, `sms` or `push`. + */ + providerType: string; + /** + * The target identifier. + */ + identifier: string; + /** + * Is the target expired. + */ + expired: boolean; } }