react-native-appwrite 0.16.0 → 0.17.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (41) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/dist/cjs/sdk.js +371 -17
  3. package/dist/cjs/sdk.js.map +1 -1
  4. package/dist/esm/sdk.js +371 -17
  5. package/dist/esm/sdk.js.map +1 -1
  6. package/docs/examples/databases/create-document.md +2 -1
  7. package/docs/examples/databases/create-operations.md +24 -0
  8. package/docs/examples/databases/create-transaction.md +13 -0
  9. package/docs/examples/databases/decrement-document-attribute.md +2 -1
  10. package/docs/examples/databases/delete-document.md +2 -1
  11. package/docs/examples/databases/delete-transaction.md +13 -0
  12. package/docs/examples/databases/get-document.md +2 -1
  13. package/docs/examples/databases/get-transaction.md +13 -0
  14. package/docs/examples/databases/increment-document-attribute.md +2 -1
  15. package/docs/examples/databases/list-documents.md +2 -1
  16. package/docs/examples/databases/list-transactions.md +13 -0
  17. package/docs/examples/databases/update-document.md +2 -1
  18. package/docs/examples/databases/update-transaction.md +15 -0
  19. package/docs/examples/databases/upsert-document.md +2 -1
  20. package/docs/examples/tablesdb/create-operations.md +24 -0
  21. package/docs/examples/tablesdb/create-row.md +2 -1
  22. package/docs/examples/tablesdb/create-transaction.md +13 -0
  23. package/docs/examples/tablesdb/decrement-row-column.md +2 -1
  24. package/docs/examples/tablesdb/delete-row.md +2 -1
  25. package/docs/examples/tablesdb/delete-transaction.md +13 -0
  26. package/docs/examples/tablesdb/get-row.md +2 -1
  27. package/docs/examples/tablesdb/get-transaction.md +13 -0
  28. package/docs/examples/tablesdb/increment-row-column.md +2 -1
  29. package/docs/examples/tablesdb/list-rows.md +2 -1
  30. package/docs/examples/tablesdb/list-transactions.md +13 -0
  31. package/docs/examples/tablesdb/update-row.md +2 -1
  32. package/docs/examples/tablesdb/update-transaction.md +15 -0
  33. package/docs/examples/tablesdb/upsert-row.md +2 -1
  34. package/package.json +1 -1
  35. package/src/client.ts +1 -1
  36. package/src/models.ts +44 -0
  37. package/src/services/databases.ts +414 -56
  38. package/src/services/tables-db.ts +414 -56
  39. package/types/models.d.ts +42 -0
  40. package/types/services/databases.d.ts +155 -8
  41. package/types/services/tables-db.d.ts +155 -8
@@ -17,7 +17,8 @@ const result = await databases.createDocument({
17
17
  "age": 30,
18
18
  "isAdmin": false
19
19
  },
20
- permissions: ["read("any")"] // optional
20
+ permissions: ["read("any")"], // optional
21
+ transactionId: '<TRANSACTION_ID>' // optional
21
22
  });
22
23
 
23
24
  console.log(result);
@@ -0,0 +1,24 @@
1
+ import { Client, Databases } from "react-native-appwrite";
2
+
3
+ const client = new Client()
4
+ .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint
5
+ .setProject('<YOUR_PROJECT_ID>'); // Your project ID
6
+
7
+ const databases = new Databases(client);
8
+
9
+ const result = await databases.createOperations({
10
+ transactionId: '<TRANSACTION_ID>',
11
+ operations: [
12
+ {
13
+ "action": "create",
14
+ "databaseId": "<DATABASE_ID>",
15
+ "collectionId": "<COLLECTION_ID>",
16
+ "documentId": "<DOCUMENT_ID>",
17
+ "data": {
18
+ "name": "Walter O'Brien"
19
+ }
20
+ }
21
+ ] // optional
22
+ });
23
+
24
+ console.log(result);
@@ -0,0 +1,13 @@
1
+ import { Client, Databases } from "react-native-appwrite";
2
+
3
+ const client = new Client()
4
+ .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint
5
+ .setProject('<YOUR_PROJECT_ID>'); // Your project ID
6
+
7
+ const databases = new Databases(client);
8
+
9
+ const result = await databases.createTransaction({
10
+ ttl: 60 // optional
11
+ });
12
+
13
+ console.log(result);
@@ -12,7 +12,8 @@ const result = await databases.decrementDocumentAttribute({
12
12
  documentId: '<DOCUMENT_ID>',
13
13
  attribute: '',
14
14
  value: 0, // optional
15
- min: 0 // optional
15
+ min: 0, // optional
16
+ transactionId: '<TRANSACTION_ID>' // optional
16
17
  });
