react-native-appwrite 0.19.0 → 0.21.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 (156) hide show
  1. package/.github/workflows/publish.yml +9 -8
  2. package/CHANGELOG.md +12 -0
  3. package/LICENSE +1 -1
  4. package/README.md +3 -3
  5. package/dist/cjs/sdk.js +254 -64
  6. package/dist/cjs/sdk.js.map +1 -1
  7. package/dist/esm/sdk.js +250 -65
  8. package/dist/esm/sdk.js.map +1 -1
  9. package/docs/examples/account/create-anonymous-session.md +2 -0
  10. package/docs/examples/account/create-email-password-session.md +2 -0
  11. package/docs/examples/account/create-email-token.md +2 -0
  12. package/docs/examples/account/create-email-verification.md +2 -0
  13. package/docs/examples/account/create-jwt.md +5 -1
  14. package/docs/examples/account/create-magic-url-token.md +2 -0
  15. package/docs/examples/account/create-mfa-authenticator.md +2 -0
  16. package/docs/examples/account/create-mfa-challenge.md +2 -0
  17. package/docs/examples/account/create-mfa-recovery-codes.md +2 -0
  18. package/docs/examples/account/create-o-auth-2-session.md +2 -0
  19. package/docs/examples/account/create-o-auth-2-token.md +2 -0
  20. package/docs/examples/account/create-phone-token.md +2 -0
  21. package/docs/examples/account/create-phone-verification.md +2 -0
  22. package/docs/examples/account/create-push-target.md +2 -0
  23. package/docs/examples/account/create-recovery.md +2 -0
  24. package/docs/examples/account/create-session.md +2 -0
  25. package/docs/examples/account/create-verification.md +2 -0
  26. package/docs/examples/account/create.md +2 -0
  27. package/docs/examples/account/delete-identity.md +2 -0
  28. package/docs/examples/account/delete-mfa-authenticator.md +2 -0
  29. package/docs/examples/account/delete-push-target.md +2 -0
  30. package/docs/examples/account/delete-session.md +2 -0
  31. package/docs/examples/account/delete-sessions.md +2 -0
  32. package/docs/examples/account/get-mfa-recovery-codes.md +2 -0
  33. package/docs/examples/account/get-prefs.md +2 -0
  34. package/docs/examples/account/get-session.md +2 -0
  35. package/docs/examples/account/get.md +2 -0
  36. package/docs/examples/account/list-identities.md +2 -0
  37. package/docs/examples/account/list-logs.md +2 -0
  38. package/docs/examples/account/list-mfa-factors.md +2 -0
  39. package/docs/examples/account/list-sessions.md +2 -0
  40. package/docs/examples/account/update-email-verification.md +2 -0
  41. package/docs/examples/account/update-email.md +2 -0
  42. package/docs/examples/account/update-magic-url-session.md +2 -0
  43. package/docs/examples/account/update-mfa-authenticator.md +2 -0
  44. package/docs/examples/account/update-mfa-challenge.md +2 -0
  45. package/docs/examples/account/update-mfa-recovery-codes.md +2 -0
  46. package/docs/examples/account/update-mfa.md +2 -0
  47. package/docs/examples/account/update-name.md +2 -0
  48. package/docs/examples/account/update-password.md +2 -0
  49. package/docs/examples/account/update-phone-session.md +2 -0
  50. package/docs/examples/account/update-phone-verification.md +2 -0
  51. package/docs/examples/account/update-phone.md +2 -0
  52. package/docs/examples/account/update-prefs.md +2 -0
  53. package/docs/examples/account/update-push-target.md +2 -0
  54. package/docs/examples/account/update-recovery.md +2 -0
  55. package/docs/examples/account/update-session.md +2 -0
  56. package/docs/examples/account/update-status.md +2 -0
  57. package/docs/examples/account/update-verification.md +2 -0
  58. package/docs/examples/avatars/get-browser.md +2 -0
  59. package/docs/examples/avatars/get-credit-card.md +2 -0
  60. package/docs/examples/avatars/get-favicon.md +2 -0
  61. package/docs/examples/avatars/get-flag.md +2 -0
  62. package/docs/examples/avatars/get-image.md +2 -0
  63. package/docs/examples/avatars/get-initials.md +2 -0
  64. package/docs/examples/avatars/get-qr.md +2 -0
  65. package/docs/examples/avatars/get-screenshot.md +7 -5
  66. package/docs/examples/databases/create-document.md +2 -0
  67. package/docs/examples/databases/create-operations.md +2 -0
  68. package/docs/examples/databases/create-transaction.md +2 -0
  69. package/docs/examples/databases/decrement-document-attribute.md +2 -0
  70. package/docs/examples/databases/delete-document.md +2 -0
  71. package/docs/examples/databases/delete-transaction.md +2 -0
  72. package/docs/examples/databases/get-document.md +2 -0
  73. package/docs/examples/databases/get-transaction.md +2 -0
  74. package/docs/examples/databases/increment-document-attribute.md +2 -0
  75. package/docs/examples/databases/list-documents.md +2 -0
  76. package/docs/examples/databases/list-transactions.md +2 -0
  77. package/docs/examples/databases/update-document.md +9 -1
  78. package/docs/examples/databases/update-transaction.md +2 -0
  79. package/docs/examples/databases/upsert-document.md +9 -1
  80. package/docs/examples/functions/create-execution.md +2 -0
  81. package/docs/examples/functions/get-execution.md +2 -0
  82. package/docs/examples/functions/list-executions.md +2 -0
  83. package/docs/examples/graphql/mutation.md +2 -0
  84. package/docs/examples/graphql/query.md +2 -0
  85. package/docs/examples/locale/get.md +2 -0
  86. package/docs/examples/locale/list-codes.md +2 -0
  87. package/docs/examples/locale/list-continents.md +2 -0
  88. package/docs/examples/locale/list-countries-eu.md +2 -0
  89. package/docs/examples/locale/list-countries-phones.md +2 -0
  90. package/docs/examples/locale/list-countries.md +2 -0
  91. package/docs/examples/locale/list-currencies.md +2 -0
  92. package/docs/examples/locale/list-languages.md +2 -0
  93. package/docs/examples/messaging/create-subscriber.md +2 -0
  94. package/docs/examples/messaging/delete-subscriber.md +2 -0
  95. package/docs/examples/storage/create-file.md +2 -0
  96. package/docs/examples/storage/delete-file.md +2 -0
  97. package/docs/examples/storage/get-file-download.md +2 -0
  98. package/docs/examples/storage/get-file-preview.md +2 -0
  99. package/docs/examples/storage/get-file-view.md +2 -0
  100. package/docs/examples/storage/get-file.md +2 -0
  101. package/docs/examples/storage/list-files.md +2 -0
  102. package/docs/examples/storage/update-file.md +2 -0
  103. package/docs/examples/tablesdb/create-operations.md +2 -0
  104. package/docs/examples/tablesdb/create-row.md +2 -0
  105. package/docs/examples/tablesdb/create-transaction.md +2 -0
  106. package/docs/examples/tablesdb/decrement-row-column.md +2 -0
  107. package/docs/examples/tablesdb/delete-row.md +2 -0
  108. package/docs/examples/tablesdb/delete-transaction.md +2 -0
  109. package/docs/examples/tablesdb/get-row.md +2 -0
  110. package/docs/examples/tablesdb/get-transaction.md +2 -0
  111. package/docs/examples/tablesdb/increment-row-column.md +2 -0
  112. package/docs/examples/tablesdb/list-rows.md +2 -0
  113. package/docs/examples/tablesdb/list-transactions.md +2 -0
  114. package/docs/examples/tablesdb/update-row.md +9 -1
  115. package/docs/examples/tablesdb/update-transaction.md +2 -0
  116. package/docs/examples/tablesdb/upsert-row.md +9 -1
  117. package/docs/examples/teams/create-membership.md +2 -0
  118. package/docs/examples/teams/create.md +2 -0
  119. package/docs/examples/teams/delete-membership.md +2 -0
  120. package/docs/examples/teams/delete.md +2 -0
  121. package/docs/examples/teams/get-membership.md +2 -0
  122. package/docs/examples/teams/get-prefs.md +2 -0
  123. package/docs/examples/teams/get.md +2 -0
  124. package/docs/examples/teams/list-memberships.md +2 -0
  125. package/docs/examples/teams/list.md +2 -0
  126. package/docs/examples/teams/update-membership-status.md +2 -0
  127. package/docs/examples/teams/update-membership.md +2 -0
  128. package/docs/examples/teams/update-name.md +2 -0
  129. package/docs/examples/teams/update-prefs.md +2 -0
  130. package/package.json +6 -3
  131. package/rollup.config.js +3 -1
  132. package/src/channel.ts +132 -0
  133. package/src/client.ts +72 -10
  134. package/src/enums/browser-permission.ts +22 -0
  135. package/src/enums/o-auth-provider.ts +2 -1
  136. package/src/index.ts +3 -2
  137. package/src/models.ts +8 -0
  138. package/src/query.ts +54 -9
  139. package/src/services/account.ts +45 -16
  140. package/src/services/avatars.ts +20 -19
  141. package/src/services/databases.ts +5 -9
  142. package/src/services/graphql.ts +2 -2
  143. package/src/services/storage.ts +8 -8
  144. package/types/channel.d.ts +71 -0
  145. package/types/client.d.ts +2 -1
  146. package/types/enums/browser-permission.d.ts +22 -0
  147. package/types/enums/o-auth-provider.d.ts +2 -1
  148. package/types/index.d.ts +3 -2
  149. package/types/models.d.ts +8 -0
  150. package/types/query.d.ts +36 -6
  151. package/types/services/account.d.ts +17 -5
  152. package/types/services/avatars.d.ts +12 -11
  153. package/types/services/databases.d.ts +2 -2
  154. package/types/services/storage.d.ts +8 -8
  155. package/src/enums/output.ts +0 -9
  156. package/types/enums/output.d.ts +0 -9
