react-native-appwrite 0.10.1 → 0.12.0

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 (126) hide show
  1. package/CHANGELOG.md +7 -1
  2. package/README.md +84 -3
  3. package/dist/cjs/sdk.js +1810 -1113
  4. package/dist/cjs/sdk.js.map +1 -1
  5. package/dist/esm/sdk.js +1810 -1114
  6. package/dist/esm/sdk.js.map +1 -1
  7. package/docs/examples/account/create-email-password-session.md +4 -4
  8. package/docs/examples/account/create-email-token.md +5 -5
  9. package/docs/examples/account/{create-magic-u-r-l-token.md → create-magic-url-token.md} +6 -6
  10. package/docs/examples/account/create-mfa-authenticator.md +3 -3
  11. package/docs/examples/account/create-mfa-challenge.md +3 -3
  12. package/docs/examples/account/create-mfa-recovery-codes.md +1 -1
  13. package/docs/examples/account/{create-o-auth2token.md → create-o-auth-2-session.md} +6 -6
  14. package/docs/examples/account/{create-o-auth2session.md → create-o-auth-2-token.md} +6 -6
  15. package/docs/examples/account/create-phone-token.md +4 -4
  16. package/docs/examples/account/create-push-target.md +5 -5
  17. package/docs/examples/account/create-recovery.md +4 -4
  18. package/docs/examples/account/create-session.md +4 -4
  19. package/docs/examples/account/create-verification.md +3 -3
  20. package/docs/examples/account/create.md +6 -6
  21. package/docs/examples/account/delete-identity.md +3 -3
  22. package/docs/examples/account/delete-mfa-authenticator.md +3 -3
  23. package/docs/examples/account/delete-push-target.md +3 -3
  24. package/docs/examples/account/delete-session.md +3 -3
  25. package/docs/examples/account/get-mfa-recovery-codes.md +1 -1
  26. package/docs/examples/account/get-session.md +3 -3
  27. package/docs/examples/account/list-identities.md +3 -3
  28. package/docs/examples/account/list-logs.md +3 -3
  29. package/docs/examples/account/list-mfa-factors.md +1 -1
  30. package/docs/examples/account/update-email.md +4 -4
  31. package/docs/examples/account/{update-magic-u-r-l-session.md → update-magic-url-session.md} +4 -4
  32. package/docs/examples/account/update-mfa-authenticator.md +4 -4
  33. package/docs/examples/account/update-mfa-challenge.md +4 -4
  34. package/docs/examples/account/update-mfa-recovery-codes.md +1 -1
  35. package/docs/examples/account/{update-m-f-a.md → update-mfa.md} +3 -3
  36. package/docs/examples/account/update-name.md +3 -3
  37. package/docs/examples/account/update-password.md +4 -4
  38. package/docs/examples/account/update-phone-session.md +4 -4
  39. package/docs/examples/account/update-phone-verification.md +4 -4
  40. package/docs/examples/account/update-phone.md +4 -4
  41. package/docs/examples/account/update-prefs.md +3 -3
  42. package/docs/examples/account/update-push-target.md +4 -4
  43. package/docs/examples/account/update-recovery.md +5 -5
  44. package/docs/examples/account/update-session.md +3 -3
  45. package/docs/examples/account/update-verification.md +4 -4
  46. package/docs/examples/avatars/get-browser.md +6 -6
  47. package/docs/examples/avatars/get-credit-card.md +6 -6
  48. package/docs/examples/avatars/get-favicon.md +3 -3
  49. package/docs/examples/avatars/get-flag.md +6 -6
  50. package/docs/examples/avatars/get-image.md +5 -5
  51. package/docs/examples/avatars/get-initials.md +6 -6
  52. package/docs/examples/avatars/{get-q-r.md → get-qr.md} +6 -6
  53. package/docs/examples/databases/create-document.md +8 -10
  54. package/docs/examples/databases/decrement-document-attribute.md +18 -0
  55. package/docs/examples/databases/delete-document.md +5 -5
  56. package/docs/examples/databases/get-document.md +6 -6
  57. package/docs/examples/databases/increment-document-attribute.md +18 -0
  58. package/docs/examples/databases/list-documents.md +5 -5
  59. package/docs/examples/databases/update-document.md +7 -7
  60. package/docs/examples/databases/upsert-document.md +7 -7
  61. package/docs/examples/functions/create-execution.md +9 -9
  62. package/docs/examples/functions/get-execution.md +4 -4
  63. package/docs/examples/functions/list-executions.md +4 -4
  64. package/docs/examples/graphql/mutation.md +3 -3
  65. package/docs/examples/graphql/query.md +3 -3
  66. package/docs/examples/messaging/create-subscriber.md +5 -5
  67. package/docs/examples/messaging/delete-subscriber.md +4 -4
  68. package/docs/examples/storage/create-file.md +6 -6
  69. package/docs/examples/storage/delete-file.md +4 -4
  70. package/docs/examples/storage/get-file-download.md +5 -5
  71. package/docs/examples/storage/get-file-preview.md +16 -16
  72. package/docs/examples/storage/get-file-view.md +5 -5
  73. package/docs/examples/storage/get-file.md +4 -4
  74. package/docs/examples/storage/list-files.md +5 -5
  75. package/docs/examples/storage/update-file.md +6 -6
  76. package/docs/examples/tablesdb/create-row.md +17 -0
  77. package/docs/examples/tablesdb/decrement-row-column.md +18 -0
  78. package/docs/examples/tablesdb/delete-row.md +15 -0
  79. package/docs/examples/tablesdb/get-row.md +16 -0
  80. package/docs/examples/tablesdb/increment-row-column.md +18 -0
  81. package/docs/examples/tablesdb/list-rows.md +15 -0
  82. package/docs/examples/tablesdb/update-row.md +17 -0
  83. package/docs/examples/tablesdb/upsert-row.md +17 -0
  84. package/docs/examples/teams/create-membership.md +9 -9
  85. package/docs/examples/teams/create.md +5 -5
  86. package/docs/examples/teams/delete-membership.md +4 -4
  87. package/docs/examples/teams/delete.md +3 -3
  88. package/docs/examples/teams/get-membership.md +4 -4
  89. package/docs/examples/teams/get-prefs.md +3 -3
  90. package/docs/examples/teams/get.md +3 -3
  91. package/docs/examples/teams/list-memberships.md +5 -5
  92. package/docs/examples/teams/list.md +4 -4
  93. package/docs/examples/teams/update-membership-status.md +6 -6
  94. package/docs/examples/teams/update-membership.md +5 -5
  95. package/docs/examples/teams/update-name.md +4 -4
  96. package/docs/examples/teams/update-prefs.md +4 -4
  97. package/package.json +1 -1
  98. package/src/client.ts +2 -2
  99. package/src/index.ts +1 -0
  100. package/src/models.ts +139 -21
  101. package/src/query.ts +95 -0
  102. package/src/services/account.ts +1518 -364
  103. package/src/services/avatars.ts +296 -87
  104. package/src/services/databases.ts +438 -55
  105. package/src/services/functions.ts +118 -23
  106. package/src/services/graphql.ts +54 -6
  107. package/src/services/locale.ts +16 -27
  108. package/src/services/messaging.ts +68 -9
  109. package/src/services/storage.ts +353 -84
  110. package/src/services/tables-db.ts +621 -0
  111. package/src/services/teams.ts +467 -106
  112. package/types/index.d.ts +1 -0
  113. package/types/models.d.ts +127 -62
  114. package/types/query.d.ts +77 -0
  115. package/types/services/account.d.ts +791 -337
  116. package/types/services/avatars.d.ts +175 -80
  117. package/types/services/databases.d.ts +220 -53
  118. package/types/services/functions.d.ts +65 -20
  119. package/types/services/graphql.d.ts +26 -4
  120. package/types/services/locale.d.ts +16 -27
  121. package/types/services/messaging.d.ts +35 -7
  122. package/types/services/storage.d.ts +209 -76
  123. package/types/services/tables-db.d.ts +245 -0
  124. package/types/services/teams.d.ts +261 -99
  125. /package/docs/examples/account/{create-j-w-t.md → create-jwt.md} +0 -0
  126. /package/docs/examples/locale/{list-countries-e-u.md → list-countries-eu.md} +0 -0