17
18
 
18
19
  console.log(result);
@@ -9,7 +9,8 @@ const databases = new Databases(client);
9
9
  const result = await databases.deleteDocument({
10
10
  databaseId: '<DATABASE_ID>',
11
11
  collectionId: '<COLLECTION_ID>',
12
- documentId: '<DOCUMENT_ID>'
12
+ documentId: '<DOCUMENT_ID>',
13
+ transactionId: '<TRANSACTION_ID>' // optional
13
14
  });
14
15
 
15
16
  console.log(result);
@@ -0,0 +1,13 @@
1
+ import { Client, Databases } from "react-native-appwrite";
2
+
3
+ const client = new Client()
4
+ .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint
5
+ .setProject('<YOUR_PROJECT_ID>'); // Your project ID
6
+
7
+ const databases = new Databases(client);
8
+
9
+ const result = await databases.deleteTransaction({
10
+ transactionId: '<TRANSACTION_ID>'
11
+ });
12
+
13
+ console.log(result);
@@ -10,7 +10,8 @@ const result = await databases.getDocument({
10
10
  databaseId: '<DATABASE_ID>',
11
11
  collectionId: '<COLLECTION_ID>',
12
12
  documentId: '<DOCUMENT_ID>',
13
- queries: [] // optional
13
+ queries: [], // optional
14
+ transactionId: '<TRANSACTION_ID>' // optional
14
15
  });
15
16
 
16
17
  console.log(result);
@@ -0,0 +1,13 @@
1
+ import { Client, Databases } from "react-native-appwrite";
2
+
3
+ const client = new Client()
4
+ .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint
5
+ .setProject('<YOUR_PROJECT_ID>'); // Your project ID
6
+
7
+ const databases = new Databases(client);
8
+
9
+ const result = await databases.getTransaction({
10
+ transactionId: '<TRANSACTION_ID>'
11
+ });
12
+
13
+ console.log(result);
@@ -12,7 +12,8 @@ const result = await databases.incrementDocumentAttribute({
12
12
  documentId: '<DOCUMENT_ID>',
13
13
  attribute: '',
14
14
  value: 0, // optional
15
- max: 0 // optional
15
+ max: 0, // optional
16
+ transactionId: '<TRANSACTION_ID>' // optional
16
17
  });
17
18
 
18
19
  console.log(result);
@@ -9,7 +9,8 @@ const databases = new Databases(client);
9
9
  const result = await databases.listDocuments({
10
10
  databaseId: '<DATABASE_ID>',
11
11
  collectionId: '<COLLECTION_ID>',
12
- queries: [] // optional
12
+ queries: [], // optional
13
+ transactionId: '<TRANSACTION_ID>' // optional
13
14
  });
14
15
 
15
16
  console.log(result);
@@ -0,0 +1,13 @@
1
+ import { Client, Databases } from "react-native-appwrite";
2
+
3
+ const client = new Client()
4
+ .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint
5
+ .setProject('<YOUR_PROJECT_ID>'); // Your project ID
6
+
7
+ const databases = new Databases(client);
8
+
9
+ const result = await databases.listTransactions({
10
+ queries: [] // optional
11
+ });
12
+
13
+ console.log(result);
@@ -11,7 +11,8 @@ const result = await databases.updateDocument({
11
11
  collectionId: '<COLLECTION_ID>',
12
12
  documentId: '<DOCUMENT_ID>',
13
13
  data: {}, // optional
14
- permissions: ["read("any")"] // optional
14
+ permissions: ["read("any")"], // optional
15
+ transactionId: '<TRANSACTION_ID>' // optional
15
16
  });
16
17
 
17
18
  console.log(result);
@@ -0,0 +1,15 @@
1
+ import { Client, Databases } from "react-native-appwrite";
2
+
3
+ const client = new Client()
4
+ .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint
5
+ .setProject('<YOUR_PROJECT_ID>'); // Your project ID
6
+
7
+ const databases = new Databases(client);
8
+
9
+ const result = await databases.updateTransaction({
10
+ transactionId: '<TRANSACTION_ID>',
11
+ commit: false, // optional
12
+ rollback: false // optional
13
+ });
14
+
15
+ console.log(result);
@@ -11,7 +11,8 @@ const result = await databases.upsertDocument({
11
11
  collectionId: '<COLLECTION_ID>',
12
12
  documentId: '<DOCUMENT_ID>',
13
13
  data: {},
14
- permissions: ["read("any")"] // optional
14
+ permissions: ["read("any")"], // optional
15
+ transactionId: '<TRANSACTION_ID>' // optional
15
16
  });
