react-native-appwrite 0.9.2 → 0.10.1

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.
@@ -260,9 +260,9 @@ export class Storage extends Service {
260
260
  * @param {string} fileId
261
261
  * @param {string} token
262
262
  * @throws {AppwriteException}
263
- * @returns {URL}
263
+ * @returns {ArrayBuffer}
264
264
  */
265
- getFileDownload(bucketId: string, fileId: string, token?: string): URL {
265
+ getFileDownload(bucketId: string, fileId: string, token?: string): Promise<ArrayBuffer> {
266
266
  if (typeof bucketId === 'undefined') {
267
267
  throw new AppwriteException('Missing required parameter: "bucketId"');
268
268
  }
@@ -285,7 +285,8 @@ export class Storage extends Service {
285
285
  for (const [key, value] of Object.entries(Service.flatten(payload))) {
286
286
  uri.searchParams.append(key, value);
287
287
  }
288
- return uri;
288
+ return this.client.call('get', uri, {
289
+ }, payload, 'arrayBuffer');
289
290
  }
290
291
 
291
292
  /**
@@ -310,9 +311,9 @@ export class Storage extends Service {
310
311
  * @param {ImageFormat} output
311
312
  * @param {string} token
312
313
  * @throws {AppwriteException}
313
- * @returns {URL}
314
+ * @returns {ArrayBuffer}
314
315
  */
315
- getFilePreview(bucketId: string, fileId: string, width?: number, height?: number, gravity?: ImageGravity, quality?: number, borderWidth?: number, borderColor?: string, borderRadius?: number, opacity?: number, rotation?: number, background?: string, output?: ImageFormat, token?: string): URL {
316
+ getFilePreview(bucketId: string, fileId: string, width?: number, height?: number, gravity?: ImageGravity, quality?: number, borderWidth?: number, borderColor?: string, borderRadius?: number, opacity?: number, rotation?: number, background?: string, output?: ImageFormat, token?: string): Promise<ArrayBuffer> {
316
317
  if (typeof bucketId === 'undefined') {
317
318
  throw new AppwriteException('Missing required parameter: "bucketId"');
318
319
  }
@@ -379,7 +380,8 @@ export class Storage extends Service {
379
380
  for (const [key, value] of Object.entries(Service.flatten(payload))) {
380
381
  uri.searchParams.append(key, value);
381
382
  }
382
- return uri;
383
+ return this.client.call('get', uri, {
384
+ }, payload, 'arrayBuffer');
383
385
  }
384
386
 
385
387
  /**
@@ -391,9 +393,9 @@ export class Storage extends Service {
391
393
  * @param {string} fileId
392
394
  * @param {string} token
393
395
  * @throws {AppwriteException}
394
- * @returns {URL}
396
+ * @returns {ArrayBuffer}
395
397
  */
396
- getFileView(bucketId: string, fileId: string, token?: string): URL {
398
+ getFileView(bucketId: string, fileId: string, token?: string): Promise<ArrayBuffer> {
397
399
  if (typeof bucketId === 'undefined') {
398
400
  throw new AppwriteException('Missing required parameter: "bucketId"');
399
401
  }
@@ -416,6 +418,151 @@ export class Storage extends Service {
416
418
  for (const [key, value] of Object.entries(Service.flatten(payload))) {
417
419
  uri.searchParams.append(key, value);
418
420
  }
421
+ return this.client.call('get', uri, {
422
+ }, payload, 'arrayBuffer');
423
+ }
424
+
425
+ /**
426
+ * Get a file content by its unique ID. The endpoint response return with a
427
+ * 'Content-Disposition: attachment' header that tells the browser to start
428
+ * downloading the file to user downloads directory.
429
+ *
430
+ * @param {string} bucketId
431
+ * @param {string} fileId
432
+ * @param {string} token
433
+ * @throws {AppwriteException}
434
+ * @returns {URL}
435
+ */
436
+ getFileDownloadURL(bucketId: string, fileId: string, token?: string): URL {
437
+ const apiPath = '/storage/buckets/{bucketId}/files/{fileId}/download'.replace('{bucketId}', bucketId).replace('{fileId}', fileId);
438
+ const payload: Payload = {};
439
+
440
+ if (typeof token !== 'undefined') {
441
+ payload['token'] = token;
442
+ }
443
+
444
+ const uri = new URL(this.client.config.endpoint + apiPath);
445
+ payload['project'] = this.client.config.project;
446
+
447
+ for (const [key, value] of Object.entries(Service.flatten(payload))) {
448
+ uri.searchParams.append(key, value);
449
+ }
450
+
451
+ return uri;
452
+ }
453
+
454
+ /**
455
+ * Get a file preview image. Currently, this method supports preview for image
456
+ * files (jpg, png, and gif), other supported formats, like pdf, docs, slides,
457
+ * and spreadsheets, will return the file icon image. You can also pass query
458
+ * string arguments for cutting and resizing your preview image. Preview is
459
+ * supported only for image files smaller than 10MB.
460
+ *
461
+ * @param {string} bucketId
462
+ * @param {string} fileId
463
+ * @param {number} width
464
+ * @param {number} height
465
+ * @param {ImageGravity} gravity
466
+ * @param {number} quality
467
+ * @param {number} borderWidth
468
+ * @param {string} borderColor
469
+ * @param {number} borderRadius
470
+ * @param {number} opacity
471
+ * @param {number} rotation
472
+ * @param {string} background
473
+ * @param {ImageFormat} output
474
+ * @param {string} token
475
+ * @throws {AppwriteException}
476
+ * @returns {URL}
477
+ */
478
+ getFilePreviewURL(bucketId: string, fileId: string, width?: number, height?: number, gravity?: ImageGravity, quality?: number, borderWidth?: number, borderColor?: string, borderRadius?: number, opacity?: number, rotation?: number, background?: string, output?: ImageFormat, token?: string): URL {
479
+ const apiPath = '/storage/buckets/{bucketId}/files/{fileId}/preview'.replace('{bucketId}', bucketId).replace('{fileId}', fileId);
480
+ const payload: Payload = {};
481
+
482
+ if (typeof width !== 'undefined') {
483
+ payload['width'] = width;
484
+ }
485
+
486
+ if (typeof height !== 'undefined') {
487
+ payload['height'] = height;
488
+ }
489
+
490
+ if (typeof gravity !== 'undefined') {
491
+ payload['gravity'] = gravity;
492
+ }
493
+
494
+ if (typeof quality !== 'undefined') {
495
+ payload['quality'] = quality;
496
+ }
497
+
498
+ if (typeof borderWidth !== 'undefined') {
499
+ payload['borderWidth'] = borderWidth;
500
+ }
501
+
502
+ if (typeof borderColor !== 'undefined') {
503
+ payload['borderColor'] = borderColor;
504
+ }
505
+
506
+ if (typeof borderRadius !== 'undefined') {
507
+ payload['borderRadius'] = borderRadius;
508
+ }
509
+
510
+ if (typeof opacity !== 'undefined') {
511
+ payload['opacity'] = opacity;
512
+ }
513
+
514
+ if (typeof rotation !== 'undefined') {
515
+ payload['rotation'] = rotation;
516
+ }
517
+
518
+ if (typeof background !== 'undefined') {
519
+ payload['background'] = background;
520
+ }
521
+
522
+ if (typeof output !== 'undefined') {
523
+ payload['output'] = output;
524
+ }
525
+
526
+ if (typeof token !== 'undefined') {
527
+ payload['token'] = token;
528
+ }
529
+
530
+ const uri = new URL(this.client.config.endpoint + apiPath);
531
+ payload['project'] = this.client.config.project;
532
+
533
+ for (const [key, value] of Object.entries(Service.flatten(payload))) {
534
+ uri.searchParams.append(key, value);
535
+ }
536
+
537
+ return uri;
538
+ }
539
+
540
+ /**
541
+ * Get a file content by its unique ID. This endpoint is similar to the
542
+ * download method but returns with no 'Content-Disposition: attachment'
543
+ * header.
544
+ *
545
+ * @param {string} bucketId
546
+ * @param {string} fileId
547
+ * @param {string} token
548
+ * @throws {AppwriteException}
549
+ * @returns {URL}
550
+ */
551
+ getFileViewURL(bucketId: string, fileId: string, token?: string): URL {
552
+ const apiPath = '/storage/buckets/{bucketId}/files/{fileId}/view'.replace('{bucketId}', bucketId).replace('{fileId}', fileId);
553
+ const payload: Payload = {};
554
+
555
+ if (typeof token !== 'undefined') {
556
+ payload['token'] = token;
557
+ }
558
+
559
+ const uri = new URL(this.client.config.endpoint + apiPath);
560
+ payload['project'] = this.client.config.project;
561
+
562
+ for (const [key, value] of Object.entries(Service.flatten(payload))) {
563
+ uri.searchParams.append(key, value);
564
+ }
565
+
419
566
  return uri;
420
567
  }
421
568
  };
package/types/client.d.ts CHANGED
@@ -138,7 +138,7 @@ declare class Client {
138
138
  * @returns {() => void} Unsubscribes from events.
139
139
  */
140
140
  subscribe<T extends unknown>(channels: string | string[], callback: (payload: RealtimeResponseEvent<T>) => void): () => void;
141
- call(method: string, url: URL, headers?: Headers, params?: Payload): Promise<any>;
141
+ call(method: string, url: URL, headers?: Headers, params?: Payload, responseType?: string): Promise<any>;
142
142
  }
143
143
  export { Client, AppwriteException };
144
144
  export type { Models, Payload };
@@ -4,5 +4,6 @@ export declare enum ImageFormat {
4
4
  Png = "png",
5
5
  Webp = "webp",
6
6
  Heic = "heic",
7
- Avif = "avif"
7
+ Avif = "avif",
8
+ Gif = "gif"
8
9
  }
@@ -5,6 +5,135 @@ import { CreditCard } from '../enums/credit-card';
5
5
  import { Flag } from '../enums/flag';
6
6
  export declare class Avatars extends Service {
7
7
  constructor(client: Client);
8
+ /**
9
+ * You can use this endpoint to show different browser icons to your users.
10
+ * The code argument receives the browser code as it appears in your user [GET
11
+ * /account/sessions](https://appwrite.io/docs/references/cloud/client-web/account#getSessions)
12
+ * endpoint. Use width, height and quality arguments to change the output
13
+ * settings.
14
+ *
15
+ * When one dimension is specified and the other is 0, the image is scaled
16
+ * with preserved aspect ratio. If both dimensions are 0, the API provides an
17
+ * image at source quality. If dimensions are not specified, the default size
18
+ * of image returned is 100x100px.
19
+ *
20
+ * @param {Browser} code
21
+ * @param {number} width
22
+ * @param {number} height
23
+ * @param {number} quality
24
+ * @throws {AppwriteException}
25
+ * @returns {ArrayBuffer}
26
+ */
27
+ getBrowser(code: Browser, width?: number, height?: number, quality?: number): Promise<ArrayBuffer>;
28
+ /**
29
+ * The credit card endpoint will return you the icon of the credit card
30
+ * provider you need. Use width, height and quality arguments to change the
31
+ * output settings.
32
+ *
33
+ * When one dimension is specified and the other is 0, the image is scaled
34
+ * with preserved aspect ratio. If both dimensions are 0, the API provides an
35
+ * image at source quality. If dimensions are not specified, the default size
36
+ * of image returned is 100x100px.
37
+ *
38
+ *
39
+ * @param {CreditCard} code
40
+ * @param {number} width
41
+ * @param {number} height
42
+ * @param {number} quality
43
+ * @throws {AppwriteException}
44
+ * @returns {ArrayBuffer}
45
+ */
46
+ getCreditCard(code: CreditCard, width?: number, height?: number, quality?: number): Promise<ArrayBuffer>;
47
+ /**
48
+ * Use this endpoint to fetch the favorite icon (AKA favicon) of any remote
49
+ * website URL.
50
+ *
51
+ * This endpoint does not follow HTTP redirects.
52
+ *
53
+ * @param {string} url
54
+ * @throws {AppwriteException}
55
+ * @returns {ArrayBuffer}
56
+ */
57
+ getFavicon(url: string): Promise<ArrayBuffer>;
58
+ /**
59
+ * You can use this endpoint to show different country flags icons to your
60
+ * users. The code argument receives the 2 letter country code. Use width,
61
+ * height and quality arguments to change the output settings. Country codes
62
+ * follow the [ISO 3166-1](https://en.wikipedia.org/wiki/ISO_3166-1) standard.
63
+ *
64
+ * When one dimension is specified and the other is 0, the image is scaled
65
+ * with preserved aspect ratio. If both dimensions are 0, the API provides an
66
+ * image at source quality. If dimensions are not specified, the default size
67
+ * of image returned is 100x100px.
68
+ *
69
+ *
70
+ * @param {Flag} code
71
+ * @param {number} width
72
+ * @param {number} height
73
+ * @param {number} quality
74
+ * @throws {AppwriteException}
75
+ * @returns {ArrayBuffer}
76
+ */
77
+ getFlag(code: Flag, width?: number, height?: number, quality?: number): Promise<ArrayBuffer>;
78
+ /**
79
+ * Use this endpoint to fetch a remote image URL and crop it to any image size
80
+ * you want. This endpoint is very useful if you need to crop and display
81
+ * remote images in your app or in case you want to make sure a 3rd party
82
+ * image is properly served using a TLS protocol.
83
+ *
84
+ * When one dimension is specified and the other is 0, the image is scaled
85
+ * with preserved aspect ratio. If both dimensions are 0, the API provides an
86
+ * image at source quality. If dimensions are not specified, the default size
87
+ * of image returned is 400x400px.
88
+ *
89
+ * This endpoint does not follow HTTP redirects.
90
+ *
91
+ * @param {string} url
92
+ * @param {number} width
93
+ * @param {number} height
94
+ * @throws {AppwriteException}
95
+ * @returns {ArrayBuffer}
96
+ */
97
+ getImage(url: string, width?: number, height?: number): Promise<ArrayBuffer>;
98
+ /**
99
+ * Use this endpoint to show your user initials avatar icon on your website or
100
+ * app. By default, this route will try to print your logged-in user name or
101
+ * email initials. You can also overwrite the user name if you pass the 'name'
102
+ * parameter. If no name is given and no user is logged, an empty avatar will
103
+ * be returned.
104
+ *
105
+ * You can use the color and background params to change the avatar colors. By
106
+ * default, a random theme will be selected. The random theme will persist for
107
+ * the user's initials when reloading the same theme will always return for
108
+ * the same initials.
109
+ *
110
+ * When one dimension is specified and the other is 0, the image is scaled
111
+ * with preserved aspect ratio. If both dimensions are 0, the API provides an
112
+ * image at source quality. If dimensions are not specified, the default size
113
+ * of image returned is 100x100px.
114
+ *
115
+ *
116
+ * @param {string} name
117
+ * @param {number} width
118
+ * @param {number} height
119
+ * @param {string} background
120
+ * @throws {AppwriteException}
121
+ * @returns {ArrayBuffer}
122
+ */
123
+ getInitials(name?: string, width?: number, height?: number, background?: string): Promise<ArrayBuffer>;
124
+ /**
125
+ * Converts a given plain text to a QR code image. You can use the query
126
+ * parameters to change the size and style of the resulting image.
127
+ *
128
+ *
129
+ * @param {string} text
130
+ * @param {number} size
131
+ * @param {number} margin
132
+ * @param {boolean} download
133
+ * @throws {AppwriteException}
134
+ * @returns {ArrayBuffer}
135
+ */
136
+ getQR(text: string, size?: number, margin?: number, download?: boolean): Promise<ArrayBuffer>;
8
137
  /**
9
138
  * You can use this endpoint to show different browser icons to your users.
10
139
  * The code argument receives the browser code as it appears in your user [GET
@@ -24,7 +153,7 @@ export declare class Avatars extends Service {
24
153
  * @throws {AppwriteException}
25
154
  * @returns {URL}
26
155
  */
27
- getBrowser(code: Browser, width?: number, height?: number, quality?: number): URL;
156
+ getBrowserURL(code: Browser, width?: number, height?: number, quality?: number): URL;
28
157
  /**
29
158
  * The credit card endpoint will return you the icon of the credit card
30
159
  * provider you need. Use width, height and quality arguments to change the
@@ -43,7 +172,7 @@ export declare class Avatars extends Service {
43
172
  * @throws {AppwriteException}
44
173
  * @returns {URL}
45
174
  */
46
- getCreditCard(code: CreditCard, width?: number, height?: number, quality?: number): URL;
175
+ getCreditCardURL(code: CreditCard, width?: number, height?: number, quality?: number): URL;
47
176
  /**
48
177
  * Use this endpoint to fetch the favorite icon (AKA favicon) of any remote
49
178
  * website URL.
@@ -54,7 +183,7 @@ export declare class Avatars extends Service {
54
183
  * @throws {AppwriteException}
55
184
  * @returns {URL}
56
185
  */
57
- getFavicon(url: string): URL;
186
+ getFaviconURL(url: string): URL;
58
187
  /**
59
188
  * You can use this endpoint to show different country flags icons to your
60
189
  * users. The code argument receives the 2 letter country code. Use width,
@@ -74,7 +203,7 @@ export declare class Avatars extends Service {
74
203
  * @throws {AppwriteException}
75
204
  * @returns {URL}
76
205
  */
77
- getFlag(code: Flag, width?: number, height?: number, quality?: number): URL;
206
+ getFlagURL(code: Flag, width?: number, height?: number, quality?: number): URL;
78
207
  /**
79
208
  * Use this endpoint to fetch a remote image URL and crop it to any image size
80
209
  * you want. This endpoint is very useful if you need to crop and display
@@ -94,7 +223,7 @@ export declare class Avatars extends Service {
94
223
  * @throws {AppwriteException}
95
224
  * @returns {URL}
96
225
  */
97
- getImage(url: string, width?: number, height?: number): URL;
226
+ getImageURL(url: string, width?: number, height?: number): URL;
98
227
  /**
99
228
  * Use this endpoint to show your user initials avatar icon on your website or
100
229
  * app. By default, this route will try to print your logged-in user name or
@@ -120,7 +249,7 @@ export declare class Avatars extends Service {
120
249
  * @throws {AppwriteException}
121
250
  * @returns {URL}
122
251
  */
123
- getInitials(name?: string, width?: number, height?: number, background?: string): URL;
252
+ getInitialsURL(name?: string, width?: number, height?: number, background?: string): URL;
124
253
  /**
125
254
  * Converts a given plain text to a QR code image. You can use the query
126
255
  * parameters to change the size and style of the resulting image.
@@ -133,5 +262,5 @@ export declare class Avatars extends Service {
133
262
  * @throws {AppwriteException}
134
263
  * @returns {URL}
135
264
  */
136
- getQR(text: string, size?: number, margin?: number, download?: boolean): URL;
265
+ getQRURL(text: string, size?: number, margin?: number, download?: boolean): URL;
137
266
  }
@@ -42,6 +42,10 @@ export declare class Databases extends Service {
42
42
  */
43
43
  getDocument<Document extends Models.Document>(databaseId: string, collectionId: string, documentId: string, queries?: string[]): Promise<Document>;
44
44
  /**
45
+ * **WARNING: Experimental Feature** - This endpoint is experimental and not
46
+ * yet officially supported. It may be subject to breaking changes or removal
47
+ * in future versions.
48
+ *
45
49
  * Create or update a Document. Before using this route, you should create a
46
50
  * new collection resource using either a [server
47
51
  * integration](https://appwrite.io/docs/server/databases#databasesCreateCollection)
@@ -82,6 +82,55 @@ export declare class Storage extends Service {
82
82
  * @returns {Promise}
83
83
  */
84
84
  deleteFile(bucketId: string, fileId: string): Promise<{}>;
85
+ /**
86
+ * Get a file content by its unique ID. The endpoint response return with a
87
+ * 'Content-Disposition: attachment' header that tells the browser to start
88
+ * downloading the file to user downloads directory.
89
+ *
90
+ * @param {string} bucketId
91
+ * @param {string} fileId
92
+ * @param {string} token
93
+ * @throws {AppwriteException}
94
+ * @returns {ArrayBuffer}
95
+ */
96
+ getFileDownload(bucketId: string, fileId: string, token?: string): Promise<ArrayBuffer>;
97
+ /**
98
+ * Get a file preview image. Currently, this method supports preview for image
99
+ * files (jpg, png, and gif), other supported formats, like pdf, docs, slides,
100
+ * and spreadsheets, will return the file icon image. You can also pass query
101
+ * string arguments for cutting and resizing your preview image. Preview is
102
+ * supported only for image files smaller than 10MB.
103
+ *
104
+ * @param {string} bucketId
105
+ * @param {string} fileId
106
+ * @param {number} width
107
+ * @param {number} height
108
+ * @param {ImageGravity} gravity
109
+ * @param {number} quality
110
+ * @param {number} borderWidth
111
+ * @param {string} borderColor
112
+ * @param {number} borderRadius
113
+ * @param {number} opacity
114
+ * @param {number} rotation
115
+ * @param {string} background
116
+ * @param {ImageFormat} output
117
+ * @param {string} token
118
+ * @throws {AppwriteException}
119
+ * @returns {ArrayBuffer}
120
+ */
121
+ getFilePreview(bucketId: string, fileId: string, width?: number, height?: number, gravity?: ImageGravity, quality?: number, borderWidth?: number, borderColor?: string, borderRadius?: number, opacity?: number, rotation?: number, background?: string, output?: ImageFormat, token?: string): Promise<ArrayBuffer>;
122
+ /**
123
+ * Get a file content by its unique ID. This endpoint is similar to the
124
+ * download method but returns with no 'Content-Disposition: attachment'
125
+ * header.
126
+ *
127
+ * @param {string} bucketId
128
+ * @param {string} fileId
129
+ * @param {string} token
130
+ * @throws {AppwriteException}
131
+ * @returns {ArrayBuffer}
132
+ */
133
+ getFileView(bucketId: string, fileId: string, token?: string): Promise<ArrayBuffer>;
85
134
  /**
86
135
  * Get a file content by its unique ID. The endpoint response return with a
87
136
  * 'Content-Disposition: attachment' header that tells the browser to start
@@ -93,7 +142,7 @@ export declare class Storage extends Service {
93
142
  * @throws {AppwriteException}
94
143
  * @returns {URL}
95
144
  */
96
- getFileDownload(bucketId: string, fileId: string, token?: string): URL;
145
+ getFileDownloadURL(bucketId: string, fileId: string, token?: string): URL;
97
146
  /**
98
147
  * Get a file preview image. Currently, this method supports preview for image
99
148
  * files (jpg, png, and gif), other supported formats, like pdf, docs, slides,
@@ -118,7 +167,7 @@ export declare class Storage extends Service {
118
167
  * @throws {AppwriteException}
119
168
  * @returns {URL}
120
169
  */
121
- getFilePreview(bucketId: string, fileId: string, width?: number, height?: number, gravity?: ImageGravity, quality?: number, borderWidth?: number, borderColor?: string, borderRadius?: number, opacity?: number, rotation?: number, background?: string, output?: ImageFormat, token?: string): URL;
170
+ getFilePreviewURL(bucketId: string, fileId: string, width?: number, height?: number, gravity?: ImageGravity, quality?: number, borderWidth?: number, borderColor?: string, borderRadius?: number, opacity?: number, rotation?: number, background?: string, output?: ImageFormat, token?: string): URL;
122
171
  /**
123
172
  * Get a file content by its unique ID. This endpoint is similar to the
124
173
  * download method but returns with no 'Content-Disposition: attachment'
@@ -130,5 +179,5 @@ export declare class Storage extends Service {
130
179
  * @throws {AppwriteException}
131
180
  * @returns {URL}
132
181
  */
133
- getFileView(bucketId: string, fileId: string, token?: string): URL;
182
+ getFileViewURL(bucketId: string, fileId: string, token?: string): URL;
134
183
  }