@@ -14,16 +14,47 @@ export class Databases extends Service {
14
14
  }
15
15
 
16
16
  /**
17
- * Get a list of all the user's documents in a given collection. You can use
18
- * the query params to filter your results.
17
+ * Get a list of all the user's documents in a given collection. You can use the query params to filter your results.
19
18
  *
20
- * @param {string} databaseId
21
- * @param {string} collectionId
22
- * @param {string[]} queries
19
+ * @param {string} params.databaseId - Database ID.
20
+ * @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).
21
+ * @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.
23
22
  * @throws {AppwriteException}
24
23
  * @returns {Promise}
25
- */
26
- listDocuments<Document extends Models.Document>(databaseId: string, collectionId: string, queries?: string[]): Promise<Models.DocumentList<Document>> {
24
+ * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.listRows` instead.
25
+ */
26
+ listDocuments<Document extends Models.Document = Models.DefaultDocument>(params: { databaseId: string, collectionId: string, queries?: string[] }): Promise<Models.DocumentList<Document>>;
27
+ /**
28
+ * Get a list of all the user's documents in a given collection. You can use the query params to filter your results.
29
+ *
30
+ * @param {string} databaseId - Database ID.
31
+ * @param {string} collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection).
32
+ * @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.
33
+ * @throws {AppwriteException}
34
+ * @returns {Promise<Models.DocumentList<Document>>}
35
+ * @deprecated Use the object parameter style method for a better developer experience.
36
+ */
37
+ listDocuments<Document extends Models.Document = Models.DefaultDocument>(databaseId: string, collectionId: string, queries?: string[]): Promise<Models.DocumentList<Document>>;
38
+ listDocuments<Document extends Models.Document = Models.DefaultDocument>(
39
+ paramsOrFirst: { databaseId: string, collectionId: string, queries?: string[] } | string,
40
+ ...rest: [(string)?, (string[])?]
41
+ ): Promise<Models.DocumentList<Document>> {
42
+ let params: { databaseId: string, collectionId: string, queries?: string[] };
43
+
44
+ if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) {
45
+ params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, queries?: string[] };
46
+ } else {
47
+ params = {
48
+ databaseId: paramsOrFirst as string,
49
+ collectionId: rest[0] as string,
50
+ queries: rest[1] as string[]
51
+ };
52
+ }
53
+
54
+ const databaseId = params.databaseId;
55
+ const collectionId = params.collectionId;
56
+ const queries = params.queries;
57
+
27
58
  if (typeof databaseId === 'undefined') {
28
59
  throw new AppwriteException('Missing required parameter: "databaseId"');
29
60
  }
@@ -45,20 +76,55 @@ export class Databases extends Service {
45
76
  }
46
77
 
47
78
  /**
48
- * Create a new Document. Before using this route, you should create a new
49
- * collection resource using either a [server
50
- * integration](https://appwrite.io/docs/server/databases#databasesCreateCollection)
51
- * API or directly from your database console.
79
+ * 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.
52
80
  *
53
- * @param {string} databaseId
54
- * @param {string} collectionId
55
- * @param {string} documentId
56
- * @param {object} data
57
- * @param {string[]} permissions
81
+ * @param {string} params.databaseId - Database ID.
82
+ * @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.
83
+ * @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.
84
+ * @param {Document extends Models.DefaultDocument ? Partial<Models.Document> & Record<string, any> : Partial<Models.Document> & Omit<Document, keyof Models.Document>} params.data - Document data as JSON object.
85
+ * @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).
58
86
  * @throws {AppwriteException}
59
87
  * @returns {Promise}
60
- */
61
- createDocument<Document extends Models.Document>(databaseId: string, collectionId: string, documentId: string, data: object, permissions?: string[]): Promise<Document> {
88
+ * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.createRow` instead.
89
+ */
90
+ createDocument<Document extends Models.Document = Models.DefaultDocument>(params: { databaseId: string, collectionId: string, documentId: string, data: Document extends Models.DefaultDocument ? Partial<Models.Document> & Record<string, any> : Partial<Models.Document> & Omit<Document, keyof Models.Document>, permissions?: string[] }): Promise<Document>;
91
+ /**
92
+ * 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.
93
+ *
94
+ * @param {string} databaseId - Database ID.
95
+ * @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.
96
+ * @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.
97
+ * @param {Document extends Models.DefaultDocument ? Partial<Models.Document> & Record<string, any> : Partial<Models.Document> & Omit<Document, keyof Models.Document>} data - Document data as JSON object.
98
+ * @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).
99
+ * @throws {AppwriteException}
100
+ * @returns {Promise<Document>}
101
+ * @deprecated Use the object parameter style method for a better developer experience.
102
+ */
103
+ createDocument<Document extends Models.Document = Models.DefaultDocument>(databaseId: string, collectionId: string, documentId: string, data: Document extends Models.DefaultDocument ? Partial<Models.Document> & Record<string, any> : Partial<Models.Document> & Omit<Document, keyof Models.Document>, permissions?: string[]): Promise<Document>;
104
+ createDocument<Document extends Models.Document = Models.DefaultDocument>(
105
+ paramsOrFirst: { databaseId: string, collectionId: string, documentId: string, data: Document extends Models.DefaultDocument ? Partial<Models.Document> & Record<string, any> : Partial<Models.Document> & Omit<Document, keyof Models.Document>, permissions?: string[] } | string,
106
+ ...rest: [(string)?, (string)?, (Document extends Models.DefaultDocument ? Partial<Models.Document> & Record<string, any> : Partial<Models.Document> & Omit<Document, keyof Models.Document>)?, (string[])?]
107
+ ): Promise<Document> {
108
+ let params: { databaseId: string, collectionId: string, documentId: string, data: Document extends Models.DefaultDocument ? Partial<Models.Document> & Record<string, any> : Partial<Models.Document> & Omit<Document, keyof Models.Document>, permissions?: string[] };
109
+
110
+ if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) {
111
+ params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, documentId: string, data: Document extends Models.DefaultDocument ? Partial<Models.Document> & Record<string, any> : Partial<Models.Document> & Omit<Document, keyof Models.Document>, permissions?: string[] };
112
+ } else {
113
+ params = {
114
+ databaseId: paramsOrFirst as string,
115
+ collectionId: rest[0] as string,
116
+ documentId: rest[1] as string,
117
+ data: rest[2] as Document extends Models.DefaultDocument ? Partial<Models.Document> & Record<string, any> : Partial<Models.Document> & Omit<Document, keyof Models.Document>,
118
+ permissions: rest[3] as string[]
119
+ };
120
+ }
121
+
122
+ const databaseId = params.databaseId;
123
+ const collectionId = params.collectionId;
124
+ const documentId = params.documentId;
125
+ const data = params.data;
126
+ const permissions = params.permissions;
127
+
62
128
  if (typeof databaseId === 'undefined') {
63
129
  throw new AppwriteException('Missing required parameter: "databaseId"');
64
130
  }
