diff --git a/CHANGELOG.md b/CHANGELOG.md index 7d6926d..a646e56 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,14 @@ # Change Log +## 20.2.0 + +* Add transaction support for Databases and TablesDB + +## 20.1.0 + +* Deprecate `createVerification` method in `Account` service +* Add `createEmailVerification` method in `Account` service + ## 17.2.0 * Add `incrementDocumentAttribute` and `decrementDocumentAttribute` support to `Databases` service diff --git a/docs/examples/account/create-email-verification.md b/docs/examples/account/create-email-verification.md new file mode 100644 index 0000000..e2aaf80 --- /dev/null +++ b/docs/examples/account/create-email-verification.md @@ -0,0 +1,12 @@ +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setSession(''); // The user session to authenticate with + +const account = new sdk.Account(client); + +const result = await account.createEmailVerification({ + url: 'https://example.com' +}); diff --git a/docs/examples/account/update-email-verification.md b/docs/examples/account/update-email-verification.md new file mode 100644 index 0000000..eb6507e --- /dev/null +++ b/docs/examples/account/update-email-verification.md @@ -0,0 +1,13 @@ +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setSession(''); // The user session to authenticate with + +const account = new sdk.Account(client); + +const result = await account.updateEmailVerification({ + userId: '', + secret: '' +}); diff --git a/docs/examples/databases/create-document.md b/docs/examples/databases/create-document.md index 175e063..6fe77c4 100644 --- a/docs/examples/databases/create-document.md +++ b/docs/examples/databases/create-document.md @@ -18,5 +18,6 @@ const result = await databases.createDocument({ "age": 30, "isAdmin": false }, - permissions: ["read("any")"] // optional + permissions: ["read("any")"], // optional + transactionId: '' // optional }); diff --git a/docs/examples/databases/create-documents.md b/docs/examples/databases/create-documents.md index 73d08aa..8815d8d 100644 --- a/docs/examples/databases/create-documents.md +++ b/docs/examples/databases/create-documents.md @@ -10,5 +10,6 @@ const databases = new sdk.Databases(client); const result = await databases.createDocuments({ databaseId: '', collectionId: '', - documents: [] + documents: [], + transactionId: '' // optional }); diff --git a/docs/examples/databases/create-line-attribute.md b/docs/examples/databases/create-line-attribute.md index 2b356de..160bb5b 100644 --- a/docs/examples/databases/create-line-attribute.md +++ b/docs/examples/databases/create-line-attribute.md @@ -12,5 +12,5 @@ const result = await databases.createLineAttribute({ collectionId: '', key: '', required: false, - default: [[1,2], [3, 4]] // optional + default: [[1, 2], [3, 4], [5, 6]] // optional }); diff --git a/docs/examples/databases/create-operations.md b/docs/examples/databases/create-operations.md new file mode 100644 index 0000000..da8452e --- /dev/null +++ b/docs/examples/databases/create-operations.md @@ -0,0 +1,23 @@ +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +const databases = new sdk.Databases(client); + +const result = await databases.createOperations({ + transactionId: '', + operations: [ + { + "action": "create", + "databaseId": "", + "collectionId": "", + "documentId": "", + "data": { + "name": "Walter O'Brien" + } + } + ] // optional +}); diff --git a/docs/examples/databases/create-point-attribute.md b/docs/examples/databases/create-point-attribute.md index 3733d73..e65f5bd 100644 --- a/docs/examples/databases/create-point-attribute.md +++ b/docs/examples/databases/create-point-attribute.md @@ -12,5 +12,5 @@ const result = await databases.createPointAttribute({ collectionId: '', key: '', required: false, - default: [[1,2], [3, 4]] // optional + default: [1, 2] // optional }); diff --git a/docs/examples/databases/create-polygon-attribute.md b/docs/examples/databases/create-polygon-attribute.md index 0fbe7de..3d51887 100644 --- a/docs/examples/databases/create-polygon-attribute.md +++ b/docs/examples/databases/create-polygon-attribute.md @@ -12,5 +12,5 @@ const result = await databases.createPolygonAttribute({ collectionId: '', key: '', required: false, - default: [[1,2], [3, 4]] // optional + default: [[[1, 2], [3, 4], [5, 6], [1, 2]]] // optional }); diff --git a/docs/examples/databases/create-transaction.md b/docs/examples/databases/create-transaction.md new file mode 100644 index 0000000..f3da291 --- /dev/null +++ b/docs/examples/databases/create-transaction.md @@ -0,0 +1,12 @@ +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +const databases = new sdk.Databases(client); + +const result = await databases.createTransaction({ + ttl: 60 // optional +}); diff --git a/docs/examples/databases/decrement-document-attribute.md b/docs/examples/databases/decrement-document-attribute.md index 87e4d7d..c01b250 100644 --- a/docs/examples/databases/decrement-document-attribute.md +++ b/docs/examples/databases/decrement-document-attribute.md @@ -13,5 +13,6 @@ const result = await databases.decrementDocumentAttribute({ documentId: '', attribute: '', value: null, // optional - min: null // optional + min: null, // optional + transactionId: '' // optional }); diff --git a/docs/examples/databases/delete-document.md b/docs/examples/databases/delete-document.md index 429554b..bfc1977 100644 --- a/docs/examples/databases/delete-document.md +++ b/docs/examples/databases/delete-document.md @@ -10,5 +10,6 @@ const databases = new sdk.Databases(client); const result = await databases.deleteDocument({ databaseId: '', collectionId: '', - documentId: '' + documentId: '', + transactionId: '' // optional }); diff --git a/docs/examples/databases/delete-documents.md b/docs/examples/databases/delete-documents.md index 0965d8d..9440d20 100644 --- a/docs/examples/databases/delete-documents.md +++ b/docs/examples/databases/delete-documents.md @@ -10,5 +10,6 @@ const databases = new sdk.Databases(client); const result = await databases.deleteDocuments({ databaseId: '', collectionId: '', - queries: [] // optional + queries: [], // optional + transactionId: '' // optional }); diff --git a/docs/examples/databases/delete-transaction.md b/docs/examples/databases/delete-transaction.md new file mode 100644 index 0000000..53d676e --- /dev/null +++ b/docs/examples/databases/delete-transaction.md @@ -0,0 +1,12 @@ +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +const databases = new sdk.Databases(client); + +const result = await databases.deleteTransaction({ + transactionId: '' +}); diff --git a/docs/examples/databases/get-document.md b/docs/examples/databases/get-document.md index 7cc71cd..7abea4e 100644 --- a/docs/examples/databases/get-document.md +++ b/docs/examples/databases/get-document.md @@ -11,5 +11,6 @@ const result = await databases.getDocument({ databaseId: '', collectionId: '', documentId: '', - queries: [] // optional + queries: [], // optional + transactionId: '' // optional }); diff --git a/docs/examples/databases/get-transaction.md b/docs/examples/databases/get-transaction.md new file mode 100644 index 0000000..9b7297c --- /dev/null +++ b/docs/examples/databases/get-transaction.md @@ -0,0 +1,12 @@ +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +const databases = new sdk.Databases(client); + +const result = await databases.getTransaction({ + transactionId: '' +}); diff --git a/docs/examples/databases/increment-document-attribute.md b/docs/examples/databases/increment-document-attribute.md index 2b47f5a..843d163 100644 --- a/docs/examples/databases/increment-document-attribute.md +++ b/docs/examples/databases/increment-document-attribute.md @@ -13,5 +13,6 @@ const result = await databases.incrementDocumentAttribute({ documentId: '', attribute: '', value: null, // optional - max: null // optional + max: null, // optional + transactionId: '' // optional }); diff --git a/docs/examples/databases/list-documents.md b/docs/examples/databases/list-documents.md index 148bf83..7405f3e 100644 --- a/docs/examples/databases/list-documents.md +++ b/docs/examples/databases/list-documents.md @@ -10,5 +10,6 @@ const databases = new sdk.Databases(client); const result = await databases.listDocuments({ databaseId: '', collectionId: '', - queries: [] // optional + queries: [], // optional + transactionId: '' // optional }); diff --git a/docs/examples/databases/list-transactions.md b/docs/examples/databases/list-transactions.md new file mode 100644 index 0000000..9a36eb0 --- /dev/null +++ b/docs/examples/databases/list-transactions.md @@ -0,0 +1,12 @@ +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +const databases = new sdk.Databases(client); + +const result = await databases.listTransactions({ + queries: [] // optional +}); diff --git a/docs/examples/databases/update-document.md b/docs/examples/databases/update-document.md index 8a9a685..3e95376 100644 --- a/docs/examples/databases/update-document.md +++ b/docs/examples/databases/update-document.md @@ -12,5 +12,6 @@ const result = await databases.updateDocument({ collectionId: '', documentId: '', data: {}, // optional - permissions: ["read("any")"] // optional + permissions: ["read("any")"], // optional + transactionId: '' // optional }); diff --git a/docs/examples/databases/update-documents.md b/docs/examples/databases/update-documents.md index 2cfb8c7..dc79e43 100644 --- a/docs/examples/databases/update-documents.md +++ b/docs/examples/databases/update-documents.md @@ -11,5 +11,6 @@ const result = await databases.updateDocuments({ databaseId: '', collectionId: '', data: {}, // optional - queries: [] // optional + queries: [], // optional + transactionId: '' // optional }); diff --git a/docs/examples/databases/update-line-attribute.md b/docs/examples/databases/update-line-attribute.md index dfc6a30..3c4d785 100644 --- a/docs/examples/databases/update-line-attribute.md +++ b/docs/examples/databases/update-line-attribute.md @@ -12,6 +12,6 @@ const result = await databases.updateLineAttribute({ collectionId: '', key: '', required: false, - default: [[1,2], [3, 4]], // optional + default: [[1, 2], [3, 4], [5, 6]], // optional newKey: '' // optional }); diff --git a/docs/examples/databases/update-point-attribute.md b/docs/examples/databases/update-point-attribute.md index 9587f4f..0da3b33 100644 --- a/docs/examples/databases/update-point-attribute.md +++ b/docs/examples/databases/update-point-attribute.md @@ -12,6 +12,6 @@ const result = await databases.updatePointAttribute({ collectionId: '', key: '', required: false, - default: [[1,2], [3, 4]], // optional + default: [1, 2], // optional newKey: '' // optional }); diff --git a/docs/examples/databases/update-polygon-attribute.md b/docs/examples/databases/update-polygon-attribute.md index f3df251..c7767cb 100644 --- a/docs/examples/databases/update-polygon-attribute.md +++ b/docs/examples/databases/update-polygon-attribute.md @@ -12,6 +12,6 @@ const result = await databases.updatePolygonAttribute({ collectionId: '', key: '', required: false, - default: [[1,2], [3, 4]], // optional + default: [[[1, 2], [3, 4], [5, 6], [1, 2]]], // optional newKey: '' // optional }); diff --git a/docs/examples/databases/update-transaction.md b/docs/examples/databases/update-transaction.md new file mode 100644 index 0000000..5765449 --- /dev/null +++ b/docs/examples/databases/update-transaction.md @@ -0,0 +1,14 @@ +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +const databases = new sdk.Databases(client); + +const result = await databases.updateTransaction({ + transactionId: '', + commit: false, // optional + rollback: false // optional +}); diff --git a/docs/examples/databases/upsert-document.md b/docs/examples/databases/upsert-document.md index 5ec3e05..0aaec4e 100644 --- a/docs/examples/databases/upsert-document.md +++ b/docs/examples/databases/upsert-document.md @@ -12,5 +12,6 @@ const result = await databases.upsertDocument({ collectionId: '', documentId: '', data: {}, - permissions: ["read("any")"] // optional + permissions: ["read("any")"], // optional + transactionId: '' // optional }); diff --git a/docs/examples/databases/upsert-documents.md b/docs/examples/databases/upsert-documents.md index 8deec53..16ed70f 100644 --- a/docs/examples/databases/upsert-documents.md +++ b/docs/examples/databases/upsert-documents.md @@ -10,5 +10,6 @@ const databases = new sdk.Databases(client); const result = await databases.upsertDocuments({ databaseId: '', collectionId: '', - documents: [] + documents: [], + transactionId: '' // optional }); diff --git a/docs/examples/messaging/create-push.md b/docs/examples/messaging/create-push.md index c0a7f47..4c64813 100644 --- a/docs/examples/messaging/create-push.md +++ b/docs/examples/messaging/create-push.md @@ -16,7 +16,7 @@ const result = await messaging.createPush({ targets: [], // optional data: {}, // optional action: '', // optional - image: '[ID1:ID2]', // optional + image: '', // optional icon: '', // optional sound: '', // optional color: '', // optional diff --git a/docs/examples/messaging/update-push.md b/docs/examples/messaging/update-push.md index 5e857f1..6f5899f 100644 --- a/docs/examples/messaging/update-push.md +++ b/docs/examples/messaging/update-push.md @@ -16,7 +16,7 @@ const result = await messaging.updatePush({ body: '', // optional data: {}, // optional action: '', // optional - image: '[ID1:ID2]', // optional + image: '', // optional icon: '', // optional sound: '', // optional color: '', // optional diff --git a/docs/examples/tablesdb/create-line-column.md b/docs/examples/tablesdb/create-line-column.md index 719f95b..84b941c 100644 --- a/docs/examples/tablesdb/create-line-column.md +++ b/docs/examples/tablesdb/create-line-column.md @@ -12,5 +12,5 @@ const result = await tablesDB.createLineColumn({ tableId: '', key: '', required: false, - default: [[1,2], [3, 4]] // optional + default: [[1, 2], [3, 4], [5, 6]] // optional }); diff --git a/docs/examples/tablesdb/create-operations.md b/docs/examples/tablesdb/create-operations.md new file mode 100644 index 0000000..2549239 --- /dev/null +++ b/docs/examples/tablesdb/create-operations.md @@ -0,0 +1,23 @@ +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +const tablesDB = new sdk.TablesDB(client); + +const result = await tablesDB.createOperations({ + transactionId: '', + operations: [ + { + "action": "create", + "databaseId": "", + "tableId": "", + "rowId": "", + "data": { + "name": "Walter O'Brien" + } + } + ] // optional +}); diff --git a/docs/examples/tablesdb/create-point-column.md b/docs/examples/tablesdb/create-point-column.md index 4dbba23..c59e420 100644 --- a/docs/examples/tablesdb/create-point-column.md +++ b/docs/examples/tablesdb/create-point-column.md @@ -12,5 +12,5 @@ const result = await tablesDB.createPointColumn({ tableId: '', key: '', required: false, - default: [[1,2], [3, 4]] // optional + default: [1, 2] // optional }); diff --git a/docs/examples/tablesdb/create-polygon-column.md b/docs/examples/tablesdb/create-polygon-column.md index 76dabf3..36f2f4c 100644 --- a/docs/examples/tablesdb/create-polygon-column.md +++ b/docs/examples/tablesdb/create-polygon-column.md @@ -12,5 +12,5 @@ const result = await tablesDB.createPolygonColumn({ tableId: '', key: '', required: false, - default: [[1,2], [3, 4]] // optional + default: [[[1, 2], [3, 4], [5, 6], [1, 2]]] // optional }); diff --git a/docs/examples/tablesdb/create-row.md b/docs/examples/tablesdb/create-row.md index 29ddab6..4468c16 100644 --- a/docs/examples/tablesdb/create-row.md +++ b/docs/examples/tablesdb/create-row.md @@ -18,5 +18,6 @@ const result = await tablesDB.createRow({ "age": 30, "isAdmin": false }, - permissions: ["read("any")"] // optional + permissions: ["read("any")"], // optional + transactionId: '' // optional }); diff --git a/docs/examples/tablesdb/create-rows.md b/docs/examples/tablesdb/create-rows.md index 61eb1d1..20807c1 100644 --- a/docs/examples/tablesdb/create-rows.md +++ b/docs/examples/tablesdb/create-rows.md @@ -10,5 +10,6 @@ const tablesDB = new sdk.TablesDB(client); const result = await tablesDB.createRows({ databaseId: '', tableId: '', - rows: [] + rows: [], + transactionId: '' // optional }); diff --git a/docs/examples/tablesdb/create-transaction.md b/docs/examples/tablesdb/create-transaction.md new file mode 100644 index 0000000..249406e --- /dev/null +++ b/docs/examples/tablesdb/create-transaction.md @@ -0,0 +1,12 @@ +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +const tablesDB = new sdk.TablesDB(client); + +const result = await tablesDB.createTransaction({ + ttl: 60 // optional +}); diff --git a/docs/examples/tablesdb/decrement-row-column.md b/docs/examples/tablesdb/decrement-row-column.md index e3b13a8..0310399 100644 --- a/docs/examples/tablesdb/decrement-row-column.md +++ b/docs/examples/tablesdb/decrement-row-column.md @@ -13,5 +13,6 @@ const result = await tablesDB.decrementRowColumn({ rowId: '', column: '', value: null, // optional - min: null // optional + min: null, // optional + transactionId: '' // optional }); diff --git a/docs/examples/tablesdb/delete-row.md b/docs/examples/tablesdb/delete-row.md index 9802f0d..68a965d 100644 --- a/docs/examples/tablesdb/delete-row.md +++ b/docs/examples/tablesdb/delete-row.md @@ -10,5 +10,6 @@ const tablesDB = new sdk.TablesDB(client); const result = await tablesDB.deleteRow({ databaseId: '', tableId: '', - rowId: '' + rowId: '', + transactionId: '' // optional }); diff --git a/docs/examples/tablesdb/delete-rows.md b/docs/examples/tablesdb/delete-rows.md index 6f4d7cd..ce1d0f4 100644 --- a/docs/examples/tablesdb/delete-rows.md +++ b/docs/examples/tablesdb/delete-rows.md @@ -10,5 +10,6 @@ const tablesDB = new sdk.TablesDB(client); const result = await tablesDB.deleteRows({ databaseId: '', tableId: '', - queries: [] // optional + queries: [], // optional + transactionId: '' // optional }); diff --git a/docs/examples/tablesdb/delete-transaction.md b/docs/examples/tablesdb/delete-transaction.md new file mode 100644 index 0000000..28d086b --- /dev/null +++ b/docs/examples/tablesdb/delete-transaction.md @@ -0,0 +1,12 @@ +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +const tablesDB = new sdk.TablesDB(client); + +const result = await tablesDB.deleteTransaction({ + transactionId: '' +}); diff --git a/docs/examples/tablesdb/get-row.md b/docs/examples/tablesdb/get-row.md index 7ea3d1f..fe67e2f 100644 --- a/docs/examples/tablesdb/get-row.md +++ b/docs/examples/tablesdb/get-row.md @@ -11,5 +11,6 @@ const result = await tablesDB.getRow({ databaseId: '', tableId: '', rowId: '', - queries: [] // optional + queries: [], // optional + transactionId: '' // optional }); diff --git a/docs/examples/tablesdb/get-transaction.md b/docs/examples/tablesdb/get-transaction.md new file mode 100644 index 0000000..208368b --- /dev/null +++ b/docs/examples/tablesdb/get-transaction.md @@ -0,0 +1,12 @@ +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +const tablesDB = new sdk.TablesDB(client); + +const result = await tablesDB.getTransaction({ + transactionId: '' +}); diff --git a/docs/examples/tablesdb/increment-row-column.md b/docs/examples/tablesdb/increment-row-column.md index f5cac2e..aaa6cd6 100644 --- a/docs/examples/tablesdb/increment-row-column.md +++ b/docs/examples/tablesdb/increment-row-column.md @@ -13,5 +13,6 @@ const result = await tablesDB.incrementRowColumn({ rowId: '', column: '', value: null, // optional - max: null // optional + max: null, // optional + transactionId: '' // optional }); diff --git a/docs/examples/tablesdb/list-rows.md b/docs/examples/tablesdb/list-rows.md index 6d3b883..3f29781 100644 --- a/docs/examples/tablesdb/list-rows.md +++ b/docs/examples/tablesdb/list-rows.md @@ -10,5 +10,6 @@ const tablesDB = new sdk.TablesDB(client); const result = await tablesDB.listRows({ databaseId: '', tableId: '', - queries: [] // optional + queries: [], // optional + transactionId: '' // optional }); diff --git a/docs/examples/tablesdb/list-transactions.md b/docs/examples/tablesdb/list-transactions.md new file mode 100644 index 0000000..3ad0c95 --- /dev/null +++ b/docs/examples/tablesdb/list-transactions.md @@ -0,0 +1,12 @@ +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +const tablesDB = new sdk.TablesDB(client); + +const result = await tablesDB.listTransactions({ + queries: [] // optional +}); diff --git a/docs/examples/tablesdb/update-line-column.md b/docs/examples/tablesdb/update-line-column.md index 8c00645..4ec0abe 100644 --- a/docs/examples/tablesdb/update-line-column.md +++ b/docs/examples/tablesdb/update-line-column.md @@ -12,6 +12,6 @@ const result = await tablesDB.updateLineColumn({ tableId: '', key: '', required: false, - default: [[1,2], [3, 4]], // optional + default: [[1, 2], [3, 4], [5, 6]], // optional newKey: '' // optional }); diff --git a/docs/examples/tablesdb/update-point-column.md b/docs/examples/tablesdb/update-point-column.md index 5ece8d8..cddb198 100644 --- a/docs/examples/tablesdb/update-point-column.md +++ b/docs/examples/tablesdb/update-point-column.md @@ -12,6 +12,6 @@ const result = await tablesDB.updatePointColumn({ tableId: '', key: '', required: false, - default: [[1,2], [3, 4]], // optional + default: [1, 2], // optional newKey: '' // optional }); diff --git a/docs/examples/tablesdb/update-polygon-column.md b/docs/examples/tablesdb/update-polygon-column.md index 0649a84..963db8b 100644 --- a/docs/examples/tablesdb/update-polygon-column.md +++ b/docs/examples/tablesdb/update-polygon-column.md @@ -12,6 +12,6 @@ const result = await tablesDB.updatePolygonColumn({ tableId: '', key: '', required: false, - default: [[1,2], [3, 4]], // optional + default: [[[1, 2], [3, 4], [5, 6], [1, 2]]], // optional newKey: '' // optional }); diff --git a/docs/examples/tablesdb/update-row.md b/docs/examples/tablesdb/update-row.md index 1c7f0af..58583af 100644 --- a/docs/examples/tablesdb/update-row.md +++ b/docs/examples/tablesdb/update-row.md @@ -12,5 +12,6 @@ const result = await tablesDB.updateRow({ tableId: '', rowId: '', data: {}, // optional - permissions: ["read("any")"] // optional + permissions: ["read("any")"], // optional + transactionId: '' // optional }); diff --git a/docs/examples/tablesdb/update-rows.md b/docs/examples/tablesdb/update-rows.md index 31628d7..d66fc28 100644 --- a/docs/examples/tablesdb/update-rows.md +++ b/docs/examples/tablesdb/update-rows.md @@ -11,5 +11,6 @@ const result = await tablesDB.updateRows({ databaseId: '', tableId: '', data: {}, // optional - queries: [] // optional + queries: [], // optional + transactionId: '' // optional }); diff --git a/docs/examples/tablesdb/update-transaction.md b/docs/examples/tablesdb/update-transaction.md new file mode 100644 index 0000000..03501d2 --- /dev/null +++ b/docs/examples/tablesdb/update-transaction.md @@ -0,0 +1,14 @@ +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +const tablesDB = new sdk.TablesDB(client); + +const result = await tablesDB.updateTransaction({ + transactionId: '', + commit: false, // optional + rollback: false // optional +}); diff --git a/docs/examples/tablesdb/upsert-row.md b/docs/examples/tablesdb/upsert-row.md index 9963bb6..bfb8333 100644 --- a/docs/examples/tablesdb/upsert-row.md +++ b/docs/examples/tablesdb/upsert-row.md @@ -12,5 +12,6 @@ const result = await tablesDB.upsertRow({ tableId: '', rowId: '', data: {}, // optional - permissions: ["read("any")"] // optional + permissions: ["read("any")"], // optional + transactionId: '' // optional }); diff --git a/docs/examples/tablesdb/upsert-rows.md b/docs/examples/tablesdb/upsert-rows.md index cca2b77..c985c95 100644 --- a/docs/examples/tablesdb/upsert-rows.md +++ b/docs/examples/tablesdb/upsert-rows.md @@ -10,5 +10,6 @@ const tablesDB = new sdk.TablesDB(client); const result = await tablesDB.upsertRows({ databaseId: '', tableId: '', - rows: [] + rows: [], + transactionId: '' // optional }); diff --git a/package.json b/package.json index 58e2b24..503ad00 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "node-appwrite", "homepage": "https://appwrite.io/support", "description": "Appwrite is an open-source self-hosted backend server that abstract and simplify complex and repetitive development tasks behind a very simple REST API", - "version": "19.0.0", + "version": "20.2.0", "license": "BSD-3-Clause", "main": "dist/index.js", "type": "commonjs", diff --git a/src/client.ts b/src/client.ts index 9e577e3..a91eb4b 100644 --- a/src/client.ts +++ b/src/client.ts @@ -33,7 +33,7 @@ class AppwriteException extends Error { } function getUserAgent() { - let ua = 'AppwriteNodeJSSDK/19.0.0'; + let ua = 'AppwriteNodeJSSDK/20.2.0'; // `process` is a global in Node.js, but not fully available in all runtimes. const platform: string[] = []; @@ -82,7 +82,7 @@ class Client { 'x-sdk-name': 'Node.js', 'x-sdk-platform': 'server', 'x-sdk-language': 'nodejs', - 'x-sdk-version': '19.0.0', + 'x-sdk-version': '20.2.0', 'user-agent' : getUserAgent(), 'X-Appwrite-Response-Format': '1.8.0', }; diff --git a/src/enums/attribute-status.ts b/src/enums/attribute-status.ts new file mode 100644 index 0000000..ade1d36 --- /dev/null +++ b/src/enums/attribute-status.ts @@ -0,0 +1,7 @@ +export enum AttributeStatus { + Available = 'available', + Processing = 'processing', + Deleting = 'deleting', + Stuck = 'stuck', + Failed = 'failed', +} \ No newline at end of file diff --git a/src/enums/column-status.ts b/src/enums/column-status.ts new file mode 100644 index 0000000..f53e8a6 --- /dev/null +++ b/src/enums/column-status.ts @@ -0,0 +1,7 @@ +export enum ColumnStatus { + Available = 'available', + Processing = 'processing', + Deleting = 'deleting', + Stuck = 'stuck', + Failed = 'failed', +} \ No newline at end of file diff --git a/src/enums/database-type.ts b/src/enums/database-type.ts new file mode 100644 index 0000000..71d1ed9 --- /dev/null +++ b/src/enums/database-type.ts @@ -0,0 +1,4 @@ +export enum DatabaseType { + Legacy = 'legacy', + Tablesdb = 'tablesdb', +} \ No newline at end of file diff --git a/src/enums/deployment-status.ts b/src/enums/deployment-status.ts new file mode 100644 index 0000000..34aa1fd --- /dev/null +++ b/src/enums/deployment-status.ts @@ -0,0 +1,7 @@ +export enum DeploymentStatus { + Waiting = 'waiting', + Processing = 'processing', + Building = 'building', + Ready = 'ready', + Failed = 'failed', +} \ No newline at end of file diff --git a/src/enums/execution-status.ts b/src/enums/execution-status.ts new file mode 100644 index 0000000..1781e94 --- /dev/null +++ b/src/enums/execution-status.ts @@ -0,0 +1,6 @@ +export enum ExecutionStatus { + Waiting = 'waiting', + Processing = 'processing', + Completed = 'completed', + Failed = 'failed', +} \ No newline at end of file diff --git a/src/enums/execution-trigger.ts b/src/enums/execution-trigger.ts new file mode 100644 index 0000000..1829d51 --- /dev/null +++ b/src/enums/execution-trigger.ts @@ -0,0 +1,5 @@ +export enum ExecutionTrigger { + Http = 'http', + Schedule = 'schedule', + Event = 'event', +} \ No newline at end of file diff --git a/src/enums/health-antivirus-status.ts b/src/enums/health-antivirus-status.ts new file mode 100644 index 0000000..d4da4c4 --- /dev/null +++ b/src/enums/health-antivirus-status.ts @@ -0,0 +1,5 @@ +export enum HealthAntivirusStatus { + Disabled = 'disabled', + Offline = 'offline', + Online = 'online', +} \ No newline at end of file diff --git a/src/enums/health-check-status.ts b/src/enums/health-check-status.ts new file mode 100644 index 0000000..9dbc681 --- /dev/null +++ b/src/enums/health-check-status.ts @@ -0,0 +1,4 @@ +export enum HealthCheckStatus { + Pass = 'pass', + Fail = 'fail', +} \ No newline at end of file diff --git a/src/enums/index-status.ts b/src/enums/index-status.ts new file mode 100644 index 0000000..6ce90ac --- /dev/null +++ b/src/enums/index-status.ts @@ -0,0 +1,7 @@ +export enum IndexStatus { + Available = 'available', + Processing = 'processing', + Deleting = 'deleting', + Stuck = 'stuck', + Failed = 'failed', +} \ No newline at end of file diff --git a/src/enums/message-status.ts b/src/enums/message-status.ts new file mode 100644 index 0000000..08bd483 --- /dev/null +++ b/src/enums/message-status.ts @@ -0,0 +1,7 @@ +export enum MessageStatus { + Draft = 'draft', + Processing = 'processing', + Scheduled = 'scheduled', + Sent = 'sent', + Failed = 'failed', +} \ No newline at end of file diff --git a/src/index.ts b/src/index.ts index e9170f5..83be68e 100644 --- a/src/index.ts +++ b/src/index.ts @@ -42,3 +42,13 @@ export { ImageGravity } from './enums/image-gravity'; export { ImageFormat } from './enums/image-format'; export { PasswordHash } from './enums/password-hash'; export { MessagingProviderType } from './enums/messaging-provider-type'; +export { DatabaseType } from './enums/database-type'; +export { AttributeStatus } from './enums/attribute-status'; +export { ColumnStatus } from './enums/column-status'; +export { IndexStatus } from './enums/index-status'; +export { DeploymentStatus } from './enums/deployment-status'; +export { ExecutionTrigger } from './enums/execution-trigger'; +export { ExecutionStatus } from './enums/execution-status'; +export { HealthAntivirusStatus } from './enums/health-antivirus-status'; +export { HealthCheckStatus } from './enums/health-check-status'; +export { MessageStatus } from './enums/message-status'; diff --git a/src/models.ts b/src/models.ts index c08b303..8779124 100644 --- a/src/models.ts +++ b/src/models.ts @@ -1,3 +1,14 @@ +import { DatabaseType } from "./enums/database-type" +import { AttributeStatus } from "./enums/attribute-status" +import { ColumnStatus } from "./enums/column-status" +import { IndexStatus } from "./enums/index-status" +import { DeploymentStatus } from "./enums/deployment-status" +import { ExecutionTrigger } from "./enums/execution-trigger" +import { ExecutionStatus } from "./enums/execution-status" +import { HealthAntivirusStatus } from "./enums/health-antivirus-status" +import { HealthCheckStatus } from "./enums/health-check-status" +import { MessageStatus } from "./enums/message-status" + /** * Appwrite Models */ @@ -481,6 +492,20 @@ export namespace Models { targets: Target[]; } + /** + * Transaction List + */ + export type TransactionList = { + /** + * Total number of transactions that matched your query. + */ + total: number; + /** + * List of transactions. + */ + transactions: Transaction[]; + } + /** * Specifications List */ @@ -522,7 +547,7 @@ export namespace Models { /** * Database type. */ - type: string; + type: DatabaseType; } /** @@ -600,7 +625,7 @@ export namespace Models { /** * Attribute status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` */ - status: string; + status: AttributeStatus; /** * Error message. Displays error generated on failure of creating or deleting an attribute. */ @@ -650,7 +675,7 @@ export namespace Models { /** * Attribute status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` */ - status: string; + status: AttributeStatus; /** * Error message. Displays error generated on failure of creating or deleting an attribute. */ @@ -700,7 +725,7 @@ export namespace Models { /** * Attribute status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` */ - status: string; + status: AttributeStatus; /** * Error message. Displays error generated on failure of creating or deleting an attribute. */ @@ -750,7 +775,7 @@ export namespace Models { /** * Attribute status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` */ - status: string; + status: AttributeStatus; /** * Error message. Displays error generated on failure of creating or deleting an attribute. */ @@ -792,7 +817,7 @@ export namespace Models { /** * Attribute status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` */ - status: string; + status: AttributeStatus; /** * Error message. Displays error generated on failure of creating or deleting an attribute. */ @@ -838,7 +863,7 @@ export namespace Models { /** * Attribute status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` */ - status: string; + status: AttributeStatus; /** * Error message. Displays error generated on failure of creating or deleting an attribute. */ @@ -888,7 +913,7 @@ export namespace Models { /** * Attribute status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` */ - status: string; + status: AttributeStatus; /** * Error message. Displays error generated on failure of creating or deleting an attribute. */ @@ -934,7 +959,7 @@ export namespace Models { /** * Attribute status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` */ - status: string; + status: AttributeStatus; /** * Error message. Displays error generated on failure of creating or deleting an attribute. */ @@ -980,7 +1005,7 @@ export namespace Models { /** * Attribute status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` */ - status: string; + status: AttributeStatus; /** * Error message. Displays error generated on failure of creating or deleting an attribute. */ @@ -1026,7 +1051,7 @@ export namespace Models { /** * Attribute status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` */ - status: string; + status: AttributeStatus; /** * Error message. Displays error generated on failure of creating or deleting an attribute. */ @@ -1088,7 +1113,7 @@ export namespace Models { /** * Attribute status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` */ - status: string; + status: AttributeStatus; /** * Error message. Displays error generated on failure of creating or deleting an attribute. */ @@ -1130,7 +1155,7 @@ export namespace Models { /** * Attribute status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` */ - status: string; + status: AttributeStatus; /** * Error message. Displays error generated on failure of creating or deleting an attribute. */ @@ -1172,7 +1197,7 @@ export namespace Models { /** * Attribute status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` */ - status: string; + status: AttributeStatus; /** * Error message. Displays error generated on failure of creating or deleting an attribute. */ @@ -1274,7 +1299,7 @@ export namespace Models { /** * Column status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` */ - status: string; + status: ColumnStatus; /** * Error message. Displays error generated on failure of creating or deleting an column. */ @@ -1324,7 +1349,7 @@ export namespace Models { /** * Column status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` */ - status: string; + status: ColumnStatus; /** * Error message. Displays error generated on failure of creating or deleting an column. */ @@ -1374,7 +1399,7 @@ export namespace Models { /** * Column status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` */ - status: string; + status: ColumnStatus; /** * Error message. Displays error generated on failure of creating or deleting an column. */ @@ -1424,7 +1449,7 @@ export namespace Models { /** * Column status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` */ - status: string; + status: ColumnStatus; /** * Error message. Displays error generated on failure of creating or deleting an column. */ @@ -1466,7 +1491,7 @@ export namespace Models { /** * Column status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` */ - status: string; + status: ColumnStatus; /** * Error message. Displays error generated on failure of creating or deleting an column. */ @@ -1512,7 +1537,7 @@ export namespace Models { /** * Column status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` */ - status: string; + status: ColumnStatus; /** * Error message. Displays error generated on failure of creating or deleting an column. */ @@ -1562,7 +1587,7 @@ export namespace Models { /** * Column status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` */ - status: string; + status: ColumnStatus; /** * Error message. Displays error generated on failure of creating or deleting an column. */ @@ -1608,7 +1633,7 @@ export namespace Models { /** * Column status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` */ - status: string; + status: ColumnStatus; /** * Error message. Displays error generated on failure of creating or deleting an column. */ @@ -1654,7 +1679,7 @@ export namespace Models { /** * Column status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` */ - status: string; + status: ColumnStatus; /** * Error message. Displays error generated on failure of creating or deleting an column. */ @@ -1700,7 +1725,7 @@ export namespace Models { /** * Column status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` */ - status: string; + status: ColumnStatus; /** * Error message. Displays error generated on failure of creating or deleting an column. */ @@ -1762,7 +1787,7 @@ export namespace Models { /** * Column status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` */ - status: string; + status: ColumnStatus; /** * Error message. Displays error generated on failure of creating or deleting an column. */ @@ -1804,7 +1829,7 @@ export namespace Models { /** * Column status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` */ - status: string; + status: ColumnStatus; /** * Error message. Displays error generated on failure of creating or deleting an column. */ @@ -1846,7 +1871,7 @@ export namespace Models { /** * Column status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` */ - status: string; + status: ColumnStatus; /** * Error message. Displays error generated on failure of creating or deleting an column. */ @@ -1900,7 +1925,7 @@ export namespace Models { /** * Index status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` */ - status: string; + status: IndexStatus; /** * Error message. Displays error generated on failure of creating or deleting an index. */ @@ -3211,7 +3236,7 @@ export namespace Models { /** * The deployment status. Possible values are "waiting", "processing", "building", "ready", and "failed". */ - status: string; + status: DeploymentStatus; /** * The build logs. */ @@ -3232,10 +3257,6 @@ export namespace Models { * The url of the vcs provider repository */ providerRepositoryUrl: string; - /** - * The branch of the vcs repository - */ - providerBranch: string; /** * The commit hash of the vcs commit */ @@ -3256,6 +3277,10 @@ export namespace Models { * The url of the vcs commit */ providerCommitUrl: string; + /** + * The branch of the vcs repository + */ + providerBranch: string; /** * The branch of the vcs repository */ @@ -3293,11 +3318,11 @@ export namespace Models { /** * The trigger that caused the function to execute. Possible values can be: `http`, `schedule`, or `event`. */ - trigger: string; + trigger: ExecutionTrigger; /** * The status of the function execution. Possible values can be: `waiting`, `processing`, `completed`, or `failed`. */ - status: string; + status: ExecutionStatus; /** * HTTP request method type. */ @@ -3307,7 +3332,7 @@ export namespace Models { */ requestPath: 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. + * HTTP request headers as a key-value object. This will return only whitelisted headers. All headers are returned if execution is created as synchronous. */ requestHeaders: Headers[]; /** @@ -3485,9 +3510,9 @@ export namespace Models { */ version: string; /** - * Antivirus status. Possible values can are: `disabled`, `offline`, `online` + * Antivirus status. Possible values are: `disabled`, `offline`, `online` */ - status: string; + status: HealthAntivirusStatus; } /** @@ -3513,9 +3538,9 @@ export namespace Models { */ ping: number; /** - * Service status. Possible values can are: `pass`, `fail` + * Service status. Possible values are: `pass`, `fail` */ - status: string; + status: HealthCheckStatus; } /** @@ -3767,7 +3792,7 @@ export namespace Models { /** * Status of delivery. */ - status: string; + status: MessageStatus; } /** @@ -3808,6 +3833,36 @@ export namespace Models { subscribe: string[]; } + /** + * Transaction + */ + 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; + /** + * 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; + } + /** * Subscriber */ diff --git a/src/query.ts b/src/query.ts index ddaa3f2..8b274f4 100644 --- a/src/query.ts +++ b/src/query.ts @@ -52,20 +52,20 @@ export class Query { * Filter resources where attribute is equal to value. * * @param {string} attribute - * @param {QueryTypes | any[]} value + * @param {QueryTypes} value * @returns {string} */ - static equal = (attribute: string, value: QueryTypes | any[]): string => + static equal = (attribute: string, value: QueryTypes): string => new Query("equal", attribute, value).toString(); /** * Filter resources where attribute is not equal to value. * * @param {string} attribute - * @param {QueryTypes | any[]} value + * @param {QueryTypes} value * @returns {string} */ - static notEqual = (attribute: string, value: QueryTypes | any[]): string => + static notEqual = (attribute: string, value: QueryTypes): string => new Query("notEqual", attribute, value).toString(); /** @@ -195,6 +195,14 @@ export class Query { static orderAsc = (attribute: string): string => new Query("orderAsc", attribute).toString(); + /** + * Sort results randomly. + * + * @returns {string} + */ + static orderRandom = (): string => + new Query("orderRandom").toString(); + /** * Return results after documentId. * diff --git a/src/services/account.ts b/src/services/account.ts index 979d905..4636d4e 100644 --- a/src/services/account.ts +++ b/src/services/account.ts @@ -2448,6 +2448,68 @@ export class Account { * @throws {AppwriteException} * @returns {Promise} */ + createEmailVerification(params: { url: string }): Promise; + /** + * Use this endpoint to send a verification message to your user email address to confirm they are the valid owners of that address. Both the **userId** and **secret** arguments will be passed as query parameters to the URL you have provided to be attached to the verification email. The provided URL should redirect the user back to your app and allow you to complete the verification process by verifying both the **userId** and **secret** parameters. Learn more about how to [complete the verification process](https://appwrite.io/docs/references/cloud/client-web/account#updateVerification). The verification link sent to the user's email address is valid for 7 days. + * + * Please note that in order to avoid a [Redirect Attack](https://github.com/OWASP/CheatSheetSeries/blob/master/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.md), the only valid redirect URLs are the ones from domains you have set when adding your platforms in the console interface. + * + * + * @param {string} url - URL to redirect the user back to your app from the verification email. Only URLs from hostnames in your project platform list are allowed. This requirement helps to prevent an [open redirect](https://cheatsheetseries.owasp.org/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.html) attack against your project API. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createEmailVerification(url: string): Promise; + createEmailVerification( + paramsOrFirst: { url: string } | string + ): Promise { + let params: { url: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { url: string }; + } else { + params = { + url: paramsOrFirst as string + }; + } + + const url = params.url; + + if (typeof url === 'undefined') { + throw new AppwriteException('Missing required parameter: "url"'); + } + + const apiPath = '/account/verifications/email'; + const payload: Payload = {}; + if (typeof url !== 'undefined') { + payload['url'] = url; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'post', + uri, + apiHeaders, + payload, + ); + } + + /** + * Use this endpoint to send a verification message to your user email address to confirm they are the valid owners of that address. Both the **userId** and **secret** arguments will be passed as query parameters to the URL you have provided to be attached to the verification email. The provided URL should redirect the user back to your app and allow you to complete the verification process by verifying both the **userId** and **secret** parameters. Learn more about how to [complete the verification process](https://appwrite.io/docs/references/cloud/client-web/account#updateVerification). The verification link sent to the user's email address is valid for 7 days. + * + * Please note that in order to avoid a [Redirect Attack](https://github.com/OWASP/CheatSheetSeries/blob/master/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.md), the only valid redirect URLs are the ones from domains you have set when adding your platforms in the console interface. + * + * + * @param {string} params.url - URL to redirect the user back to your app from the verification email. Only URLs from hostnames in your project platform list are allowed. This requirement helps to prevent an [open redirect](https://cheatsheetseries.owasp.org/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.html) attack against your project API. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated This API has been deprecated since 1.8.0. Please use `Account.createEmailVerification` instead. + */ createVerification(params: { url: string }): Promise; /** * Use this endpoint to send a verification message to your user email address to confirm they are the valid owners of that address. Both the **userId** and **secret** arguments will be passed as query parameters to the URL you have provided to be attached to the verification email. The provided URL should redirect the user back to your app and allow you to complete the verification process by verifying both the **userId** and **secret** parameters. Learn more about how to [complete the verification process](https://appwrite.io/docs/references/cloud/client-web/account#updateVerification). The verification link sent to the user's email address is valid for 7 days. @@ -2480,7 +2542,7 @@ export class Account { throw new AppwriteException('Missing required parameter: "url"'); } - const apiPath = '/account/verification'; + const apiPath = '/account/verifications/email'; const payload: Payload = {}; if (typeof url !== 'undefined') { payload['url'] = url; @@ -2507,6 +2569,73 @@ export class Account { * @throws {AppwriteException} * @returns {Promise} */ + updateEmailVerification(params: { userId: string, secret: string }): Promise; + /** + * Use this endpoint to complete the user email verification process. Use both the **userId** and **secret** parameters that were attached to your app URL to verify the user email ownership. If confirmed this route will return a 200 status code. + * + * @param {string} userId - User ID. + * @param {string} secret - Valid verification token. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateEmailVerification(userId: string, secret: string): Promise; + updateEmailVerification( + paramsOrFirst: { userId: string, secret: string } | string, + ...rest: [(string)?] + ): Promise { + let params: { userId: string, secret: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { userId: string, secret: string }; + } else { + params = { + userId: paramsOrFirst as string, + secret: rest[0] as string + }; + } + + const userId = params.userId; + const secret = params.secret; + + if (typeof userId === 'undefined') { + throw new AppwriteException('Missing required parameter: "userId"'); + } + if (typeof secret === 'undefined') { + throw new AppwriteException('Missing required parameter: "secret"'); + } + + const apiPath = '/account/verifications/email'; + const payload: Payload = {}; + if (typeof userId !== 'undefined') { + payload['userId'] = userId; + } + if (typeof secret !== 'undefined') { + payload['secret'] = secret; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'put', + uri, + apiHeaders, + payload, + ); + } + + /** + * Use this endpoint to complete the user email verification process. Use both the **userId** and **secret** parameters that were attached to your app URL to verify the user email ownership. If confirmed this route will return a 200 status code. + * + * @param {string} params.userId - User ID. + * @param {string} params.secret - Valid verification token. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated This API has been deprecated since 1.8.0. Please use `Account.updateEmailVerification` instead. + */ updateVerification(params: { userId: string, secret: string }): Promise; /** * Use this endpoint to complete the user email verification process. Use both the **userId** and **secret** parameters that were attached to your app URL to verify the user email ownership. If confirmed this route will return a 200 status code. @@ -2543,7 +2672,7 @@ export class Account { throw new AppwriteException('Missing required parameter: "secret"'); } - const apiPath = '/account/verification'; + const apiPath = '/account/verifications/email'; const payload: Payload = {}; if (typeof userId !== 'undefined') { payload['userId'] = userId; @@ -2573,7 +2702,7 @@ export class Account { */ createPhoneVerification(): Promise { - const apiPath = '/account/verification/phone'; + const apiPath = '/account/verifications/phone'; const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); @@ -2633,7 +2762,7 @@ export class Account { throw new AppwriteException('Missing required parameter: "secret"'); } - const apiPath = '/account/verification/phone'; + const apiPath = '/account/verifications/phone'; const payload: Payload = {}; if (typeof userId !== 'undefined') { payload['userId'] = userId; diff --git a/src/services/databases.ts b/src/services/databases.ts index a23afe5..c26c6ee 100644 --- a/src/services/databases.ts +++ b/src/services/databases.ts @@ -148,6 +148,339 @@ export class Databases { ); } + /** + * List transactions across all databases. + * + * @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; + /** + * List transactions across all databases. + * + * @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 = '/databases/transactions'; + const payload: Payload = {}; + if (typeof queries !== 'undefined') { + payload['queries'] = queries; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + } + + return this.client.call( + 'get', + uri, + apiHeaders, + payload, + ); + } + + /** + * Create a new transaction. + * + * @param {number} params.ttl - Seconds before the transaction expires. + * @throws {AppwriteException} + * @returns {Promise} + */ + createTransaction(params?: { ttl?: number }): Promise; + /** + * Create a new transaction. + * + * @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 = '/databases/transactions'; + const payload: Payload = {}; + if (typeof ttl !== 'undefined') { + payload['ttl'] = ttl; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'post', + uri, + apiHeaders, + payload, + ); + } + + /** + * Get a transaction by its unique ID. + * + * @param {string} params.transactionId - Transaction ID. + * @throws {AppwriteException} + * @returns {Promise} + */ + getTransaction(params: { transactionId: string }): Promise; + /** + * Get a transaction by its unique ID. + * + * @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 = '/databases/transactions/{transactionId}'.replace('{transactionId}', transactionId); + const payload: Payload = {}; + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + } + + return this.client.call( + 'get', + uri, + apiHeaders, + payload, + ); + } + + /** + * Update a transaction, to either commit or roll back its operations. + * + * @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; + /** + * Update a transaction, to either commit or roll back its operations. + * + * @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 = '/databases/transactions/{transactionId}'.replace('{transactionId}', transactionId); + const payload: Payload = {}; + if (typeof commit !== 'undefined') { + payload['commit'] = commit; + } + if (typeof rollback !== 'undefined') { + payload['rollback'] = rollback; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'patch', + uri, + apiHeaders, + payload, + ); + } + + /** + * Delete a transaction by its unique ID. + * + * @param {string} params.transactionId - Transaction ID. + * @throws {AppwriteException} + * @returns {Promise<{}>} + */ + deleteTransaction(params: { transactionId: string }): Promise<{}>; + /** + * Delete a transaction by its unique ID. + * + * @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 = '/databases/transactions/{transactionId}'.replace('{transactionId}', transactionId); + const payload: Payload = {}; + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'delete', + uri, + apiHeaders, + payload, + ); + } + + /** + * Create multiple operations in a single transaction. + * + * @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; + /** + * Create multiple operations in a single transaction. + * + * @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 = '/databases/transactions/{transactionId}/operations'.replace('{transactionId}', transactionId); + const payload: Payload = {}; + if (typeof operations !== 'undefined') { + payload['operations'] = operations; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'post', + uri, + apiHeaders, + payload, + ); + } + /** * Get a database by its unique ID. This endpoint response returns a JSON object with the database metadata. * @@ -3482,41 +3815,45 @@ export class Databases { * @param {string} params.databaseId - Database ID. * @param {string} params.collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). * @param {string[]} params.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>} * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.listRows` instead. */ - listDocuments(params: { databaseId: string, collectionId: string, queries?: string[] }): Promise>; + listDocuments(params: { databaseId: string, collectionId: string, queries?: string[], transactionId?: string }): 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. * @throws {AppwriteException} * @returns {Promise>} * @deprecated Use the object parameter style method for a better developer experience. */ - listDocuments(databaseId: string, collectionId: string, queries?: string[]): Promise>; + listDocuments(databaseId: string, collectionId: string, queries?: string[], transactionId?: string): Promise>; listDocuments( - paramsOrFirst: { databaseId: string, collectionId: string, queries?: string[] } | string, - ...rest: [(string)?, (string[])?] + paramsOrFirst: { databaseId: string, collectionId: string, queries?: string[], transactionId?: string } | string, + ...rest: [(string)?, (string[])?, (string)?] ): Promise> { - let params: { databaseId: string, collectionId: string, queries?: string[] }; + let params: { databaseId: string, collectionId: string, queries?: string[], transactionId?: string }; if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, queries?: string[] }; + params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, queries?: string[], transactionId?: string }; } else { params = { databaseId: paramsOrFirst as string, collectionId: rest[0] as string, - queries: rest[1] as string[] + queries: rest[1] as string[], + transactionId: rest[2] as string }; } const databaseId = params.databaseId; const collectionId = params.collectionId; const queries = params.queries; + const transactionId = params.transactionId; if (typeof databaseId === 'undefined') { throw new AppwriteException('Missing required parameter: "databaseId"'); @@ -3530,6 +3867,9 @@ export class Databases { if (typeof queries !== 'undefined') { payload['queries'] = queries; } + if (typeof transactionId !== 'undefined') { + payload['transactionId'] = transactionId; + } const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -3551,11 +3891,12 @@ export class Databases { * @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). + * @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.createRow` instead. */ - createDocument(params: { databaseId: string, collectionId: string, documentId: string, data: Document extends Models.DefaultDocument ? Partial & Record : Partial & Omit, permissions?: string[] }): Promise; + createDocument(params: { databaseId: string, collectionId: string, documentId: string, data: Document extends Models.DefaultDocument ? Partial & Record : Partial & Omit, permissions?: string[], transactionId?: 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#databasesCreateCollection) API or directly from your database console. * @@ -3564,26 +3905,28 @@ export class Databases { * @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). + * @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. */ - createDocument(databaseId: string, collectionId: string, documentId: string, data: Document extends Models.DefaultDocument ? Partial & Record : Partial & Omit, permissions?: string[]): Promise; + createDocument(databaseId: string, collectionId: string, documentId: string, data: Document extends Models.DefaultDocument ? Partial & Record : Partial & Omit, permissions?: string[], transactionId?: 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[])?] + paramsOrFirst: { databaseId: string, collectionId: string, documentId: string, data: Document extends Models.DefaultDocument ? Partial & Record : Partial & Omit, permissions?: string[], transactionId?: string } | string, + ...rest: [(string)?, (string)?, (Document extends Models.DefaultDocument ? Partial & Record : Partial & Omit)?, (string[])?, (string)?] ): Promise { - let params: { databaseId: string, collectionId: string, documentId: string, data: Document extends Models.DefaultDocument ? Partial & Record : Partial & Omit, permissions?: string[] }; + let params: { databaseId: string, collectionId: string, documentId: string, data: Document extends Models.DefaultDocument ? Partial & Record : Partial & Omit, 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 & Omit, permissions?: string[] }; + params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, documentId: string, data: Document extends Models.DefaultDocument ? Partial & Record : Partial & Omit, 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 & Omit, - permissions: rest[3] as string[] + permissions: rest[3] as string[], + transactionId: rest[4] as string }; } @@ -3592,6 +3935,7 @@ export class Databases { 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"'); @@ -3617,6 +3961,9 @@ export class Databases { if (typeof permissions !== 'undefined') { payload['permissions'] = permissions; } + if (typeof transactionId !== 'undefined') { + payload['transactionId'] = transactionId; + } const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -3637,41 +3984,45 @@ export class Databases { * @param {string} params.databaseId - Database ID. * @param {string} params.collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). Make sure to define attributes before creating documents. * @param {object[]} params.documents - Array of documents data as JSON objects. + * @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.createRows` instead. */ - createDocuments(params: { databaseId: string, collectionId: string, documents: object[] }): Promise>; + createDocuments(params: { databaseId: string, collectionId: string, documents: object[], transactionId?: string }): 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#databasesCreateCollection) 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. + * @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. */ - createDocuments(databaseId: string, collectionId: string, documents: object[]): Promise>; + createDocuments(databaseId: string, collectionId: string, documents: object[], transactionId?: string): Promise>; createDocuments( - paramsOrFirst: { databaseId: string, collectionId: string, documents: object[] } | string, - ...rest: [(string)?, (object[])?] + paramsOrFirst: { databaseId: string, collectionId: string, documents: object[], transactionId?: string } | string, + ...rest: [(string)?, (object[])?, (string)?] ): Promise> { - let params: { databaseId: string, collectionId: string, documents: object[] }; + 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[] }; + 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[] + 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"'); @@ -3688,6 +4039,9 @@ export class Databases { if (typeof documents !== 'undefined') { payload['documents'] = documents; } + if (typeof transactionId !== 'undefined') { + payload['transactionId'] = transactionId; + } const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -3709,11 +4063,12 @@ export class Databases { * @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[] }): Promise>; + upsertDocuments(params: { databaseId: string, collectionId: string, documents: object[], transactionId?: string }): Promise>; /** * Create or update Documents. Before using this route, you should create a new collection resource using either a [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection) API or directly from your database console. * @@ -3721,30 +4076,33 @@ export class Databases { * @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[]): Promise>; + upsertDocuments(databaseId: string, collectionId: string, documents: object[], transactionId?: string): Promise>; upsertDocuments( - paramsOrFirst: { databaseId: string, collectionId: string, documents: object[] } | string, - ...rest: [(string)?, (object[])?] + paramsOrFirst: { databaseId: string, collectionId: string, documents: object[], transactionId?: string } | string, + ...rest: [(string)?, (object[])?, (string)?] ): Promise> { - let params: { databaseId: string, collectionId: string, documents: object[] }; + 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[] }; + 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[] + 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"'); @@ -3761,6 +4119,9 @@ export class Databases { if (typeof documents !== 'undefined') { payload['documents'] = documents; } + if (typeof transactionId !== 'undefined') { + payload['transactionId'] = transactionId; + } const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -3782,11 +4143,12 @@ export class Databases { * @param {string} params.collectionId - Collection ID. * @param {object} params.data - Document data as JSON object. Include only attribute and value pairs to be updated. * @param {string[]} params.queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. + * @param {string} params.transactionId - Transaction ID for staging the operation. * @throws {AppwriteException} * @returns {Promise>} * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.updateRows` instead. */ - updateDocuments(params: { databaseId: string, collectionId: string, data?: object, queries?: string[] }): Promise>; + updateDocuments(params: { databaseId: string, collectionId: string, data?: object, queries?: string[], transactionId?: string }): Promise>; /** * Update all documents that match your queries, if no queries are submitted then all documents are updated. You can pass only specific fields to be updated. * @@ -3794,25 +4156,27 @@ export class Databases { * @param {string} collectionId - Collection ID. * @param {object} data - Document data as JSON object. Include only attribute and value pairs to be updated. * @param {string[]} queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. + * @param {string} transactionId - Transaction ID for staging the operation. * @throws {AppwriteException} * @returns {Promise>} * @deprecated Use the object parameter style method for a better developer experience. */ - updateDocuments(databaseId: string, collectionId: string, data?: object, queries?: string[]): Promise>; + updateDocuments(databaseId: string, collectionId: string, data?: object, queries?: string[], transactionId?: string): Promise>; updateDocuments( - paramsOrFirst: { databaseId: string, collectionId: string, data?: object, queries?: string[] } | string, - ...rest: [(string)?, (object)?, (string[])?] + paramsOrFirst: { databaseId: string, collectionId: string, data?: object, queries?: string[], transactionId?: string } | string, + ...rest: [(string)?, (object)?, (string[])?, (string)?] ): Promise> { - let params: { databaseId: string, collectionId: string, data?: object, queries?: string[] }; + let params: { databaseId: string, collectionId: string, data?: object, queries?: string[], transactionId?: string }; if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, data?: object, queries?: string[] }; + params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, data?: object, queries?: string[], transactionId?: string }; } else { params = { databaseId: paramsOrFirst as string, collectionId: rest[0] as string, data: rest[1] as object, - queries: rest[2] as string[] + queries: rest[2] as string[], + transactionId: rest[3] as string }; } @@ -3820,6 +4184,7 @@ export class Databases { const collectionId = params.collectionId; const data = params.data; const queries = params.queries; + const transactionId = params.transactionId; if (typeof databaseId === 'undefined') { throw new AppwriteException('Missing required parameter: "databaseId"'); @@ -3836,6 +4201,9 @@ export class Databases { if (typeof queries !== 'undefined') { payload['queries'] = queries; } + if (typeof transactionId !== 'undefined') { + payload['transactionId'] = transactionId; + } const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -3856,41 +4224,45 @@ export class Databases { * @param {string} params.databaseId - Database ID. * @param {string} params.collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). * @param {string[]} params.queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. + * @param {string} params.transactionId - Transaction ID for staging the operation. * @throws {AppwriteException} * @returns {Promise>} * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.deleteRows` instead. */ - deleteDocuments(params: { databaseId: string, collectionId: string, queries?: string[] }): Promise>; + deleteDocuments(params: { databaseId: string, collectionId: string, queries?: string[], transactionId?: string }): Promise>; /** * Bulk delete documents using queries, if no queries are passed then all documents are deleted. * * @param {string} databaseId - Database ID. * @param {string} collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). * @param {string[]} queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. + * @param {string} transactionId - Transaction ID for staging the operation. * @throws {AppwriteException} * @returns {Promise>} * @deprecated Use the object parameter style method for a better developer experience. */ - deleteDocuments(databaseId: string, collectionId: string, queries?: string[]): Promise>; + deleteDocuments(databaseId: string, collectionId: string, queries?: string[], transactionId?: string): Promise>; deleteDocuments( - paramsOrFirst: { databaseId: string, collectionId: string, queries?: string[] } | string, - ...rest: [(string)?, (string[])?] + paramsOrFirst: { databaseId: string, collectionId: string, queries?: string[], transactionId?: string } | string, + ...rest: [(string)?, (string[])?, (string)?] ): Promise> { - let params: { databaseId: string, collectionId: string, queries?: string[] }; + let params: { databaseId: string, collectionId: string, queries?: string[], transactionId?: string }; if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, queries?: string[] }; + params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, queries?: string[], transactionId?: string }; } else { params = { databaseId: paramsOrFirst as string, collectionId: rest[0] as string, - queries: rest[1] as string[] + queries: rest[1] as string[], + transactionId: rest[2] as string }; } const databaseId = params.databaseId; const collectionId = params.collectionId; const queries = params.queries; + const transactionId = params.transactionId; if (typeof databaseId === 'undefined') { throw new AppwriteException('Missing required parameter: "databaseId"'); @@ -3904,6 +4276,9 @@ export class Databases { if (typeof queries !== 'undefined') { payload['queries'] = queries; } + if (typeof transactionId !== 'undefined') { + payload['transactionId'] = transactionId; + } const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -3925,11 +4300,12 @@ export class Databases { * @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} * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.getRow` instead. */ - getDocument(params: { databaseId: string, collectionId: string, documentId: string, queries?: string[] }): 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. * @@ -3937,25 +4313,27 @@ export class Databases { * @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[]): Promise; + getDocument(databaseId: string, collectionId: string, documentId: string, queries?: string[], transactionId?: string): Promise; getDocument( - paramsOrFirst: { databaseId: string, collectionId: string, documentId: string, queries?: string[] } | string, - ...rest: [(string)?, (string)?, (string[])?] + 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[] }; + 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[] }; + 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[] + queries: rest[2] as string[], + transactionId: rest[3] as string }; } @@ -3963,6 +4341,7 @@ export class Databases { 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"'); @@ -3979,6 +4358,9 @@ export class Databases { if (typeof queries !== 'undefined') { payload['queries'] = queries; } + if (typeof transactionId !== 'undefined') { + payload['transactionId'] = transactionId; + } const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -4000,11 +4382,12 @@ export class Databases { * @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 attributes 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} * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.upsertRow` instead. */ - upsertDocument(params: { databaseId: string, collectionId: string, documentId: string, data: Document extends Models.DefaultDocument ? Partial & Record : Partial & Partial>, permissions?: string[] }): 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#databasesCreateCollection) API or directly from your database console. * @@ -4013,26 +4396,28 @@ export class Databases { * @param {string} documentId - Document ID. * @param {Document extends Models.DefaultDocument ? Partial & Record : Partial & Partial>} data - Document data as JSON object. Include all required attributes 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[]): Promise; + 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[] } | string, - ...rest: [(string)?, (string)?, (Document extends Models.DefaultDocument ? Partial & Record : Partial & Partial>)?, (string[])?] + 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[] }; + 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[] }; + 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[] + permissions: rest[3] as string[], + transactionId: rest[4] as string }; } @@ -4041,6 +4426,7 @@ export class Databases { 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"'); @@ -4063,6 +4449,9 @@ export class Databases { if (typeof permissions !== 'undefined') { payload['permissions'] = permissions; } + if (typeof transactionId !== 'undefined') { + payload['transactionId'] = transactionId; + } const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -4085,11 +4474,12 @@ export class Databases { * @param {string} params.documentId - Document ID. * @param {Document extends Models.DefaultDocument ? Partial & Record : Partial & Partial>} params.data - Document data as JSON object. Include only attribute 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} * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.updateRow` instead. */ - updateDocument(params: { databaseId: string, collectionId: string, documentId: string, data?: Document extends Models.DefaultDocument ? Partial & Record : Partial & Partial>, permissions?: string[] }): 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. * @@ -4098,26 +4488,28 @@ export class Databases { * @param {string} documentId - Document ID. * @param {Document extends Models.DefaultDocument ? Partial & Record : Partial & Partial>} data - Document data as JSON object. Include only attribute 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[]): Promise; + 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[] } | string, - ...rest: [(string)?, (string)?, (Document extends Models.DefaultDocument ? Partial & Record : Partial & Partial>)?, (string[])?] + 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[] }; + 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[] }; + 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[] + permissions: rest[3] as string[], + transactionId: rest[4] as string }; } @@ -4126,6 +4518,7 @@ export class Databases { 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"'); @@ -4145,6 +4538,9 @@ export class Databases { if (typeof permissions !== 'undefined') { payload['permissions'] = permissions; } + if (typeof transactionId !== 'undefined') { + payload['transactionId'] = transactionId; + } const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -4165,41 +4561,45 @@ export class Databases { * @param {string} params.databaseId - Database ID. * @param {string} params.collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). * @param {string} params.documentId - Document ID. + * @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.deleteRow` instead. */ - deleteDocument(params: { databaseId: string, collectionId: string, documentId: string }): 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): Promise<{}>; + deleteDocument(databaseId: string, collectionId: string, documentId: string, transactionId?: string): Promise<{}>; deleteDocument( - paramsOrFirst: { databaseId: string, collectionId: string, documentId: string } | string, - ...rest: [(string)?, (string)?] + paramsOrFirst: { databaseId: string, collectionId: string, documentId: string, transactionId?: string } | string, + ...rest: [(string)?, (string)?, (string)?] ): Promise<{}> { - let params: { databaseId: string, collectionId: string, documentId: string }; + 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 }; + 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 + 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"'); @@ -4213,6 +4613,9 @@ export class Databases { const apiPath = '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId).replace('{documentId}', documentId); const payload: Payload = {}; + if (typeof transactionId !== 'undefined') { + payload['transactionId'] = transactionId; + } const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -4236,11 +4639,12 @@ export class Databases { * @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.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} * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.decrementRowColumn` instead. */ - decrementDocumentAttribute(params: { databaseId: string, collectionId: string, documentId: string, attribute: string, value?: number, min?: number }): Promise; + decrementDocumentAttribute(params: { databaseId: string, collectionId: string, documentId: string, attribute: string, value?: number, min?: number, transactionId?: string }): Promise; /** * Decrement a specific attribute of a document by a given value. * @@ -4250,19 +4654,20 @@ export class Databases { * @param {string} attribute - Attribute key. * @param {number} value - Value to increment 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): Promise; + 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 } | string, - ...rest: [(string)?, (string)?, (string)?, (number)?, (number)?] + 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 }; + 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 }; + params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, documentId: string, attribute: string, value?: number, min?: number, transactionId?: string }; } else { params = { databaseId: paramsOrFirst as string, @@ -4270,7 +4675,8 @@ export class Databases { documentId: rest[1] as string, attribute: rest[2] as string, value: rest[3] as number, - min: rest[4] as number + min: rest[4] as number, + transactionId: rest[5] as string }; } @@ -4280,6 +4686,7 @@ export class Databases { 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"'); @@ -4302,6 +4709,9 @@ export class Databases { if (typeof min !== 'undefined') { payload['min'] = min; } + if (typeof transactionId !== 'undefined') { + payload['transactionId'] = transactionId; + } const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -4325,11 +4735,12 @@ export class Databases { * @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} * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.incrementRowColumn` instead. */ - incrementDocumentAttribute(params: { databaseId: string, collectionId: string, documentId: string, attribute: string, value?: number, max?: number }): Promise; + incrementDocumentAttribute(params: { databaseId: string, collectionId: string, documentId: string, attribute: string, value?: number, max?: number, transactionId?: string }): Promise; /** * Increment a specific attribute of a document by a given value. * @@ -4339,19 +4750,20 @@ export class Databases { * @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): Promise; + 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 } | string, - ...rest: [(string)?, (string)?, (string)?, (number)?, (number)?] + 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 }; + 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 }; + params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, documentId: string, attribute: string, value?: number, max?: number, transactionId?: string }; } else { params = { databaseId: paramsOrFirst as string, @@ -4359,7 +4771,8 @@ export class Databases { documentId: rest[1] as string, attribute: rest[2] as string, value: rest[3] as number, - max: rest[4] as number + max: rest[4] as number, + transactionId: rest[5] as string }; } @@ -4369,6 +4782,7 @@ export class Databases { 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"'); @@ -4391,6 +4805,9 @@ export class Databases { if (typeof max !== 'undefined') { payload['max'] = max; } + if (typeof transactionId !== 'undefined') { + payload['transactionId'] = transactionId; + } const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -4580,7 +4997,7 @@ export class Databases { } /** - * Get index by ID. + * Get an index 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). @@ -4591,7 +5008,7 @@ export class Databases { */ getIndex(params: { databaseId: string, collectionId: string, key: string }): Promise; /** - * Get index by ID. + * Get an index 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). diff --git a/src/services/functions.ts b/src/services/functions.ts index 6c0239d..d379d26 100644 --- a/src/services/functions.ts +++ b/src/services/functions.ts @@ -878,7 +878,7 @@ export class Functions { /** * Create a deployment based on a template. * - * Use this endpoint with combination of [listTemplates](https://appwrite.io/docs/server/functions#listTemplates) to find the template details. + * Use this endpoint with combination of [listTemplates](https://appwrite.io/docs/products/functions/templates) to find the template details. * * @param {string} params.functionId - Function ID. * @param {string} params.repository - Repository name of the template. @@ -893,7 +893,7 @@ export class Functions { /** * Create a deployment based on a template. * - * Use this endpoint with combination of [listTemplates](https://appwrite.io/docs/server/functions#listTemplates) to find the template details. + * Use this endpoint with combination of [listTemplates](https://appwrite.io/docs/products/functions/templates) to find the template details. * * @param {string} functionId - Function ID. * @param {string} repository - Repository name of the template. diff --git a/src/services/sites.ts b/src/services/sites.ts index e8c0aed..3236d1a 100644 --- a/src/services/sites.ts +++ b/src/services/sites.ts @@ -877,7 +877,7 @@ export class Sites { /** * Create a deployment based on a template. * - * Use this endpoint with combination of [listTemplates](https://appwrite.io/docs/server/sites#listTemplates) to find the template details. + * Use this endpoint with combination of [listTemplates](https://appwrite.io/docs/products/sites/templates) to find the template details. * * @param {string} params.siteId - Site ID. * @param {string} params.repository - Repository name of the template. @@ -892,7 +892,7 @@ export class Sites { /** * Create a deployment based on a template. * - * Use this endpoint with combination of [listTemplates](https://appwrite.io/docs/server/sites#listTemplates) to find the template details. + * Use this endpoint with combination of [listTemplates](https://appwrite.io/docs/products/sites/templates) to find the template details. * * @param {string} siteId - Site ID. * @param {string} repository - Repository name of the template. diff --git a/src/services/tables-db.ts b/src/services/tables-db.ts index 096f07e..e2c9c4a 100644 --- a/src/services/tables-db.ts +++ b/src/services/tables-db.ts @@ -146,6 +146,339 @@ export class TablesDB { ); } + /** + * List transactions across all databases. + * + * @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; + /** + * List transactions across all databases. + * + * @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 = '/tablesdb/transactions'; + const payload: Payload = {}; + if (typeof queries !== 'undefined') { + payload['queries'] = queries; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + } + + return this.client.call( + 'get', + uri, + apiHeaders, + payload, + ); + } + + /** + * Create a new transaction. + * + * @param {number} params.ttl - Seconds before the transaction expires. + * @throws {AppwriteException} + * @returns {Promise} + */ + createTransaction(params?: { ttl?: number }): Promise; + /** + * Create a new transaction. + * + * @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 = '/tablesdb/transactions'; + const payload: Payload = {}; + if (typeof ttl !== 'undefined') { + payload['ttl'] = ttl; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'post', + uri, + apiHeaders, + payload, + ); + } + + /** + * Get a transaction by its unique ID. + * + * @param {string} params.transactionId - Transaction ID. + * @throws {AppwriteException} + * @returns {Promise} + */ + getTransaction(params: { transactionId: string }): Promise; + /** + * Get a transaction by its unique ID. + * + * @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 = '/tablesdb/transactions/{transactionId}'.replace('{transactionId}', transactionId); + const payload: Payload = {}; + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + } + + return this.client.call( + 'get', + uri, + apiHeaders, + payload, + ); + } + + /** + * Update a transaction, to either commit or roll back its operations. + * + * @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; + /** + * Update a transaction, to either commit or roll back its operations. + * + * @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 = '/tablesdb/transactions/{transactionId}'.replace('{transactionId}', transactionId); + const payload: Payload = {}; + if (typeof commit !== 'undefined') { + payload['commit'] = commit; + } + if (typeof rollback !== 'undefined') { + payload['rollback'] = rollback; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'patch', + uri, + apiHeaders, + payload, + ); + } + + /** + * Delete a transaction by its unique ID. + * + * @param {string} params.transactionId - Transaction ID. + * @throws {AppwriteException} + * @returns {Promise<{}>} + */ + deleteTransaction(params: { transactionId: string }): Promise<{}>; + /** + * Delete a transaction by its unique ID. + * + * @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 = '/tablesdb/transactions/{transactionId}'.replace('{transactionId}', transactionId); + const payload: Payload = {}; + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'delete', + uri, + apiHeaders, + payload, + ); + } + + /** + * Create multiple operations in a single transaction. + * + * @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; + /** + * Create multiple operations in a single transaction. + * + * @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 = '/tablesdb/transactions/{transactionId}/operations'.replace('{transactionId}', transactionId); + const payload: Payload = {}; + if (typeof operations !== 'undefined') { + payload['operations'] = operations; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'post', + uri, + apiHeaders, + payload, + ); + } + /** * Get a database by its unique ID. This endpoint response returns a JSON object with the database metadata. * @@ -386,7 +719,7 @@ export class TablesDB { } /** - * Create a new Table. Before using this route, you should create a new database resource using either a [server integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreateTable) API or directly from your database console. + * Create a new Table. Before using this route, you should create a new database resource using either a [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable) API or directly from your database console. * * @param {string} params.databaseId - Database ID. * @param {string} params.tableId - Unique Id. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. @@ -399,7 +732,7 @@ export class TablesDB { */ createTable(params: { databaseId: string, tableId: string, name: string, permissions?: string[], rowSecurity?: boolean, enabled?: boolean }): Promise; /** - * Create a new Table. Before using this route, you should create a new database resource using either a [server integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreateTable) API or directly from your database console. + * Create a new Table. Before using this route, you should create a new database resource using either a [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable) API or directly from your database console. * * @param {string} databaseId - Database ID. * @param {string} tableId - Unique Id. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. @@ -760,7 +1093,7 @@ export class TablesDB { * * * @param {string} params.databaseId - Database ID. - * @param {string} params.tableId - Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreate). + * @param {string} params.tableId - Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable). * @param {string} params.key - Column Key. * @param {boolean} params.required - Is column required? * @param {boolean} params.xdefault - Default value for column when not provided. Cannot be set when column is required. @@ -774,7 +1107,7 @@ export class TablesDB { * * * @param {string} databaseId - Database ID. - * @param {string} tableId - Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreate). + * @param {string} tableId - Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable). * @param {string} key - Column Key. * @param {boolean} required - Is column required? * @param {boolean} xdefault - Default value for column when not provided. Cannot be set when column is required. @@ -855,7 +1188,7 @@ export class TablesDB { * Update a boolean column. Changing the `default` value will not update already existing rows. * * @param {string} params.databaseId - Database ID. - * @param {string} params.tableId - Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreate). + * @param {string} params.tableId - Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable). * @param {string} params.key - Column Key. * @param {boolean} params.required - Is column required? * @param {boolean} params.xdefault - Default value for column when not provided. Cannot be set when column is required. @@ -868,7 +1201,7 @@ export class TablesDB { * Update a boolean column. Changing the `default` value will not update already existing rows. * * @param {string} databaseId - Database ID. - * @param {string} tableId - Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreate). + * @param {string} tableId - Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable). * @param {string} key - Column Key. * @param {boolean} required - Is column required? * @param {boolean} xdefault - Default value for column when not provided. Cannot be set when column is required. @@ -2171,7 +2504,7 @@ export class TablesDB { * Create a geometric line column. * * @param {string} params.databaseId - Database ID. - * @param {string} params.tableId - Table ID. You can create a new table using the TablesDB service [server integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreate). + * @param {string} params.tableId - Table ID. You can create a new table using the TablesDB service [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable). * @param {string} params.key - Column Key. * @param {boolean} params.required - Is column required? * @param {any[]} params.xdefault - Default value for column when not provided, two-dimensional array of coordinate pairs, [[longitude, latitude], [longitude, latitude], …], listing the vertices of the line in order. Cannot be set when column is required. @@ -2183,7 +2516,7 @@ export class TablesDB { * Create a geometric line column. * * @param {string} databaseId - Database ID. - * @param {string} tableId - Table ID. You can create a new table using the TablesDB service [server integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreate). + * @param {string} tableId - Table ID. You can create a new table using the TablesDB service [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable). * @param {string} key - Column Key. * @param {boolean} required - Is column required? * @param {any[]} xdefault - Default value for column when not provided, two-dimensional array of coordinate pairs, [[longitude, latitude], [longitude, latitude], …], listing the vertices of the line in order. Cannot be set when column is required. @@ -2258,7 +2591,7 @@ export class TablesDB { * Update a line column. Changing the `default` value will not update already existing rows. * * @param {string} params.databaseId - Database ID. - * @param {string} params.tableId - Table ID. You can create a new table using the TablesDB service [server integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreate). + * @param {string} params.tableId - Table ID. You can create a new table using the TablesDB service [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable). * @param {string} params.key - Column Key. * @param {boolean} params.required - Is column required? * @param {any[]} params.xdefault - Default value for column when not provided, two-dimensional array of coordinate pairs, [[longitude, latitude], [longitude, latitude], …], listing the vertices of the line in order. Cannot be set when column is required. @@ -2271,7 +2604,7 @@ export class TablesDB { * Update a line column. Changing the `default` value will not update already existing rows. * * @param {string} databaseId - Database ID. - * @param {string} tableId - Table ID. You can create a new table using the TablesDB service [server integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreate). + * @param {string} tableId - Table ID. You can create a new table using the TablesDB service [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable). * @param {string} key - Column Key. * @param {boolean} required - Is column required? * @param {any[]} xdefault - Default value for column when not provided, two-dimensional array of coordinate pairs, [[longitude, latitude], [longitude, latitude], …], listing the vertices of the line in order. Cannot be set when column is required. @@ -2349,7 +2682,7 @@ export class TablesDB { * Create a geometric point column. * * @param {string} params.databaseId - Database ID. - * @param {string} params.tableId - Table ID. You can create a new table using the TablesDB service [server integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreate). + * @param {string} params.tableId - Table ID. You can create a new table using the TablesDB service [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable). * @param {string} params.key - Column Key. * @param {boolean} params.required - Is column required? * @param {any[]} params.xdefault - Default value for column when not provided, array of two numbers [longitude, latitude], representing a single coordinate. Cannot be set when column is required. @@ -2361,7 +2694,7 @@ export class TablesDB { * Create a geometric point column. * * @param {string} databaseId - Database ID. - * @param {string} tableId - Table ID. You can create a new table using the TablesDB service [server integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreate). + * @param {string} tableId - Table ID. You can create a new table using the TablesDB service [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable). * @param {string} key - Column Key. * @param {boolean} required - Is column required? * @param {any[]} xdefault - Default value for column when not provided, array of two numbers [longitude, latitude], representing a single coordinate. Cannot be set when column is required. @@ -2436,7 +2769,7 @@ export class TablesDB { * Update a point column. Changing the `default` value will not update already existing rows. * * @param {string} params.databaseId - Database ID. - * @param {string} params.tableId - Table ID. You can create a new table using the TablesDB service [server integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreate). + * @param {string} params.tableId - Table ID. You can create a new table using the TablesDB service [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable). * @param {string} params.key - Column Key. * @param {boolean} params.required - Is column required? * @param {any[]} params.xdefault - Default value for column when not provided, array of two numbers [longitude, latitude], representing a single coordinate. Cannot be set when column is required. @@ -2449,7 +2782,7 @@ export class TablesDB { * Update a point column. Changing the `default` value will not update already existing rows. * * @param {string} databaseId - Database ID. - * @param {string} tableId - Table ID. You can create a new table using the TablesDB service [server integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreate). + * @param {string} tableId - Table ID. You can create a new table using the TablesDB service [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable). * @param {string} key - Column Key. * @param {boolean} required - Is column required? * @param {any[]} xdefault - Default value for column when not provided, array of two numbers [longitude, latitude], representing a single coordinate. Cannot be set when column is required. @@ -2527,7 +2860,7 @@ export class TablesDB { * Create a geometric polygon column. * * @param {string} params.databaseId - Database ID. - * @param {string} params.tableId - Table ID. You can create a new table using the TablesDB service [server integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreate). + * @param {string} params.tableId - Table ID. You can create a new table using the TablesDB service [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable). * @param {string} params.key - Column Key. * @param {boolean} params.required - Is column required? * @param {any[]} params.xdefault - Default value for column when not provided, three-dimensional array where the outer array holds one or more linear rings, [[[longitude, latitude], …], …], the first ring is the exterior boundary, any additional rings are interior holes, and each ring must start and end with the same coordinate pair. Cannot be set when column is required. @@ -2539,7 +2872,7 @@ export class TablesDB { * Create a geometric polygon column. * * @param {string} databaseId - Database ID. - * @param {string} tableId - Table ID. You can create a new table using the TablesDB service [server integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreate). + * @param {string} tableId - Table ID. You can create a new table using the TablesDB service [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable). * @param {string} key - Column Key. * @param {boolean} required - Is column required? * @param {any[]} xdefault - Default value for column when not provided, three-dimensional array where the outer array holds one or more linear rings, [[[longitude, latitude], …], …], the first ring is the exterior boundary, any additional rings are interior holes, and each ring must start and end with the same coordinate pair. Cannot be set when column is required. @@ -2614,7 +2947,7 @@ export class TablesDB { * Update a polygon column. Changing the `default` value will not update already existing rows. * * @param {string} params.databaseId - Database ID. - * @param {string} params.tableId - Table ID. You can create a new table using the TablesDB service [server integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreate). + * @param {string} params.tableId - Table ID. You can create a new table using the TablesDB service [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable). * @param {string} params.key - Column Key. * @param {boolean} params.required - Is column required? * @param {any[]} params.xdefault - Default value for column when not provided, three-dimensional array where the outer array holds one or more linear rings, [[[longitude, latitude], …], …], the first ring is the exterior boundary, any additional rings are interior holes, and each ring must start and end with the same coordinate pair. Cannot be set when column is required. @@ -2627,7 +2960,7 @@ export class TablesDB { * Update a polygon column. Changing the `default` value will not update already existing rows. * * @param {string} databaseId - Database ID. - * @param {string} tableId - Table ID. You can create a new table using the TablesDB service [server integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreate). + * @param {string} tableId - Table ID. You can create a new table using the TablesDB service [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable). * @param {string} key - Column Key. * @param {boolean} required - Is column required? * @param {any[]} xdefault - Default value for column when not provided, three-dimensional array where the outer array holds one or more linear rings, [[[longitude, latitude], …], …], the first ring is the exterior boundary, any additional rings are interior holes, and each ring must start and end with the same coordinate pair. Cannot be set when column is required. @@ -2816,7 +3149,7 @@ export class TablesDB { * * * @param {string} params.databaseId - Database ID. - * @param {string} params.tableId - Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreate). + * @param {string} params.tableId - Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable). * @param {string} params.key - Column Key. * @param {number} params.size - Column size for text columns, in number of characters. * @param {boolean} params.required - Is column required? @@ -2832,7 +3165,7 @@ export class TablesDB { * * * @param {string} databaseId - Database ID. - * @param {string} tableId - Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreate). + * @param {string} tableId - Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable). * @param {string} key - Column Key. * @param {number} size - Column size for text columns, in number of characters. * @param {boolean} required - Is column required? @@ -2929,7 +3262,7 @@ export class TablesDB { * * * @param {string} params.databaseId - Database ID. - * @param {string} params.tableId - Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreate). + * @param {string} params.tableId - Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable). * @param {string} params.key - Column Key. * @param {boolean} params.required - Is column required? * @param {string} params.xdefault - Default value for column when not provided. Cannot be set when column is required. @@ -2944,7 +3277,7 @@ export class TablesDB { * * * @param {string} databaseId - Database ID. - * @param {string} tableId - Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreate). + * @param {string} tableId - Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable). * @param {string} key - Column Key. * @param {boolean} required - Is column required? * @param {string} xdefault - Default value for column when not provided. Cannot be set when column is required. @@ -3439,7 +3772,7 @@ export class TablesDB { * List indexes on the table. * * @param {string} params.databaseId - Database ID. - * @param {string} params.tableId - Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreate). + * @param {string} params.tableId - Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable). * @param {string[]} params.queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following columns: key, type, status, attributes, error * @throws {AppwriteException} * @returns {Promise} @@ -3449,7 +3782,7 @@ export class TablesDB { * List indexes on the table. * * @param {string} databaseId - Database ID. - * @param {string} tableId - Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreate). + * @param {string} tableId - Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable). * @param {string[]} queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following columns: key, type, status, attributes, error * @throws {AppwriteException} * @returns {Promise} @@ -3506,7 +3839,7 @@ export class TablesDB { * Type can be `key`, `fulltext`, or `unique`. * * @param {string} params.databaseId - Database ID. - * @param {string} params.tableId - Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreate). + * @param {string} params.tableId - Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable). * @param {string} params.key - Index Key. * @param {IndexType} params.type - Index type. * @param {string[]} params.columns - Array of columns to index. Maximum of 100 columns are allowed, each 32 characters long. @@ -3521,7 +3854,7 @@ export class TablesDB { * Type can be `key`, `fulltext`, or `unique`. * * @param {string} databaseId - Database ID. - * @param {string} tableId - Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreate). + * @param {string} tableId - Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable). * @param {string} key - Index Key. * @param {IndexType} type - Index type. * @param {string[]} columns - Array of columns to index. Maximum of 100 columns are allowed, each 32 characters long. @@ -3611,7 +3944,7 @@ export class TablesDB { * Get index by ID. * * @param {string} params.databaseId - Database ID. - * @param {string} params.tableId - Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreate). + * @param {string} params.tableId - Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable). * @param {string} params.key - Index Key. * @throws {AppwriteException} * @returns {Promise} @@ -3621,7 +3954,7 @@ export class TablesDB { * Get index by ID. * * @param {string} databaseId - Database ID. - * @param {string} tableId - Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreate). + * @param {string} tableId - Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable). * @param {string} key - Index Key. * @throws {AppwriteException} * @returns {Promise} @@ -3677,7 +4010,7 @@ export class TablesDB { * Delete an index. * * @param {string} params.databaseId - Database ID. - * @param {string} params.tableId - Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreate). + * @param {string} params.tableId - Table ID. You can create a new table using the TablesDB service [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable). * @param {string} params.key - Index Key. * @throws {AppwriteException} * @returns {Promise<{}>} @@ -3687,7 +4020,7 @@ export class TablesDB { * Delete an index. * * @param {string} databaseId - Database ID. - * @param {string} tableId - Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreate). + * @param {string} tableId - Table ID. You can create a new table using the TablesDB service [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable). * @param {string} key - Index Key. * @throws {AppwriteException} * @returns {Promise<{}>} @@ -3744,42 +4077,46 @@ export class TablesDB { * Get a list of all the user's rows in a given table. You can use the query params to filter your results. * * @param {string} params.databaseId - Database ID. - * @param {string} params.tableId - Table ID. You can create a new table using the TableDB service [server integration](https://appwrite.io/docs/server/tablesdbdb#tablesdbCreate). + * @param {string} params.tableId - Table ID. You can create a new table using the TablesDB service [server integration](https://appwrite.io/docs/products/databases/tables#create-table). * @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>} */ - listRows(params: { databaseId: string, tableId: string, queries?: string[] }): Promise>; + listRows(params: { databaseId: string, tableId: string, queries?: string[], transactionId?: string }): Promise>; /** * Get a list of all the user's rows in a given table. You can use the query params to filter your results. * * @param {string} databaseId - Database ID. - * @param {string} tableId - Table ID. You can create a new table using the TableDB service [server integration](https://appwrite.io/docs/server/tablesdbdb#tablesdbCreate). + * @param {string} tableId - Table ID. You can create a new table using the TablesDB service [server integration](https://appwrite.io/docs/products/databases/tables#create-table). * @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. */ - listRows(databaseId: string, tableId: string, queries?: string[]): Promise>; + listRows(databaseId: string, tableId: string, queries?: string[], transactionId?: string): Promise>; listRows( - paramsOrFirst: { databaseId: string, tableId: string, queries?: string[] } | string, - ...rest: [(string)?, (string[])?] + paramsOrFirst: { databaseId: string, tableId: string, queries?: string[], transactionId?: string } | string, + ...rest: [(string)?, (string[])?, (string)?] ): Promise> { - let params: { databaseId: string, tableId: string, queries?: string[] }; + let params: { databaseId: string, tableId: string, queries?: string[], transactionId?: string }; if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, tableId: string, queries?: string[] }; + params = (paramsOrFirst || {}) as { databaseId: string, tableId: string, queries?: string[], transactionId?: string }; } else { params = { databaseId: paramsOrFirst as string, tableId: rest[0] as string, - queries: rest[1] as string[] + queries: rest[1] as string[], + transactionId: rest[2] as string }; } const databaseId = params.databaseId; const tableId = params.tableId; const queries = params.queries; + const transactionId = params.transactionId; if (typeof databaseId === 'undefined') { throw new AppwriteException('Missing required parameter: "databaseId"'); @@ -3793,6 +4130,9 @@ export class TablesDB { if (typeof queries !== 'undefined') { payload['queries'] = queries; } + if (typeof transactionId !== 'undefined') { + payload['transactionId'] = transactionId; + } const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -3807,45 +4147,48 @@ export class TablesDB { } /** - * Create a new Row. Before using this route, you should create a new table resource using either a [server integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreateTable) API or directly from your database console. + * Create a new Row. Before using this route, you should create a new table resource using either a [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable) API or directly from your database console. * * @param {string} params.databaseId - Database ID. - * @param {string} params.tableId - Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreate). Make sure to define columns before creating rows. + * @param {string} params.tableId - Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable). Make sure to define columns before creating rows. * @param {string} params.rowId - Row 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 {Row extends Models.DefaultRow ? Partial & Record : Partial & Omit} params.data - Row 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). + * @param {string} params.transactionId - Transaction ID for staging the operation. * @throws {AppwriteException} * @returns {Promise} */ - createRow(params: { databaseId: string, tableId: string, rowId: string, data: Row extends Models.DefaultRow ? Partial & Record : Partial & Omit, permissions?: string[] }): Promise; + createRow(params: { databaseId: string, tableId: string, rowId: string, data: Row extends Models.DefaultRow ? Partial & Record : Partial & Omit, permissions?: string[], transactionId?: string }): Promise; /** - * Create a new Row. Before using this route, you should create a new table resource using either a [server integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreateTable) API or directly from your database console. + * Create a new Row. Before using this route, you should create a new table resource using either a [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable) API or directly from your database console. * * @param {string} databaseId - Database ID. - * @param {string} tableId - Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreate). Make sure to define columns before creating rows. + * @param {string} tableId - Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable). Make sure to define columns before creating rows. * @param {string} rowId - Row 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 {Row extends Models.DefaultRow ? Partial & Record : Partial & Omit} data - Row 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). + * @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. */ - createRow(databaseId: string, tableId: string, rowId: string, data: Row extends Models.DefaultRow ? Partial & Record : Partial & Omit, permissions?: string[]): Promise; + createRow(databaseId: string, tableId: string, rowId: string, data: Row extends Models.DefaultRow ? Partial & Record : Partial & Omit, permissions?: string[], transactionId?: string): Promise; createRow( - paramsOrFirst: { databaseId: string, tableId: string, rowId: string, data: Row extends Models.DefaultRow ? Partial & Record : Partial & Omit, permissions?: string[] } | string, - ...rest: [(string)?, (string)?, (Row extends Models.DefaultRow ? Partial & Record : Partial & Omit)?, (string[])?] + paramsOrFirst: { databaseId: string, tableId: string, rowId: string, data: Row extends Models.DefaultRow ? Partial & Record : Partial & Omit, permissions?: string[], transactionId?: string } | string, + ...rest: [(string)?, (string)?, (Row extends Models.DefaultRow ? Partial & Record : Partial & Omit)?, (string[])?, (string)?] ): Promise { - let params: { databaseId: string, tableId: string, rowId: string, data: Row extends Models.DefaultRow ? Partial & Record : Partial & Omit, permissions?: string[] }; + let params: { databaseId: string, tableId: string, rowId: string, data: Row extends Models.DefaultRow ? Partial & Record : Partial & Omit, permissions?: string[], transactionId?: string }; if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, tableId: string, rowId: string, data: Row extends Models.DefaultRow ? Partial & Record : Partial & Omit, permissions?: string[] }; + params = (paramsOrFirst || {}) as { databaseId: string, tableId: string, rowId: string, data: Row extends Models.DefaultRow ? Partial & Record : Partial & Omit, permissions?: string[], transactionId?: string }; } else { params = { databaseId: paramsOrFirst as string, tableId: rest[0] as string, rowId: rest[1] as string, data: rest[2] as Row extends Models.DefaultRow ? Partial & Record : Partial & Omit, - permissions: rest[3] as string[] + permissions: rest[3] as string[], + transactionId: rest[4] as string }; } @@ -3854,6 +4197,7 @@ export class TablesDB { const rowId = params.rowId; const data = params.data; const permissions = params.permissions; + const transactionId = params.transactionId; if (typeof databaseId === 'undefined') { throw new AppwriteException('Missing required parameter: "databaseId"'); @@ -3879,6 +4223,9 @@ export class TablesDB { if (typeof permissions !== 'undefined') { payload['permissions'] = permissions; } + if (typeof transactionId !== 'undefined') { + payload['transactionId'] = transactionId; + } const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -3894,45 +4241,49 @@ export class TablesDB { } /** - * Create new Rows. Before using this route, you should create a new table resource using either a [server integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreateTable) API or directly from your database console. + * Create new Rows. Before using this route, you should create a new table resource using either a [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable) API or directly from your database console. * * @param {string} params.databaseId - Database ID. - * @param {string} params.tableId - Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreate). Make sure to define columns before creating rows. - * @param {object[]} params.rows - Array of documents data as JSON objects. + * @param {string} params.tableId - Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable). Make sure to define columns before creating rows. + * @param {object[]} params.rows - Array of rows data as JSON objects. + * @param {string} params.transactionId - Transaction ID for staging the operation. * @throws {AppwriteException} * @returns {Promise>} */ - createRows(params: { databaseId: string, tableId: string, rows: object[] }): Promise>; + createRows(params: { databaseId: string, tableId: string, rows: object[], transactionId?: string }): Promise>; /** - * Create new Rows. Before using this route, you should create a new table resource using either a [server integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreateTable) API or directly from your database console. + * Create new Rows. Before using this route, you should create a new table resource using either a [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable) API or directly from your database console. * * @param {string} databaseId - Database ID. - * @param {string} tableId - Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreate). Make sure to define columns before creating rows. - * @param {object[]} rows - Array of documents data as JSON objects. + * @param {string} tableId - Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable). Make sure to define columns before creating rows. + * @param {object[]} rows - Array of rows data as JSON objects. + * @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. */ - createRows(databaseId: string, tableId: string, rows: object[]): Promise>; + createRows(databaseId: string, tableId: string, rows: object[], transactionId?: string): Promise>; createRows( - paramsOrFirst: { databaseId: string, tableId: string, rows: object[] } | string, - ...rest: [(string)?, (object[])?] + paramsOrFirst: { databaseId: string, tableId: string, rows: object[], transactionId?: string } | string, + ...rest: [(string)?, (object[])?, (string)?] ): Promise> { - let params: { databaseId: string, tableId: string, rows: object[] }; + let params: { databaseId: string, tableId: string, rows: object[], transactionId?: string }; if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, tableId: string, rows: object[] }; + params = (paramsOrFirst || {}) as { databaseId: string, tableId: string, rows: object[], transactionId?: string }; } else { params = { databaseId: paramsOrFirst as string, tableId: rest[0] as string, - rows: rest[1] as object[] + rows: rest[1] as object[], + transactionId: rest[2] as string }; } const databaseId = params.databaseId; const tableId = params.tableId; const rows = params.rows; + const transactionId = params.transactionId; if (typeof databaseId === 'undefined') { throw new AppwriteException('Missing required parameter: "databaseId"'); @@ -3949,6 +4300,9 @@ export class TablesDB { if (typeof rows !== 'undefined') { payload['rows'] = rows; } + if (typeof transactionId !== 'undefined') { + payload['transactionId'] = transactionId; + } const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -3964,47 +4318,51 @@ export class TablesDB { } /** - * Create or update Rows. Before using this route, you should create a new table resource using either a [server integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreateTable) API or directly from your database console. + * Create or update Rows. Before using this route, you should create a new table resource using either a [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable) API or directly from your database console. * * * @param {string} params.databaseId - Database ID. * @param {string} params.tableId - Table ID. * @param {object[]} params.rows - Array of row data as JSON objects. May contain partial rows. + * @param {string} params.transactionId - Transaction ID for staging the operation. * @throws {AppwriteException} * @returns {Promise>} */ - upsertRows(params: { databaseId: string, tableId: string, rows: object[] }): Promise>; + upsertRows(params: { databaseId: string, tableId: string, rows: object[], transactionId?: string }): Promise>; /** - * Create or update Rows. Before using this route, you should create a new table resource using either a [server integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreateTable) API or directly from your database console. + * Create or update Rows. Before using this route, you should create a new table resource using either a [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable) API or directly from your database console. * * * @param {string} databaseId - Database ID. * @param {string} tableId - Table ID. * @param {object[]} rows - Array of row data as JSON objects. May contain partial rows. + * @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. */ - upsertRows(databaseId: string, tableId: string, rows: object[]): Promise>; + upsertRows(databaseId: string, tableId: string, rows: object[], transactionId?: string): Promise>; upsertRows( - paramsOrFirst: { databaseId: string, tableId: string, rows: object[] } | string, - ...rest: [(string)?, (object[])?] + paramsOrFirst: { databaseId: string, tableId: string, rows: object[], transactionId?: string } | string, + ...rest: [(string)?, (object[])?, (string)?] ): Promise> { - let params: { databaseId: string, tableId: string, rows: object[] }; + let params: { databaseId: string, tableId: string, rows: object[], transactionId?: string }; if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, tableId: string, rows: object[] }; + params = (paramsOrFirst || {}) as { databaseId: string, tableId: string, rows: object[], transactionId?: string }; } else { params = { databaseId: paramsOrFirst as string, tableId: rest[0] as string, - rows: rest[1] as object[] + rows: rest[1] as object[], + transactionId: rest[2] as string }; } const databaseId = params.databaseId; const tableId = params.tableId; const rows = params.rows; + const transactionId = params.transactionId; if (typeof databaseId === 'undefined') { throw new AppwriteException('Missing required parameter: "databaseId"'); @@ -4021,6 +4379,9 @@ export class TablesDB { if (typeof rows !== 'undefined') { payload['rows'] = rows; } + if (typeof transactionId !== 'undefined') { + payload['transactionId'] = transactionId; + } const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -4042,10 +4403,11 @@ export class TablesDB { * @param {string} params.tableId - Table ID. * @param {object} params.data - Row data as JSON object. Include only column and value pairs to be updated. * @param {string[]} params.queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. + * @param {string} params.transactionId - Transaction ID for staging the operation. * @throws {AppwriteException} * @returns {Promise>} */ - updateRows(params: { databaseId: string, tableId: string, data?: object, queries?: string[] }): Promise>; + updateRows(params: { databaseId: string, tableId: string, data?: object, queries?: string[], transactionId?: string }): Promise>; /** * Update all rows that match your queries, if no queries are submitted then all rows are updated. You can pass only specific fields to be updated. * @@ -4053,25 +4415,27 @@ export class TablesDB { * @param {string} tableId - Table ID. * @param {object} data - Row data as JSON object. Include only column and value pairs to be updated. * @param {string[]} queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. + * @param {string} transactionId - Transaction ID for staging the operation. * @throws {AppwriteException} * @returns {Promise>} * @deprecated Use the object parameter style method for a better developer experience. */ - updateRows(databaseId: string, tableId: string, data?: object, queries?: string[]): Promise>; + updateRows(databaseId: string, tableId: string, data?: object, queries?: string[], transactionId?: string): Promise>; updateRows( - paramsOrFirst: { databaseId: string, tableId: string, data?: object, queries?: string[] } | string, - ...rest: [(string)?, (object)?, (string[])?] + paramsOrFirst: { databaseId: string, tableId: string, data?: object, queries?: string[], transactionId?: string } | string, + ...rest: [(string)?, (object)?, (string[])?, (string)?] ): Promise> { - let params: { databaseId: string, tableId: string, data?: object, queries?: string[] }; + let params: { databaseId: string, tableId: string, data?: object, queries?: string[], transactionId?: string }; if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, tableId: string, data?: object, queries?: string[] }; + params = (paramsOrFirst || {}) as { databaseId: string, tableId: string, data?: object, queries?: string[], transactionId?: string }; } else { params = { databaseId: paramsOrFirst as string, tableId: rest[0] as string, data: rest[1] as object, - queries: rest[2] as string[] + queries: rest[2] as string[], + transactionId: rest[3] as string }; } @@ -4079,6 +4443,7 @@ export class TablesDB { const tableId = params.tableId; const data = params.data; const queries = params.queries; + const transactionId = params.transactionId; if (typeof databaseId === 'undefined') { throw new AppwriteException('Missing required parameter: "databaseId"'); @@ -4095,6 +4460,9 @@ export class TablesDB { if (typeof queries !== 'undefined') { payload['queries'] = queries; } + if (typeof transactionId !== 'undefined') { + payload['transactionId'] = transactionId; + } const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -4113,42 +4481,46 @@ export class TablesDB { * Bulk delete rows using queries, if no queries are passed then all rows are deleted. * * @param {string} params.databaseId - Database ID. - * @param {string} params.tableId - Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreate). + * @param {string} params.tableId - Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable). * @param {string[]} params.queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. + * @param {string} params.transactionId - Transaction ID for staging the operation. * @throws {AppwriteException} * @returns {Promise>} */ - deleteRows(params: { databaseId: string, tableId: string, queries?: string[] }): Promise>; + deleteRows(params: { databaseId: string, tableId: string, queries?: string[], transactionId?: string }): Promise>; /** * Bulk delete rows using queries, if no queries are passed then all rows are deleted. * * @param {string} databaseId - Database ID. - * @param {string} tableId - Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreate). + * @param {string} tableId - Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable). * @param {string[]} queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. + * @param {string} transactionId - Transaction ID for staging the operation. * @throws {AppwriteException} * @returns {Promise>} * @deprecated Use the object parameter style method for a better developer experience. */ - deleteRows(databaseId: string, tableId: string, queries?: string[]): Promise>; + deleteRows(databaseId: string, tableId: string, queries?: string[], transactionId?: string): Promise>; deleteRows( - paramsOrFirst: { databaseId: string, tableId: string, queries?: string[] } | string, - ...rest: [(string)?, (string[])?] + paramsOrFirst: { databaseId: string, tableId: string, queries?: string[], transactionId?: string } | string, + ...rest: [(string)?, (string[])?, (string)?] ): Promise> { - let params: { databaseId: string, tableId: string, queries?: string[] }; + let params: { databaseId: string, tableId: string, queries?: string[], transactionId?: string }; if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, tableId: string, queries?: string[] }; + params = (paramsOrFirst || {}) as { databaseId: string, tableId: string, queries?: string[], transactionId?: string }; } else { params = { databaseId: paramsOrFirst as string, tableId: rest[0] as string, - queries: rest[1] as string[] + queries: rest[1] as string[], + transactionId: rest[2] as string }; } const databaseId = params.databaseId; const tableId = params.tableId; const queries = params.queries; + const transactionId = params.transactionId; if (typeof databaseId === 'undefined') { throw new AppwriteException('Missing required parameter: "databaseId"'); @@ -4162,6 +4534,9 @@ export class TablesDB { if (typeof queries !== 'undefined') { payload['queries'] = queries; } + if (typeof transactionId !== 'undefined') { + payload['transactionId'] = transactionId; + } const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -4180,39 +4555,42 @@ export class TablesDB { * Get a row by its unique ID. This endpoint response returns a JSON object with the row data. * * @param {string} params.databaseId - Database ID. - * @param {string} params.tableId - Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreate). + * @param {string} params.tableId - Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable). * @param {string} params.rowId - Row 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} */ - getRow(params: { databaseId: string, tableId: string, rowId: string, queries?: string[] }): Promise; + getRow(params: { databaseId: string, tableId: string, rowId: string, queries?: string[], transactionId?: string }): Promise; /** * Get a row by its unique ID. This endpoint response returns a JSON object with the row data. * * @param {string} databaseId - Database ID. - * @param {string} tableId - Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreate). + * @param {string} tableId - Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable). * @param {string} rowId - Row 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. */ - getRow(databaseId: string, tableId: string, rowId: string, queries?: string[]): Promise; + getRow(databaseId: string, tableId: string, rowId: string, queries?: string[], transactionId?: string): Promise; getRow( - paramsOrFirst: { databaseId: string, tableId: string, rowId: string, queries?: string[] } | string, - ...rest: [(string)?, (string)?, (string[])?] + paramsOrFirst: { databaseId: string, tableId: string, rowId: string, queries?: string[], transactionId?: string } | string, + ...rest: [(string)?, (string)?, (string[])?, (string)?] ): Promise { - let params: { databaseId: string, tableId: string, rowId: string, queries?: string[] }; + let params: { databaseId: string, tableId: string, rowId: string, queries?: string[], transactionId?: string }; if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, tableId: string, rowId: string, queries?: string[] }; + params = (paramsOrFirst || {}) as { databaseId: string, tableId: string, rowId: string, queries?: string[], transactionId?: string }; } else { params = { databaseId: paramsOrFirst as string, tableId: rest[0] as string, rowId: rest[1] as string, - queries: rest[2] as string[] + queries: rest[2] as string[], + transactionId: rest[3] as string }; } @@ -4220,6 +4598,7 @@ export class TablesDB { const tableId = params.tableId; const rowId = params.rowId; const queries = params.queries; + const transactionId = params.transactionId; if (typeof databaseId === 'undefined') { throw new AppwriteException('Missing required parameter: "databaseId"'); @@ -4236,6 +4615,9 @@ export class TablesDB { if (typeof queries !== 'undefined') { payload['queries'] = queries; } + if (typeof transactionId !== 'undefined') { + payload['transactionId'] = transactionId; + } const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -4250,45 +4632,48 @@ export class TablesDB { } /** - * Create or update a Row. Before using this route, you should create a new table resource using either a [server integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreateTable) API or directly from your database console. + * Create or update a Row. Before using this route, you should create a new table resource using either a [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable) API or directly from your database console. * * @param {string} params.databaseId - Database ID. * @param {string} params.tableId - Table ID. * @param {string} params.rowId - Row ID. * @param {Row extends Models.DefaultRow ? Partial & Record : Partial & Partial>} params.data - Row data as JSON object. Include all required columns of the row 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} */ - upsertRow(params: { databaseId: string, tableId: string, rowId: string, data?: Row extends Models.DefaultRow ? Partial & Record : Partial & Partial>, permissions?: string[] }): Promise; + upsertRow(params: { databaseId: string, tableId: string, rowId: string, data?: Row extends Models.DefaultRow ? Partial & Record : Partial & Partial>, permissions?: string[], transactionId?: string }): Promise; /** - * Create or update a Row. Before using this route, you should create a new table resource using either a [server integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreateTable) API or directly from your database console. + * Create or update a Row. Before using this route, you should create a new table resource using either a [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable) API or directly from your database console. * * @param {string} databaseId - Database ID. * @param {string} tableId - Table ID. * @param {string} rowId - Row ID. * @param {Row extends Models.DefaultRow ? Partial & Record : Partial & Partial>} data - Row data as JSON object. Include all required columns of the row 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. */ - upsertRow(databaseId: string, tableId: string, rowId: string, data?: Row extends Models.DefaultRow ? Partial & Record : Partial & Partial>, permissions?: string[]): Promise; + upsertRow(databaseId: string, tableId: string, rowId: string, data?: Row extends Models.DefaultRow ? Partial & Record : Partial & Partial>, permissions?: string[], transactionId?: string): Promise; upsertRow( - paramsOrFirst: { databaseId: string, tableId: string, rowId: string, data?: Row extends Models.DefaultRow ? Partial & Record : Partial & Partial>, permissions?: string[] } | string, - ...rest: [(string)?, (string)?, (Row extends Models.DefaultRow ? Partial & Record : Partial & Partial>)?, (string[])?] + paramsOrFirst: { databaseId: string, tableId: string, rowId: string, data?: Row extends Models.DefaultRow ? Partial & Record : Partial & Partial>, permissions?: string[], transactionId?: string } | string, + ...rest: [(string)?, (string)?, (Row extends Models.DefaultRow ? Partial & Record : Partial & Partial>)?, (string[])?, (string)?] ): Promise { - let params: { databaseId: string, tableId: string, rowId: string, data?: Row extends Models.DefaultRow ? Partial & Record : Partial & Partial>, permissions?: string[] }; + let params: { databaseId: string, tableId: string, rowId: string, data?: Row extends Models.DefaultRow ? Partial & Record : Partial & Partial>, permissions?: string[], transactionId?: string }; if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, tableId: string, rowId: string, data?: Row extends Models.DefaultRow ? Partial & Record : Partial & Partial>, permissions?: string[] }; + params = (paramsOrFirst || {}) as { databaseId: string, tableId: string, rowId: string, data?: Row extends Models.DefaultRow ? Partial & Record : Partial & Partial>, permissions?: string[], transactionId?: string }; } else { params = { databaseId: paramsOrFirst as string, tableId: rest[0] as string, rowId: rest[1] as string, data: rest[2] as Row extends Models.DefaultRow ? Partial & Record : Partial & Partial>, - permissions: rest[3] as string[] + permissions: rest[3] as string[], + transactionId: rest[4] as string }; } @@ -4297,6 +4682,7 @@ export class TablesDB { const rowId = params.rowId; const data = params.data; const permissions = params.permissions; + const transactionId = params.transactionId; if (typeof databaseId === 'undefined') { throw new AppwriteException('Missing required parameter: "databaseId"'); @@ -4316,6 +4702,9 @@ export class TablesDB { if (typeof permissions !== 'undefined') { payload['permissions'] = permissions; } + if (typeof transactionId !== 'undefined') { + payload['transactionId'] = transactionId; + } const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -4338,10 +4727,11 @@ export class TablesDB { * @param {string} params.rowId - Row ID. * @param {Row extends Models.DefaultRow ? Partial & Record : Partial & Partial>} params.data - Row data as JSON object. Include only columns 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} */ - updateRow(params: { databaseId: string, tableId: string, rowId: string, data?: Row extends Models.DefaultRow ? Partial & Record : Partial & Partial>, permissions?: string[] }): Promise; + updateRow(params: { databaseId: string, tableId: string, rowId: string, data?: Row extends Models.DefaultRow ? Partial & Record : Partial & Partial>, permissions?: string[], transactionId?: string }): Promise; /** * Update a row by its unique ID. Using the patch method you can pass only specific fields that will get updated. * @@ -4350,26 +4740,28 @@ export class TablesDB { * @param {string} rowId - Row ID. * @param {Row extends Models.DefaultRow ? Partial & Record : Partial & Partial>} data - Row data as JSON object. Include only columns 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. */ - updateRow(databaseId: string, tableId: string, rowId: string, data?: Row extends Models.DefaultRow ? Partial & Record : Partial & Partial>, permissions?: string[]): Promise; + updateRow(databaseId: string, tableId: string, rowId: string, data?: Row extends Models.DefaultRow ? Partial & Record : Partial & Partial>, permissions?: string[], transactionId?: string): Promise; updateRow( - paramsOrFirst: { databaseId: string, tableId: string, rowId: string, data?: Row extends Models.DefaultRow ? Partial & Record : Partial & Partial>, permissions?: string[] } | string, - ...rest: [(string)?, (string)?, (Row extends Models.DefaultRow ? Partial & Record : Partial & Partial>)?, (string[])?] + paramsOrFirst: { databaseId: string, tableId: string, rowId: string, data?: Row extends Models.DefaultRow ? Partial & Record : Partial & Partial>, permissions?: string[], transactionId?: string } | string, + ...rest: [(string)?, (string)?, (Row extends Models.DefaultRow ? Partial & Record : Partial & Partial>)?, (string[])?, (string)?] ): Promise { - let params: { databaseId: string, tableId: string, rowId: string, data?: Row extends Models.DefaultRow ? Partial & Record : Partial & Partial>, permissions?: string[] }; + let params: { databaseId: string, tableId: string, rowId: string, data?: Row extends Models.DefaultRow ? Partial & Record : Partial & Partial>, permissions?: string[], transactionId?: string }; if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, tableId: string, rowId: string, data?: Row extends Models.DefaultRow ? Partial & Record : Partial & Partial>, permissions?: string[] }; + params = (paramsOrFirst || {}) as { databaseId: string, tableId: string, rowId: string, data?: Row extends Models.DefaultRow ? Partial & Record : Partial & Partial>, permissions?: string[], transactionId?: string }; } else { params = { databaseId: paramsOrFirst as string, tableId: rest[0] as string, rowId: rest[1] as string, data: rest[2] as Row extends Models.DefaultRow ? Partial & Record : Partial & Partial>, - permissions: rest[3] as string[] + permissions: rest[3] as string[], + transactionId: rest[4] as string }; } @@ -4378,6 +4770,7 @@ export class TablesDB { const rowId = params.rowId; const data = params.data; const permissions = params.permissions; + const transactionId = params.transactionId; if (typeof databaseId === 'undefined') { throw new AppwriteException('Missing required parameter: "databaseId"'); @@ -4397,6 +4790,9 @@ export class TablesDB { if (typeof permissions !== 'undefined') { payload['permissions'] = permissions; } + if (typeof transactionId !== 'undefined') { + payload['transactionId'] = transactionId; + } const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -4415,42 +4811,46 @@ export class TablesDB { * Delete a row by its unique ID. * * @param {string} params.databaseId - Database ID. - * @param {string} params.tableId - Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreate). + * @param {string} params.tableId - Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable). * @param {string} params.rowId - Row ID. + * @param {string} params.transactionId - Transaction ID for staging the operation. * @throws {AppwriteException} * @returns {Promise<{}>} */ - deleteRow(params: { databaseId: string, tableId: string, rowId: string }): Promise<{}>; + deleteRow(params: { databaseId: string, tableId: string, rowId: string, transactionId?: string }): Promise<{}>; /** * Delete a row by its unique ID. * * @param {string} databaseId - Database ID. - * @param {string} tableId - Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreate). + * @param {string} tableId - Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable). * @param {string} rowId - Row 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. */ - deleteRow(databaseId: string, tableId: string, rowId: string): Promise<{}>; + deleteRow(databaseId: string, tableId: string, rowId: string, transactionId?: string): Promise<{}>; deleteRow( - paramsOrFirst: { databaseId: string, tableId: string, rowId: string } | string, - ...rest: [(string)?, (string)?] + paramsOrFirst: { databaseId: string, tableId: string, rowId: string, transactionId?: string } | string, + ...rest: [(string)?, (string)?, (string)?] ): Promise<{}> { - let params: { databaseId: string, tableId: string, rowId: string }; + let params: { databaseId: string, tableId: string, rowId: string, transactionId?: string }; if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, tableId: string, rowId: string }; + params = (paramsOrFirst || {}) as { databaseId: string, tableId: string, rowId: string, transactionId?: string }; } else { params = { databaseId: paramsOrFirst as string, tableId: rest[0] as string, - rowId: rest[1] as string + rowId: rest[1] as string, + transactionId: rest[2] as string }; } const databaseId = params.databaseId; const tableId = params.tableId; const rowId = params.rowId; + const transactionId = params.transactionId; if (typeof databaseId === 'undefined') { throw new AppwriteException('Missing required parameter: "databaseId"'); @@ -4464,6 +4864,9 @@ export class TablesDB { const apiPath = '/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}'.replace('{databaseId}', databaseId).replace('{tableId}', tableId).replace('{rowId}', rowId); const payload: Payload = {}; + if (typeof transactionId !== 'undefined') { + payload['transactionId'] = transactionId; + } const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -4487,10 +4890,11 @@ export class TablesDB { * @param {string} params.column - Column key. * @param {number} params.value - Value to increment the column by. The value must be a number. * @param {number} params.min - Minimum value for the column. 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} */ - decrementRowColumn(params: { databaseId: string, tableId: string, rowId: string, column: string, value?: number, min?: number }): Promise; + decrementRowColumn(params: { databaseId: string, tableId: string, rowId: string, column: string, value?: number, min?: number, transactionId?: string }): Promise; /** * Decrement a specific column of a row by a given value. * @@ -4500,19 +4904,20 @@ export class TablesDB { * @param {string} column - Column key. * @param {number} value - Value to increment the column by. The value must be a number. * @param {number} min - Minimum value for the column. 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. */ - decrementRowColumn(databaseId: string, tableId: string, rowId: string, column: string, value?: number, min?: number): Promise; + decrementRowColumn(databaseId: string, tableId: string, rowId: string, column: string, value?: number, min?: number, transactionId?: string): Promise; decrementRowColumn( - paramsOrFirst: { databaseId: string, tableId: string, rowId: string, column: string, value?: number, min?: number } | string, - ...rest: [(string)?, (string)?, (string)?, (number)?, (number)?] + paramsOrFirst: { databaseId: string, tableId: string, rowId: string, column: string, value?: number, min?: number, transactionId?: string } | string, + ...rest: [(string)?, (string)?, (string)?, (number)?, (number)?, (string)?] ): Promise { - let params: { databaseId: string, tableId: string, rowId: string, column: string, value?: number, min?: number }; + let params: { databaseId: string, tableId: string, rowId: string, column: string, value?: number, min?: number, transactionId?: string }; if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, tableId: string, rowId: string, column: string, value?: number, min?: number }; + params = (paramsOrFirst || {}) as { databaseId: string, tableId: string, rowId: string, column: string, value?: number, min?: number, transactionId?: string }; } else { params = { databaseId: paramsOrFirst as string, @@ -4520,7 +4925,8 @@ export class TablesDB { rowId: rest[1] as string, column: rest[2] as string, value: rest[3] as number, - min: rest[4] as number + min: rest[4] as number, + transactionId: rest[5] as string }; } @@ -4530,6 +4936,7 @@ export class TablesDB { const column = params.column; const value = params.value; const min = params.min; + const transactionId = params.transactionId; if (typeof databaseId === 'undefined') { throw new AppwriteException('Missing required parameter: "databaseId"'); @@ -4552,6 +4959,9 @@ export class TablesDB { if (typeof min !== 'undefined') { payload['min'] = min; } + if (typeof transactionId !== 'undefined') { + payload['transactionId'] = transactionId; + } const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -4575,10 +4985,11 @@ export class TablesDB { * @param {string} params.column - Column key. * @param {number} params.value - Value to increment the column by. The value must be a number. * @param {number} params.max - Maximum value for the column. 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} */ - incrementRowColumn(params: { databaseId: string, tableId: string, rowId: string, column: string, value?: number, max?: number }): Promise; + incrementRowColumn(params: { databaseId: string, tableId: string, rowId: string, column: string, value?: number, max?: number, transactionId?: string }): Promise; /** * Increment a specific column of a row by a given value. * @@ -4588,19 +4999,20 @@ export class TablesDB { * @param {string} column - Column key. * @param {number} value - Value to increment the column by. The value must be a number. * @param {number} max - Maximum value for the column. 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. */ - incrementRowColumn(databaseId: string, tableId: string, rowId: string, column: string, value?: number, max?: number): Promise; + incrementRowColumn(databaseId: string, tableId: string, rowId: string, column: string, value?: number, max?: number, transactionId?: string): Promise; incrementRowColumn( - paramsOrFirst: { databaseId: string, tableId: string, rowId: string, column: string, value?: number, max?: number } | string, - ...rest: [(string)?, (string)?, (string)?, (number)?, (number)?] + paramsOrFirst: { databaseId: string, tableId: string, rowId: string, column: string, value?: number, max?: number, transactionId?: string } | string, + ...rest: [(string)?, (string)?, (string)?, (number)?, (number)?, (string)?] ): Promise { - let params: { databaseId: string, tableId: string, rowId: string, column: string, value?: number, max?: number }; + let params: { databaseId: string, tableId: string, rowId: string, column: string, value?: number, max?: number, transactionId?: string }; if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, tableId: string, rowId: string, column: string, value?: number, max?: number }; + params = (paramsOrFirst || {}) as { databaseId: string, tableId: string, rowId: string, column: string, value?: number, max?: number, transactionId?: string }; } else { params = { databaseId: paramsOrFirst as string, @@ -4608,7 +5020,8 @@ export class TablesDB { rowId: rest[1] as string, column: rest[2] as string, value: rest[3] as number, - max: rest[4] as number + max: rest[4] as number, + transactionId: rest[5] as string }; } @@ -4618,6 +5031,7 @@ export class TablesDB { const column = params.column; const value = params.value; const max = params.max; + const transactionId = params.transactionId; if (typeof databaseId === 'undefined') { throw new AppwriteException('Missing required parameter: "databaseId"'); @@ -4640,6 +5054,9 @@ export class TablesDB { if (typeof max !== 'undefined') { payload['max'] = max; } + if (typeof transactionId !== 'undefined') { + payload['transactionId'] = transactionId; + } const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = {