react-native-appwrite 0.16.0 → 0.18.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 (64) hide show
  1. package/CHANGELOG.md +9 -0
  2. package/dist/cjs/sdk.js +707 -31
  3. package/dist/cjs/sdk.js.map +1 -1
  4. package/dist/esm/sdk.js +707 -32
  5. package/dist/esm/sdk.js.map +1 -1
  6. package/docs/examples/account/list-identities.md +2 -1
  7. package/docs/examples/account/list-logs.md +2 -1
  8. package/docs/examples/databases/create-document.md +3 -2
  9. package/docs/examples/databases/create-operations.md +24 -0
  10. package/docs/examples/databases/create-transaction.md +13 -0
  11. package/docs/examples/databases/decrement-document-attribute.md +2 -1
  12. package/docs/examples/databases/delete-document.md +2 -1
  13. package/docs/examples/databases/delete-transaction.md +13 -0
  14. package/docs/examples/databases/get-document.md +2 -1
  15. package/docs/examples/databases/get-transaction.md +13 -0
  16. package/docs/examples/databases/increment-document-attribute.md +2 -1
  17. package/docs/examples/databases/list-documents.md +3 -1
  18. package/docs/examples/databases/list-transactions.md +13 -0
  19. package/docs/examples/databases/update-document.md +3 -2
  20. package/docs/examples/databases/update-transaction.md +15 -0
  21. package/docs/examples/databases/upsert-document.md +3 -2
  22. package/docs/examples/functions/list-executions.md +2 -1
  23. package/docs/examples/storage/create-file.md +1 -1
  24. package/docs/examples/storage/list-files.md +2 -1
  25. package/docs/examples/storage/update-file.md +1 -1
  26. package/docs/examples/tablesdb/create-operations.md +24 -0
  27. package/docs/examples/tablesdb/create-row.md +3 -2
  28. package/docs/examples/tablesdb/create-transaction.md +13 -0
  29. package/docs/examples/tablesdb/decrement-row-column.md +2 -1
  30. package/docs/examples/tablesdb/delete-row.md +2 -1
  31. package/docs/examples/tablesdb/delete-transaction.md +13 -0
  32. package/docs/examples/tablesdb/get-row.md +2 -1
  33. package/docs/examples/tablesdb/get-transaction.md +13 -0
  34. package/docs/examples/tablesdb/increment-row-column.md +2 -1
  35. package/docs/examples/tablesdb/list-rows.md +3 -1
  36. package/docs/examples/tablesdb/list-transactions.md +13 -0
  37. package/docs/examples/tablesdb/update-row.md +3 -2
  38. package/docs/examples/tablesdb/update-transaction.md +15 -0
  39. package/docs/examples/tablesdb/upsert-row.md +3 -2
  40. package/docs/examples/teams/list-memberships.md +2 -1
  41. package/docs/examples/teams/list.md +2 -1
  42. package/package.json +2 -3
  43. package/src/client.ts +1 -1
  44. package/src/enums/execution-status.ts +1 -0
  45. package/src/index.ts +3 -0
  46. package/src/models.ts +45 -1
  47. package/src/operator.ts +308 -0
  48. package/src/query.ts +6 -6
  49. package/src/services/account.ts +30 -12
  50. package/src/services/databases.ts +422 -56
  51. package/src/services/functions.ts +15 -7
  52. package/src/services/storage.ts +15 -7
  53. package/src/services/tables-db.ts +422 -56
  54. package/src/services/teams.ts +30 -14
  55. package/types/enums/execution-status.d.ts +2 -1
  56. package/types/index.d.ts +3 -0
  57. package/types/models.d.ts +43 -1
  58. package/types/operator.d.ts +180 -0
  59. package/types/services/account.d.ts +8 -2
  60. package/types/services/databases.d.ts +158 -8
  61. package/types/services/functions.d.ts +4 -1
  62. package/types/services/storage.d.ts +4 -1
  63. package/types/services/tables-db.d.ts +158 -8
  64. package/types/services/teams.d.ts +8 -2
