react-native-appwrite 0.11.0 → 0.12.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.
- package/README.md +84 -3
- package/dist/cjs/sdk.js +1741 -1120
- package/dist/cjs/sdk.js.map +1 -1
- package/dist/esm/sdk.js +1741 -1121
- package/dist/esm/sdk.js.map +1 -1
- package/docs/examples/account/create-email-password-session.md +4 -4
- package/docs/examples/account/create-email-token.md +5 -5
- package/docs/examples/account/{create-magic-u-r-l-token.md → create-magic-url-token.md} +6 -6
- package/docs/examples/account/create-mfa-authenticator.md +3 -3
- package/docs/examples/account/create-mfa-challenge.md +3 -3
- package/docs/examples/account/create-mfa-recovery-codes.md +1 -1
- package/docs/examples/account/{create-o-auth2token.md → create-o-auth-2-session.md} +6 -6
- package/docs/examples/account/{create-o-auth2session.md → create-o-auth-2-token.md} +6 -6
- package/docs/examples/account/create-phone-token.md +4 -4
- package/docs/examples/account/create-push-target.md +5 -5
- package/docs/examples/account/create-recovery.md +4 -4
- package/docs/examples/account/create-session.md +4 -4
- package/docs/examples/account/create-verification.md +3 -3
- package/docs/examples/account/create.md +6 -6
- package/docs/examples/account/delete-identity.md +3 -3
- package/docs/examples/account/delete-mfa-authenticator.md +3 -3
- package/docs/examples/account/delete-push-target.md +3 -3
- package/docs/examples/account/delete-session.md +3 -3
- package/docs/examples/account/get-mfa-recovery-codes.md +1 -1
- package/docs/examples/account/get-session.md +3 -3
- package/docs/examples/account/list-identities.md +3 -3
- package/docs/examples/account/list-logs.md +3 -3
- package/docs/examples/account/list-mfa-factors.md +1 -1
- package/docs/examples/account/update-email.md +4 -4
- package/docs/examples/account/{update-magic-u-r-l-session.md → update-magic-url-session.md} +4 -4
- package/docs/examples/account/update-mfa-authenticator.md +4 -4
- package/docs/examples/account/update-mfa-challenge.md +4 -4
- package/docs/examples/account/update-mfa-recovery-codes.md +1 -1
- package/docs/examples/account/{update-m-f-a.md → update-mfa.md} +3 -3
- package/docs/examples/account/update-name.md +3 -3
- package/docs/examples/account/update-password.md +4 -4
- package/docs/examples/account/update-phone-session.md +4 -4
- package/docs/examples/account/update-phone-verification.md +4 -4
- package/docs/examples/account/update-phone.md +4 -4
- package/docs/examples/account/update-prefs.md +3 -3
- package/docs/examples/account/update-push-target.md +4 -4
- package/docs/examples/account/update-recovery.md +5 -5
- package/docs/examples/account/update-session.md +3 -3
- package/docs/examples/account/update-verification.md +4 -4
- package/docs/examples/avatars/get-browser.md +6 -6
- package/docs/examples/avatars/get-credit-card.md +6 -6
- package/docs/examples/avatars/get-favicon.md +3 -3
- package/docs/examples/avatars/get-flag.md +6 -6
- package/docs/examples/avatars/get-image.md +5 -5
- package/docs/examples/avatars/get-initials.md +6 -6
- package/docs/examples/avatars/{get-q-r.md → get-qr.md} +6 -6
- package/docs/examples/databases/create-document.md +7 -7
- package/docs/examples/databases/decrement-document-attribute.md +8 -8
- package/docs/examples/databases/delete-document.md +5 -5
- package/docs/examples/databases/get-document.md +6 -6
- package/docs/examples/databases/increment-document-attribute.md +8 -8
- package/docs/examples/databases/list-documents.md +5 -5
- package/docs/examples/databases/update-document.md +7 -7
- package/docs/examples/databases/upsert-document.md +7 -7
- package/docs/examples/functions/create-execution.md +9 -9
- package/docs/examples/functions/get-execution.md +4 -4
- package/docs/examples/functions/list-executions.md +4 -4
- package/docs/examples/graphql/mutation.md +3 -3
- package/docs/examples/graphql/query.md +3 -3
- package/docs/examples/messaging/create-subscriber.md +5 -5
- package/docs/examples/messaging/delete-subscriber.md +4 -4
- package/docs/examples/storage/create-file.md +6 -6
- package/docs/examples/storage/delete-file.md +4 -4
- package/docs/examples/storage/get-file-download.md +5 -5
- package/docs/examples/storage/get-file-preview.md +16 -16
- package/docs/examples/storage/get-file-view.md +5 -5
- package/docs/examples/storage/get-file.md +4 -4
- package/docs/examples/storage/list-files.md +5 -5
- package/docs/examples/storage/update-file.md +6 -6
- package/docs/examples/tablesdb/create-row.md +17 -0
- package/docs/examples/tablesdb/decrement-row-column.md +18 -0
- package/docs/examples/tablesdb/delete-row.md +15 -0
- package/docs/examples/tablesdb/get-row.md +16 -0
- package/docs/examples/tablesdb/increment-row-column.md +18 -0
- package/docs/examples/tablesdb/list-rows.md +15 -0
- package/docs/examples/tablesdb/update-row.md +17 -0
- package/docs/examples/tablesdb/upsert-row.md +17 -0
- package/docs/examples/teams/create-membership.md +9 -9
- package/docs/examples/teams/create.md +5 -5
- package/docs/examples/teams/delete-membership.md +4 -4
- package/docs/examples/teams/delete.md +3 -3
- package/docs/examples/teams/get-membership.md +4 -4
- package/docs/examples/teams/get-prefs.md +3 -3
- package/docs/examples/teams/get.md +3 -3
- package/docs/examples/teams/list-memberships.md +5 -5
- package/docs/examples/teams/list.md +4 -4
- package/docs/examples/teams/update-membership-status.md +6 -6
- package/docs/examples/teams/update-membership.md +5 -5
- package/docs/examples/teams/update-name.md +4 -4
- package/docs/examples/teams/update-prefs.md +4 -4
- package/package.json +1 -1
- package/src/client.ts +2 -2
- package/src/index.ts +1 -0
- package/src/models.ts +72 -27
- package/src/query.ts +95 -0
- package/src/services/account.ts +1469 -315
- package/src/services/avatars.ts +289 -80
- package/src/services/databases.ts +354 -63
- package/src/services/functions.ts +115 -20
- package/src/services/graphql.ts +52 -4
- package/src/services/locale.ts +8 -19
- package/src/services/messaging.ts +66 -7
- package/src/services/storage.ts +345 -76
- package/src/services/tables-db.ts +621 -0
- package/src/services/teams.ts +454 -93
- package/types/index.d.ts +1 -0
- package/types/models.d.ts +69 -25
- package/types/query.d.ts +77 -0
- package/types/services/account.d.ts +734 -280
- package/types/services/avatars.d.ts +168 -73
- package/types/services/databases.d.ts +199 -58
- package/types/services/functions.d.ts +62 -17
- package/types/services/graphql.d.ts +24 -2
- package/types/services/locale.d.ts +8 -19
- package/types/services/messaging.d.ts +33 -5
- package/types/services/storage.d.ts +201 -68
- package/types/services/tables-db.d.ts +245 -0
- package/types/services/teams.d.ts +242 -80
- /package/docs/examples/account/{create-j-w-t.md → create-jwt.md} +0 -0
- /package/docs/examples/locale/{list-countries-e-u.md → list-countries-eu.md} +0 -0
package/src/services/storage.ts
CHANGED
|
@@ -16,16 +16,46 @@ export class Storage extends Service {
|
|
|
16
16
|
}
|
|
17
17
|
|
|
18
18
|
/**
|
|
19
|
-
* Get a list of all the user files. You can use the query params to filter
|
|
20
|
-
* your results.
|
|
19
|
+
* Get a list of all the user files. You can use the query params to filter your results.
|
|
21
20
|
*
|
|
22
|
-
* @param {string} bucketId
|
|
23
|
-
* @param {string[]} queries
|
|
24
|
-
* @param {string} search
|
|
21
|
+
* @param {string} params.bucketId - Storage bucket unique ID. You can create a new storage bucket using the Storage service [server integration](https://appwrite.io/docs/server/storage#createBucket).
|
|
22
|
+
* @param {string[]} params.queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: name, signature, mimeType, sizeOriginal, chunksTotal, chunksUploaded
|
|
23
|
+
* @param {string} params.search - Search term to filter your list results. Max length: 256 chars.
|
|
25
24
|
* @throws {AppwriteException}
|
|
26
25
|
* @returns {Promise}
|
|
27
26
|
*/
|
|
28
|
-
listFiles(bucketId: string, queries?: string[], search?: string): Promise<Models.FileList
|
|
27
|
+
listFiles(params: { bucketId: string, queries?: string[], search?: string }): Promise<Models.FileList>;
|
|
28
|
+
/**
|
|
29
|
+
* Get a list of all the user files. You can use the query params to filter your results.
|
|
30
|
+
*
|
|
31
|
+
* @param {string} bucketId - Storage bucket unique ID. You can create a new storage bucket using the Storage service [server integration](https://appwrite.io/docs/server/storage#createBucket).
|
|
32
|
+
* @param {string[]} queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: name, signature, mimeType, sizeOriginal, chunksTotal, chunksUploaded
|
|
33
|
+
* @param {string} search - Search term to filter your list results. Max length: 256 chars.
|
|
34
|
+
* @throws {AppwriteException}
|
|
35
|
+
* @returns {Promise<Models.FileList>}
|
|
36
|
+
* @deprecated Use the object parameter style method for a better developer experience.
|
|
37
|
+
*/
|
|
38
|
+
listFiles(bucketId: string, queries?: string[], search?: string): Promise<Models.FileList>;
|
|
39
|
+
listFiles(
|
|
40
|
+
paramsOrFirst: { bucketId: string, queries?: string[], search?: string } | string,
|
|
41
|
+
...rest: [(string[])?, (string)?]
|
|
42
|
+
): Promise<Models.FileList> {
|
|
43
|
+
let params: { bucketId: string, queries?: string[], search?: string };
|
|
44
|
+
|
|
45
|
+
if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) {
|
|
46
|
+
params = (paramsOrFirst || {}) as { bucketId: string, queries?: string[], search?: string };
|
|
47
|
+
} else {
|
|
48
|
+
params = {
|
|
49
|
+
bucketId: paramsOrFirst as string,
|
|
50
|
+
queries: rest[0] as string[],
|
|
51
|
+
search: rest[1] as string
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
const bucketId = params.bucketId;
|
|
56
|
+
const queries = params.queries;
|
|
57
|
+
const search = params.search;
|
|
58
|
+
|
|
29
59
|
if (typeof bucketId === 'undefined') {
|
|
30
60
|
throw new AppwriteException('Missing required parameter: "bucketId"');
|
|
31
61
|
}
|
|
@@ -47,33 +77,67 @@ export class Storage extends Service {
|
|
|
47
77
|
}
|
|
48
78
|
|
|
49
79
|
/**
|
|
50
|
-
* Create a new file. Before using this route, you should create a new bucket
|
|
51
|
-
* resource using either a [server
|
|
52
|
-
* integration](https://appwrite.io/docs/server/storage#storageCreateBucket)
|
|
53
|
-
* API or directly from your Appwrite console.
|
|
80
|
+
* Create a new file. Before using this route, you should create a new bucket resource using either a [server integration](https://appwrite.io/docs/server/storage#storageCreateBucket) API or directly from your Appwrite console.
|
|
54
81
|
*
|
|
55
|
-
* Larger files should be uploaded using multiple requests with the
|
|
56
|
-
* [content-range](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Range)
|
|
57
|
-
* header to send a partial request with a maximum supported chunk of `5MB`.
|
|
58
|
-
* The `content-range` header values should always be in bytes.
|
|
82
|
+
* Larger files should be uploaded using multiple requests with the [content-range](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Range) header to send a partial request with a maximum supported chunk of `5MB`. The `content-range` header values should always be in bytes.
|
|
59
83
|
*
|
|
60
|
-
* When the first request is sent, the server will return the **File** object,
|
|
61
|
-
* and the subsequent part request must include the file's **id** in
|
|
62
|
-
* `x-appwrite-id` header to allow the server to know that the partial upload
|
|
63
|
-
* is for the existing file and not for a new one.
|
|
84
|
+
* When the first request is sent, the server will return the **File** object, and the subsequent part request must include the file's **id** in `x-appwrite-id` header to allow the server to know that the partial upload is for the existing file and not for a new one.
|
|
64
85
|
*
|
|
65
|
-
* If you're creating a new file using one of the Appwrite SDKs, all the
|
|
66
|
-
* chunking logic will be managed by the SDK internally.
|
|
86
|
+
* If you're creating a new file using one of the Appwrite SDKs, all the chunking logic will be managed by the SDK internally.
|
|
67
87
|
*
|
|
68
88
|
*
|
|
69
|
-
* @param {string} bucketId
|
|
70
|
-
* @param {string} fileId
|
|
71
|
-
* @param {{name: string, type: string, size: number, uri: string}} file
|
|
72
|
-
* @param {string[]} permissions
|
|
89
|
+
* @param {string} params.bucketId - Storage bucket unique ID. You can create a new storage bucket using the Storage service [server integration](https://appwrite.io/docs/server/storage#createBucket).
|
|
90
|
+
* @param {string} params.fileId - File ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars.
|
|
91
|
+
* @param {{name: string, type: string, size: number, uri: string}} params.file - Binary file. Appwrite SDKs provide helpers to handle file input. [Learn about file input](https://appwrite.io/docs/products/storage/upload-download#input-file).
|
|
92
|
+
* @param {string[]} params.permissions - An array of permission strings. By default, only the current user is granted all permissions. [Learn more about permissions](https://appwrite.io/docs/permissions).
|
|
73
93
|
* @throws {AppwriteException}
|
|
74
94
|
* @returns {Promise}
|
|
75
95
|
*/
|
|
76
|
-
async createFile(bucketId: string, fileId: string, file: {name: string, type: string, size: number, uri: string}, permissions?: string[], onProgress
|
|
96
|
+
async createFile(params: { bucketId: string, fileId: string, file: {name: string, type: string, size: number, uri: string}, permissions?: string[] , onProgress?: (progress: UploadProgress) => void }): Promise<Models.File>;
|
|
97
|
+
/**
|
|
98
|
+
* Create a new file. Before using this route, you should create a new bucket resource using either a [server integration](https://appwrite.io/docs/server/storage#storageCreateBucket) API or directly from your Appwrite console.
|
|
99
|
+
*
|
|
100
|
+
* Larger files should be uploaded using multiple requests with the [content-range](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Range) header to send a partial request with a maximum supported chunk of `5MB`. The `content-range` header values should always be in bytes.
|
|
101
|
+
*
|
|
102
|
+
* When the first request is sent, the server will return the **File** object, and the subsequent part request must include the file's **id** in `x-appwrite-id` header to allow the server to know that the partial upload is for the existing file and not for a new one.
|
|
103
|
+
*
|
|
104
|
+
* If you're creating a new file using one of the Appwrite SDKs, all the chunking logic will be managed by the SDK internally.
|
|
105
|
+
*
|
|
106
|
+
*
|
|
107
|
+
* @param {string} bucketId - Storage bucket unique ID. You can create a new storage bucket using the Storage service [server integration](https://appwrite.io/docs/server/storage#createBucket).
|
|
108
|
+
* @param {string} fileId - File ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars.
|
|
109
|
+
* @param {{name: string, type: string, size: number, uri: string}} file - Binary file. Appwrite SDKs provide helpers to handle file input. [Learn about file input](https://appwrite.io/docs/products/storage/upload-download#input-file).
|
|
110
|
+
* @param {string[]} permissions - An array of permission strings. By default, only the current user is granted all permissions. [Learn more about permissions](https://appwrite.io/docs/permissions).
|
|
111
|
+
* @throws {AppwriteException}
|
|
112
|
+
* @returns {Promise<Models.File>}
|
|
113
|
+
* @deprecated Use the object parameter style method for a better developer experience.
|
|
114
|
+
*/
|
|
115
|
+
async createFile(bucketId: string, fileId: string, file: {name: string, type: string, size: number, uri: string}, permissions?: string[], onProgress?: (progress: UploadProgress) => void): Promise<Models.File>;
|
|
116
|
+
async createFile(
|
|
117
|
+
paramsOrFirst: { bucketId: string, fileId: string, file: {name: string, type: string, size: number, uri: string}, permissions?: string[], onProgress?: (progress: UploadProgress) => void } | string,
|
|
118
|
+
...rest: [(string)?, ({name: string, type: string, size: number, uri: string})?, (string[])?,((progress: UploadProgress) => void)?]
|
|
119
|
+
): Promise<Models.File> {
|
|
120
|
+
let params: { bucketId: string, fileId: string, file: {name: string, type: string, size: number, uri: string}, permissions?: string[] };
|
|
121
|
+
let onProgress: ((progress: UploadProgress) => void);
|
|
122
|
+
|
|
123
|
+
if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) {
|
|
124
|
+
params = (paramsOrFirst || {}) as { bucketId: string, fileId: string, file: {name: string, type: string, size: number, uri: string}, permissions?: string[] };
|
|
125
|
+
onProgress = paramsOrFirst?.onProgress as ((progress: UploadProgress) => void);
|
|
126
|
+
} else {
|
|
127
|
+
params = {
|
|
128
|
+
bucketId: paramsOrFirst as string,
|
|
129
|
+
fileId: rest[0] as string,
|
|
130
|
+
file: rest[1] as {name: string, type: string, size: number, uri: string},
|
|
131
|
+
permissions: rest[2] as string[]
|
|
132
|
+
};
|
|
133
|
+
onProgress = rest[3] as ((progress: UploadProgress) => void);
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
const bucketId = params.bucketId;
|
|
137
|
+
const fileId = params.fileId;
|
|
138
|
+
const file = params.file;
|
|
139
|
+
const permissions = params.permissions;
|
|
140
|
+
|
|
77
141
|
if (typeof bucketId === 'undefined') {
|
|
78
142
|
throw new AppwriteException('Missing required parameter: "bucketId"');
|
|
79
143
|
}
|
|
@@ -162,15 +226,42 @@ export class Storage extends Service {
|
|
|
162
226
|
}
|
|
163
227
|
|
|
164
228
|
/**
|
|
165
|
-
* Get a file by its unique ID. This endpoint response returns a JSON object
|
|
166
|
-
* with the file metadata.
|
|
229
|
+
* Get a file by its unique ID. This endpoint response returns a JSON object with the file metadata.
|
|
167
230
|
*
|
|
168
|
-
* @param {string} bucketId
|
|
169
|
-
* @param {string} fileId
|
|
231
|
+
* @param {string} params.bucketId - Storage bucket unique ID. You can create a new storage bucket using the Storage service [server integration](https://appwrite.io/docs/server/storage#createBucket).
|
|
232
|
+
* @param {string} params.fileId - File ID.
|
|
170
233
|
* @throws {AppwriteException}
|
|
171
234
|
* @returns {Promise}
|
|
172
235
|
*/
|
|
173
|
-
getFile(bucketId: string, fileId: string): Promise<Models.File
|
|
236
|
+
getFile(params: { bucketId: string, fileId: string }): Promise<Models.File>;
|
|
237
|
+
/**
|
|
238
|
+
* Get a file by its unique ID. This endpoint response returns a JSON object with the file metadata.
|
|
239
|
+
*
|
|
240
|
+
* @param {string} bucketId - Storage bucket unique ID. You can create a new storage bucket using the Storage service [server integration](https://appwrite.io/docs/server/storage#createBucket).
|
|
241
|
+
* @param {string} fileId - File ID.
|
|
242
|
+
* @throws {AppwriteException}
|
|
243
|
+
* @returns {Promise<Models.File>}
|
|
244
|
+
* @deprecated Use the object parameter style method for a better developer experience.
|
|
245
|
+
*/
|
|
246
|
+
getFile(bucketId: string, fileId: string): Promise<Models.File>;
|
|
247
|
+
getFile(
|
|
248
|
+
paramsOrFirst: { bucketId: string, fileId: string } | string,
|
|
249
|
+
...rest: [(string)?]
|
|
250
|
+
): Promise<Models.File> {
|
|
251
|
+
let params: { bucketId: string, fileId: string };
|
|
252
|
+
|
|
253
|
+
if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) {
|
|
254
|
+
params = (paramsOrFirst || {}) as { bucketId: string, fileId: string };
|
|
255
|
+
} else {
|
|
256
|
+
params = {
|
|
257
|
+
bucketId: paramsOrFirst as string,
|
|
258
|
+
fileId: rest[0] as string
|
|
259
|
+
};
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
const bucketId = params.bucketId;
|
|
263
|
+
const fileId = params.fileId;
|
|
264
|
+
|
|
174
265
|
if (typeof bucketId === 'undefined') {
|
|
175
266
|
throw new AppwriteException('Missing required parameter: "bucketId"');
|
|
176
267
|
}
|
|
@@ -188,17 +279,50 @@ export class Storage extends Service {
|
|
|
188
279
|
}
|
|
189
280
|
|
|
190
281
|
/**
|
|
191
|
-
* Update a file by its unique ID. Only users with write permissions have
|
|
192
|
-
* access to update this resource.
|
|
282
|
+
* Update a file by its unique ID. Only users with write permissions have access to update this resource.
|
|
193
283
|
*
|
|
194
|
-
* @param {string} bucketId
|
|
195
|
-
* @param {string} fileId
|
|
196
|
-
* @param {string} name
|
|
197
|
-
* @param {string[]} permissions
|
|
284
|
+
* @param {string} params.bucketId - Storage bucket unique ID. You can create a new storage bucket using the Storage service [server integration](https://appwrite.io/docs/server/storage#createBucket).
|
|
285
|
+
* @param {string} params.fileId - File unique ID.
|
|
286
|
+
* @param {string} params.name - Name of the file
|
|
287
|
+
* @param {string[]} params.permissions - An array of permission string. By default, the current permissions are inherited. [Learn more about permissions](https://appwrite.io/docs/permissions).
|
|
198
288
|
* @throws {AppwriteException}
|
|
199
289
|
* @returns {Promise}
|
|
200
290
|
*/
|
|
201
|
-
updateFile(bucketId: string, fileId: string, name?: string, permissions?: string[]): Promise<Models.File
|
|
291
|
+
updateFile(params: { bucketId: string, fileId: string, name?: string, permissions?: string[] }): Promise<Models.File>;
|
|
292
|
+
/**
|
|
293
|
+
* Update a file by its unique ID. Only users with write permissions have access to update this resource.
|
|
294
|
+
*
|
|
295
|
+
* @param {string} bucketId - Storage bucket unique ID. You can create a new storage bucket using the Storage service [server integration](https://appwrite.io/docs/server/storage#createBucket).
|
|
296
|
+
* @param {string} fileId - File unique ID.
|
|
297
|
+
* @param {string} name - Name of the file
|
|
298
|
+
* @param {string[]} permissions - An array of permission string. By default, the current permissions are inherited. [Learn more about permissions](https://appwrite.io/docs/permissions).
|
|
299
|
+
* @throws {AppwriteException}
|
|
300
|
+
* @returns {Promise<Models.File>}
|
|
301
|
+
* @deprecated Use the object parameter style method for a better developer experience.
|
|
302
|
+
*/
|
|
303
|
+
updateFile(bucketId: string, fileId: string, name?: string, permissions?: string[]): Promise<Models.File>;
|
|
304
|
+
updateFile(
|
|
305
|
+
paramsOrFirst: { bucketId: string, fileId: string, name?: string, permissions?: string[] } | string,
|
|
306
|
+
...rest: [(string)?, (string)?, (string[])?]
|
|
307
|
+
): Promise<Models.File> {
|
|
308
|
+
let params: { bucketId: string, fileId: string, name?: string, permissions?: string[] };
|
|
309
|
+
|
|
310
|
+
if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) {
|
|
311
|
+
params = (paramsOrFirst || {}) as { bucketId: string, fileId: string, name?: string, permissions?: string[] };
|
|
312
|
+
} else {
|
|
313
|
+
params = {
|
|
314
|
+
bucketId: paramsOrFirst as string,
|
|
315
|
+
fileId: rest[0] as string,
|
|
316
|
+
name: rest[1] as string,
|
|
317
|
+
permissions: rest[2] as string[]
|
|
318
|
+
};
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
const bucketId = params.bucketId;
|
|
322
|
+
const fileId = params.fileId;
|
|
323
|
+
const name = params.name;
|
|
324
|
+
const permissions = params.permissions;
|
|
325
|
+
|
|
202
326
|
if (typeof bucketId === 'undefined') {
|
|
203
327
|
throw new AppwriteException('Missing required parameter: "bucketId"');
|
|
204
328
|
}
|
|
@@ -225,15 +349,42 @@ export class Storage extends Service {
|
|
|
225
349
|
}
|
|
226
350
|
|
|
227
351
|
/**
|
|
228
|
-
* Delete a file by its unique ID. Only users with write permissions have
|
|
229
|
-
* access to delete this resource.
|
|
352
|
+
* Delete a file by its unique ID. Only users with write permissions have access to delete this resource.
|
|
230
353
|
*
|
|
231
|
-
* @param {string} bucketId
|
|
232
|
-
* @param {string} fileId
|
|
354
|
+
* @param {string} params.bucketId - Storage bucket unique ID. You can create a new storage bucket using the Storage service [server integration](https://appwrite.io/docs/server/storage#createBucket).
|
|
355
|
+
* @param {string} params.fileId - File ID.
|
|
233
356
|
* @throws {AppwriteException}
|
|
234
357
|
* @returns {Promise}
|
|
235
358
|
*/
|
|
236
|
-
deleteFile(bucketId: string, fileId: string): Promise<{}
|
|
359
|
+
deleteFile(params: { bucketId: string, fileId: string }): Promise<{}>;
|
|
360
|
+
/**
|
|
361
|
+
* Delete a file by its unique ID. Only users with write permissions have access to delete this resource.
|
|
362
|
+
*
|
|
363
|
+
* @param {string} bucketId - Storage bucket unique ID. You can create a new storage bucket using the Storage service [server integration](https://appwrite.io/docs/server/storage#createBucket).
|
|
364
|
+
* @param {string} fileId - File ID.
|
|
365
|
+
* @throws {AppwriteException}
|
|
366
|
+
* @returns {Promise<{}>}
|
|
367
|
+
* @deprecated Use the object parameter style method for a better developer experience.
|
|
368
|
+
*/
|
|
369
|
+
deleteFile(bucketId: string, fileId: string): Promise<{}>;
|
|
370
|
+
deleteFile(
|
|
371
|
+
paramsOrFirst: { bucketId: string, fileId: string } | string,
|
|
372
|
+
...rest: [(string)?]
|
|
373
|
+
): Promise<{}> {
|
|
374
|
+
let params: { bucketId: string, fileId: string };
|
|
375
|
+
|
|
376
|
+
if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) {
|
|
377
|
+
params = (paramsOrFirst || {}) as { bucketId: string, fileId: string };
|
|
378
|
+
} else {
|
|
379
|
+
params = {
|
|
380
|
+
bucketId: paramsOrFirst as string,
|
|
381
|
+
fileId: rest[0] as string
|
|
382
|
+
};
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
const bucketId = params.bucketId;
|
|
386
|
+
const fileId = params.fileId;
|
|
387
|
+
|
|
237
388
|
if (typeof bucketId === 'undefined') {
|
|
238
389
|
throw new AppwriteException('Missing required parameter: "bucketId"');
|
|
239
390
|
}
|
|
@@ -252,17 +403,46 @@ export class Storage extends Service {
|
|
|
252
403
|
}
|
|
253
404
|
|
|
254
405
|
/**
|
|
255
|
-
* Get a file content by its unique ID. The endpoint response return with a
|
|
256
|
-
* 'Content-Disposition: attachment' header that tells the browser to start
|
|
257
|
-
* downloading the file to user downloads directory.
|
|
406
|
+
* Get a file content by its unique ID. The endpoint response return with a 'Content-Disposition: attachment' header that tells the browser to start downloading the file to user downloads directory.
|
|
258
407
|
*
|
|
259
|
-
* @param {string} bucketId
|
|
260
|
-
* @param {string} fileId
|
|
261
|
-
* @param {string} token
|
|
408
|
+
* @param {string} params.bucketId - Storage bucket ID. You can create a new storage bucket using the Storage service [server integration](https://appwrite.io/docs/server/storage#createBucket).
|
|
409
|
+
* @param {string} params.fileId - File ID.
|
|
410
|
+
* @param {string} params.token - File token for accessing this file.
|
|
262
411
|
* @throws {AppwriteException}
|
|
263
412
|
* @returns {ArrayBuffer}
|
|
264
413
|
*/
|
|
265
|
-
getFileDownload(bucketId: string, fileId: string, token?: string): Promise<ArrayBuffer
|
|
414
|
+
getFileDownload(params: { bucketId: string, fileId: string, token?: string }): Promise<ArrayBuffer>;
|
|
415
|
+
/**
|
|
416
|
+
* Get a file content by its unique ID. The endpoint response return with a 'Content-Disposition: attachment' header that tells the browser to start downloading the file to user downloads directory.
|
|
417
|
+
*
|
|
418
|
+
* @param {string} bucketId - Storage bucket ID. You can create a new storage bucket using the Storage service [server integration](https://appwrite.io/docs/server/storage#createBucket).
|
|
419
|
+
* @param {string} fileId - File ID.
|
|
420
|
+
* @param {string} token - File token for accessing this file.
|
|
421
|
+
* @throws {AppwriteException}
|
|
422
|
+
* @returns {Promise<ArrayBuffer>}
|
|
423
|
+
* @deprecated Use the object parameter style method for a better developer experience.
|
|
424
|
+
*/
|
|
425
|
+
getFileDownload(bucketId: string, fileId: string, token?: string): Promise<ArrayBuffer>;
|
|
426
|
+
getFileDownload(
|
|
427
|
+
paramsOrFirst: { bucketId: string, fileId: string, token?: string } | string,
|
|
428
|
+
...rest: [(string)?, (string)?]
|
|
429
|
+
): Promise<ArrayBuffer> {
|
|
430
|
+
let params: { bucketId: string, fileId: string, token?: string };
|
|
431
|
+
|
|
432
|
+
if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) {
|
|
433
|
+
params = (paramsOrFirst || {}) as { bucketId: string, fileId: string, token?: string };
|
|
434
|
+
} else {
|
|
435
|
+
params = {
|
|
436
|
+
bucketId: paramsOrFirst as string,
|
|
437
|
+
fileId: rest[0] as string,
|
|
438
|
+
token: rest[1] as string
|
|
439
|
+
};
|
|
440
|
+
}
|
|
441
|
+
|
|
442
|
+
const bucketId = params.bucketId;
|
|
443
|
+
const fileId = params.fileId;
|
|
444
|
+
const token = params.token;
|
|
445
|
+
|
|
266
446
|
if (typeof bucketId === 'undefined') {
|
|
267
447
|
throw new AppwriteException('Missing required parameter: "bucketId"');
|
|
268
448
|
}
|
|
@@ -290,30 +470,90 @@ export class Storage extends Service {
|
|
|
290
470
|
}
|
|
291
471
|
|
|
292
472
|
/**
|
|
293
|
-
* Get a file preview image. Currently, this method supports preview for image
|
|
294
|
-
* files (jpg, png, and gif), other supported formats, like pdf, docs, slides,
|
|
295
|
-
* and spreadsheets, will return the file icon image. You can also pass query
|
|
296
|
-
* string arguments for cutting and resizing your preview image. Preview is
|
|
297
|
-
* supported only for image files smaller than 10MB.
|
|
473
|
+
* Get a file preview image. Currently, this method supports preview for image files (jpg, png, and gif), other supported formats, like pdf, docs, slides, and spreadsheets, will return the file icon image. You can also pass query string arguments for cutting and resizing your preview image. Preview is supported only for image files smaller than 10MB.
|
|
298
474
|
*
|
|
299
|
-
* @param {string} bucketId
|
|
300
|
-
* @param {string} fileId
|
|
301
|
-
* @param {number} width
|
|
302
|
-
* @param {number} height
|
|
303
|
-
* @param {ImageGravity} gravity
|
|
304
|
-
* @param {number} quality
|
|
305
|
-
* @param {number} borderWidth
|
|
306
|
-
* @param {string} borderColor
|
|
307
|
-
* @param {number} borderRadius
|
|
308
|
-
* @param {number} opacity
|
|
309
|
-
* @param {number} rotation
|
|
310
|
-
* @param {string} background
|
|
311
|
-
* @param {ImageFormat} output
|
|
312
|
-
* @param {string} token
|
|
475
|
+
* @param {string} params.bucketId - Storage bucket unique ID. You can create a new storage bucket using the Storage service [server integration](https://appwrite.io/docs/server/storage#createBucket).
|
|
476
|
+
* @param {string} params.fileId - File ID
|
|
477
|
+
* @param {number} params.width - Resize preview image width, Pass an integer between 0 to 4000.
|
|
478
|
+
* @param {number} params.height - Resize preview image height, Pass an integer between 0 to 4000.
|
|
479
|
+
* @param {ImageGravity} params.gravity - Image crop gravity. Can be one of center,top-left,top,top-right,left,right,bottom-left,bottom,bottom-right
|
|
480
|
+
* @param {number} params.quality - Preview image quality. Pass an integer between 0 to 100. Defaults to keep existing image quality.
|
|
481
|
+
* @param {number} params.borderWidth - Preview image border in pixels. Pass an integer between 0 to 100. Defaults to 0.
|
|
482
|
+
* @param {string} params.borderColor - Preview image border color. Use a valid HEX color, no # is needed for prefix.
|
|
483
|
+
* @param {number} params.borderRadius - Preview image border radius in pixels. Pass an integer between 0 to 4000.
|
|
484
|
+
* @param {number} params.opacity - Preview image opacity. Only works with images having an alpha channel (like png). Pass a number between 0 to 1.
|
|
485
|
+
* @param {number} params.rotation - Preview image rotation in degrees. Pass an integer between -360 and 360.
|
|
486
|
+
* @param {string} params.background - Preview image background color. Only works with transparent images (png). Use a valid HEX color, no # is needed for prefix.
|
|
487
|
+
* @param {ImageFormat} params.output - Output format type (jpeg, jpg, png, gif and webp).
|
|
488
|
+
* @param {string} params.token - File token for accessing this file.
|
|
313
489
|
* @throws {AppwriteException}
|
|
314
490
|
* @returns {ArrayBuffer}
|
|
315
491
|
*/
|
|
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
|
|
492
|
+
getFilePreview(params: { 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>;
|
|
493
|
+
/**
|
|
494
|
+
* Get a file preview image. Currently, this method supports preview for image files (jpg, png, and gif), other supported formats, like pdf, docs, slides, and spreadsheets, will return the file icon image. You can also pass query string arguments for cutting and resizing your preview image. Preview is supported only for image files smaller than 10MB.
|
|
495
|
+
*
|
|
496
|
+
* @param {string} bucketId - Storage bucket unique ID. You can create a new storage bucket using the Storage service [server integration](https://appwrite.io/docs/server/storage#createBucket).
|
|
497
|
+
* @param {string} fileId - File ID
|
|
498
|
+
* @param {number} width - Resize preview image width, Pass an integer between 0 to 4000.
|
|
499
|
+
* @param {number} height - Resize preview image height, Pass an integer between 0 to 4000.
|
|
500
|
+
* @param {ImageGravity} gravity - Image crop gravity. Can be one of center,top-left,top,top-right,left,right,bottom-left,bottom,bottom-right
|
|
501
|
+
* @param {number} quality - Preview image quality. Pass an integer between 0 to 100. Defaults to keep existing image quality.
|
|
502
|
+
* @param {number} borderWidth - Preview image border in pixels. Pass an integer between 0 to 100. Defaults to 0.
|
|
503
|
+
* @param {string} borderColor - Preview image border color. Use a valid HEX color, no # is needed for prefix.
|
|
504
|
+
* @param {number} borderRadius - Preview image border radius in pixels. Pass an integer between 0 to 4000.
|
|
505
|
+
* @param {number} opacity - Preview image opacity. Only works with images having an alpha channel (like png). Pass a number between 0 to 1.
|
|
506
|
+
* @param {number} rotation - Preview image rotation in degrees. Pass an integer between -360 and 360.
|
|
507
|
+
* @param {string} background - Preview image background color. Only works with transparent images (png). Use a valid HEX color, no # is needed for prefix.
|
|
508
|
+
* @param {ImageFormat} output - Output format type (jpeg, jpg, png, gif and webp).
|
|
509
|
+
* @param {string} token - File token for accessing this file.
|
|
510
|
+
* @throws {AppwriteException}
|
|
511
|
+
* @returns {Promise<ArrayBuffer>}
|
|
512
|
+
* @deprecated Use the object parameter style method for a better developer experience.
|
|
513
|
+
*/
|
|
514
|
+
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>;
|
|
515
|
+
getFilePreview(
|
|
516
|
+
paramsOrFirst: { 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 } | string,
|
|
517
|
+
...rest: [(string)?, (number)?, (number)?, (ImageGravity)?, (number)?, (number)?, (string)?, (number)?, (number)?, (number)?, (string)?, (ImageFormat)?, (string)?]
|
|
518
|
+
): Promise<ArrayBuffer> {
|
|
519
|
+
let params: { 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 };
|
|
520
|
+
|
|
521
|
+
if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) {
|
|
522
|
+
params = (paramsOrFirst || {}) as { 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 };
|
|
523
|
+
} else {
|
|
524
|
+
params = {
|
|
525
|
+
bucketId: paramsOrFirst as string,
|
|
526
|
+
fileId: rest[0] as string,
|
|
527
|
+
width: rest[1] as number,
|
|
528
|
+
height: rest[2] as number,
|
|
529
|
+
gravity: rest[3] as ImageGravity,
|
|
530
|
+
quality: rest[4] as number,
|
|
531
|
+
borderWidth: rest[5] as number,
|
|
532
|
+
borderColor: rest[6] as string,
|
|
533
|
+
borderRadius: rest[7] as number,
|
|
534
|
+
opacity: rest[8] as number,
|
|
535
|
+
rotation: rest[9] as number,
|
|
536
|
+
background: rest[10] as string,
|
|
537
|
+
output: rest[11] as ImageFormat,
|
|
538
|
+
token: rest[12] as string
|
|
539
|
+
};
|
|
540
|
+
}
|
|
541
|
+
|
|
542
|
+
const bucketId = params.bucketId;
|
|
543
|
+
const fileId = params.fileId;
|
|
544
|
+
const width = params.width;
|
|
545
|
+
const height = params.height;
|
|
546
|
+
const gravity = params.gravity;
|
|
547
|
+
const quality = params.quality;
|
|
548
|
+
const borderWidth = params.borderWidth;
|
|
549
|
+
const borderColor = params.borderColor;
|
|
550
|
+
const borderRadius = params.borderRadius;
|
|
551
|
+
const opacity = params.opacity;
|
|
552
|
+
const rotation = params.rotation;
|
|
553
|
+
const background = params.background;
|
|
554
|
+
const output = params.output;
|
|
555
|
+
const token = params.token;
|
|
556
|
+
|
|
317
557
|
if (typeof bucketId === 'undefined') {
|
|
318
558
|
throw new AppwriteException('Missing required parameter: "bucketId"');
|
|
319
559
|
}
|
|
@@ -385,17 +625,46 @@ export class Storage extends Service {
|
|
|
385
625
|
}
|
|
386
626
|
|
|
387
627
|
/**
|
|
388
|
-
* Get a file content by its unique ID. This endpoint is similar to the
|
|
389
|
-
* download method but returns with no 'Content-Disposition: attachment'
|
|
390
|
-
* header.
|
|
628
|
+
* Get a file content by its unique ID. This endpoint is similar to the download method but returns with no 'Content-Disposition: attachment' header.
|
|
391
629
|
*
|
|
392
|
-
* @param {string} bucketId
|
|
393
|
-
* @param {string} fileId
|
|
394
|
-
* @param {string} token
|
|
630
|
+
* @param {string} params.bucketId - Storage bucket unique ID. You can create a new storage bucket using the Storage service [server integration](https://appwrite.io/docs/server/storage#createBucket).
|
|
631
|
+
* @param {string} params.fileId - File ID.
|
|
632
|
+
* @param {string} params.token - File token for accessing this file.
|
|
395
633
|
* @throws {AppwriteException}
|
|
396
634
|
* @returns {ArrayBuffer}
|
|
397
635
|
*/
|
|
398
|
-
getFileView(bucketId: string, fileId: string, token?: string): Promise<ArrayBuffer
|
|
636
|
+
getFileView(params: { bucketId: string, fileId: string, token?: string }): Promise<ArrayBuffer>;
|
|
637
|
+
/**
|
|
638
|
+
* Get a file content by its unique ID. This endpoint is similar to the download method but returns with no 'Content-Disposition: attachment' header.
|
|
639
|
+
*
|
|
640
|
+
* @param {string} bucketId - Storage bucket unique ID. You can create a new storage bucket using the Storage service [server integration](https://appwrite.io/docs/server/storage#createBucket).
|
|
641
|
+
* @param {string} fileId - File ID.
|
|
642
|
+
* @param {string} token - File token for accessing this file.
|
|
643
|
+
* @throws {AppwriteException}
|
|
644
|
+
* @returns {Promise<ArrayBuffer>}
|
|
645
|
+
* @deprecated Use the object parameter style method for a better developer experience.
|
|
646
|
+
*/
|
|
647
|
+
getFileView(bucketId: string, fileId: string, token?: string): Promise<ArrayBuffer>;
|
|
648
|
+
getFileView(
|
|
649
|
+
paramsOrFirst: { bucketId: string, fileId: string, token?: string } | string,
|
|
650
|
+
...rest: [(string)?, (string)?]
|
|
651
|
+
): Promise<ArrayBuffer> {
|
|
652
|
+
let params: { bucketId: string, fileId: string, token?: string };
|
|
653
|
+
|
|
654
|
+
if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) {
|
|
655
|
+
params = (paramsOrFirst || {}) as { bucketId: string, fileId: string, token?: string };
|
|
656
|
+
} else {
|
|
657
|
+
params = {
|
|
658
|
+
bucketId: paramsOrFirst as string,
|
|
659
|
+
fileId: rest[0] as string,
|
|
660
|
+
token: rest[1] as string
|
|
661
|
+
};
|
|
662
|
+
}
|
|
663
|
+
|
|
664
|
+
const bucketId = params.bucketId;
|
|
665
|
+
const fileId = params.fileId;
|
|
666
|
+
const token = params.token;
|
|
667
|
+
|
|
399
668
|
if (typeof bucketId === 'undefined') {
|
|
400
669
|
throw new AppwriteException('Missing required parameter: "bucketId"');
|
|
401
670
|
}
|