package/dist/esm/sdk.js CHANGED
@@ -1,4 +1,6 @@
1
1
  import { Platform } from 'react-native';
2
+ import JSONbigModule from 'json-bigint';
3
+ import BigNumber from 'bignumber.js';
2
4
  import * as FileSystem from 'expo-file-system';
3
5
 
4
6
  /******************************************************************************
@@ -52,6 +54,28 @@ class Service {
52
54
  }
53
55
  Service.CHUNK_SIZE = 5 * 1024 * 1024; // 5MB
54
56
 
57
+ const JSONbigParser = JSONbigModule({ storeAsString: false });
58
+ const JSONbigSerializer = JSONbigModule({ useNativeBigInt: true });
59
+ const MAX_SAFE = BigInt(Number.MAX_SAFE_INTEGER);
60
+ const MIN_SAFE = BigInt(Number.MIN_SAFE_INTEGER);
61
+ function reviver(_key, value) {
62
+ if (BigNumber.isBigNumber(value)) {
63
+ if (value.isInteger()) {
64
+ const str = value.toFixed();
65
+ const bi = BigInt(str);
66
+ if (bi >= MIN_SAFE && bi <= MAX_SAFE) {
67
+ return Number(str);
68
+ }
69
+ return bi;
70
+ }
71
+ return value.toNumber();
72
+ }
73
+ return value;
74
+ }
75
+ const JSONbig$1 = {
76
+ parse: (text) => JSONbigParser.parse(text, reviver),
77
+ stringify: JSONbigSerializer.stringify
78
+ };
55
79
  class AppwriteException extends Error {
56
80
  constructor(message, code = 0, type = '', response = '') {
57
81
  super(message);
@@ -78,7 +102,7 @@ class Client {
78
102
  'x-sdk-name': 'React Native',
79
103
  'x-sdk-platform': 'client',
80
104
  'x-sdk-language': 'reactnative',
81
- 'x-sdk-version': '0.19.0',
105
+ 'x-sdk-version': '0.21.0',
82
106
  'X-Appwrite-Response-Format': '1.8.0',
83
107
  };
84
108
  this.realtime = {
@@ -87,6 +111,7 @@ class Client {
87
111
  heartbeat: undefined,
88
112
  url: '',
89
113
  channels: new Set(),
114
+ queries: new Set(),
90
115
  subscriptions: new Map(),
91
116
  subscriptionsCounter: 0,
92
117
  reconnect: true,
@@ -116,7 +141,7 @@ class Client {
116
141
  }
117
142
  this.realtime.heartbeat = window === null || window === void 0 ? void 0 : window.setInterval(() => {
118
143
  var _a;
119
- (_a = this.realtime.socket) === null || _a === void 0 ? void 0 : _a.send(JSON.stringify({
144
+ (_a = this.realtime.socket) === null || _a === void 0 ? void 0 : _a.send(JSONbig$1.stringify({
120
145
  type: 'ping'
121
146
  }));
122
147
  }, 20000);
@@ -133,6 +158,9 @@ class Client {
133
158
  this.realtime.channels.forEach(channel => {
134
159
  channels.append('channels[]', channel);
135
160
  });
161
+ this.realtime.queries.forEach(query => {
162
+ channels.append('queries[]', query);
163
+ });
136
164
  const url = this.config.endpointRealtime + '/realtime?' + channels.toString();
137
165
  if (url !== this.realtime.url || // Check if URL is present
138
166
  !this.realtime.socket || // Check if WebSocket has not been created
@@ -176,7 +204,7 @@ class Client {
176
204
  },
177
205
  onMessage: (event) => {
178
206
  try {
179
- const message = JSON.parse(event.data);
207
+ const message = JSONbig$1.parse(event.data);
180
208
  this.realtime.lastMessage = message;
181
209
  switch (message.type) {
182
210
  case 'event':
@@ -204,7 +232,7 @@ class Client {
204
232
  console.error(e);
205
233
  }
206
234
  },
207
- cleanUp: channels => {
235
+ cleanUp: (channels, queries) => {
208
236
  this.realtime.channels.forEach(channel => {
209
237
  if (channels.includes(channel)) {
210
238
  let found = Array.from(this.realtime.subscriptions).some(([_key, subscription]) => {
@@ -215,6 +243,17 @@ class Client {
215
243
  }
216
244
  }
217
245
  });
246
+ this.realtime.queries.forEach(query => {
247
+ if (queries.includes(query)) {
248
+ let found = Array.from(this.realtime.subscriptions).some(([_key, subscription]) => {
249
+ var _a;
250
+ return (_a = subscription.queries) === null || _a === void 0 ? void 0 : _a.includes(query);
251
+ });
252
+ if (!found) {
253
+ this.realtime.queries.delete(query);
254
+ }
255
+ }
256
+ });
218
257
  }
219
258
  };
220
259
  }
@@ -228,6 +267,9 @@ class Client {
228
267
  * @returns {this}
229
268
  */
