react-native-appwrite 0.7.1 → 0.7.3

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.
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "react-native-appwrite",
3
3
  "homepage": "https://appwrite.io/support",
4
4
  "description": "Appwrite is an open-source self-hosted backend server that abstract and simplify complex and repetitive development tasks behind a very simple REST API",
5
- "version": "0.7.1",
5
+ "version": "0.7.3",
6
6
  "license": "BSD-3-Clause",
7
7
  "main": "dist/cjs/sdk.js",
8
8
  "exports": {
@@ -30,11 +30,11 @@
30
30
  "rollup": "2.75.4",
31
31
  "serve-handler": "6.1.0",
32
32
  "tslib": "2.4.0",
33
- "typescript": "4.7.2"
33
+ "typescript": "^5.3.3"
34
34
  },
35
35
  "dependencies": {
36
- "expo-file-system": "16.0.8",
37
- "react-native": "^0.73.6"
36
+ "expo-file-system": "~18.0.11",
37
+ "react-native": "0.76.7"
38
38
  },
39
39
  "peerDependencies": {
40
40
  "expo": "*",
package/src/client.ts CHANGED
@@ -114,7 +114,7 @@ class Client {
114
114
  'x-sdk-name': 'React Native',
115
115
  'x-sdk-platform': 'client',
116
116
  'x-sdk-language': 'reactnative',
117
- 'x-sdk-version': '0.7.1',
117
+ 'x-sdk-version': '0.7.3',
118
118
  'X-Appwrite-Response-Format': '1.6.0',
119
119
  };
120
120
 
@@ -128,8 +128,12 @@ class Client {
128
128
  * @returns {this}
129
129
  */
130
130
  setEndpoint(endpoint: string): this {
131
+ if (!endpoint.startsWith('http://') && !endpoint.startsWith('https://')) {
132
+ throw new AppwriteException('Invalid endpoint URL: ' + endpoint);
133
+ }
134
+
131
135
  this.config.endpoint = endpoint;
132
- this.config.endpointRealtime = this.config.endpointRealtime || this.config.endpoint.replace('https://', 'wss://').replace('http://', 'ws://');
136
+ this.config.endpointRealtime = endpoint.replace('https://', 'wss://').replace('http://', 'ws://');
133
137
 
134
138
  return this;
135
139
  }
@@ -142,8 +146,11 @@ class Client {
142
146
  * @returns {this}
143
147
  */
144
148
  setEndpointRealtime(endpointRealtime: string): this {
145
- this.config.endpointRealtime = endpointRealtime;
149
+ if (!endpointRealtime.startsWith('ws://') && !endpointRealtime.startsWith('wss://')) {
150
+ throw new AppwriteException('Invalid realtime endpoint URL: ' + endpointRealtime);
151
+ }
146
152
 
153
+ this.config.endpointRealtime = endpointRealtime;
147
154
  return this;
148
155
  }
149
156
 
@@ -452,8 +459,8 @@ class Client {
452
459
 
453
460
  try {
454
461
  let data = null;
462
+
455
463
  const response = await fetch(url.toString(), options);
456
- const text = await response.text()
457
464
 
458
465
  const warnings = response.headers.get('x-appwrite-warning');
459
466
  if (warnings) {
@@ -464,12 +471,18 @@ class Client {
464
471
  data = await response.json();
465
472
  } else {
466
473
  data = {
467
- message: text
474
+ message: await response.text()
468
475
  };
469
476
  }
470
477
 
471
478
  if (400 <= response.status) {
472
- throw new AppwriteException(data?.message, response.status, data?.type, text);
479
+ let responseText = '';
480
+ if (response.headers.get('content-type')?.includes('application/json')) {
481
+ responseText = JSON.stringify(data);
482
+ } else {
483
+ responseText = data?.message;
484
+ }
485
+ throw new AppwriteException(data?.message, response.status, data?.type, responseText);
473
486
  }
474
487
 
475
488
  const cookieFallback = response.headers.get('X-Fallback-Cookies');
@@ -15,4 +15,5 @@ export enum CreditCard {
15
15
  Visa = 'visa',
16
16
  MIR = 'mir',
17
17
  Maestro = 'maestro',
18
+ Rupay = 'rupay',
18
19
  }
@@ -13,6 +13,7 @@ export enum OAuthProvider {
13
13
  Dropbox = 'dropbox',
14
14
  Etsy = 'etsy',
15
15
  Facebook = 'facebook',
16
+ Figma = 'figma',
16
17
  Github = 'github',
17
18
  Gitlab = 'gitlab',
18
19
  Google = 'google',
@@ -28,7 +28,6 @@ export class Account extends Service {
28
28
 
29
29
  const uri = new URL(this.client.config.endpoint + apiPath);
30
30
  return this.client.call('get', uri, {
31
- 'content-type': 'application/json',
32
31
  }, payload);
33
32
  }
34
33
 
@@ -144,7 +143,6 @@ export class Account extends Service {
144
143
 
145
144
  const uri = new URL(this.client.config.endpoint + apiPath);
146
145
  return this.client.call('get', uri, {
147
- 'content-type': 'application/json',
148
146
  }, payload);
149
147
  }
150
148
 
@@ -207,7 +205,6 @@ export class Account extends Service {
207
205
 
208
206
  const uri = new URL(this.client.config.endpoint + apiPath);
209
207
  return this.client.call('get', uri, {
210
- 'content-type': 'application/json',
211
208
  }, payload);
212
209
  }
213
210
 
@@ -390,7 +387,6 @@ export class Account extends Service {
390
387
 
391
388
  const uri = new URL(this.client.config.endpoint + apiPath);
392
389
  return this.client.call('get', uri, {
393
- 'content-type': 'application/json',
394
390
  }, payload);
395
391
  }
396
392
 
@@ -409,7 +405,6 @@ export class Account extends Service {
409
405
 
410
406
  const uri = new URL(this.client.config.endpoint + apiPath);
411
407
  return this.client.call('get', uri, {
412
- 'content-type': 'application/json',
413
408
  }, payload);
414
409
  }
415
410
 
@@ -559,7 +554,6 @@ export class Account extends Service {
559
554
 
560
555
  const uri = new URL(this.client.config.endpoint + apiPath);
561
556
  return this.client.call('get', uri, {
562
- 'content-type': 'application/json',
563
557
  }, payload);
564
558
  }
565
559
 
@@ -696,7 +690,6 @@ export class Account extends Service {
696
690
 
697
691
  const uri = new URL(this.client.config.endpoint + apiPath);
698
692
  return this.client.call('get', uri, {
699
- 'content-type': 'application/json',
700
693
  }, payload);
701
694
  }
702
695
 
@@ -959,7 +952,6 @@ export class Account extends Service {
959
952
 
960
953
  const uri = new URL(this.client.config.endpoint + apiPath);
961
954
  return this.client.call('get', uri, {
962
- 'content-type': 'application/json',
963
955
  }, payload);
964
956
  }
965
957
 
@@ -41,7 +41,6 @@ export class Databases extends Service {
41
41
 
42
42
  const uri = new URL(this.client.config.endpoint + apiPath);
43
43
  return this.client.call('get', uri, {
44
- 'content-type': 'application/json',
45
44
  }, payload);
46
45
  }
47
46
 
@@ -50,6 +49,7 @@ export class Databases extends Service {
50
49
  * collection resource using either a [server
51
50
  * integration](https://appwrite.io/docs/server/databases#databasesCreateCollection)
52
51
  * API or directly from your database console.
52
+ *
53
53
  *
54
54
  * @param {string} databaseId
55
55
  * @param {string} collectionId
@@ -130,7 +130,6 @@ export class Databases extends Service {
130
130
 
131
131
  const uri = new URL(this.client.config.endpoint + apiPath);
132
132
  return this.client.call('get', uri, {
133
- 'content-type': 'application/json',
134
133
  }, payload);
135
134
  }
136
135
 
@@ -42,7 +42,6 @@ export class Functions extends Service {
42
42
 
43
43
  const uri = new URL(this.client.config.endpoint + apiPath);
44
44
  return this.client.call('get', uri, {
45
- 'content-type': 'application/json',
46
45
  }, payload);
47
46
  }
48
47
 
@@ -122,7 +121,6 @@ export class Functions extends Service {
122
121
 
123
122
  const uri = new URL(this.client.config.endpoint + apiPath);
124
123
  return this.client.call('get', uri, {
125
- 'content-type': 'application/json',
126
124
  }, payload);
127
125
  }
128
126
  };
@@ -30,7 +30,6 @@ export class Locale extends Service {
30
30
 
31
31
  const uri = new URL(this.client.config.endpoint + apiPath);
32
32
  return this.client.call('get', uri, {
33
- 'content-type': 'application/json',
34
33
  }, payload);
35
34
  }
36
35
 
@@ -47,7 +46,6 @@ export class Locale extends Service {
47
46
 
48
47
  const uri = new URL(this.client.config.endpoint + apiPath);
49
48
  return this.client.call('get', uri, {
50
- 'content-type': 'application/json',
51
49
  }, payload);
52
50
  }
53
51
 
@@ -64,7 +62,6 @@ export class Locale extends Service {
64
62
 
65
63
  const uri = new URL(this.client.config.endpoint + apiPath);
66
64
  return this.client.call('get', uri, {
67
- 'content-type': 'application/json',
68
65
  }, payload);
69
66
  }
70
67
 
@@ -81,7 +78,6 @@ export class Locale extends Service {
81
78
 
82
79
  const uri = new URL(this.client.config.endpoint + apiPath);
83
80
  return this.client.call('get', uri, {
84
- 'content-type': 'application/json',
85
81
  }, payload);
86
82
  }
87
83
 
@@ -98,7 +94,6 @@ export class Locale extends Service {
98
94
 
99
95
  const uri = new URL(this.client.config.endpoint + apiPath);
100
96
  return this.client.call('get', uri, {
101
- 'content-type': 'application/json',
102
97
  }, payload);
103
98
  }
104
99
 
@@ -115,7 +110,6 @@ export class Locale extends Service {
115
110
 
116
111
  const uri = new URL(this.client.config.endpoint + apiPath);
117
112
  return this.client.call('get', uri, {
118
- 'content-type': 'application/json',
119
113
  }, payload);
120
114
  }
121
115
 
@@ -133,7 +127,6 @@ export class Locale extends Service {
133
127
 
134
128
  const uri = new URL(this.client.config.endpoint + apiPath);
135
129
  return this.client.call('get', uri, {
136
- 'content-type': 'application/json',
137
130
  }, payload);
138
131
  }
139
132
 
@@ -150,7 +143,6 @@ export class Locale extends Service {
150
143
 
151
144
  const uri = new URL(this.client.config.endpoint + apiPath);
152
145
  return this.client.call('get', uri, {
153
- 'content-type': 'application/json',
154
146
  }, payload);
155
147
  }
156
148
  };
@@ -43,7 +43,6 @@ export class Storage extends Service {
43
43
 
44
44
  const uri = new URL(this.client.config.endpoint + apiPath);
45
45
  return this.client.call('get', uri, {
46
- 'content-type': 'application/json',
47
46
  }, payload);
48
47
  }
49
48
 
@@ -185,7 +184,6 @@ export class Storage extends Service {
185
184
 
186
185
  const uri = new URL(this.client.config.endpoint + apiPath);
187
186
  return this.client.call('get', uri, {
188
- 'content-type': 'application/json',
189
187
  }, payload);
190
188
  }
191
189
 
@@ -36,7 +36,6 @@ export class Teams extends Service {
36
36
 
37
37
  const uri = new URL(this.client.config.endpoint + apiPath);
38
38
  return this.client.call('get', uri, {
39
- 'content-type': 'application/json',
40
39
  }, payload);
41
40
  }
42
41
 
@@ -98,7 +97,6 @@ export class Teams extends Service {
98
97
 
99
98
  const uri = new URL(this.client.config.endpoint + apiPath);
100
99
  return this.client.call('get', uri, {
101
- 'content-type': 'application/json',
102
100
  }, payload);
103
101
  }
104
102
 
@@ -183,7 +181,6 @@ export class Teams extends Service {
183
181
 
184
182
  const uri = new URL(this.client.config.endpoint + apiPath);
185
183
  return this.client.call('get', uri, {
186
- 'content-type': 'application/json',
187
184
  }, payload);
188
185
  }
189
186
 
@@ -286,7 +283,6 @@ export class Teams extends Service {
286
283
 
287
284
  const uri = new URL(this.client.config.endpoint + apiPath);
288
285
  return this.client.call('get', uri, {
289
- 'content-type': 'application/json',
290
286
  }, payload);
291
287
  }
292
288
 
@@ -425,7 +421,6 @@ export class Teams extends Service {
425
421
 
426
422
  const uri = new URL(this.client.config.endpoint + apiPath);
427
423
  return this.client.call('get', uri, {
428
- 'content-type': 'application/json',
429
424
  }, payload);
430
425
  }
431
426
 
package/types/client.d.ts CHANGED
@@ -1,17 +1,17 @@
1
1
  import { Models } from './models';
2
- declare type Payload = {
2
+ type Payload = {
3
3
  [key: string]: any;
4
4
  };
5
- declare type Headers = {
5
+ type Headers = {
6
6
  [key: string]: string;
7
7
  };
8
- export declare type RealtimeResponseEvent<T extends unknown> = {
8
+ export type RealtimeResponseEvent<T extends unknown> = {
9
9
  events: string[];
10
10
  channels: string[];
11
11
  timestamp: number;
12
12
  payload: T;
13
13
  };
14
- export declare type UploadProgress = {
14
+ export type UploadProgress = {
15
15
  $id: string;
16
16
  progress: number;
17
17
  sizeUploaded: number;
@@ -14,5 +14,6 @@ export declare enum CreditCard {
14
14
  UnionChinaPay = "union-china-pay",
15
15
  Visa = "visa",
16
16
  MIR = "mir",
17
- Maestro = "maestro"
17
+ Maestro = "maestro",
18
+ Rupay = "rupay"
18
19
  }
@@ -13,6 +13,7 @@ export declare enum OAuthProvider {
13
13
  Dropbox = "dropbox",
14
14
  Etsy = "etsy",
15
15
  Facebook = "facebook",
16
+ Figma = "figma",
16
17
  Github = "github",
17
18
  Gitlab = "gitlab",
18
19
  Google = "google",
package/types/query.d.ts CHANGED
@@ -1,7 +1,7 @@
1
- declare type QueryTypesSingle = string | number | boolean;
2
- export declare type QueryTypesList = string[] | number[] | boolean[] | Query[];
3
- export declare type QueryTypes = QueryTypesSingle | QueryTypesList;
4
- declare type AttributesTypes = string | string[];
1
+ type QueryTypesSingle = string | number | boolean;
2
+ export type QueryTypesList = string[] | number[] | boolean[] | Query[];
3
+ export type QueryTypes = QueryTypesSingle | QueryTypesList;
4
+ type AttributesTypes = string | string[];
5
5
  export declare class Query {
6
6
  method: string;
7
7
  attribute: AttributesTypes | undefined;
@@ -20,6 +20,7 @@ export declare class Databases extends Service {
20
20
  * integration](https://appwrite.io/docs/server/databases#databasesCreateCollection)
21
21
  * API or directly from your database console.
22
22
  *
23
+ *
23
24
  * @param {string} databaseId
24
25
  * @param {string} collectionId
25
26
  * @param {string} documentId