@@ -75,6 +141,9 @@ export class Databases extends Service {
75
141
  throw new AppwriteException('Missing required parameter: "data"');
76
142
  }
77
143
 
144
+ delete data?.$sequence;
145
+ delete data?.$collectionId;
146
+ delete data?.$databaseId;
78
147
  const apiPath = '/databases/{databaseId}/collections/{collectionId}/documents'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId);
79
148
  const payload: Payload = {};
80
149
 
@@ -97,17 +166,51 @@ export class Databases extends Service {
97
166
  }
98
167
 
99
168
  /**
100
- * Get a document by its unique ID. This endpoint response returns a JSON
101
- * object with the document data.
169
+ * Get a document by its unique ID. This endpoint response returns a JSON object with the document data.
102
170
  *
103
- * @param {string} databaseId
104
- * @param {string} collectionId
105
- * @param {string} documentId
106
- * @param {string[]} queries
171
+ * @param {string} params.databaseId - Database ID.
172
+ * @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).
173
+ * @param {string} params.documentId - Document ID.
174
+ * @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.
107
175
  * @throws {AppwriteException}
108
176
  * @returns {Promise}
109
- */
110
- getDocument<Document extends Models.Document>(databaseId: string, collectionId: string, documentId: string, queries?: string[]): Promise<Document> {
177
+ * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.getRow` instead.
178
+ */
179
+ getDocument<Document extends Models.Document = Models.DefaultDocument>(params: { databaseId: string, collectionId: string, documentId: string, queries?: string[] }): Promise<Document>;
180
+ /**
181
+ * Get a document by its unique ID. This endpoint response returns a JSON object with the document data.
182
+ *
183
+ * @param {string} databaseId - Database ID.
184
+ * @param {string} collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection).
185
+ * @param {string} documentId - Document ID.
186
+ * @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.
187
+ * @throws {AppwriteException}
188
+ * @returns {Promise<Document>}
189
+ * @deprecated Use the object parameter style method for a better developer experience.
190
+ */
191
+ getDocument<Document extends Models.Document = Models.DefaultDocument>(databaseId: string, collectionId: string, documentId: string, queries?: string[]): Promise<Document>;
192
+ getDocument<Document extends Models.Document = Models.DefaultDocument>(
193
+ paramsOrFirst: { databaseId: string, collectionId: string, documentId: string, queries?: string[] } | string,
194
+ ...rest: [(string)?, (string)?, (string[])?]
195
+ ): Promise<Document> {
196
+ let params: { databaseId: string, collectionId: string, documentId: string, queries?: string[] };
197
+
198
+ if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) {
199
+ params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, documentId: string, queries?: string[] };
200
+ } else {
201
+ params = {
202
+ databaseId: paramsOrFirst as string,
203
+ collectionId: rest[0] as string,
204
+ documentId: rest[1] as string,
205
+ queries: rest[2] as string[]
206
+ };
207
+ }
208
+
209
+ const databaseId = params.databaseId;
210
+ const collectionId = params.collectionId;
211
+ const documentId = params.documentId;
212
+ const queries = params.queries;
213
+
111
214
  if (typeof databaseId === 'undefined') {
112
215
  throw new AppwriteException('Missing required parameter: "databaseId"');
113
216
  }
@@ -133,24 +236,55 @@ export class Databases extends Service {
133
236
  }
134
237
 
135
238
  /**
136
- * **WARNING: Experimental Feature** - This endpoint is experimental and not
137
- * yet officially supported. It may be subject to breaking changes or removal
138
- * in future versions.
139
- *
140
- * Create or update a Document. Before using this route, you should create a
141
- * new collection resource using either a [server
142
- * integration](https://appwrite.io/docs/server/databases#databasesCreateCollection)
143
- * API or directly from your database console.
239
+ * 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.
144
240
  *
145
- * @param {string} databaseId
146
- * @param {string} collectionId
147
- * @param {string} documentId
148
- * @param {object} data
149
- * @param {string[]} permissions
241
+ * @param {string} params.databaseId - Database ID.
242
+ * @param {string} params.collectionId - Collection ID.
243
+ * @param {string} params.documentId - Document ID.
244
+ * @param {Document extends Models.DefaultDocument ? Partial<Models.Document> & Record<string, any> : Partial<Models.Document> & Partial<Omit<Document, keyof Models.Document>>} params.data - Document data as JSON object. Include all required attributes of the document to be created or updated.
245
+ * @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).
150
246
  * @throws {AppwriteException}
151
247
  * @returns {Promise}
152
- */
153
- upsertDocument<Document extends Models.Document>(databaseId: string, collectionId: string, documentId: string, data: object, permissions?: string[]): Promise<Document> {
248
+ * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.upsertRow` instead.
249
+ */
250
+ upsertDocument<Document extends Models.Document = Models.DefaultDocument>(params: { databaseId: string, collectionId: string, documentId: string, data: Document extends Models.DefaultDocument ? Partial<Models.Document> & Record<string, any> : Partial<Models.Document> & Partial<Omit<Document, keyof Models.Document>>, permissions?: string[] }): Promise<Document>;
251
+ /**
252
+ * 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.
253
+ *
254
+ * @param {string} databaseId - Database ID.
255
+ * @param {string} collectionId - Collection ID.
256
+ * @param {string} documentId - Document ID.
257
+ * @param {Document extends Models.DefaultDocument ? Partial<Models.Document> & Record<string, any> : Partial<Models.Document> & Partial<Omit<Document, keyof Models.Document>>} data - Document data as JSON object. Include all required attributes of the document to be created or updated.
258
+ * @param {string[]} permissions - An array of permissions strings. By default, the current permissions are inherited. [Learn more about permissions](https://appwrite.io/docs/permissions).
259
+ * @throws {AppwriteException}
260
+ * @returns {Promise<Document>}
261
+ * @deprecated Use the object parameter style method for a better developer experience.
262
+ */
263
+ upsertDocument<Document extends Models.Document = Models.DefaultDocument>(databaseId: string, collectionId: string, documentId: string, data: Document extends Models.DefaultDocument ? Partial<Models.Document> & Record<string, any> : Partial<Models.Document> & Partial<Omit<Document, keyof Models.Document>>, permissions?: string[]): Promise<Document>;
264
+ upsertDocument<Document extends Models.Document = Models.DefaultDocument>(
265
+ paramsOrFirst: { databaseId: string, collectionId: string, documentId: string, data: Document extends Models.DefaultDocument ? Partial<Models.Document> & Record<string, any> : Partial<Models.Document> & Partial<Omit<Document, keyof Models.Document>>, permissions?: string[] } | string,
266
+ ...rest: [(string)?, (string)?, (Document extends Models.DefaultDocument ? Partial<Models.Document> & Record<string, any> : Partial<Models.Document> & Partial<Omit<Document, keyof Models.Document>>)?, (string[])?]
267
+ ): Promise<Document> {
268
+ let params: { databaseId: string, collectionId: string, documentId: string, data: Document extends Models.DefaultDocument ? Partial<Models.Document> & Record<string, any> : Partial<Models.Document> & Partial<Omit<Document, keyof Models.Document>>, permissions?: string[] };
269
+
270
+ if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) {
271
+ params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, documentId: string, data: Document extends Models.DefaultDocument ? Partial<Models.Document> & Record<string, any> : Partial<Models.Document> & Partial<Omit<Document, keyof Models.Document>>, permissions?: string[] };
272
+ } else {
273
+ params = {
274
+ databaseId: paramsOrFirst as string,
275
+ collectionId: rest[0] as string,
276
+ documentId: rest[1] as string,
277
+ data: rest[2] as Document extends Models.DefaultDocument ? Partial<Models.Document> & Record<string, any> : Partial<Models.Document> & Partial<Omit<Document, keyof Models.Document>>,
278
+ permissions: rest[3] as string[]
279
+ };
280
+ }
281
+
282
+ const databaseId = params.databaseId;
283
+ const collectionId = params.collectionId;
284
+ const documentId = params.documentId;
285
+ const data = params.data;
286
+ const permissions = params.permissions;
287
+
154
288
  if (typeof databaseId === 'undefined') {
155
289
  throw new AppwriteException('Missing required parameter: "databaseId"');
156
290
  }