230
269
  setEndpoint(endpoint) {
270
+ if (!endpoint || typeof endpoint !== 'string') {
271
+ throw new AppwriteException('Endpoint must be a valid string');
272
+ }
231
273
  if (!endpoint.startsWith('http://') && !endpoint.startsWith('https://')) {
232
274
  throw new AppwriteException('Invalid endpoint URL: ' + endpoint);
233
275
  }
@@ -243,6 +285,9 @@ class Client {
243
285
  * @returns {this}
244
286
  */
245
287
  setEndpointRealtime(endpointRealtime) {
288
+ if (!endpointRealtime || typeof endpointRealtime !== 'string') {
289
+ throw new AppwriteException('Endpoint must be a valid string');
290
+ }
246
291
  if (!endpointRealtime.startsWith('ws://') && !endpointRealtime.startsWith('wss://')) {
247
292
  throw new AppwriteException('Invalid realtime endpoint URL: ' + endpointRealtime);
248
293
  }
@@ -354,18 +399,21 @@ class Client {
354
399
  * @param {(payload: RealtimeMessage) => void} callback Is called on every realtime update.
355
400
  * @returns {() => void} Unsubscribes from events.
356
401
  */
357
- subscribe(channels, callback) {
402
+ subscribe(channels, callback, queries = []) {
358
403
  let channelArray = typeof channels === 'string' ? [channels] : channels;
359
404
  channelArray.forEach(channel => this.realtime.channels.add(channel));
405
+ const queryStrings = (queries !== null && queries !== void 0 ? queries : []).map(q => typeof q === 'string' ? q : q.toString());
406
+ queryStrings.forEach(query => this.realtime.queries.add(query));
360
407
  const counter = this.realtime.subscriptionsCounter++;
361
408
  this.realtime.subscriptions.set(counter, {
362
409
  channels: channelArray,
410
+ queries: queryStrings,
363
411
  callback
364
412
  });
365
413
  this.realtime.connect();
366
414
  return () => {
367
415
  this.realtime.subscriptions.delete(counter);
368
- this.realtime.cleanUp(channelArray);
416
+ this.realtime.cleanUp(channelArray, queryStrings);
369
417
  this.realtime.connect();
370
418
  };
371
419
  }
@@ -390,7 +438,7 @@ class Client {
390
438
  else {
391
439
  switch (headers['content-type']) {
392
440
  case 'application/json':
393
- options.body = JSON.stringify(params);
441
+ options.body = JSONbig$1.stringify(params);
394
442
  break;
395
443
  case 'multipart/form-data':
396
444
  let formData = new FormData();
@@ -417,7 +465,7 @@ class Client {
417
465
  warnings.split(';').forEach((warning) => console.warn('Warning: ' + warning));
418
466
  }
419
467
  if ((_a = response.headers.get('content-type')) === null || _a === void 0 ? void 0 : _a.includes('application/json')) {
420
- data = yield response.json();
468
+ data = JSONbig$1.parse(yield response.text());
421
469
  }
422
470
  else if (responseType === 'arrayBuffer') {
423
471
  data = yield response.arrayBuffer();
@@ -430,7 +478,7 @@ class Client {
430
478
  if (400 <= response.status) {
431
479
  let responseText = '';
432
480
  if ((_b = response.headers.get('content-type')) === null || _b === void 0 ? void 0 : _b.includes('application/json')) {
433
- responseText = JSON.stringify(data);
481
+ responseText = JSONbig$1.stringify(data);
434
482
  }
435
483
  else {
436
484
  responseText = data === null || data === void 0 ? void 0 : data.message;
@@ -592,15 +640,22 @@ class Account extends Service {
592
640
  'content-type': 'application/json',
593
641
  }, payload);
594
642
  }
595
- /**
596
- * Use this endpoint to create a JSON Web Token. You can use the resulting JWT to authenticate on behalf of the current user when working with the Appwrite server-side API and SDKs. The JWT secret is valid for 15 minutes from its creation and will be invalid if the user will logout in that time frame.
597
- *
598
- * @throws {AppwriteException}
599
- * @returns {Promise}
600
- */
601
- createJWT() {
643
+ createJWT(paramsOrFirst) {
644
+ let params;
645
+ if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) {
646
+ params = (paramsOrFirst || {});
647
+ }
648
+ else {
649
+ params = {
650
+ duration: paramsOrFirst
651
+ };
652
+ }
653
+ const duration = params.duration;
602
654
  const apiPath = '/account/jwts';
603
655
  const payload = {};
656
+ if (typeof duration !== 'undefined') {
657
+ payload['duration'] = duration;
658
+ }
604
659
  const uri = new URL(this.client.config.endpoint + apiPath);
605
660
  return this.client.call('post', uri, {
606
661
  'content-type': 'application/json',
@@ -656,7 +711,7 @@ class Account extends Service {
656
711
  }
657
712
  createMfaAuthenticator(paramsOrFirst) {
658
713
  let params;
659
- if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst) && 'type' in paramsOrFirst)) {
714
+ if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst) && ('type' in paramsOrFirst))) {
660
715
  params = (paramsOrFirst || {});
661
716
  }
662
717
  else {
@@ -677,7 +732,7 @@ class Account extends Service {
677
732
  }
678
733
  createMFAAuthenticator(paramsOrFirst) {
679
734
  let params;
680
- if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst) && 'type' in paramsOrFirst)) {
735
+ if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst) && ('type' in paramsOrFirst))) {
681
736
  params = (paramsOrFirst || {});
682
737
  }
683
738
  else {
@@ -698,7 +753,7 @@ class Account extends Service {
698
753
  }
699
754
  updateMfaAuthenticator(paramsOrFirst, ...rest) {
700
755
  let params;
701
- if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst) && 'type' in paramsOrFirst)) {
756
+ if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst) && ('type' in paramsOrFirst || 'otp' in paramsOrFirst))) {
702
757
  params = (paramsOrFirst || {});
703
758
  }
704
759
  else {
@@ -727,7 +782,7 @@ class Account extends Service {
727
782
  }
728
783
  updateMFAAuthenticator(paramsOrFirst, ...rest) {
729
784
  let params;
730
- if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst) && 'type' in paramsOrFirst)) {
785
+ if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst) && ('type' in paramsOrFirst || 'otp' in paramsOrFirst))) {
731
786
  params = (paramsOrFirst || {});
732
787
  }