16
17
 
17
18
  console.log(result);
@@ -0,0 +1,24 @@
1
+ import { Client, TablesDB } from "react-native-appwrite";
2
+
3
+ const client = new Client()
4
+ .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint
5
+ .setProject('<YOUR_PROJECT_ID>'); // Your project ID
6
+
7
+ const tablesDB = new TablesDB(client);
8
+
9
+ const result = await tablesDB.createOperations({
10
+ transactionId: '<TRANSACTION_ID>',
11
+ operations: [
12
+ {
13
+ "action": "create",
14
+ "databaseId": "<DATABASE_ID>",
15
+ "tableId": "<TABLE_ID>",
16
+ "rowId": "<ROW_ID>",
17
+ "data": {
18
+ "name": "Walter O'Brien"
19
+ }
20
+ }
21
+ ] // optional
22
+ });
23
+
24
+ console.log(result);
@@ -17,7 +17,8 @@ const result = await tablesDB.createRow({
17
17
  "age": 30,
18
18
  "isAdmin": false
19
19
  },
20
- permissions: ["read("any")"] // optional
20
+ permissions: ["read("any")"], // optional
21
+ transactionId: '<TRANSACTION_ID>' // optional
21
22
  });
22
23
 
23
24
  console.log(result);
@@ -0,0 +1,13 @@
1
+ import { Client, TablesDB } from "react-native-appwrite";
2
+
3
+ const client = new Client()
4
+ .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint
5
+ .setProject('<YOUR_PROJECT_ID>'); // Your project ID
6
+
7
+ const tablesDB = new TablesDB(client);
8
+
9
+ const result = await tablesDB.createTransaction({
10
+ ttl: 60 // optional
11
+ });
12
+
13
+ console.log(result);
@@ -12,7 +12,8 @@ const result = await tablesDB.decrementRowColumn({
12
12
  rowId: '<ROW_ID>',
13
13
  column: '',
14
14
  value: 0, // optional
15
- min: 0 // optional
15
+ min: 0, // optional
16
+ transactionId: '<TRANSACTION_ID>' // optional
16
17
  });
17
18
 
18
19
  console.log(result);
@@ -9,7 +9,8 @@ const tablesDB = new TablesDB(client);
9
9
  const result = await tablesDB.deleteRow({
10
10
  databaseId: '<DATABASE_ID>',
11
11
  tableId: '<TABLE_ID>',
12
- rowId: '<ROW_ID>'
12
+ rowId: '<ROW_ID>',
13
+ transactionId: '<TRANSACTION_ID>' // optional
13
14
  });
14
15
 
15
16
  console.log(result);
@@ -0,0 +1,13 @@
1
+ import { Client, TablesDB } from "react-native-appwrite";
2
+
3
+ const client = new Client()
4
+ .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint
5
+ .setProject('<YOUR_PROJECT_ID>'); // Your project ID
6
+
7
+ const tablesDB = new TablesDB(client);
8
+
9
+ const result = await tablesDB.deleteTransaction({
10
+ transactionId: '<TRANSACTION_ID>'
11
+ });
12
+
13
+ console.log(result);
@@ -10,7 +10,8 @@ const result = await tablesDB.getRow({
10
10
  databaseId: '<DATABASE_ID>',
11
11
  tableId: '<TABLE_ID>',
12
12
  rowId: '<ROW_ID>',
13
- queries: [] // optional
13
+ queries: [], // optional
14
+ transactionId: '<TRANSACTION_ID>' // optional
14
15
  });
15
16
 
16
17
  console.log(result);
@@ -0,0 +1,13 @@
1
+ import { Client, TablesDB } from "react-native-appwrite";
2
+
3
+ const client = new Client()
4
+ .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint
5
+ .setProject('<YOUR_PROJECT_ID>'); // Your project ID
6
+
7
+ const tablesDB = new TablesDB(client);
8
+
9
+ const result = await tablesDB.getTransaction({
10
+ transactionId: '<TRANSACTION_ID>'
11
+ });
12
+
13
+ console.log(result);
@@ -12,7 +12,8 @@ const result = await tablesDB.incrementRowColumn({
12
12
  rowId: '<ROW_ID>',
13
13
  column: '',
14
14
  value: 0, // optional
15
- max: 0 // optional
15
+ max: 0, // optional
16
+ transactionId: '<TRANSACTION_ID>' // optional
16
17
  });
17
18
 
18
19
  console.log(result);