@@ -167,6 +301,9 @@ export class Databases extends Service {
167
301
  throw new AppwriteException('Missing required parameter: "data"');
168
302
  }
169
303
 
304
+ delete data?.$sequence;
305
+ delete data?.$collectionId;
306
+ delete data?.$databaseId;
170
307
  const apiPath = '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId).replace('{documentId}', documentId);
171
308
  const payload: Payload = {};
172
309
 
@@ -185,18 +322,55 @@ export class Databases extends Service {
185
322
  }
186
323
 
187
324
  /**
188
- * Update a document by its unique ID. Using the patch method you can pass
189
- * only specific fields that will get updated.
325
+ * Update a document by its unique ID. Using the patch method you can pass only specific fields that will get updated.
190
326
  *
191
- * @param {string} databaseId
192
- * @param {string} collectionId
193
- * @param {string} documentId
194
- * @param {object} data
195
- * @param {string[]} permissions
327
+ * @param {string} params.databaseId - Database ID.
328
+ * @param {string} params.collectionId - Collection ID.
329
+ * @param {string} params.documentId - Document ID.
330
+ * @param {Document extends Models.DefaultDocument ? Partial<Models.Document> & Record<string, any> : Partial<Models.Document> & Partial<Omit<Document, keyof Models.Document>>} params.data - Document data as JSON object. Include only attribute and value pairs to be updated.
331
+ * @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).
196
332
  * @throws {AppwriteException}
197
333
  * @returns {Promise}
198
- */
199
- updateDocument<Document extends Models.Document>(databaseId: string, collectionId: string, documentId: string, data?: object, permissions?: string[]): Promise<Document> {
334
+ * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.updateRow` instead.
335
+ */
336
+ updateDocument<Document extends Models.Document = Models.DefaultDocument>(params: { databaseId: string, collectionId: string, documentId: string, data?: Document extends Models.DefaultDocument ? Partial<Models.Document> & Record<string, any> : Partial<Models.Document> & Partial<Omit<Document, keyof Models.Document>>, permissions?: string[] }): Promise<Document>;
337
+ /**
338
+ * Update a document by its unique ID. Using the patch method you can pass only specific fields that will get updated.
339
+ *
340
+ * @param {string} databaseId - Database ID.
341
+ * @param {string} collectionId - Collection ID.
342
+ * @param {string} documentId - Document ID.
343
+ * @param {Document extends Models.DefaultDocument ? Partial<Models.Document> & Record<string, any> : Partial<Models.Document> & Partial<Omit<Document, keyof Models.Document>>} data - Document data as JSON object. Include only attribute and value pairs to be updated.
344
+ * @param {string[]} permissions - An array of permissions strings. By default, the current permissions are inherited. [Learn more about permissions](https://appwrite.io/docs/permissions).
345
+ * @throws {AppwriteException}
346
+ * @returns {Promise<Document>}
347
+ * @deprecated Use the object parameter style method for a better developer experience.
348
+ */
349
+ updateDocument<Document extends Models.Document = Models.DefaultDocument>(databaseId: string, collectionId: string, documentId: string, data?: Document extends Models.DefaultDocument ? Partial<Models.Document> & Record<string, any> : Partial<Models.Document> & Partial<Omit<Document, keyof Models.Document>>, permissions?: string[]): Promise<Document>;
350
+ updateDocument<Document extends Models.Document = Models.DefaultDocument>(
351
+ paramsOrFirst: { databaseId: string, collectionId: string, documentId: string, data?: Document extends Models.DefaultDocument ? Partial<Models.Document> & Record<string, any> : Partial<Models.Document> & Partial<Omit<Document, keyof Models.Document>>, permissions?: string[] } | string,
352
+ ...rest: [(string)?, (string)?, (Document extends Models.DefaultDocument ? Partial<Models.Document> & Record<string, any> : Partial<Models.Document> & Partial<Omit<Document, keyof Models.Document>>)?, (string[])?]
353
+ ): Promise<Document> {
354
+ let params: { databaseId: string, collectionId: string, documentId: string, data?: Document extends Models.DefaultDocument ? Partial<Models.Document> & Record<string, any> : Partial<Models.Document> & Partial<Omit<Document, keyof Models.Document>>, permissions?: string[] };
355
+
356
+ if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) {
357
+ params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, documentId: string, data?: Document extends Models.DefaultDocument ? Partial<Models.Document> & Record<string, any> : Partial<Models.Document> & Partial<Omit<Document, keyof Models.Document>>, permissions?: string[] };
358
+ } else {
359
+ params = {
360
+ databaseId: paramsOrFirst as string,
361
+ collectionId: rest[0] as string,
362
+ documentId: rest[1] as string,
363
+ data: rest[2] as Document extends Models.DefaultDocument ? Partial<Models.Document> & Record<string, any> : Partial<Models.Document> & Partial<Omit<Document, keyof Models.Document>>,
364
+ permissions: rest[3] as string[]
365
+ };
366
+ }
367
+
368
+ const databaseId = params.databaseId;
369
+ const collectionId = params.collectionId;
370
+ const documentId = params.documentId;
371
+ const data = params.data;
372
+ const permissions = params.permissions;
373
+
200
374
  if (typeof databaseId === 'undefined') {
201
375
  throw new AppwriteException('Missing required parameter: "databaseId"');
202
376
  }
@@ -209,6 +383,9 @@ export class Databases extends Service {
209
383
  throw new AppwriteException('Missing required parameter: "documentId"');
210
384
  }
211
385
 
386
+ delete data?.$sequence;
387
+ delete data?.$collectionId;
388
+ delete data?.$databaseId;
212
389
  const apiPath = '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId).replace('{documentId}', documentId);
213
390
  const payload: Payload = {};
214
391
 
@@ -229,13 +406,45 @@ export class Databases extends Service {
229
406
  /**
230
407
  * Delete a document by its unique ID.
231
408
  *
232
- * @param {string} databaseId
233
- * @param {string} collectionId
234
- * @param {string} documentId
409
+ * @param {string} params.databaseId - Database ID.
410
+ * @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).
411
+ * @param {string} params.documentId - Document ID.
235
412
  * @throws {AppwriteException}
236
413
  * @returns {Promise}
237
- */
238
- deleteDocument(databaseId: string, collectionId: string, documentId: string): Promise<{}> {
414
+ * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.deleteRow` instead.
415
+ */
416
+ deleteDocument(params: { databaseId: string, collectionId: string, documentId: string }): Promise<{}>;
417
+ /**
418
+ * Delete a document by its unique ID.
419
+ *
420
+ * @param {string} databaseId - Database ID.
421
+ * @param {string} collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection).
422
+ * @param {string} documentId - Document ID.
423
+ * @throws {AppwriteException}
424
+ * @returns {Promise<{}>}
425
+ * @deprecated Use the object parameter style method for a better developer experience.
426
+ */
427
+ deleteDocument(databaseId: string, collectionId: string, documentId: string): Promise<{}>;
428
+ deleteDocument(
429
+ paramsOrFirst: { databaseId: string, collectionId: string, documentId: string } | string,
430
+ ...rest: [(string)?, (string)?]
431
+ ): Promise<{}> {
432
+ let params: { databaseId: string, collectionId: string, documentId: string };
433
+
434
+ if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) {
435
+ params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, documentId: string };
436
+ } else {
437
+ params = {
438
+ databaseId: paramsOrFirst as string,
439
+ collectionId: rest[0] as string,
440
+ documentId: rest[1] as string
441
+ };
442
+ }
443
+
444
+ const databaseId = params.databaseId;
445
+ const collectionId = params.collectionId;
446
+ const documentId = params.documentId;
447
+
239
448
  if (typeof databaseId === 'undefined') {
240
449
  throw new AppwriteException('Missing required parameter: "databaseId"');
241
450
  }