@@ -18,37 +18,41 @@ export class Teams extends Service {
18
18
  *
19
19
  * @param {string[]} params.queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: name, total, billingPlan
20
20
  * @param {string} params.search - Search term to filter your list results. Max length: 256 chars.
21
+ * @param {boolean} params.total - When set to false, the total count returned will be 0 and will not be calculated.
21
22
  * @throws {AppwriteException}
22
23
  * @returns {Promise}
23
24
  */
24
- list<Preferences extends Models.Preferences = Models.DefaultPreferences>(params?: { queries?: string[], search?: string }): Promise<Models.TeamList<Preferences>>;
25
+ list<Preferences extends Models.Preferences = Models.DefaultPreferences>(params?: { queries?: string[], search?: string, total?: boolean }): Promise<Models.TeamList<Preferences>>;
25
26
  /**
26
27
  * Get a list of all the teams in which the current user is a member. You can use the parameters to filter your results.
27
28
  *
28
29
  * @param {string[]} queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: name, total, billingPlan
29
30
  * @param {string} search - Search term to filter your list results. Max length: 256 chars.
31
+ * @param {boolean} total - When set to false, the total count returned will be 0 and will not be calculated.
30
32
  * @throws {AppwriteException}
31
33
  * @returns {Promise<Models.TeamList<Preferences>>}
32
34
  * @deprecated Use the object parameter style method for a better developer experience.
33
35
  */
34
- list<Preferences extends Models.Preferences = Models.DefaultPreferences>(queries?: string[], search?: string): Promise<Models.TeamList<Preferences>>;
36
+ list<Preferences extends Models.Preferences = Models.DefaultPreferences>(queries?: string[], search?: string, total?: boolean): Promise<Models.TeamList<Preferences>>;
35
37
  list<Preferences extends Models.Preferences = Models.DefaultPreferences>(
36
- paramsOrFirst?: { queries?: string[], search?: string } | string[],
37
- ...rest: [(string)?]
38
+ paramsOrFirst?: { queries?: string[], search?: string, total?: boolean } | string[],
39
+ ...rest: [(string)?, (boolean)?]
38
40
  ): Promise<Models.TeamList<Preferences>> {
39
- let params: { queries?: string[], search?: string };
41
+ let params: { queries?: string[], search?: string, total?: boolean };
40
42
 
41
43
  if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) {
42
- params = (paramsOrFirst || {}) as { queries?: string[], search?: string };
44
+ params = (paramsOrFirst || {}) as { queries?: string[], search?: string, total?: boolean };
43
45
  } else {
44
46
  params = {
45
47
  queries: paramsOrFirst as string[],
46
- search: rest[0] as string
48
+ search: rest[0] as string,
49
+ total: rest[1] as boolean
47
50
  };
48
51
  }
49
52
 
50
53
  const queries = params.queries;
51
54
  const search = params.search;
55
+ const total = params.total;
52
56
 
53
57
  const apiPath = '/teams';
54
58
  const payload: Payload = {};
@@ -61,6 +65,10 @@ export class Teams extends Service {
61
65
  payload['search'] = search;
62
66
  }
63
67
 
68
+ if (typeof total !== 'undefined') {
69
+ payload['total'] = total;
70
+ }
71
+
64
72
  const uri = new URL(this.client.config.endpoint + apiPath);
65
73
  return this.client.call('get', uri, {
66
74
  }, payload);
@@ -289,40 +297,44 @@ export class Teams extends Service {
289
297
  * @param {string} params.teamId - Team ID.
290
298
  * @param {string[]} params.queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: userId, teamId, invited, joined, confirm, roles
291
299
  * @param {string} params.search - Search term to filter your list results. Max length: 256 chars.
300
+ * @param {boolean} params.total - When set to false, the total count returned will be 0 and will not be calculated.
292
301
  * @throws {AppwriteException}
293
302
  * @returns {Promise}
294
303
  */
295
- listMemberships(params: { teamId: string, queries?: string[], search?: string }): Promise<Models.MembershipList>;
304
+ listMemberships(params: { teamId: string, queries?: string[], search?: string, total?: boolean }): Promise<Models.MembershipList>;
296
305
  /**
297
306
  * Use this endpoint to list a team's members using the team's ID. All team members have read access to this endpoint. Hide sensitive attributes from the response by toggling membership privacy in the Console.
298
307
  *
299
308
  * @param {string} teamId - Team ID.
300
309
  * @param {string[]} queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: userId, teamId, invited, joined, confirm, roles
301
310
  * @param {string} search - Search term to filter your list results. Max length: 256 chars.
311
+ * @param {boolean} total - When set to false, the total count returned will be 0 and will not be calculated.
302
312
  * @throws {AppwriteException}
303
313
  * @returns {Promise<Models.MembershipList>}
304
314
  * @deprecated Use the object parameter style method for a better developer experience.
305
315
  */
306
- listMemberships(teamId: string, queries?: string[], search?: string): Promise<Models.MembershipList>;
316
+ listMemberships(teamId: string, queries?: string[], search?: string, total?: boolean): Promise<Models.MembershipList>;
307
317
  listMemberships(
308
- paramsOrFirst: { teamId: string, queries?: string[], search?: string } | string,
309
- ...rest: [(string[])?, (string)?]
318
+ paramsOrFirst: { teamId: string, queries?: string[], search?: string, total?: boolean } | string,
319
+ ...rest: [(string[])?, (string)?, (boolean)?]
310
320
  ): Promise<Models.MembershipList> {
311
- let params: { teamId: string, queries?: string[], search?: string };
321
+ let params: { teamId: string, queries?: string[], search?: string, total?: boolean };
312
322
 
313
323
  if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) {
314
- params = (paramsOrFirst || {}) as { teamId: string, queries?: string[], search?: string };
324
+ params = (paramsOrFirst || {}) as { teamId: string, queries?: string[], search?: string, total?: boolean };
315
325
  } else {
316
326
  params = {
317
327
  teamId: paramsOrFirst as string,
318
328
  queries: rest[0] as string[],
319
- search: rest[1] as string
329
+ search: rest[1] as string,
330
+ total: rest[2] as boolean
320
331
  };
321
332
  }
322
333
 
323
334
  const teamId = params.teamId;
324
335
  const queries = params.queries;
325
336
  const search = params.search;
337
+ const total = params.total;
326
338
 
327
339
  if (typeof teamId === 'undefined') {
328
340
  throw new AppwriteException('Missing required parameter: "teamId"');
@@ -339,6 +351,10 @@ export class Teams extends Service {
339
351
  payload['search'] = search;
340
352
  }
341
353
 
354
+ if (typeof total !== 'undefined') {
355
+ payload['total'] = total;
356
+ }
357
+
342
358
  const uri = new URL(this.client.config.endpoint + apiPath);
343
359
  return this.client.call('get', uri, {
344
360
  }, payload);
@@ -2,5 +2,6 @@ export declare enum ExecutionStatus {
2
2
  Waiting = "waiting",
3
3
  Processing = "processing",
4
4
  Completed = "completed",
5
- Failed = "failed"
5
+ Failed = "failed",
6
+ Scheduled = "scheduled"
6
7
  }
package/types/index.d.ts CHANGED
@@ -15,6 +15,7 @@ export { Query } from './query';
15
15
  export { Permission } from './permission';
16
16
  export { Role } from './role';
17
17
  export { ID } from './id';
18
+ export { Operator, Condition } from './operator';
18
19
  export { AuthenticatorType } from './enums/authenticator-type';
19
20
  export { AuthenticationFactor } from './enums/authentication-factor';
20
21
  export { OAuthProvider } from './enums/o-auth-provider';
@@ -24,3 +25,5 @@ export { Flag } from './enums/flag';
24
25
  export { ExecutionMethod } from './enums/execution-method';
25
26
  export { ImageGravity } from './enums/image-gravity';
26
27
  export { ImageFormat } from './enums/image-format';
28
+ export { ExecutionTrigger } from './enums/execution-trigger';
29
+ export { ExecutionStatus } from './enums/execution-status';
package/types/models.d.ts CHANGED
@@ -197,6 +197,19 @@ export declare namespace Models {
197
197
  */
198
198
  localeCodes: LocaleCode[];
199
199
  };
200
+ /**
201
+ * Transaction List
202
+ */
203
+ export type TransactionList = {
204
+ /**
205
+ * Total number of transactions that matched your query.
206
+ */
207
+ total: number;
208
+ /**
209
+ * List of transactions.
210
+ */
211
+ transactions: Transaction[];
212
+ };
200
213
  /**
201
214
  * Row
202
215
  */
@@ -970,7 +983,7 @@ export declare namespace Models {
970
983
  */
971
984
  trigger: ExecutionTrigger;
972
985
  /**
973
- * The status of the function execution. Possible values can be: `waiting`, `processing`, `completed`, or `failed`.
986
+ * The status of the function execution. Possible values can be: `waiting`, `processing`, `completed`, `failed`, or `scheduled`.
974
987
  */
975
988
  status: ExecutionStatus;
976
989
  /**
@@ -1184,6 +1197,35 @@ export declare namespace Models {
1184
1197
  */
1185
1198
  recoveryCode: boolean;
1186
1199
  };
1200
+ /**
1201
+ * Transaction
1202
+ */
1203
+ export type Transaction = {
1204
+ /**
1205
+ * Transaction ID.
1206
+ */
1207
+ $id: string;
1208
+ /**
1209
+ * Transaction creation time in ISO 8601 format.
1210
+ */
1211
+ $createdAt: string;
1212
+ /**
1213
+ * Transaction update date in ISO 8601 format.
1214
+ */
1215
+ $updatedAt: string;
1216
+ /**
1217
+ * Current status of the transaction. One of: pending, committing, committed, rolled_back, failed.
1218
+ */
1219
+ status: string;
1220
+ /**
1221
+ * Number of operations in the transaction.
1222
+ */
1223
+ operations: number;
1224
+ /**
1225
+ * Expiration time in ISO 8601 format.
1226
+ */
1227
+ expiresAt: string;
1228
+ };
1187
1229
  /**
1188
1230
  * Subscriber
1189
1231
  */
@@ -0,0 +1,180 @@
1
+ type OperatorValuesSingle = string | number | boolean;
2
+ export type OperatorValuesList = string[] | number[] | boolean[] | any[];
3
+ export type OperatorValues = OperatorValuesSingle | OperatorValuesList;
4
+ export declare enum Condition {
5
+ Equal = "equal",
6
+ NotEqual = "notEqual",
7
+ GreaterThan = "greaterThan",
8
+ GreaterThanEqual = "greaterThanEqual",
9
+ LessThan = "lessThan",
10
+ LessThanEqual = "lessThanEqual",
11
+ Contains = "contains",
12
+ IsNull = "isNull",
13
+ IsNotNull = "isNotNull"
14
+ }
15
+ /**
16
+ * Helper class to generate operator strings for atomic operations.
17
+ */
18
+ export declare class Operator {
19
+ method: string;
20
+ values: OperatorValuesList | undefined;
21
+ /**
22
+ * Constructor for Operator class.
23
+ *
24
+ * @param {string} method
25
+ * @param {OperatorValues} values
26
+ */
27
+ constructor(method: string, values?: OperatorValues);
28
+ /**
29
+ * Convert the operator object to a JSON string.
30
+ *
31
+ * @returns {string}
32
+ */
33
+ toString(): string;
34
+ /**
35
+ * Increment a numeric attribute by a specified value.
36
+ *
37
+ * @param {number} value
38
+ * @param {number} max
39
+ * @returns {string}
40
+ */
41
+ static increment: (value?: number, max?: number) => string;
42
+ /**
43
+ * Decrement a numeric attribute by a specified value.
44
+ *
45
+ * @param {number} value
46
+ * @param {number} min
47
+ * @returns {string}
48
+ */
49
+ static decrement: (value?: number, min?: number) => string;
50
+ /**
51
+ * Multiply a numeric attribute by a specified factor.
52
+ *
53
+ * @param {number} factor
54
+ * @param {number} max
55
+ * @returns {string}
56
+ */
57
+ static multiply: (factor: number, max?: number) => string;
58
+ /**
59
+ * Divide a numeric attribute by a specified divisor.
60
+ *
61
+ * @param {number} divisor
62
+ * @param {number} min
63
+ * @returns {string}
64
+ */
65
+ static divide: (divisor: number, min?: number) => string;
66
+ /**
67
+ * Apply modulo operation on a numeric attribute.
68
+ *
69
+ * @param {number} divisor
70
+ * @returns {string}
71
+ */
72
+ static modulo: (divisor: number) => string;
73
+ /**
74
+ * Raise a numeric attribute to a specified power.
75
+ *
76
+ * @param {number} exponent
77
+ * @param {number} max
78
+ * @returns {string}
79
+ */
80
+ static power: (exponent: number, max?: number) => string;
81
+ /**
82
+ * Append values to an array attribute.
83
+ *
84
+ * @param {any[]} values
85
+ * @returns {string}
86
+ */
87
+ static arrayAppend: (values: any[]) => string;
88
+ /**
89
+ * Prepend values to an array attribute.
90
+ *
91
+ * @param {any[]} values
92
+ * @returns {string}
93
+ */
94
+ static arrayPrepend: (values: any[]) => string;
95
+ /**
96
+ * Insert a value at a specific index in an array attribute.
97
+ *
98
+ * @param {number} index
99
+ * @param {any} value
100
+ * @returns {string}
101
+ */
102
+ static arrayInsert: (index: number, value: any) => string;
103
+ /**
104
+ * Remove a value from an array attribute.
105
+ *
106
+ * @param {any} value
107
+ * @returns {string}
108
+ */
109
+ static arrayRemove: (value: any) => string;
110
+ /**
111
+ * Remove duplicate values from an array attribute.
112
+ *
113
+ * @returns {string}
114
+ */
115
+ static arrayUnique: () => string;
116
+ /**
117
+ * Keep only values that exist in both the current array and the provided array.
118
+ *
119
+ * @param {any[]} values
120
+ * @returns {string}
121
+ */
122
+ static arrayIntersect: (values: any[]) => string;
123
+ /**
124
+ * Remove values from the array that exist in the provided array.
125
+ *
126
+ * @param {any[]} values
127
+ * @returns {string}
128
+ */
129
+ static arrayDiff: (values: any[]) => string;
130
+ /**
131
+ * Filter array values based on a condition.
132
+ *
133
+ * @param {Condition} condition
134
+ * @param {any} value
135
+ * @returns {string}
136
+ */
137
+ static arrayFilter: (condition: Condition, value?: any) => string;
138
+ /**
139
+ * Concatenate a value to a string or array attribute.
140
+ *
141
+ * @param {any} value
142
+ * @returns {string}
143
+ */
144
+ static stringConcat: (value: any) => string;
145
+ /**
146
+ * Replace occurrences of a search string with a replacement string.
147
+ *
148
+ * @param {string} search
149
+ * @param {string} replace
150
+ * @returns {string}
151
+ */
152
+ static stringReplace: (search: string, replace: string) => string;
153
+ /**
154
+ * Toggle a boolean attribute.
155
+ *
156
+ * @returns {string}
157
+ */
158
+ static toggle: () => string;
159
+ /**
160
+ * Add days to a date attribute.
161
+ *
162
+ * @param {number} days
163
+ * @returns {string}
164
+ */
165
+ static dateAddDays: (days: number) => string;
166
+ /**
167
+ * Subtract days from a date attribute.
168
+ *
169
+ * @param {number} days
170
+ * @returns {string}
171
+ */
172
+ static dateSubDays: (days: number) => string;
173
+ /**
174
+ * Set a date attribute to the current date and time.
175
+ *
176
+ * @returns {string}
177
+ */
178
+ static dateSetNow: () => string;
179
+ }
180
+ export {};
@@ -71,21 +71,24 @@ export declare class Account extends Service {
71
71
  * Get the list of identities for the currently logged in user.
72
72
  *
73
73
  * @param {string[]} params.queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: userId, provider, providerUid, providerEmail, providerAccessTokenExpiry
74
+ * @param {boolean} params.total - When set to false, the total count returned will be 0 and will not be calculated.
74
75
  * @throws {AppwriteException}
75
76
  * @returns {Promise}
76
77
  */
77
78
  listIdentities(params?: {
78
79
  queries?: string[];
80
+ total?: boolean;
79
81
  }): Promise<Models.IdentityList>;
80
82
  /**
81
83
  * Get the list of identities for the currently logged in user.
82
84
  *
83
85
  * @param {string[]} queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: userId, provider, providerUid, providerEmail, providerAccessTokenExpiry
86
+ * @param {boolean} total - When set to false, the total count returned will be 0 and will not be calculated.
84
87
  * @throws {AppwriteException}
85
88
  * @returns {Promise<Models.IdentityList>}
86
89
  * @deprecated Use the object parameter style method for a better developer experience.
87
90
  */
88
- listIdentities(queries?: string[]): Promise<Models.IdentityList>;
91
+ listIdentities(queries?: string[], total?: boolean): Promise<Models.IdentityList>;
89
92
  /**
90
93
  * Delete an identity by its unique ID.
91
94
  *
@@ -116,21 +119,24 @@ export declare class Account extends Service {
116
119
  * Get the list of latest security activity logs for the currently logged in user. Each log returns user IP address, location and date and time of log.
117
120
  *
118
121
  * @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). Only supported methods are limit and offset
122
+ * @param {boolean} params.total - When set to false, the total count returned will be 0 and will not be calculated.
119
123
  * @throws {AppwriteException}
120
124
  * @returns {Promise}
121
125
  */
122
126
  listLogs(params?: {
123
127
  queries?: string[];
128
+ total?: boolean;
124
129
  }): Promise<Models.LogList>;
125
130
  /**
126
131
  * Get the list of latest security activity logs for the currently logged in user. Each log returns user IP address, location and date and time of log.
127
132
  *
128
133
  * @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). Only supported methods are limit and offset
134
+ * @param {boolean} total - When set to false, the total count returned will be 0 and will not be calculated.
129
135
  * @throws {AppwriteException}
130
136
  * @returns {Promise<Models.LogList>}
131
137
  * @deprecated Use the object parameter style method for a better developer experience.
132
138
  */
133
- listLogs(queries?: string[]): Promise<Models.LogList>;
139
+ listLogs(queries?: string[], total?: boolean): Promise<Models.LogList>;
134
140
  /**
135
141
  * Enable or disable MFA on an account.
136
142
  *