react-native-appwrite 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (109) hide show
  1. package/.github/ISSUE_TEMPLATE/bug.yaml +82 -0
  2. package/.github/ISSUE_TEMPLATE/documentation.yaml +32 -0
  3. package/.github/ISSUE_TEMPLATE/feature.yaml +40 -0
  4. package/.github/workflows/publish.yml +33 -0
  5. package/.gitpod.yml +10 -0
  6. package/CHANGELOG.md +1 -0
  7. package/LICENSE +12 -0
  8. package/README.md +111 -0
  9. package/dist/cjs/sdk.js +3127 -0
  10. package/dist/cjs/sdk.js.map +1 -0
  11. package/dist/esm/sdk.js +3108 -0
  12. package/dist/esm/sdk.js.map +1 -0
  13. package/dist/iife/sdk.js +3126 -0
  14. package/docs/examples/account/create-anonymous-session.md +18 -0
  15. package/docs/examples/account/create-email-session.md +18 -0
  16. package/docs/examples/account/create-j-w-t.md +18 -0
  17. package/docs/examples/account/create-magic-u-r-l-session.md +18 -0
  18. package/docs/examples/account/create-o-auth2session.md +14 -0
  19. package/docs/examples/account/create-phone-session.md +18 -0
  20. package/docs/examples/account/create-phone-verification.md +18 -0
  21. package/docs/examples/account/create-recovery.md +18 -0
  22. package/docs/examples/account/create-verification.md +18 -0
  23. package/docs/examples/account/create.md +18 -0
  24. package/docs/examples/account/delete-identity.md +18 -0
  25. package/docs/examples/account/delete-session.md +18 -0
  26. package/docs/examples/account/delete-sessions.md +18 -0
  27. package/docs/examples/account/get-prefs.md +18 -0
  28. package/docs/examples/account/get-session.md +18 -0
  29. package/docs/examples/account/get.md +18 -0
  30. package/docs/examples/account/list-identities.md +18 -0
  31. package/docs/examples/account/list-logs.md +18 -0
  32. package/docs/examples/account/list-sessions.md +18 -0
  33. package/docs/examples/account/update-email.md +18 -0
  34. package/docs/examples/account/update-magic-u-r-l-session.md +18 -0
  35. package/docs/examples/account/update-name.md +18 -0
  36. package/docs/examples/account/update-password.md +18 -0
  37. package/docs/examples/account/update-phone-session.md +18 -0
  38. package/docs/examples/account/update-phone-verification.md +18 -0
  39. package/docs/examples/account/update-phone.md +18 -0
  40. package/docs/examples/account/update-prefs.md +18 -0
  41. package/docs/examples/account/update-recovery.md +18 -0
  42. package/docs/examples/account/update-session.md +18 -0
  43. package/docs/examples/account/update-status.md +18 -0
  44. package/docs/examples/account/update-verification.md +18 -0
  45. package/docs/examples/avatars/get-browser.md +14 -0
  46. package/docs/examples/avatars/get-credit-card.md +14 -0
  47. package/docs/examples/avatars/get-favicon.md +14 -0
  48. package/docs/examples/avatars/get-flag.md +14 -0
  49. package/docs/examples/avatars/get-image.md +14 -0
  50. package/docs/examples/avatars/get-initials.md +14 -0
  51. package/docs/examples/avatars/get-q-r.md +14 -0
  52. package/docs/examples/databases/create-document.md +18 -0
  53. package/docs/examples/databases/delete-document.md +18 -0
  54. package/docs/examples/databases/get-document.md +18 -0
  55. package/docs/examples/databases/list-documents.md +18 -0
  56. package/docs/examples/databases/update-document.md +18 -0
  57. package/docs/examples/functions/create-execution.md +18 -0
  58. package/docs/examples/functions/get-execution.md +18 -0
  59. package/docs/examples/functions/list-executions.md +18 -0
  60. package/docs/examples/graphql/mutation.md +18 -0
  61. package/docs/examples/graphql/query.md +18 -0
  62. package/docs/examples/locale/get.md +18 -0
  63. package/docs/examples/locale/list-codes.md +18 -0
  64. package/docs/examples/locale/list-continents.md +18 -0
  65. package/docs/examples/locale/list-countries-e-u.md +18 -0
  66. package/docs/examples/locale/list-countries-phones.md +18 -0
  67. package/docs/examples/locale/list-countries.md +18 -0
  68. package/docs/examples/locale/list-currencies.md +18 -0
  69. package/docs/examples/locale/list-languages.md +18 -0
  70. package/docs/examples/storage/create-file.md +18 -0
  71. package/docs/examples/storage/delete-file.md +18 -0
  72. package/docs/examples/storage/get-file-download.md +14 -0
  73. package/docs/examples/storage/get-file-preview.md +14 -0
  74. package/docs/examples/storage/get-file-view.md +14 -0
  75. package/docs/examples/storage/get-file.md +18 -0
  76. package/docs/examples/storage/list-files.md +18 -0
  77. package/docs/examples/storage/update-file.md +18 -0
  78. package/docs/examples/teams/create-membership.md +18 -0
  79. package/docs/examples/teams/create.md +18 -0
  80. package/docs/examples/teams/delete-membership.md +18 -0
  81. package/docs/examples/teams/delete.md +18 -0
  82. package/docs/examples/teams/get-membership.md +18 -0
  83. package/docs/examples/teams/get-prefs.md +18 -0
  84. package/docs/examples/teams/get.md +18 -0
  85. package/docs/examples/teams/list-memberships.md +18 -0
  86. package/docs/examples/teams/list.md +18 -0
  87. package/docs/examples/teams/update-membership-status.md +18 -0
  88. package/docs/examples/teams/update-membership.md +18 -0
  89. package/docs/examples/teams/update-name.md +18 -0
  90. package/docs/examples/teams/update-prefs.md +18 -0
  91. package/package.json +47 -0
  92. package/rollup.config.js +31 -0
  93. package/src/client.ts +437 -0
  94. package/src/id.ts +9 -0
  95. package/src/index.ts +14 -0
  96. package/src/models.ts +1021 -0
  97. package/src/permission.ts +22 -0
  98. package/src/query.ts +74 -0
  99. package/src/role.ts +100 -0
  100. package/src/service.ts +30 -0
  101. package/src/services/account.ts +1066 -0
  102. package/src/services/avatars.ts +352 -0
  103. package/src/services/databases.ts +216 -0
  104. package/src/services/functions.ts +125 -0
  105. package/src/services/graphql.ts +68 -0
  106. package/src/services/locale.ts +169 -0
  107. package/src/services/storage.ts +411 -0
  108. package/src/services/teams.ts +484 -0
  109. package/tsconfig.json +24 -0