733
788
  else {
@@ -756,7 +811,7 @@ class Account extends Service {
756
811
  }
757
812
  deleteMfaAuthenticator(paramsOrFirst) {
758
813
  let params;
759
- if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst) && 'type' in paramsOrFirst)) {
814
+ if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst) && ('type' in paramsOrFirst))) {
760
815
  params = (paramsOrFirst || {});
761
816
  }
762
817
  else {
@@ -777,7 +832,7 @@ class Account extends Service {
777
832
  }
778
833
  deleteMFAAuthenticator(paramsOrFirst) {
779
834
  let params;
780
- if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst) && 'type' in paramsOrFirst)) {
835
+ if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst) && ('type' in paramsOrFirst))) {
781
836
  params = (paramsOrFirst || {});
782
837
  }
783
838
  else {
@@ -798,7 +853,7 @@ class Account extends Service {
798
853
  }
799
854
  createMfaChallenge(paramsOrFirst) {
800
855
  let params;
801
- if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst) && 'factor' in paramsOrFirst)) {
856
+ if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst) && ('factor' in paramsOrFirst))) {
802
857
  params = (paramsOrFirst || {});
803
858
  }
804
859
  else {
@@ -822,7 +877,7 @@ class Account extends Service {
822
877
  }
823
878
  createMFAChallenge(paramsOrFirst) {
824
879
  let params;
825
- if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst) && 'factor' in paramsOrFirst)) {
880
+ if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst) && ('factor' in paramsOrFirst))) {
826
881
  params = (paramsOrFirst || {});
827
882
  }