@@ -9,7 +9,8 @@ const tablesDB = new TablesDB(client);
9
9
  const result = await tablesDB.listRows({
10
10
  databaseId: '<DATABASE_ID>',
11
11
  tableId: '<TABLE_ID>',
12
- queries: [] // optional
12
+ queries: [], // optional
13
+ transactionId: '<TRANSACTION_ID>' // optional
13
14
  });
14
15
 
15
16
  console.log(result);
@@ -0,0 +1,13 @@
1
+ import { Client, TablesDB } from "react-native-appwrite";
2
+
3
+ const client = new Client()
4
+ .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint
5
+ .setProject('<YOUR_PROJECT_ID>'); // Your project ID
6
+
7
+ const tablesDB = new TablesDB(client);
8
+
9
+ const result = await tablesDB.listTransactions({
10
+ queries: [] // optional
11
+ });
12
+
13
+ console.log(result);
@@ -11,7 +11,8 @@ const result = await tablesDB.updateRow({
11
11
  tableId: '<TABLE_ID>',
12
12
  rowId: '<ROW_ID>',
13
13
  data: {}, // optional
14
- permissions: ["read("any")"] // optional
14
+ permissions: ["read("any")"], // optional
15
+ transactionId: '<TRANSACTION_ID>' // optional
15
16
  });
16
17
 
17
18
  console.log(result);
@@ -0,0 +1,15 @@
1
+ import { Client, TablesDB } from "react-native-appwrite";
2
+
3
+ const client = new Client()
4
+ .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint
5
+ .setProject('<YOUR_PROJECT_ID>'); // Your project ID
6
+
7
+ const tablesDB = new TablesDB(client);
8
+
9
+ const result = await tablesDB.updateTransaction({
10
+ transactionId: '<TRANSACTION_ID>',
11
+ commit: false, // optional
12
+ rollback: false // optional
13
+ });
14
+
15
+ console.log(result);
@@ -11,7 +11,8 @@ const result = await tablesDB.upsertRow({
11
11
  tableId: '<TABLE_ID>',
12
12
  rowId: '<ROW_ID>',
13
13
  data: {}, // optional
14
- permissions: ["read("any")"] // optional
14
+ permissions: ["read("any")"], // optional
15
+ transactionId: '<TRANSACTION_ID>' // optional
15
16
  });
16
17
 
17
18
  console.log(result);
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "react-native-appwrite",
3
3
  "homepage": "https://appwrite.io/support",
4
4
  "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",
5
- "version": "0.16.0",
5
+ "version": "0.17.1",
6
6
  "license": "BSD-3-Clause",
7
7
  "main": "dist/cjs/sdk.js",
8
8
  "exports": {
package/src/client.ts CHANGED
@@ -115,7 +115,7 @@ class Client {
115
115
  'x-sdk-name': 'React Native',
116
116
  'x-sdk-platform': 'client',
117
117
  'x-sdk-language': 'reactnative',
118
- 'x-sdk-version': '0.16.0',
118
+ 'x-sdk-version': '0.17.1',
119
119
  'X-Appwrite-Response-Format': '1.8.0',
120
120
  };
121
121
 
package/src/models.ts CHANGED
@@ -215,6 +215,20 @@ export namespace Models {
215
215
  localeCodes: LocaleCode[];
216
216
  }
217
217
 
218
+ /**
219
+ * Transaction List
220
+ */
221
+ export type TransactionList = {
222
+ /**
223
+ * Total number of transactions that matched your query.
224
+ */
225
+ total: number;
226
+ /**
227
+ * List of transactions.
228
+ */
229
+ transactions: Transaction[];
230
+ }
231
+
218
232
  /**
219
233
  * Row
220
234
  */
@@ -1238,6 +1252,36 @@ export namespace Models {
1238
1252
  recoveryCode: boolean;
1239
1253
  }
1240
1254
 
1255
+ /**
1256
+ * Transaction
1257
+ */
1258
+ export type Transaction = {
1259
+ /**
1260
+ * Transaction ID.
1261
+ */
1262
+ $id: string;
1263
+ /**
1264
+ * Transaction creation time in ISO 8601 format.
1265
+ */
1266
+ $createdAt: string;
1267
+ /**
1268
+ * Transaction update date in ISO 8601 format.
1269
+ */
1270
+ $updatedAt: string;
1271
+ /**
1272
+ * Current status of the transaction. One of: pending, committing, committed, rolled_back, failed.
1273
+ */
1274
+ status: string;
1275
+ /**
1276
+ * Number of operations in the transaction.
1277
+ */
1278
+ operations: number;
1279
+ /**
1280
+ * Expiration time in ISO 8601 format.
1281
+ */
1282
+ expiresAt: string;
1283
+ }
1284
+
1241
1285
  /**
1242
1286
  * Subscriber
1243
1287
  */