@@ -0,0 +1,352 @@
1
+ import { Service } from '../service';
2
+ import { AppwriteException, Client } from '../client';
3
+ import type { Models } from '../models';
4
+ import type { UploadProgress, Payload } from '../client';
5
+
6
+ export class Avatars extends Service {
7
+
8
+ constructor(client: Client)
9
+ {
10
+ super(client);
11
+ }
12
+
13
+ /**
14
+ * Get browser icon
15
+ *
16
+ * You can use this endpoint to show different browser icons to your users.
17
+ * The code argument receives the browser code as it appears in your user [GET
18
+ * /account/sessions](https://appwrite.io/docs/references/cloud/client-web/account#getSessions)
19
+ * endpoint. Use width, height and quality arguments to change the output
20
+ * settings.
21
+ *
22
+ * When one dimension is specified and the other is 0, the image is scaled
23
+ * with preserved aspect ratio. If both dimensions are 0, the API provides an
24
+ * image at source quality. If dimensions are not specified, the default size
25
+ * of image returned is 100x100px.
26
+ *
27
+ * @param {string} code
28
+ * @param {number} width
29
+ * @param {number} height
30
+ * @param {number} quality
31
+ * @throws {AppwriteException}
32
+ * @returns {URL}
33
+ */
34
+ getBrowser(code: string, width?: number, height?: number, quality?: number): URL {
35
+ if (typeof code === 'undefined') {
36
+ throw new AppwriteException('Missing required parameter: "code"');
37
+ }
38
+
39
+ const apiPath = '/avatars/browsers/{code}'.replace('{code}', code);
40
+ const payload: Payload = {};
41
+
42
+ if (typeof width !== 'undefined') {
43
+ payload['width'] = width;
44
+ }
45
+
46
+ if (typeof height !== 'undefined') {
47
+ payload['height'] = height;
48
+ }
49
+
50
+ if (typeof quality !== 'undefined') {
51
+ payload['quality'] = quality;
52
+ }
53
+
54
+ const uri = new URL(this.client.config.endpoint + apiPath);
55
+ payload['project'] = this.client.config.project;
56
+
57
+
58
+ for (const [key, value] of Object.entries(Service.flatten(payload))) {
59
+ uri.searchParams.append(key, value);
60
+ }
61
+ return uri;
62
+ }
63
+
64
+ /**
65
+ * Get credit card icon
66
+ *
67
+ * The credit card endpoint will return you the icon of the credit card
68
+ * provider you need. Use width, height and quality arguments to change the
69
+ * output settings.
70
+ *
71
+ * When one dimension is specified and the other is 0, the image is scaled
72
+ * with preserved aspect ratio. If both dimensions are 0, the API provides an
73
+ * image at source quality. If dimensions are not specified, the default size
74
+ * of image returned is 100x100px.
75
+ *
76
+ *
77
+ * @param {string} code
78
+ * @param {number} width
79
+ * @param {number} height
80
+ * @param {number} quality
81
+ * @throws {AppwriteException}
82
+ * @returns {URL}
83
+ */
84
+ getCreditCard(code: string, width?: number, height?: number, quality?: number): URL {
85
+ if (typeof code === 'undefined') {
86
+ throw new AppwriteException('Missing required parameter: "code"');
87
+ }
88
+
89
+ const apiPath = '/avatars/credit-cards/{code}'.replace('{code}', code);
90
+ const payload: Payload = {};
91
+
92
+ if (typeof width !== 'undefined') {
93
+ payload['width'] = width;
94
+ }
95
+
96
+ if (typeof height !== 'undefined') {
97
+ payload['height'] = height;
98
+ }
99
+
100
+ if (typeof quality !== 'undefined') {
101
+ payload['quality'] = quality;
102
+ }
103
+
104
+ const uri = new URL(this.client.config.endpoint + apiPath);
105
+ payload['project'] = this.client.config.project;
106
+
107
+
108
+ for (const [key, value] of Object.entries(Service.flatten(payload))) {
109
+ uri.searchParams.append(key, value);
110
+ }
111
+ return uri;
112
+ }
113
+
114
+ /**
115
+ * Get favicon
116
+ *
117
+ * Use this endpoint to fetch the favorite icon (AKA favicon) of any remote
118
+ * website URL.
119
+ *
120
+ *
121
+ * @param {string} url
122
+ * @throws {AppwriteException}
123
+ * @returns {URL}
124
+ */
125
+ getFavicon(url: string): URL {
126
+ if (typeof url === 'undefined') {
127
+ throw new AppwriteException('Missing required parameter: "url"');
128
+ }
129
+
130
+ const apiPath = '/avatars/favicon';
131
+ const payload: Payload = {};
132
+
133
+ if (typeof url !== 'undefined') {
134
+ payload['url'] = url;
135
+ }
136
+
137
+ const uri = new URL(this.client.config.endpoint + apiPath);
138
+ payload['project'] = this.client.config.project;
139
+
140
+
141
+ for (const [key, value] of Object.entries(Service.flatten(payload))) {
142
+ uri.searchParams.append(key, value);
143
+ }
144
+ return uri;
145
+ }
146
+
147
+ /**
148
+ * Get country flag
149
+ *
150
+ * You can use this endpoint to show different country flags icons to your
151
+ * users. The code argument receives the 2 letter country code. Use width,
152
+ * height and quality arguments to change the output settings. Country codes
153
+ * follow the [ISO 3166-1](https://en.wikipedia.org/wiki/ISO_3166-1) standard.
154
+ *
155
+ * When one dimension is specified and the other is 0, the image is scaled
156
+ * with preserved aspect ratio. If both dimensions are 0, the API provides an
157
+ * image at source quality. If dimensions are not specified, the default size
158
+ * of image returned is 100x100px.
159
+ *
160
+ *
161
+ * @param {string} code
162
+ * @param {number} width
163
+ * @param {number} height
164
+ * @param {number} quality
165
+ * @throws {AppwriteException}
166
+ * @returns {URL}
167
+ */
168
+ getFlag(code: string, width?: number, height?: number, quality?: number): URL {
169
+ if (typeof code === 'undefined') {
170
+ throw new AppwriteException('Missing required parameter: "code"');
171
+ }
172
+
173
+ const apiPath = '/avatars/flags/{code}'.replace('{code}', code);
174
+ const payload: Payload = {};
175
+
176
+ if (typeof width !== 'undefined') {
177
+ payload['width'] = width;
178
+ }
179
+
180
+ if (typeof height !== 'undefined') {
181
+ payload['height'] = height;
182
+ }
183
+
184
+ if (typeof quality !== 'undefined') {
185
+ payload['quality'] = quality;
186
+ }
187
+
188
+ const uri = new URL(this.client.config.endpoint + apiPath);
189
+ payload['project'] = this.client.config.project;
190
+
191
+
192
+ for (const [key, value] of Object.entries(Service.flatten(payload))) {
193
+ uri.searchParams.append(key, value);
194
+ }
195
+ return uri;
196
+ }
197
+
198
+ /**
199
+ * Get image from URL
200
+ *
201
+ * Use this endpoint to fetch a remote image URL and crop it to any image size
202
+ * you want. This endpoint is very useful if you need to crop and display
203
+ * remote images in your app or in case you want to make sure a 3rd party
204
+ * image is properly served using a TLS protocol.
205
+ *
206
+ * When one dimension is specified and the other is 0, the image is scaled
207
+ * with preserved aspect ratio. If both dimensions are 0, the API provides an
208
+ * image at source quality. If dimensions are not specified, the default size
209
+ * of image returned is 400x400px.
210
+ *
211
+ *
212
+ * @param {string} url
213
+ * @param {number} width
214
+ * @param {number} height
215
+ * @throws {AppwriteException}
216
+ * @returns {URL}
217
+ */
218
+ getImage(url: string, width?: number, height?: number): URL {
219
+ if (typeof url === 'undefined') {
220
+ throw new AppwriteException('Missing required parameter: "url"');
221
+ }
222
+
223
+ const apiPath = '/avatars/image';
224
+ const payload: Payload = {};
225
+
226
+ if (typeof url !== 'undefined') {
227
+ payload['url'] = url;
228
+ }
229
+
230
+ if (typeof width !== 'undefined') {
231
+ payload['width'] = width;
232
+ }
233
+
234
+ if (typeof height !== 'undefined') {
235
+ payload['height'] = height;
236
+ }
237
+
238
+ const uri = new URL(this.client.config.endpoint + apiPath);
239
+ payload['project'] = this.client.config.project;
240
+
241
+
242
+ for (const [key, value] of Object.entries(Service.flatten(payload))) {
243
+ uri.searchParams.append(key, value);
244
+ }
245
+ return uri;
246
+ }
247
+
248
+ /**
249
+ * Get user initials
250
+ *
251
+ * Use this endpoint to show your user initials avatar icon on your website or
252
+ * app. By default, this route will try to print your logged-in user name or
253
+ * email initials. You can also overwrite the user name if you pass the 'name'
254
+ * parameter. If no name is given and no user is logged, an empty avatar will
255
+ * be returned.
256
+ *
257
+ * You can use the color and background params to change the avatar colors. By
258
+ * default, a random theme will be selected. The random theme will persist for
259
+ * the user's initials when reloading the same theme will always return for
260
+ * the same initials.
261
+ *
262
+ * When one dimension is specified and the other is 0, the image is scaled
263
+ * with preserved aspect ratio. If both dimensions are 0, the API provides an
264
+ * image at source quality. If dimensions are not specified, the default size
265
+ * of image returned is 100x100px.
266
+ *
267
+ *
268
+ * @param {string} name
269
+ * @param {number} width
270
+ * @param {number} height
271
+ * @param {string} background
272
+ * @throws {AppwriteException}
273
+ * @returns {URL}
274
+ */
275
+ getInitials(name?: string, width?: number, height?: number, background?: string): URL {
276
+ const apiPath = '/avatars/initials';
277
+ const payload: Payload = {};
278
+
279
+ if (typeof name !== 'undefined') {
280
+ payload['name'] = name;
281
+ }
282
+
283
+ if (typeof width !== 'undefined') {
284
+ payload['width'] = width;
285
+ }
286
+
287
+ if (typeof height !== 'undefined') {
288
+ payload['height'] = height;
289
+ }
290
+
291
+ if (typeof background !== 'undefined') {
292
+ payload['background'] = background;
293
+ }
294
+
295
+ const uri = new URL(this.client.config.endpoint + apiPath);
296
+ payload['project'] = this.client.config.project;
297
+
298
+
299
+ for (const [key, value] of Object.entries(Service.flatten(payload))) {
300
+ uri.searchParams.append(key, value);
301
+ }
302
+ return uri;
303
+ }
304
+
305
+ /**
306
+ * Get QR code
307
+ *
308
+ * Converts a given plain text to a QR code image. You can use the query
309
+ * parameters to change the size and style of the resulting image.
310
+ *
311
+ *
312
+ * @param {string} text
313
+ * @param {number} size
314
+ * @param {number} margin
315
+ * @param {boolean} download
316
+ * @throws {AppwriteException}
317
+ * @returns {URL}
318
+ */
319
+ getQR(text: string, size?: number, margin?: number, download?: boolean): URL {
320
+ if (typeof text === 'undefined') {
321
+ throw new AppwriteException('Missing required parameter: "text"');
322
+ }
323
+
324
+ const apiPath = '/avatars/qr';
325
+ const payload: Payload = {};
326
+
327
+ if (typeof text !== 'undefined') {
328
+ payload['text'] = text;
329
+ }
330
+
331
+ if (typeof size !== 'undefined') {
332
+ payload['size'] = size;
333
+ }
334
+
335
+ if (typeof margin !== 'undefined') {
336
+ payload['margin'] = margin;
337
+ }
338
+
339
+ if (typeof download !== 'undefined') {
340
+ payload['download'] = download;
341
+ }
342
+
343
+ const uri = new URL(this.client.config.endpoint + apiPath);
344
+ payload['project'] = this.client.config.project;
345
+
346
+
347
+ for (const [key, value] of Object.entries(Service.flatten(payload))) {
348
+ uri.searchParams.append(key, value);
349
+ }
350
+ return uri;
351
+ }
352
+ };
@@ -0,0 +1,216 @@
1
+ import { Service } from '../service';
2
+ import { AppwriteException, Client } from '../client';
3
+ import type { Models } from '../models';
4
+ import type { UploadProgress, Payload } from '../client';
5
+
6
+ export class Databases extends Service {
7
+
8
+ constructor(client: Client)
9
+ {
10
+ super(client);
11
+ }
12
+
13
+ /**
14
+ * List documents
15
+ *
16
+ * Get a list of all the user's documents in a given collection. You can use
17
+ * the query params to filter your results.
18
+ *
19
+ * @param {string} databaseId
20
+ * @param {string} collectionId
21
+ * @param {string[]} queries
22
+ * @throws {AppwriteException}
23
+ * @returns {Promise}
24
+ */
25
+ async listDocuments<Document extends Models.Document>(databaseId: string, collectionId: string, queries?: string[]): Promise<Models.DocumentList<Document>> {
26
+ if (typeof databaseId === 'undefined') {
27
+ throw new AppwriteException('Missing required parameter: "databaseId"');
28
+ }
29
+
30
+ if (typeof collectionId === 'undefined') {
31
+ throw new AppwriteException('Missing required parameter: "collectionId"');
32
+ }
33
+
34
+ const apiPath = '/databases/{databaseId}/collections/{collectionId}/documents'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId);
35
+ const payload: Payload = {};
36
+
37
+ if (typeof queries !== 'undefined') {
38
+ payload['queries'] = queries;
39
+ }
40
+
41
+ const uri = new URL(this.client.config.endpoint + apiPath);
42
+ return await this.client.call('get', uri, {
43
+ 'content-type': 'application/json',
44
+ }, payload);
45
+ }
46
+
47
+ /**
48
+ * Create document
49
+ *
50
+ * Create a new Document. Before using this route, you should create a new
51
+ * collection resource using either a [server
52
+ * integration](https://appwrite.io/docs/server/databases#databasesCreateCollection)
53
+ * API or directly from your database console.
54
+ *
55
+ * @param {string} databaseId
56
+ * @param {string} collectionId
57
+ * @param {string} documentId
58
+ * @param {Omit<Document, keyof Models.Document>} data
59
+ * @param {string[]} permissions
60
+ * @throws {AppwriteException}
61
+ * @returns {Promise}
62
+ */
63
+ async createDocument<Document extends Models.Document>(databaseId: string, collectionId: string, documentId: string, data: Omit<Document, keyof Models.Document>, permissions?: string[]): Promise<Document> {
64
+ if (typeof databaseId === 'undefined') {
65
+ throw new AppwriteException('Missing required parameter: "databaseId"');
66
+ }
67
+
68
+ if (typeof collectionId === 'undefined') {
69
+ throw new AppwriteException('Missing required parameter: "collectionId"');
70
+ }
71
+
72
+ if (typeof documentId === 'undefined') {
73
+ throw new AppwriteException('Missing required parameter: "documentId"');
74
+ }
75
+
76
+ if (typeof data === 'undefined') {
77
+ throw new AppwriteException('Missing required parameter: "data"');
78
+ }
79
+
80
+ const apiPath = '/databases/{databaseId}/collections/{collectionId}/documents'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId);
81
+ const payload: Payload = {};
82
+
83
+ if (typeof documentId !== 'undefined') {
84
+ payload['documentId'] = documentId;
85
+ }
86
+
87
+ if (typeof data !== 'undefined') {
88
+ payload['data'] = data;
89
+ }
90
+
91
+ if (typeof permissions !== 'undefined') {
92
+ payload['permissions'] = permissions;
93
+ }
94
+
95
+ const uri = new URL(this.client.config.endpoint + apiPath);
96
+ return await this.client.call('post', uri, {
97
+ 'content-type': 'application/json',
98
+ }, payload);
99
+ }
100
+
101
+ /**
102
+ * Get document
103
+ *
104
+ * Get a document by its unique ID. This endpoint response returns a JSON
105
+ * object with the document data.
106
+ *
107
+ * @param {string} databaseId
108
+ * @param {string} collectionId
109
+ * @param {string} documentId
110
+ * @param {string[]} queries
111
+ * @throws {AppwriteException}
112
+ * @returns {Promise}
113
+ */
114
+ async getDocument<Document extends Models.Document>(databaseId: string, collectionId: string, documentId: string, queries?: string[]): Promise<Document> {
115
+ if (typeof databaseId === 'undefined') {
116
+ throw new AppwriteException('Missing required parameter: "databaseId"');
117
+ }
118
+
119
+ if (typeof collectionId === 'undefined') {
120
+ throw new AppwriteException('Missing required parameter: "collectionId"');
121
+ }
122
+
123
+ if (typeof documentId === 'undefined') {
124
+ throw new AppwriteException('Missing required parameter: "documentId"');
125
+ }
126
+
127
+ const apiPath = '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId).replace('{documentId}', documentId);
128
+ const payload: Payload = {};
129
+
130
+ if (typeof queries !== 'undefined') {
131
+ payload['queries'] = queries;
132
+ }
133
+
134
+ const uri = new URL(this.client.config.endpoint + apiPath);
135
+ return await this.client.call('get', uri, {
136
+ 'content-type': 'application/json',
137
+ }, payload);
138
+ }
139
+
140
+ /**
141
+ * Update document
142
+ *
143
+ * Update a document by its unique ID. Using the patch method you can pass
144
+ * only specific fields that will get updated.
145
+ *
146
+ * @param {string} databaseId
147
+ * @param {string} collectionId
148
+ * @param {string} documentId
149
+ * @param {Partial<Omit<Document, keyof Models.Document>>} data
150
+ * @param {string[]} permissions
151
+ * @throws {AppwriteException}
152
+ * @returns {Promise}
153
+ */
154
+ async updateDocument<Document extends Models.Document>(databaseId: string, collectionId: string, documentId: string, data?: Partial<Omit<Document, keyof Models.Document>>, permissions?: string[]): Promise<Document> {
155
+ if (typeof databaseId === 'undefined') {
156
+ throw new AppwriteException('Missing required parameter: "databaseId"');
157
+ }
158
+
159
+ if (typeof collectionId === 'undefined') {
160
+ throw new AppwriteException('Missing required parameter: "collectionId"');
161
+ }
162
+
163
+ if (typeof documentId === 'undefined') {
164
+ throw new AppwriteException('Missing required parameter: "documentId"');
165
+ }
166
+
167
+ const apiPath = '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId).replace('{documentId}', documentId);
168
+ const payload: Payload = {};
169
+
170
+ if (typeof data !== 'undefined') {
171
+ payload['data'] = data;
172
+ }
173
+
174
+ if (typeof permissions !== 'undefined') {
175
+ payload['permissions'] = permissions;
176
+ }
177
+
178
+ const uri = new URL(this.client.config.endpoint + apiPath);
179
+ return await this.client.call('patch', uri, {
180
+ 'content-type': 'application/json',
181
+ }, payload);
182
+ }
183
+
184
+ /**
185
+ * Delete document
186
+ *
187
+ * Delete a document by its unique ID.
188
+ *
189
+ * @param {string} databaseId
190
+ * @param {string} collectionId
191
+ * @param {string} documentId
192
+ * @throws {AppwriteException}
193
+ * @returns {Promise}
194
+ */
195
+ async deleteDocument(databaseId: string, collectionId: string, documentId: string): Promise<{}> {
196
+ if (typeof databaseId === 'undefined') {
197
+ throw new AppwriteException('Missing required parameter: "databaseId"');
198
+ }
199
+
200
+ if (typeof collectionId === 'undefined') {
201
+ throw new AppwriteException('Missing required parameter: "collectionId"');
202
+ }
203
+
204
+ if (typeof documentId === 'undefined') {
205
+ throw new AppwriteException('Missing required parameter: "documentId"');
206
+ }
207
+
208
+ const apiPath = '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId).replace('{documentId}', documentId);
209
+ const payload: Payload = {};
210
+
211
+ const uri = new URL(this.client.config.endpoint + apiPath);
212
+ return await this.client.call('delete', uri, {
213
+ 'content-type': 'application/json',
214
+ }, payload);
215
+ }
216
+ };
@@ -0,0 +1,125 @@
1
+ import { Service } from '../service';
2
+ import { AppwriteException, Client } from '../client';
3
+ import type { Models } from '../models';
4
+ import type { UploadProgress, Payload } from '../client';
5
+
6
+ export class Functions extends Service {
7
+
8
+ constructor(client: Client)
9
+ {
10
+ super(client);
11
+ }
12
+
13
+ /**
14
+ * List executions
15
+ *
16
+ * Get a list of all the current user function execution logs. You can use the
17
+ * query params to filter your results.
18
+ *
19
+ * @param {string} functionId
20
+ * @param {string[]} queries
21
+ * @param {string} search
22
+ * @throws {AppwriteException}
23
+ * @returns {Promise}
24
+ */
25
+ async listExecutions(functionId: string, queries?: string[], search?: string): Promise<Models.ExecutionList> {
26
+ if (typeof functionId === 'undefined') {
27
+ throw new AppwriteException('Missing required parameter: "functionId"');
28
+ }
29
+
30
+ const apiPath = '/functions/{functionId}/executions'.replace('{functionId}', functionId);
31
+ const payload: Payload = {};
32
+
33
+ if (typeof queries !== 'undefined') {
34
+ payload['queries'] = queries;
35
+ }
36
+
37
+ if (typeof search !== 'undefined') {
38
+ payload['search'] = search;
39
+ }
40
+
41
+ const uri = new URL(this.client.config.endpoint + apiPath);
42
+ return await this.client.call('get', uri, {
43
+ 'content-type': 'application/json',
44
+ }, payload);
45
+ }
46
+
47
+ /**
48
+ * Create execution
49
+ *
50
+ * Trigger a function execution. The returned object will return you the
51
+ * current execution status. You can ping the `Get Execution` endpoint to get
52
+ * updates on the current execution status. Once this endpoint is called, your
53
+ * function execution process will start asynchronously.
54
+ *
55
+ * @param {string} functionId
56
+ * @param {string} body
57
+ * @param {boolean} async
58
+ * @param {string} xpath
59
+ * @param {string} method
60
+ * @param {object} headers
61
+ * @throws {AppwriteException}
62
+ * @returns {Promise}
63
+ */
64
+ async createExecution(functionId: string, body?: string, async?: boolean, xpath?: string, method?: string, headers?: object): Promise<Models.Execution> {
65
+ if (typeof functionId === 'undefined') {
66
+ throw new AppwriteException('Missing required parameter: "functionId"');
67
+ }
68
+
69
+ const apiPath = '/functions/{functionId}/executions'.replace('{functionId}', functionId);
70
+ const payload: Payload = {};
71
+
72
+ if (typeof body !== 'undefined') {
73
+ payload['body'] = body;
74
+ }
75
+
76
+ if (typeof async !== 'undefined') {
77
+ payload['async'] = async;
78
+ }
79
+
80
+ if (typeof xpath !== 'undefined') {
81
+ payload['path'] = xpath;
82
+ }
83
+
84
+ if (typeof method !== 'undefined') {
85
+ payload['method'] = method;
86
+ }
87
+
88
+ if (typeof headers !== 'undefined') {
89
+ payload['headers'] = headers;
90
+ }
91
+
92
+ const uri = new URL(this.client.config.endpoint + apiPath);
93
+ return await this.client.call('post', uri, {
94
+ 'content-type': 'application/json',
95
+ }, payload);
96
+ }
97
+
98
+ /**
99
+ * Get execution
100
+ *
101
+ * Get a function execution log by its unique ID.
102
+ *
103
+ * @param {string} functionId
104
+ * @param {string} executionId
105
+ * @throws {AppwriteException}
106
+ * @returns {Promise}
107
+ */
108
+ async getExecution(functionId: string, executionId: string): Promise<Models.Execution> {
109
+ if (typeof functionId === 'undefined') {
110
+ throw new AppwriteException('Missing required parameter: "functionId"');
111
+ }
112
+
113
+ if (typeof executionId === 'undefined') {
114
+ throw new AppwriteException('Missing required parameter: "executionId"');
115
+ }
116
+
117
+ const apiPath = '/functions/{functionId}/executions/{executionId}'.replace('{functionId}', functionId).replace('{executionId}', executionId);
118
+ const payload: Payload = {};
119
+
120
+ const uri = new URL(this.client.config.endpoint + apiPath);
121
+ return await this.client.call('get', uri, {
122
+ 'content-type': 'application/json',
123
+ }, payload);
124
+ }
125
+ };