react-native-appwrite 0.20.0 → 0.23.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.
@@ -1,5 +1,5 @@
1
1
  ```javascript
2
- import { Client, Teams, Roles } from "react-native-appwrite";
2
+ import { Client, Teams } from "react-native-appwrite";
3
3
 
4
4
  const client = new Client()
5
5
  .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint
@@ -9,7 +9,7 @@ const teams = new Teams(client);
9
9
 
10
10
  const result = await teams.createMembership({
11
11
  teamId: '<TEAM_ID>',
12
- roles: [Roles.Admin],
12
+ roles: [],
13
13
  email: 'email@example.com', // optional
14
14
  userId: '<USER_ID>', // optional
15
15
  phone: '+12065550100', // optional
@@ -1,5 +1,5 @@
1
1
  ```javascript
2
- import { Client, Teams, Roles } from "react-native-appwrite";
2
+ import { Client, Teams } from "react-native-appwrite";
3
3
 
4
4
  const client = new Client()
5
5
  .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint
@@ -10,7 +10,7 @@ const teams = new Teams(client);
10
10
  const result = await teams.updateMembership({
11
11
  teamId: '<TEAM_ID>',
12
12
  membershipId: '<MEMBERSHIP_ID>',
13
- roles: [Roles.Admin]
13
+ roles: []
14
14
  });
15
15
 
16
16
  console.log(result);
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "react-native-appwrite",
3
3
  "homepage": "https://appwrite.io/support",
4
4
  "description": "Appwrite is an open-source self-hosted backend server that abstracts and simplifies complex and repetitive development tasks behind a very simple REST API",
5
- "version": "0.20.0",
5
+ "version": "0.23.0",
6
6
  "license": "BSD-3-Clause",
7
7
  "main": "dist/cjs/sdk.js",