@@ -256,4 +465,178 @@ export class Databases extends Service {
256
465
  'content-type': 'application/json',
257
466
  }, payload);
258
467
  }
468
+
469
+ /**
470
+ * Decrement a specific attribute of a document by a given value.
471
+ *
472
+ * @param {string} params.databaseId - Database ID.
473
+ * @param {string} params.collectionId - Collection ID.
474
+ * @param {string} params.documentId - Document ID.
475
+ * @param {string} params.attribute - Attribute key.
476
+ * @param {number} params.value - Value to increment the attribute by. The value must be a number.
477
+ * @param {number} params.min - Minimum value for the attribute. If the current value is lesser than this value, an exception will be thrown.
478
+ * @throws {AppwriteException}
479
+ * @returns {Promise}
480
+ * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.decrementRowColumn` instead.
481
+ */
482
+ decrementDocumentAttribute<Document extends Models.Document = Models.DefaultDocument>(params: { databaseId: string, collectionId: string, documentId: string, attribute: string, value?: number, min?: number }): Promise<Document>;
483
+ /**
484
+ * Decrement a specific attribute of a document by a given value.
485
+ *
486
+ * @param {string} databaseId - Database ID.
487
+ * @param {string} collectionId - Collection ID.
488
+ * @param {string} documentId - Document ID.
489
+ * @param {string} attribute - Attribute key.
490
+ * @param {number} value - Value to increment the attribute by. The value must be a number.
491
+ * @param {number} min - Minimum value for the attribute. If the current value is lesser than this value, an exception will be thrown.
492
+ * @throws {AppwriteException}
493
+ * @returns {Promise<Document>}
494
+ * @deprecated Use the object parameter style method for a better developer experience.
495
+ */
496
+ decrementDocumentAttribute<Document extends Models.Document = Models.DefaultDocument>(databaseId: string, collectionId: string, documentId: string, attribute: string, value?: number, min?: number): Promise<Document>;
497
+ decrementDocumentAttribute<Document extends Models.Document = Models.DefaultDocument>(
498
+ paramsOrFirst: { databaseId: string, collectionId: string, documentId: string, attribute: string, value?: number, min?: number } | string,
499
+ ...rest: [(string)?, (string)?, (string)?, (number)?, (number)?]
500
+ ): Promise<Document> {
501
+ let params: { databaseId: string, collectionId: string, documentId: string, attribute: string, value?: number, min?: number };
502
+
503
+ if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) {
504
+ params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, documentId: string, attribute: string, value?: number, min?: number };
505
+ } else {
506
+ params = {
507
+ databaseId: paramsOrFirst as string,
508
+ collectionId: rest[0] as string,
509
+ documentId: rest[1] as string,
510
+ attribute: rest[2] as string,
511
+ value: rest[3] as number,
512
+ min: rest[4] as number
513
+ };
514
+ }
515
+
516
+ const databaseId = params.databaseId;
517
+ const collectionId = params.collectionId;
518
+ const documentId = params.documentId;
519
+ const attribute = params.attribute;
520
+ const value = params.value;
521
+ const min = params.min;
522
+
523
+ if (typeof databaseId === 'undefined') {
524
+ throw new AppwriteException('Missing required parameter: "databaseId"');
525
+ }
526
+
527
+ if (typeof collectionId === 'undefined') {
528
+ throw new AppwriteException('Missing required parameter: "collectionId"');
529
+ }
530
+
531
+ if (typeof documentId === 'undefined') {
532
+ throw new AppwriteException('Missing required parameter: "documentId"');
533
+ }
534
+
535
+ if (typeof attribute === 'undefined') {
536
+ throw new AppwriteException('Missing required parameter: "attribute"');
537
+ }
538
+
539
+ const apiPath = '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}/{attribute}/decrement'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId).replace('{documentId}', documentId).replace('{attribute}', attribute);
540
+ const payload: Payload = {};
541
+
542
+ if (typeof value !== 'undefined') {
543
+ payload['value'] = value;
544
+ }
545
+
546
+ if (typeof min !== 'undefined') {
547
+ payload['min'] = min;
548
+ }
549
+
550
+ const uri = new URL(this.client.config.endpoint + apiPath);
551
+ return this.client.call('patch', uri, {
552
+ 'content-type': 'application/json',
553
+ }, payload);
554
+ }
555
+
556
+ /**
557
+ * Increment a specific attribute of a document by a given value.
558
+ *
559
+ * @param {string} params.databaseId - Database ID.
560
+ * @param {string} params.collectionId - Collection ID.
561
+ * @param {string} params.documentId - Document ID.
562
+ * @param {string} params.attribute - Attribute key.
563
+ * @param {number} params.value - Value to increment the attribute by. The value must be a number.
564
+ * @param {number} params.max - Maximum value for the attribute. If the current value is greater than this value, an error will be thrown.
565
+ * @throws {AppwriteException}
566
+ * @returns {Promise}
567
+ * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.incrementRowColumn` instead.
568
+ */
569
+ incrementDocumentAttribute<Document extends Models.Document = Models.DefaultDocument>(params: { databaseId: string, collectionId: string, documentId: string, attribute: string, value?: number, max?: number }): Promise<Document>;
570
+ /**
571
+ * Increment a specific attribute of a document by a given value.
572
+ *
573
+ * @param {string} databaseId - Database ID.
574
+ * @param {string} collectionId - Collection ID.
575
+ * @param {string} documentId - Document ID.
576
+ * @param {string} attribute - Attribute key.
577
+ * @param {number} value - Value to increment the attribute by. The value must be a number.
578
+ * @param {number} max - Maximum value for the attribute. If the current value is greater than this value, an error will be thrown.
579
+ * @throws {AppwriteException}
580
+ * @returns {Promise<Document>}
581
+ * @deprecated Use the object parameter style method for a better developer experience.
582
+ */
583
+ incrementDocumentAttribute<Document extends Models.Document = Models.DefaultDocument>(databaseId: string, collectionId: string, documentId: string, attribute: string, value?: number, max?: number): Promise<Document>;
584
+ incrementDocumentAttribute<Document extends Models.Document = Models.DefaultDocument>(
585
+ paramsOrFirst: { databaseId: string, collectionId: string, documentId: string, attribute: string, value?: number, max?: number } | string,
586
+ ...rest: [(string)?, (string)?, (string)?, (number)?, (number)?]
587
+ ): Promise<Document> {
588
+ let params: { databaseId: string, collectionId: string, documentId: string, attribute: string, value?: number, max?: number };
589
+
590
+ if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) {
591
+ params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, documentId: string, attribute: string, value?: number, max?: number };
592
+ } else {
593
+ params = {
594
+ databaseId: paramsOrFirst as string,
595
+ collectionId: rest[0] as string,
596
+ documentId: rest[1] as string,
597
+ attribute: rest[2] as string,
598
+ value: rest[3] as number,
599
+ max: rest[4] as number
600
+ };
601
+ }
602
+
603
+ const databaseId = params.databaseId;
604
+ const collectionId = params.collectionId;
605
+ const documentId = params.documentId;
606
+ const attribute = params.attribute;
607
+ const value = params.value;
608
+ const max = params.max;
609
+
610
+ if (typeof databaseId === 'undefined') {
611
+ throw new AppwriteException('Missing required parameter: "databaseId"');
612
+ }
613
+
614
+ if (typeof collectionId === 'undefined') {
615
+ throw new AppwriteException('Missing required parameter: "collectionId"');
616
+ }
617
+
618
+ if (typeof documentId === 'undefined') {
619
+ throw new AppwriteException('Missing required parameter: "documentId"');
620
+ }
621
+
622
+ if (typeof attribute === 'undefined') {
623
+ throw new AppwriteException('Missing required parameter: "attribute"');
624
+ }
625
+
626
+ const apiPath = '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}/{attribute}/increment'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId).replace('{documentId}', documentId).replace('{attribute}', attribute);
627
+ const payload: Payload = {};
628
+
629
+ if (typeof value !== 'undefined') {
630
+ payload['value'] = value;
631
+ }
632
+
633
+ if (typeof max !== 'undefined') {
634
+ payload['max'] = max;
635
+ }
636
+
637
+ const uri = new URL(this.client.config.endpoint + apiPath);
638
+ return this.client.call('patch', uri, {
639
+ 'content-type': 'application/json',
640
+ }, payload);
641
+ }
259
642
  };