828
883
  else {
@@ -1115,7 +1170,7 @@ class Account extends Service {
1115
1170
  }
1116
1171
  updatePrefs(paramsOrFirst) {
1117
1172
  let params;
1118
- if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst) && 'prefs' in paramsOrFirst)) {
1173
+ if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst) && ('prefs' in paramsOrFirst))) {
1119
1174
  params = (paramsOrFirst || {});
1120
1175
  }
1121
1176
  else {
@@ -1315,7 +1370,7 @@ class Account extends Service {
1315
1370
  }
1316
1371
  createOAuth2Session(paramsOrFirst, ...rest) {
1317
1372
  let params;
1318
- if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst) && 'provider' in paramsOrFirst)) {
1373
+ if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst) && ('provider' in paramsOrFirst || 'success' in paramsOrFirst || 'failure' in paramsOrFirst || 'scopes' in paramsOrFirst))) {
1319
1374
  params = (paramsOrFirst || {});
1320
1375
  }
1321
1376
  else {
@@ -1658,7 +1713,7 @@ class Account extends Service {
1658
1713
  }
1659
1714
  createOAuth2Token(paramsOrFirst, ...rest) {
1660
1715
  let params;
1661
- if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst) && 'provider' in paramsOrFirst)) {
1716
+ if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst) && ('provider' in paramsOrFirst || 'success' in paramsOrFirst || 'failure' in paramsOrFirst || 'scopes' in paramsOrFirst))) {
1662
1717
  params = (paramsOrFirst || {});
1663
1718
  }
1664
1719
  else {
@@ -1892,7 +1947,7 @@ class Avatars extends Service {
1892
1947
  }
1893
1948
  getBrowser(paramsOrFirst, ...rest) {
1894
1949
  let params;
1895
- if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst) && 'code' in paramsOrFirst)) {
1950
+ if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst) && ('code' in paramsOrFirst || 'width' in paramsOrFirst || 'height' in paramsOrFirst || 'quality' in paramsOrFirst))) {
1896
1951
  params = (paramsOrFirst || {});
1897
1952
  }
1898
1953
  else {
@@ -1930,7 +1985,7 @@ class Avatars extends Service {
1930
1985
  }
1931
1986
  getCreditCard(paramsOrFirst, ...rest) {
1932
1987
  let params;
1933
- if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst) && 'code' in paramsOrFirst)) {
1988
+ if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst) && ('code' in paramsOrFirst || 'width' in paramsOrFirst || 'height' in paramsOrFirst || 'quality' in paramsOrFirst))) {
1934
1989
  params = (paramsOrFirst || {});
1935
1990
  }
1936
1991
  else {
@@ -1994,7 +2049,7 @@ class Avatars extends Service {
1994
2049
  }
1995
2050
  getFlag(paramsOrFirst, ...rest) {
1996
2051
  let params;
1997
- if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst) && 'code' in paramsOrFirst)) {
2052
+ if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst) && ('code' in paramsOrFirst || 'width' in paramsOrFirst || 'height' in paramsOrFirst || 'quality' in paramsOrFirst))) {
1998
2053
  params = (paramsOrFirst || {});
1999
2054
  }