8
8
  "exports": {
package/src/channel.ts CHANGED
@@ -13,7 +13,7 @@ interface Team { _team: any }
13
13
  interface Membership { _mem: any }
14
14
  interface Resolved { _res: any }
15
15
 
16
- type Actionable = Document | Row | File | Execution | Team | Membership;
16
+ type Actionable = Document | Row | File | Team | Membership;
17
17
 
18
18
  function normalize(id: string): string {
19
19
  const trimmed = id.trim();
@@ -62,11 +62,6 @@ export class Channel<T> {
62
62
  return this.next<File>("files", id);
63
63
  }
64
64
 
65
- // --- FUNCTION ROUTE ---
66
- execution(this: Channel<Func>, id: string = "*"): Channel<Execution> {
67
- return this.next<Execution>("executions", id);
68
- }
69
-
70
65
  // --- TERMINAL ACTIONS ---
71
66
  // Restricted to the Actionable union
72
67
  create(this: Channel<Actionable>): Channel<Resolved> {
@@ -98,6 +93,10 @@ export class Channel<T> {
98
93
  return new Channel<Func>(["functions", normalize(id)]);
99
94
  }
100
95
 
96
+ static execution(id: string = "*") {
97
+ return new Channel<Execution>(["executions", normalize(id)]);
98
+ }
99
+
101
100
  static team(id: string = "*") {
102
101
  return new Channel<Team>(["teams", normalize(id)]);
103
102
  }
@@ -106,27 +105,34 @@ export class Channel<T> {
106
105
  return new Channel<Membership>(["memberships", normalize(id)]);
107
106
  }
108
107
 
109
- static account(userId: string = ""): string {
110
- const id = normalize(userId);
111
- return id === "*" ? "account" : `account.${id}`;
108
+ static account(): string {
109
+ return "account";
112
110
  }
113
111
 
114
112
  // Global events
115
- static get documents(): string {
113
+ static documents(): string {
116
114
  return "documents";
117
115
  }
118
116
 
119
- static get rows(): string {
117
+ static rows(): string {
120
118
  return "rows";
121
119
  }
122
120
 
123
- static get files(): string {
121
+ static files(): string {
124
122
  return "files";
125
123
  }
126
124
 
127
- static get executions(): string {
125
+ static executions(): string {
128
126
  return "executions";
129
127
  }
128
+
129
+ static teams(): string {
130
+ return "teams";
131
+ }
132
+
133
+ static memberships(): string {
134
+ return "memberships";
135
+ }
130
136
  }
131
137
 
132
138
  // Export types for backward compatibility with realtime
package/src/client.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  import { Models } from './models';
2
2
  import { Service } from './service';
3
3
  import { Platform } from 'react-native';
4
+ import { Query } from './query';
4
5
  import JSONbigModule from 'json-bigint';
5
6
  import BigNumber from 'bignumber.js';
6
7
  const JSONbigParser = JSONbigModule({ storeAsString: false });
@@ -90,8 +91,10 @@ type Realtime = {
90
91
  url?: string;
91
92
  lastMessage?: RealtimeResponse;
92
93
  channels: Set<string>;
94
+ queries: Set<string>;
93
95
  subscriptions: Map<number, {
94
96
  channels: string[];
97
+ queries: string[];
95
98
  callback: (payload: RealtimeResponseEvent<any>) => void
96
99
  }>;
97
100
  subscriptionsCounter: number;
@@ -101,7 +104,7 @@ type Realtime = {
101
104
  connect: () => void;
102
105
  createSocket: () => void;
103
106
  createHeartbeat: () => void;
104
- cleanUp: (channels: string[]) => void;
107
+ cleanUp: (channels: string[], queries: string[]) => void;
105
108
  onMessage: (event: MessageEvent) => void;
106
109
  }
107
110
 
@@ -142,7 +145,7 @@ class Client {
142
145
  'x-sdk-name': 'React Native',
143
146
  'x-sdk-platform': 'client',
144
147
  'x-sdk-language': 'reactnative',
145
- 'x-sdk-version': '0.20.0',
148
+ 'x-sdk-version': '0.23.0',
146
149
  'X-Appwrite-Response-Format': '1.8.0',
147
150
  };
148
151
 
@@ -284,6 +287,7 @@ class Client {
284
287
  heartbeat: undefined,
285
288
  url: '',
286
289
  channels: new Set(),
290
+ queries: new Set(),
287
291
  subscriptions: new Map(),
288
292
  subscriptionsCounter: 0,
289
293
  reconnect: true,
@@ -330,6 +334,9 @@ class Client {
330
334
  this.realtime.channels.forEach(channel => {
331
335
  channels.append('channels[]', channel);
332
336
  });
337
+ this.realtime.queries.forEach(query => {
338
+ channels.append('queries[]', query);
339
+ });
333
340
 
334
341
  const url = this.config.endpointRealtime + '/realtime?' + channels.toString();
335
342
 
@@ -408,7 +415,7 @@ class Client {
408
415
  console.error(e);
409
416
  }
410
417
  },
411
- cleanUp: channels => {
418
+ cleanUp: (channels, queries) => {
412
419
  this.realtime.channels.forEach(channel => {
413
420
  if (channels.includes(channel)) {
414
421
  let found = Array.from(this.realtime.subscriptions).some(([_key, subscription] )=> {
@@ -420,6 +427,18 @@ class Client {
420
427
  }
421
428
  }
422
429
  })
430
+
431
+ this.realtime.queries.forEach(query => {
432
+ if (queries.includes(query)) {
433
+ let found = Array.from(this.realtime.subscriptions).some(([_key, subscription]) => {
434
+ return subscription.queries?.includes(query);
435
+ })
436
+
437
+ if (!found) {
438
+ this.realtime.queries.delete(query);
439
+ }
440
+ }
441
+ })
423
442
  }
424
443
  }
425
444
 
@@ -448,13 +467,21 @@ class Client {
448
467
  * @param {(payload: RealtimeMessage) => void} callback Is called on every realtime update.
449
468
  * @returns {() => void} Unsubscribes from events.
450
469
  */
451
- subscribe<T extends unknown>(channels: string | string[], callback: (payload: RealtimeResponseEvent<T>) => void): () => void {
470
+ subscribe<T extends unknown>(
471
+ channels: string | string[],
472
+ callback: (payload: RealtimeResponseEvent<T>) => void,
473
+ queries: (string | Query)[] = []
474
+ ): () => void {
452
475
  let channelArray = typeof channels === 'string' ? [channels] : channels;
453
476
  channelArray.forEach(channel => this.realtime.channels.add(channel));
454
477
 
478
+ const queryStrings = (queries ?? []).map(q => typeof q === 'string' ? q : q.toString());
479
+ queryStrings.forEach(query => this.realtime.queries.add(query));
480
+
455
481
  const counter = this.realtime.subscriptionsCounter++;
456
482
  this.realtime.subscriptions.set(counter, {
457
483
  channels: channelArray,
484
+ queries: queryStrings,
458
485
  callback
459
486
  });
460
487
 
@@ -462,7 +489,7 @@ class Client {
462
489
 
463
490
  return () => {
464
491
  this.realtime.subscriptions.delete(counter);
465
- this.realtime.cleanUp(channelArray);
492
+ this.realtime.cleanUp(channelArray, queryStrings);
466
493
  this.realtime.connect();
467
494
  }
468
495
  }
@@ -38,4 +38,6 @@ export enum OAuthProvider {
38
38
  Yandex = 'yandex',
39
39
  Zoho = 'zoho',
40
40
  Zoom = 'zoom',
41
+ GithubImagine = 'githubImagine',
42
+ GoogleImagine = 'googleImagine',
41
43
  }
package/src/index.ts CHANGED
@@ -29,6 +29,5 @@ export { BrowserPermission } from './enums/browser-permission';
29
29
  export { ImageFormat } from './enums/image-format';
30
30
  export { ExecutionMethod } from './enums/execution-method';
31
31
  export { ImageGravity } from './enums/image-gravity';
32
- export { Roles } from './enums/roles';
33
32
  export { ExecutionTrigger } from './enums/execution-trigger';
34
33
  export { ExecutionStatus } from './enums/execution-status';
@@ -447,7 +447,7 @@ export class Account extends Service {
447
447
  ): Promise<Models.MfaType> {
448
448
  let params: { type: AuthenticatorType };
449
449
 
450
- if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst) && 'type' in paramsOrFirst)) {
450
+ if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst) && ('type' in paramsOrFirst))) {
451
451
  params = (paramsOrFirst || {}) as { type: AuthenticatorType };
452
452
  } else {
453
453
  params = {
@@ -492,7 +492,7 @@ export class Account extends Service {
492
492
  ): Promise<Models.MfaType> {
493
493
  let params: { type: AuthenticatorType };
494
494
 
495
- if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst) && 'type' in paramsOrFirst)) {
495
+ if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst) && ('type' in paramsOrFirst))) {
496
496
  params = (paramsOrFirst || {}) as { type: AuthenticatorType };
497
497
  } else {
498
498
  params = {
@@ -541,7 +541,7 @@ export class Account extends Service {
541
541
  ): Promise<Models.User<Preferences>> {
542
542
  let params: { type: AuthenticatorType, otp: string };
543
543
 
544
- if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst) && 'type' in paramsOrFirst)) {
544
+ if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst) && ('type' in paramsOrFirst || 'otp' in paramsOrFirst))) {
545
545
  params = (paramsOrFirst || {}) as { type: AuthenticatorType, otp: string };
546
546
  } else {
547
547
  params = {
@@ -599,7 +599,7 @@ export class Account extends Service {
599
599
  ): Promise<Models.User<Preferences>> {
600
600
  let params: { type: AuthenticatorType, otp: string };
601
601
 
602
- if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst) && 'type' in paramsOrFirst)) {
602
+ if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst) && ('type' in paramsOrFirst || 'otp' in paramsOrFirst))) {
603
603
  params = (paramsOrFirst || {}) as { type: AuthenticatorType, otp: string };
604
604
  } else {
605
605
  params = {
@@ -655,7 +655,7 @@ export class Account extends Service {
655
655
  ): Promise<{}> {
656
656
  let params: { type: AuthenticatorType };
657
657
 
658
- if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst) && 'type' in paramsOrFirst)) {
658
+ if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst) && ('type' in paramsOrFirst))) {
659
659
  params = (paramsOrFirst || {}) as { type: AuthenticatorType };
660
660
  } else {
661
661
  params = {
@@ -700,7 +700,7 @@ export class Account extends Service {
700
700
  ): Promise<{}> {
701
701
  let params: { type: AuthenticatorType };
702
702
 
703
- if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst) && 'type' in paramsOrFirst)) {
703
+ if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst) && ('type' in paramsOrFirst))) {
704
704
  params = (paramsOrFirst || {}) as { type: AuthenticatorType };
705
705
  } else {
706
706
  params = {
@@ -746,7 +746,7 @@ export class Account extends Service {
746
746
  ): Promise<Models.MfaChallenge> {
747
747
  let params: { factor: AuthenticationFactor };
748
748
 
749
- if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst) && 'factor' in paramsOrFirst)) {
749
+ if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst) && ('factor' in paramsOrFirst))) {
750
750
  params = (paramsOrFirst || {}) as { factor: AuthenticationFactor };
751
751
  } else {
752
752
  params = {
@@ -795,7 +795,7 @@ export class Account extends Service {
795
795
  ): Promise<Models.MfaChallenge> {
796
796
  let params: { factor: AuthenticationFactor };
797
797
 
798
- if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst) && 'factor' in paramsOrFirst)) {
798
+ if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst) && ('factor' in paramsOrFirst))) {
799
799
  params = (paramsOrFirst || {}) as { factor: AuthenticationFactor };
800
800
  } else {
801
801
  params = {
@@ -1281,7 +1281,7 @@ export class Account extends Service {
1281
1281
  ): Promise<Models.User<Preferences>> {
1282
1282
  let params: { prefs: Partial<Preferences> };
1283
1283
 
1284
- if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst) && 'prefs' in paramsOrFirst)) {
1284
+ if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst) && ('prefs' in paramsOrFirst))) {
1285
1285
  params = (paramsOrFirst || {}) as { prefs: Partial<Preferences> };
1286
1286
  } else {
1287
1287
  params = {
@@ -1632,7 +1632,7 @@ export class Account extends Service {
1632
1632
  * A user is limited to 10 active sessions at a time by default. [Learn more about session limits](https://appwrite.io/docs/authentication-security#limits).
1633
1633
  *
1634
1634
  *
1635
- * @param {OAuthProvider} params.provider - OAuth2 Provider. Currently, supported providers are: amazon, apple, auth0, authentik, autodesk, bitbucket, bitly, box, dailymotion, discord, disqus, dropbox, etsy, facebook, figma, github, gitlab, google, linkedin, microsoft, notion, oidc, okta, paypal, paypalSandbox, podio, salesforce, slack, spotify, stripe, tradeshift, tradeshiftBox, twitch, wordpress, yahoo, yammer, yandex, zoho, zoom.
1635
+ * @param {OAuthProvider} params.provider - OAuth2 Provider. Currently, supported providers are: amazon, apple, auth0, authentik, autodesk, bitbucket, bitly, box, dailymotion, discord, disqus, dropbox, etsy, facebook, figma, github, gitlab, google, linkedin, microsoft, notion, oidc, okta, paypal, paypalSandbox, podio, salesforce, slack, spotify, stripe, tradeshift, tradeshiftBox, twitch, wordpress, yahoo, yammer, yandex, zoho, zoom, githubImagine, googleImagine.
1636
1636
  * @param {string} params.success - URL to redirect back to your app after a successful login attempt. Only URLs from hostnames in your project's platform list are allowed. This requirement helps to prevent an [open redirect](https://cheatsheetseries.owasp.org/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.html) attack against your project API.
1637
1637
  * @param {string} params.failure - URL to redirect back to your app after a failed login attempt. Only URLs from hostnames in your project's platform list are allowed. This requirement helps to prevent an [open redirect](https://cheatsheetseries.owasp.org/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.html) attack against your project API.
1638
1638
  * @param {string[]} params.scopes - A list of custom OAuth2 scopes. Check each provider internal docs for a list of supported scopes. Maximum of 100 scopes are allowed, each 4096 characters long.
@@ -1648,7 +1648,7 @@ export class Account extends Service {
1648
1648
  * A user is limited to 10 active sessions at a time by default. [Learn more about session limits](https://appwrite.io/docs/authentication-security#limits).
1649
1649
  *
1650
1650
  *
1651
- * @param {OAuthProvider} provider - OAuth2 Provider. Currently, supported providers are: amazon, apple, auth0, authentik, autodesk, bitbucket, bitly, box, dailymotion, discord, disqus, dropbox, etsy, facebook, figma, github, gitlab, google, linkedin, microsoft, notion, oidc, okta, paypal, paypalSandbox, podio, salesforce, slack, spotify, stripe, tradeshift, tradeshiftBox, twitch, wordpress, yahoo, yammer, yandex, zoho, zoom.
1651
+ * @param {OAuthProvider} provider - OAuth2 Provider. Currently, supported providers are: amazon, apple, auth0, authentik, autodesk, bitbucket, bitly, box, dailymotion, discord, disqus, dropbox, etsy, facebook, figma, github, gitlab, google, linkedin, microsoft, notion, oidc, okta, paypal, paypalSandbox, podio, salesforce, slack, spotify, stripe, tradeshift, tradeshiftBox, twitch, wordpress, yahoo, yammer, yandex, zoho, zoom, githubImagine, googleImagine.
1652
1652
  * @param {string} success - URL to redirect back to your app after a successful login attempt. Only URLs from hostnames in your project's platform list are allowed. This requirement helps to prevent an [open redirect](https://cheatsheetseries.owasp.org/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.html) attack against your project API.
1653
1653
  * @param {string} failure - URL to redirect back to your app after a failed login attempt. Only URLs from hostnames in your project's platform list are allowed. This requirement helps to prevent an [open redirect](https://cheatsheetseries.owasp.org/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.html) attack against your project API.
1654
1654
  * @param {string[]} scopes - A list of custom OAuth2 scopes. Check each provider internal docs for a list of supported scopes. Maximum of 100 scopes are allowed, each 4096 characters long.
@@ -1663,7 +1663,7 @@ export class Account extends Service {
1663
1663
  ): void | URL {
1664
1664
  let params: { provider: OAuthProvider, success?: string, failure?: string, scopes?: string[] };
1665
1665
 
1666
- if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst) && 'provider' in paramsOrFirst)) {
1666
+ if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst) && ('provider' in paramsOrFirst || 'success' in paramsOrFirst || 'failure' in paramsOrFirst || 'scopes' in paramsOrFirst))) {
1667
1667
  params = (paramsOrFirst || {}) as { provider: OAuthProvider, success?: string, failure?: string, scopes?: string[] };
1668
1668
  } else {
1669
1669
  params = {
@@ -2323,7 +2323,7 @@ export class Account extends Service {
2323
2323
  *
2324
2324
  * A user is limited to 10 active sessions at a time by default. [Learn more about session limits](https://appwrite.io/docs/authentication-security#limits).
2325
2325
  *
2326
- * @param {OAuthProvider} params.provider - OAuth2 Provider. Currently, supported providers are: amazon, apple, auth0, authentik, autodesk, bitbucket, bitly, box, dailymotion, discord, disqus, dropbox, etsy, facebook, figma, github, gitlab, google, linkedin, microsoft, notion, oidc, okta, paypal, paypalSandbox, podio, salesforce, slack, spotify, stripe, tradeshift, tradeshiftBox, twitch, wordpress, yahoo, yammer, yandex, zoho, zoom.
2326
+ * @param {OAuthProvider} params.provider - OAuth2 Provider. Currently, supported providers are: amazon, apple, auth0, authentik, autodesk, bitbucket, bitly, box, dailymotion, discord, disqus, dropbox, etsy, facebook, figma, github, gitlab, google, linkedin, microsoft, notion, oidc, okta, paypal, paypalSandbox, podio, salesforce, slack, spotify, stripe, tradeshift, tradeshiftBox, twitch, wordpress, yahoo, yammer, yandex, zoho, zoom, githubImagine, googleImagine.
2327
2327
  * @param {string} params.success - URL to redirect back to your app after a successful login attempt. Only URLs from hostnames in your project's platform list are allowed. This requirement helps to prevent an [open redirect](https://cheatsheetseries.owasp.org/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.html) attack against your project API.
2328
2328
  * @param {string} params.failure - URL to redirect back to your app after a failed login attempt. Only URLs from hostnames in your project's platform list are allowed. This requirement helps to prevent an [open redirect](https://cheatsheetseries.owasp.org/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.html) attack against your project API.
2329
2329
  * @param {string[]} params.scopes - A list of custom OAuth2 scopes. Check each provider internal docs for a list of supported scopes. Maximum of 100 scopes are allowed, each 4096 characters long.
@@ -2338,7 +2338,7 @@ export class Account extends Service {
2338
2338
  *
2339
2339
  * A user is limited to 10 active sessions at a time by default. [Learn more about session limits](https://appwrite.io/docs/authentication-security#limits).
2340
2340
  *
2341
- * @param {OAuthProvider} provider - OAuth2 Provider. Currently, supported providers are: amazon, apple, auth0, authentik, autodesk, bitbucket, bitly, box, dailymotion, discord, disqus, dropbox, etsy, facebook, figma, github, gitlab, google, linkedin, microsoft, notion, oidc, okta, paypal, paypalSandbox, podio, salesforce, slack, spotify, stripe, tradeshift, tradeshiftBox, twitch, wordpress, yahoo, yammer, yandex, zoho, zoom.
2341
+ * @param {OAuthProvider} provider - OAuth2 Provider. Currently, supported providers are: amazon, apple, auth0, authentik, autodesk, bitbucket, bitly, box, dailymotion, discord, disqus, dropbox, etsy, facebook, figma, github, gitlab, google, linkedin, microsoft, notion, oidc, okta, paypal, paypalSandbox, podio, salesforce, slack, spotify, stripe, tradeshift, tradeshiftBox, twitch, wordpress, yahoo, yammer, yandex, zoho, zoom, githubImagine, googleImagine.
2342
2342
  * @param {string} success - URL to redirect back to your app after a successful login attempt. Only URLs from hostnames in your project's platform list are allowed. This requirement helps to prevent an [open redirect](https://cheatsheetseries.owasp.org/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.html) attack against your project API.
2343
2343
  * @param {string} failure - URL to redirect back to your app after a failed login attempt. Only URLs from hostnames in your project's platform list are allowed. This requirement helps to prevent an [open redirect](https://cheatsheetseries.owasp.org/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.html) attack against your project API.
2344
2344
  * @param {string[]} scopes - A list of custom OAuth2 scopes. Check each provider internal docs for a list of supported scopes. Maximum of 100 scopes are allowed, each 4096 characters long.
@@ -2353,7 +2353,7 @@ export class Account extends Service {
2353
2353
  ): void | URL {
2354
2354
  let params: { provider: OAuthProvider, success?: string, failure?: string, scopes?: string[] };
2355
2355
 
2356
- if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst) && 'provider' in paramsOrFirst)) {
2356
+ if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst) && ('provider' in paramsOrFirst || 'success' in paramsOrFirst || 'failure' in paramsOrFirst || 'scopes' in paramsOrFirst))) {
2357
2357
  params = (paramsOrFirst || {}) as { provider: OAuthProvider, success?: string, failure?: string, scopes?: string[] };
2358
2358
  } else {
2359
2359
  params = {
@@ -53,7 +53,7 @@ export class Avatars extends Service {
53
53
  ): Promise<ArrayBuffer> {
54
54
  let params: { code: Browser, width?: number, height?: number, quality?: number };
55
55
 
56
- if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst) && 'code' in paramsOrFirst)) {
56
+ if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst) && ('code' in paramsOrFirst || 'width' in paramsOrFirst || 'height' in paramsOrFirst || 'quality' in paramsOrFirst))) {
57
57
  params = (paramsOrFirst || {}) as { code: Browser, width?: number, height?: number, quality?: number };
58
58
  } else {
59
59
  params = {
@@ -134,7 +134,7 @@ export class Avatars extends Service {
134
134
  ): Promise<ArrayBuffer> {
135
135
  let params: { code: CreditCard, width?: number, height?: number, quality?: number };
136
136
 
137
- if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst) && 'code' in paramsOrFirst)) {
137
+ if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst) && ('code' in paramsOrFirst || 'width' in paramsOrFirst || 'height' in paramsOrFirst || 'quality' in paramsOrFirst))) {
138
138
  params = (paramsOrFirst || {}) as { code: CreditCard, width?: number, height?: number, quality?: number };
139
139
  } else {
140
140
  params = {
@@ -273,7 +273,7 @@ export class Avatars extends Service {
273
273
  ): Promise<ArrayBuffer> {
274
274
  let params: { code: Flag, width?: number, height?: number, quality?: number };
275
275
 
276
- if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst) && 'code' in paramsOrFirst)) {
276
+ if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst) && ('code' in paramsOrFirst || 'width' in paramsOrFirst || 'height' in paramsOrFirst || 'quality' in paramsOrFirst))) {
277
277
  params = (paramsOrFirst || {}) as { code: Flag, width?: number, height?: number, quality?: number };
278
278
  } else {
279
279
  params = {
@@ -35,7 +35,7 @@ export class Graphql extends Service {
35
35
  ): Promise<{}> {
36
36
  let params: { query: object };
37
37
 
38
- if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst) && 'query' in paramsOrFirst)) {
38
+ if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst) && ('query' in paramsOrFirst))) {
39
39
  params = (paramsOrFirst || {}) as { query: object };
40
40
  } else {
41
41
  params = {
@@ -85,7 +85,7 @@ export class Graphql extends Service {
85
85
  ): Promise<{}> {
86
86
  let params: { query: object };
87
87
 
88
- if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst) && 'query' in paramsOrFirst)) {
88
+ if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst) && ('query' in paramsOrFirst))) {
89
89
  params = (paramsOrFirst || {}) as { query: object };
90
90
  } else {
91
91
  params = {
@@ -5,7 +5,6 @@ import type { UploadProgress, Payload } from '../client';
5
5
  import * as FileSystem from 'expo-file-system';
6
6
  import { Platform } from 'react-native';
7
7
 
8
- import { Roles } from '../enums/roles';
9
8
 
10
9
  export class Teams extends Service {
11
10
 
@@ -372,7 +371,7 @@ export class Teams extends Service {
372
371
  *
373
372
  *
374
373
  * @param {string} params.teamId - Team ID.
375
- * @param {Roles[]} params.roles - Array of strings. Use this param to set the user roles in the team. A role can be any string. Learn more about [roles and permissions](https://appwrite.io/docs/permissions). Maximum of 100 roles are allowed, each 32 characters long.
374
+ * @param {string[]} params.roles - Array of strings. Use this param to set the user roles in the team. A role can be any string. Learn more about [roles and permissions](https://appwrite.io/docs/permissions). Maximum of 100 roles are allowed, each 32 characters long.
376
375
  * @param {string} params.email - Email of the new team member.
377
376
  * @param {string} params.userId - ID of the user to be added to a team.
378
377
  * @param {string} params.phone - Phone number. Format this number with a leading '+' and a country code, e.g., +16175551212.
@@ -381,7 +380,7 @@ export class Teams extends Service {
381
380
  * @throws {AppwriteException}
382
381
  * @returns {Promise}
383
382
  */
384
- createMembership(params: { teamId: string, roles: Roles[], email?: string, userId?: string, phone?: string, url?: string, name?: string }): Promise<Models.Membership>;
383
+ createMembership(params: { teamId: string, roles: string[], email?: string, userId?: string, phone?: string, url?: string, name?: string }): Promise<Models.Membership>;
385
384
  /**
386
385
  * Invite a new member to join your team. Provide an ID for existing users, or invite unregistered users using an email or phone number. If initiated from a Client SDK, Appwrite will send an email or sms with a link to join the team to the invited user, and an account will be created for them if one doesn't exist. If initiated from a Server SDK, the new member will be added automatically to the team.
387
386
  *
@@ -393,7 +392,7 @@ export class Teams extends Service {
393
392
  *
394
393
  *
395
394
  * @param {string} teamId - Team ID.
396
- * @param {Roles[]} roles - Array of strings. Use this param to set the user roles in the team. A role can be any string. Learn more about [roles and permissions](https://appwrite.io/docs/permissions). Maximum of 100 roles are allowed, each 32 characters long.
395
+ * @param {string[]} roles - Array of strings. Use this param to set the user roles in the team. A role can be any string. Learn more about [roles and permissions](https://appwrite.io/docs/permissions). Maximum of 100 roles are allowed, each 32 characters long.
397
396
  * @param {string} email - Email of the new team member.
398
397
  * @param {string} userId - ID of the user to be added to a team.
399
398
  * @param {string} phone - Phone number. Format this number with a leading '+' and a country code, e.g., +16175551212.
@@ -403,19 +402,19 @@ export class Teams extends Service {
403
402
  * @returns {Promise<Models.Membership>}
404
403
  * @deprecated Use the object parameter style method for a better developer experience.
405
404
  */
406
- createMembership(teamId: string, roles: Roles[], email?: string, userId?: string, phone?: string, url?: string, name?: string): Promise<Models.Membership>;
405
+ createMembership(teamId: string, roles: string[], email?: string, userId?: string, phone?: string, url?: string, name?: string): Promise<Models.Membership>;
407
406
  createMembership(
408
- paramsOrFirst: { teamId: string, roles: Roles[], email?: string, userId?: string, phone?: string, url?: string, name?: string } | string,
409
- ...rest: [(Roles[])?, (string)?, (string)?, (string)?, (string)?, (string)?]
407
+ paramsOrFirst: { teamId: string, roles: string[], email?: string, userId?: string, phone?: string, url?: string, name?: string } | string,
408
+ ...rest: [(string[])?, (string)?, (string)?, (string)?, (string)?, (string)?]
410
409
  ): Promise<Models.Membership> {
411
- let params: { teamId: string, roles: Roles[], email?: string, userId?: string, phone?: string, url?: string, name?: string };
410
+ let params: { teamId: string, roles: string[], email?: string, userId?: string, phone?: string, url?: string, name?: string };
412
411
 
413
412
  if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) {
414
- params = (paramsOrFirst || {}) as { teamId: string, roles: Roles[], email?: string, userId?: string, phone?: string, url?: string, name?: string };
413
+ params = (paramsOrFirst || {}) as { teamId: string, roles: string[], email?: string, userId?: string, phone?: string, url?: string, name?: string };
415
414
  } else {
416
415
  params = {
417
416
  teamId: paramsOrFirst as string,
418
- roles: rest[0] as Roles[],
417
+ roles: rest[0] as string[],
419
418
  email: rest[1] as string,
420
419
  userId: rest[2] as string,
421
420
  phone: rest[3] as string,
@@ -532,36 +531,36 @@ export class Teams extends Service {
532
531
  *
533
532
  * @param {string} params.teamId - Team ID.
534
533
  * @param {string} params.membershipId - Membership ID.
535
- * @param {Roles[]} params.roles - An array of strings. Use this param to set the user's roles in the team. A role can be any string. Learn more about [roles and permissions](https://appwrite.io/docs/permissions). Maximum of 100 roles are allowed, each 32 characters long.
534
+ * @param {string[]} params.roles - An array of strings. Use this param to set the user's roles in the team. A role can be any string. Learn more about [roles and permissions](https://appwrite.io/docs/permissions). Maximum of 100 roles are allowed, each 32 characters long.
536
535
  * @throws {AppwriteException}
537
536
  * @returns {Promise}
538
537
  */
539
- updateMembership(params: { teamId: string, membershipId: string, roles: Roles[] }): Promise<Models.Membership>;
538
+ updateMembership(params: { teamId: string, membershipId: string, roles: string[] }): Promise<Models.Membership>;
540
539
  /**
541
540
  * Modify the roles of a team member. Only team members with the owner role have access to this endpoint. Learn more about [roles and permissions](https://appwrite.io/docs/permissions).
542
541
  *
543
542
  *
544
543
  * @param {string} teamId - Team ID.
545
544
  * @param {string} membershipId - Membership ID.
546
- * @param {Roles[]} roles - An array of strings. Use this param to set the user's roles in the team. A role can be any string. Learn more about [roles and permissions](https://appwrite.io/docs/permissions). Maximum of 100 roles are allowed, each 32 characters long.
545
+ * @param {string[]} roles - An array of strings. Use this param to set the user's roles in the team. A role can be any string. Learn more about [roles and permissions](https://appwrite.io/docs/permissions). Maximum of 100 roles are allowed, each 32 characters long.
547
546
  * @throws {AppwriteException}
548
547
  * @returns {Promise<Models.Membership>}
549
548
  * @deprecated Use the object parameter style method for a better developer experience.
550
549
  */
551
- updateMembership(teamId: string, membershipId: string, roles: Roles[]): Promise<Models.Membership>;
550
+ updateMembership(teamId: string, membershipId: string, roles: string[]): Promise<Models.Membership>;
552
551
  updateMembership(
553
- paramsOrFirst: { teamId: string, membershipId: string, roles: Roles[] } | string,
554
- ...rest: [(string)?, (Roles[])?]
552
+ paramsOrFirst: { teamId: string, membershipId: string, roles: string[] } | string,
553
+ ...rest: [(string)?, (string[])?]
555
554
  ): Promise<Models.Membership> {
556
- let params: { teamId: string, membershipId: string, roles: Roles[] };
555
+ let params: { teamId: string, membershipId: string, roles: string[] };
557
556
 
558
557
  if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) {
559
- params = (paramsOrFirst || {}) as { teamId: string, membershipId: string, roles: Roles[] };
558
+ params = (paramsOrFirst || {}) as { teamId: string, membershipId: string, roles: string[] };
560
559
  } else {
561
560
  params = {
562
561
  teamId: paramsOrFirst as string,
563
562
  membershipId: rest[0] as string,
564
- roles: rest[1] as Roles[]
563
+ roles: rest[1] as string[]
565
564
  };
566
565
  }
567
566
 
@@ -37,7 +37,7 @@ interface Membership {
37
37
  interface Resolved {
38
38
  _res: any;
39
39
  }
40
- type Actionable = Document | Row | File | Execution | Team | Membership;
40
+ type Actionable = Document | Row | File | Team | Membership;
41
41
  export declare class Channel<T> {
42
42
  private readonly segments;
43
43
  _type: T;
@@ -50,7 +50,6 @@ export declare class Channel<T> {
50
50
  table(this: Channel<TablesDB>, id?: string): Channel<Table>;
51
51
  row(this: Channel<Table>, id?: string): Channel<Row>;
52
52
  file(this: Channel<Bucket>, id?: string): Channel<File>;
53
- execution(this: Channel<Func>, id?: string): Channel<Execution>;
54
53
  create(this: Channel<Actionable>): Channel<Resolved>;
55
54
  update(this: Channel<Actionable>): Channel<Resolved>;
56
55
  delete(this: Channel<Actionable>): Channel<Resolved>;
@@ -58,13 +57,16 @@ export declare class Channel<T> {
58
57
  static tablesdb(id?: string): Channel<TablesDB>;
59
58
  static bucket(id?: string): Channel<Bucket>;
60
59
  static function(id?: string): Channel<Func>;
60
+ static execution(id?: string): Channel<Execution>;
61
61
  static team(id?: string): Channel<Team>;
62
62
  static membership(id?: string): Channel<Membership>;
63
- static account(userId?: string): string;
64
- static get documents(): string;
65
- static get rows(): string;
66
- static get files(): string;
67
- static get executions(): string;
63
+ static account(): string;
64
+ static documents(): string;
65
+ static rows(): string;
66
+ static files(): string;
67
+ static executions(): string;
68
+ static teams(): string;
69
+ static memberships(): string;
68
70
  }
69
71
  export type ActionableChannel = Channel<Document> | Channel<Row> | Channel<File> | Channel<Execution> | Channel<Team> | Channel<Membership>;
70
72
  export type ResolvedChannel = Channel<Resolved>;
package/types/client.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import { Models } from './models';
2
+ import { Query } from './query';
2
3
  type Payload = {
3
4
  [key: string]: any;
4
5
  };
@@ -137,7 +138,7 @@ declare class Client {
137
138
  * @param {(payload: RealtimeMessage) => void} callback Is called on every realtime update.
138
139
  * @returns {() => void} Unsubscribes from events.
139
140
  */
140
- subscribe<T extends unknown>(channels: string | string[], callback: (payload: RealtimeResponseEvent<T>) => void): () => void;
141
+ subscribe<T extends unknown>(channels: string | string[], callback: (payload: RealtimeResponseEvent<T>) => void, queries?: (string | Query)[]): () => void;
141
142
  call(method: string, url: URL, headers?: Headers, params?: Payload, responseType?: string): Promise<any>;
142
143
  }
143
144
  export { Client, AppwriteException };
@@ -37,5 +37,7 @@ export declare enum OAuthProvider {
37
37
  Yammer = "yammer",
38
38
  Yandex = "yandex",
39
39
  Zoho = "zoho",
40
- Zoom = "zoom"
40
+ Zoom = "zoom",
41
+ GithubImagine = "githubImagine",
42
+ GoogleImagine = "googleImagine"
41
43
  }
package/types/index.d.ts CHANGED
@@ -29,6 +29,5 @@ export { BrowserPermission } from './enums/browser-permission';
29
29
  export { ImageFormat } from './enums/image-format';
30
30
  export { ExecutionMethod } from './enums/execution-method';
31
31
  export { ImageGravity } from './enums/image-gravity';
32
- export { Roles } from './enums/roles';
33
32
  export { ExecutionTrigger } from './enums/execution-trigger';
34
33
  export { ExecutionStatus } from './enums/execution-status';