2000
2055
  else {
@@ -2547,12 +2602,12 @@ class Avatars extends Service {
2547
2602
  * @param {number} longitude
2548
2603
  * @param {number} accuracy
2549
2604
  * @param {boolean} touch
2550
- * @param {string[]} permissions
2605
+ * @param {BrowserPermission[]} permissions
2551
2606
  * @param {number} sleep
2552
2607
  * @param {number} width
2553
2608
  * @param {number} height
2554
2609
  * @param {number} quality
2555
- * @param {Output} output
2610
+ * @param {ImageFormat} output
2556
2611
  * @throws {AppwriteException}
2557
2612
  * @returns {URL}
2558
2613
  */
@@ -2929,9 +2984,6 @@ class Databases extends Service {
2929
2984
  if (typeof documentId === 'undefined') {
2930
2985
  throw new AppwriteException('Missing required parameter: "documentId"');
2931
2986
  }
2932
- if (typeof data === 'undefined') {
2933
- throw new AppwriteException('Missing required parameter: "data"');
2934
- }
2935
2987
  const apiPath = '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId).replace('{documentId}', documentId);
2936
2988
  const payload = {};
2937
2989
  if (typeof data !== 'undefined') {
@@ -3250,7 +3302,7 @@ class Graphql extends Service {
3250
3302
  }
3251
3303
  query(paramsOrFirst) {
3252
3304
  let params;
3253
- if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst) && 'query' in paramsOrFirst)) {
3305
+ if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst) && ('query' in paramsOrFirst))) {
3254
3306
  params = (paramsOrFirst || {});
3255
3307
  }
3256
3308
  else {
@@ -3275,7 +3327,7 @@ class Graphql extends Service {
3275
3327
  }
3276
3328
  mutation(paramsOrFirst) {
3277
3329
  let params;
3278
- if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst) && 'query' in paramsOrFirst)) {
3330
+ if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst) && ('query' in paramsOrFirst))) {
3279
3331
  params = (paramsOrFirst || {});
3280
3332
  }
3281
3333
  else {
@@ -4869,6 +4921,7 @@ class Teams extends Service {
4869
4921
  }
4870
4922
  }
4871
4923
 
4924
+ const JSONbig = JSONbigModule({ useNativeBigInt: true });
4872
4925
  class Query {
4873
4926
  constructor(method, attribute, values) {
4874
4927
  this.method = method;
@@ -4883,7 +4936,7 @@ class Query {
4883
4936
  }
4884
4937
  }
4885
4938
  toString() {
4886
- return JSON.stringify({
4939
+ return JSONbig.stringify({
4887
4940
  method: this.method,
4888
4941
  attribute: this.attribute,
4889
4942
  values: this.values,
@@ -4892,12 +4945,34 @@ class Query {
4892
4945
  }
4893
4946
  Query.equal = (attribute, value) => new Query("equal", attribute, value).toString();
4894
4947
  Query.notEqual = (attribute, value) => new Query("notEqual", attribute, value).toString();
4948
+ /**
4949
+ * Filter resources where attribute matches a regular expression pattern.
4950
+ *
4951
+ * @param {string} attribute The attribute to filter on.
4952
+ * @param {string} pattern The regular expression pattern to match.
4953
+ * @returns {string}
4954
+ */
4955
+ Query.regex = (attribute, pattern) => new Query("regex", attribute, pattern).toString();
4895
4956
  Query.lessThan = (attribute, value) => new Query("lessThan", attribute, value).toString();
4896
4957
  Query.lessThanEqual = (attribute, value) => new Query("lessThanEqual", attribute, value).toString();
4897
4958
  Query.greaterThan = (attribute, value) => new Query("greaterThan", attribute, value).toString();
4898
4959
  Query.greaterThanEqual = (attribute, value) => new Query("greaterThanEqual", attribute, value).toString();
4899
4960
  Query.isNull = (attribute) => new Query("isNull", attribute).toString();
4900
4961
  Query.isNotNull = (attribute) => new Query("isNotNull", attribute).toString();
4962
+ /**
4963
+ * Filter resources where the specified attributes exist.
4964
+ *
4965
+ * @param {string[]} attributes The list of attributes that must exist.
4966
+ * @returns {string}
4967
+ */
4968
+ Query.exists = (attributes) => new Query("exists", undefined, attributes).toString();
4969
+ /**
4970
+ * Filter resources where the specified attributes do not exist.
4971
+ *
4972
+ * @param {string[]} attributes The list of attributes that must not exist.
4973
+ * @returns {string}
4974
+ */
4975
+ Query.notExists = (attributes) => new Query("notExists", undefined, attributes).toString();
4901
4976
  Query.between = (attribute, start, end) => new Query("between", attribute, [start, end]).toString();
4902
4977
  Query.startsWith = (attribute, value) => new Query("startsWith", attribute, value).toString();
4903
4978
  Query.endsWith = (attribute, value) => new Query("endsWith", attribute, value).toString();
@@ -4939,8 +5014,8 @@ Query.notSearch = (attribute, value) => new Query("notSearch", attribute, value)
4939
5014
  * Filter resources where attribute is not between start and end (exclusive).
4940
5015
  *
4941
5016
  * @param {string} attribute
4942
- * @param {string | number} start
4943
- * @param {string | number} end
5017
+ * @param {string | number | bigint} start
5018
+ * @param {string | number | bigint} end
4944
5019
  * @returns {string}
4945
5020
  */
4946
5021
  Query.notBetween = (attribute, start, end) => new Query("notBetween", attribute, [start, end]).toString();
@@ -5004,8 +5079,16 @@ Query.updatedAfter = (value) => Query.greaterThan("$updatedAt", value);
5004
5079
  * @returns {string}
5005
5080
  */
5006
5081
  Query.updatedBetween = (start, end) => Query.between("$updatedAt", start, end);
5007
- Query.or = (queries) => new Query("or", undefined, queries.map((query) => JSON.parse(query))).toString();
5008
- Query.and = (queries) => new Query("and", undefined, queries.map((query) => JSON.parse(query))).toString();
5082
+ Query.or = (queries) => new Query("or", undefined, queries.map((query) => JSONbig.parse(query))).toString();
5083
+ Query.and = (queries) => new Query("and", undefined, queries.map((query) => JSONbig.parse(query))).toString();
5084
+ /**
5085
+ * Filter array elements where at least one element matches all the specified queries.
5086
+ *
5087
+ * @param {string} attribute The attribute containing the array to filter on.
5088
+ * @param {string[]} queries The list of query strings to match against array elements.
5089
+ * @returns {string}
5090
+ */
5091
+ Query.elemMatch = (attribute, queries) => new Query("elemMatch", attribute, queries.map((query) => JSONbig.parse(query))).toString();
5009
5092
  /**
5010
5093
  * Filter resources where attribute is at a specific distance from the given coordinates.
5011
5094
  *
@@ -5248,6 +5331,94 @@ _a = ID, _ID_hexTimestamp = function _ID_hexTimestamp() {
5248
5331
  return hexTimestamp;
5249
5332
  };
5250
5333
 
5334
+ function normalize(id) {
5335
+ const trimmed = id.trim();
5336
+ return trimmed === "" ? "*" : trimmed;
5337
+ }
5338
+ class Channel {
5339
+ constructor(segments) {
5340
+ this.segments = segments;
5341
+ }
5342
+ next(segment, id = "*") {
5343
+ return new Channel([...this.segments, segment, normalize(id)]);
5344
+ }
5345
+ resolve(action) {
5346
+ return new Channel([...this.segments, action]);
5347
+ }
5348
+ toString() {
5349
+ return this.segments.join(".");
5350
+ }
5351
+ // --- DATABASE ROUTE ---
5352
+ // Only available on Channel<Database>
5353
+ collection(id = "*") {
5354
+ return this.next("collections", id);
5355
+ }
5356
+ // Only available on Channel<Collection>
5357
+ document(id = "*") {
5358
+ return this.next("documents", id);
5359
+ }
5360
+ // --- TABLESDB ROUTE ---
5361
+ table(id = "*") {
5362
+ return this.next("tables", id);
5363
+ }
5364
+ row(id = "*") {
5365
+ return this.next("rows", id);
5366
+ }
5367
+ // --- BUCKET ROUTE ---
5368
+ file(id = "*") {
5369
+ return this.next("files", id);
5370
+ }
5371
+ // --- TERMINAL ACTIONS ---
5372
+ // Restricted to the Actionable union
5373
+ create() {
5374
+ return this.resolve("create");
5375
+ }
5376
+ update() {
5377
+ return this.resolve("update");
5378
+ }
5379
+ delete() {
5380
+ return this.resolve("delete");
5381
+ }
5382
+ // --- ROOT FACTORIES ---
5383
+ static database(id = "*") {
5384
+ return new Channel(["databases", normalize(id)]);
5385
+ }
5386
+ static tablesdb(id = "*") {
5387
+ return new Channel(["tablesdb", normalize(id)]);
5388
+ }
5389
+ static bucket(id = "*") {
5390
+ return new Channel(["buckets", normalize(id)]);
5391
+ }
5392
+ static function(id = "*") {
5393
+ return new Channel(["functions", normalize(id)]);
5394
+ }
5395
+ static execution(id = "*") {
5396
+ return new Channel(["executions", normalize(id)]);
5397
+ }
5398
+ static team(id = "*") {
5399
+ return new Channel(["teams", normalize(id)]);
5400
+ }
5401
+ static membership(id = "*") {
5402
+ return new Channel(["memberships", normalize(id)]);
5403
+ }
5404
+ static account() {
5405
+ return "account";
5406
+ }
5407
+ // Global events
5408
+ static get documents() {
5409
+ return "documents";
5410
+ }
5411
+ static get rows() {
5412
+ return "rows";
5413
+ }
5414
+ static get files() {
5415
+ return "files";
5416
+ }
5417
+ static get executions() {
5418
+ return "executions";
5419
+ }
5420
+ }
5421
+
5251
5422
  var Condition;
5252
5423
  (function (Condition) {
5253
5424
  Condition["Equal"] = "equal";
@@ -5567,7 +5738,8 @@ var OAuthProvider;
5567
5738
  OAuthProvider["Yandex"] = "yandex";
5568
5739
  OAuthProvider["Zoho"] = "zoho";
5569
5740
  OAuthProvider["Zoom"] = "zoom";
5570
- OAuthProvider["Mock"] = "mock";
5741
+ OAuthProvider["GithubImagine"] = "githubImagine";
5742
+ OAuthProvider["GoogleImagine"] = "googleImagine";
5571
5743
  })(OAuthProvider || (OAuthProvider = {}));
5572
5744
 
5573
5745
  var Browser;
@@ -6237,16 +6409,40 @@ var Timezone;
6237
6409
  Timezone["Utc"] = "utc";
6238
6410
  })(Timezone || (Timezone = {}));
6239
6411
 
6240
- var Output;
6241
- (function (Output) {
6242
- Output["Jpg"] = "jpg";
6243
- Output["Jpeg"] = "jpeg";
6244
- Output["Png"] = "png";
6245
- Output["Webp"] = "webp";
6246
- Output["Heic"] = "heic";
6247
- Output["Avif"] = "avif";
6248
- Output["Gif"] = "gif";
6249
- })(Output || (Output = {}));
6412
+ var BrowserPermission;
6413
+ (function (BrowserPermission) {
6414
+ BrowserPermission["Geolocation"] = "geolocation";
6415
+ BrowserPermission["Camera"] = "camera";
6416
+ BrowserPermission["Microphone"] = "microphone";
6417
+ BrowserPermission["Notifications"] = "notifications";
6418
+ BrowserPermission["Midi"] = "midi";
6419
+ BrowserPermission["Push"] = "push";
6420
+ BrowserPermission["ClipboardRead"] = "clipboard-read";
6421
+ BrowserPermission["ClipboardWrite"] = "clipboard-write";
6422
+ BrowserPermission["PaymentHandler"] = "payment-handler";
6423
+ BrowserPermission["Usb"] = "usb";
6424
+ BrowserPermission["Bluetooth"] = "bluetooth";
6425
+ BrowserPermission["Accelerometer"] = "accelerometer";
6426
+ BrowserPermission["Gyroscope"] = "gyroscope";
6427
+ BrowserPermission["Magnetometer"] = "magnetometer";
6428
+ BrowserPermission["AmbientLightSensor"] = "ambient-light-sensor";
6429
+ BrowserPermission["BackgroundSync"] = "background-sync";
6430
+ BrowserPermission["PersistentStorage"] = "persistent-storage";
6431
+ BrowserPermission["ScreenWakeLock"] = "screen-wake-lock";
6432
+ BrowserPermission["WebShare"] = "web-share";
6433
+ BrowserPermission["XrSpatialTracking"] = "xr-spatial-tracking";
6434
+ })(BrowserPermission || (BrowserPermission = {}));
6435
+
6436
+ var ImageFormat;
6437
+ (function (ImageFormat) {
6438
+ ImageFormat["Jpg"] = "jpg";
6439
+ ImageFormat["Jpeg"] = "jpeg";
6440
+ ImageFormat["Png"] = "png";
6441
+ ImageFormat["Webp"] = "webp";
6442
+ ImageFormat["Heic"] = "heic";
6443
+ ImageFormat["Avif"] = "avif";
6444
+ ImageFormat["Gif"] = "gif";
6445
+ })(ImageFormat || (ImageFormat = {}));
6250
6446
 
6251
6447
  var ExecutionMethod;
6252
6448
  (function (ExecutionMethod) {
@@ -6272,17 +6468,6 @@ var ImageGravity;
6272
6468
  ImageGravity["BottomRight"] = "bottom-right";
6273
6469
  })(ImageGravity || (ImageGravity = {}));
6274
6470
 
6275
- var ImageFormat;
6276
- (function (ImageFormat) {
6277
- ImageFormat["Jpg"] = "jpg";
6278
- ImageFormat["Jpeg"] = "jpeg";
6279
- ImageFormat["Png"] = "png";
6280
- ImageFormat["Webp"] = "webp";
6281
- ImageFormat["Heic"] = "heic";
6282
- ImageFormat["Avif"] = "avif";
6283
- ImageFormat["Gif"] = "gif";
6284
- })(ImageFormat || (ImageFormat = {}));
6285
-
6286
6471
  var ExecutionTrigger;
6287
6472
  (function (ExecutionTrigger) {
6288
6473
  ExecutionTrigger["Http"] = "http";
@@ -6299,5 +6484,5 @@ var ExecutionStatus;
6299
6484
  ExecutionStatus["Scheduled"] = "scheduled";
6300
6485
  })(ExecutionStatus || (ExecutionStatus = {}));
6301
6486
 
6302
- export { Account, AppwriteException, AuthenticationFactor, AuthenticatorType, Avatars, Browser, Client, Condition, CreditCard, Databases, ExecutionMethod, ExecutionStatus, ExecutionTrigger, Flag, Functions, Graphql, ID, ImageFormat, ImageGravity, Locale, Messaging, OAuthProvider, Operator, Output, Permission, Query, Role, Storage, TablesDB, Teams, Theme, Timezone };
6487
+ export { Account, AppwriteException, AuthenticationFactor, AuthenticatorType, Avatars, Browser, BrowserPermission, Channel, Client, Condition, CreditCard, Databases, ExecutionMethod, ExecutionStatus, ExecutionTrigger, Flag, Functions, Graphql, ID, ImageFormat, ImageGravity, Locale, Messaging, OAuthProvider, Operator, Permission, Query, Role, Storage, TablesDB, Teams, Theme, Timezone };
6303
6488
  //# sourceMappingURL=sdk.js.map