node-appwrite 8.2.0 → 10.0.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/LICENSE +1 -1
- package/README.md +2 -2
- package/docs/examples/account/create-phone-verification.md +1 -1
- package/docs/examples/account/create-recovery.md +1 -1
- package/docs/examples/account/create-verification.md +1 -1
- package/docs/examples/account/delete-identity.md +20 -0
- package/docs/examples/account/delete-session.md +1 -1
- package/docs/examples/account/delete-sessions.md +1 -1
- package/docs/examples/account/get-prefs.md +1 -1
- package/docs/examples/account/get-session.md +1 -1
- package/docs/examples/account/get.md +1 -1
- package/docs/examples/account/list-identities.md +20 -0
- package/docs/examples/account/list-logs.md +1 -1
- package/docs/examples/account/list-sessions.md +1 -1
- package/docs/examples/account/update-email.md +1 -1
- package/docs/examples/account/update-name.md +1 -1
- package/docs/examples/account/update-password.md +2 -2
- package/docs/examples/account/update-phone-verification.md +1 -1
- package/docs/examples/account/update-phone.md +1 -1
- package/docs/examples/account/update-prefs.md +1 -1
- package/docs/examples/account/update-recovery.md +1 -1
- package/docs/examples/account/update-session.md +1 -1
- package/docs/examples/account/update-status.md +1 -1
- package/docs/examples/account/update-verification.md +1 -1
- package/docs/examples/avatars/get-browser.md +1 -1
- package/docs/examples/avatars/get-credit-card.md +1 -1
- package/docs/examples/avatars/get-favicon.md +1 -1
- package/docs/examples/avatars/get-flag.md +1 -1
- package/docs/examples/avatars/get-image.md +1 -1
- package/docs/examples/avatars/get-initials.md +1 -1
- package/docs/examples/avatars/get-q-r.md +1 -1
- package/docs/examples/databases/create-boolean-attribute.md +1 -1
- package/docs/examples/databases/create-collection.md +1 -1
- package/docs/examples/databases/create-datetime-attribute.md +1 -1
- package/docs/examples/databases/create-document.md +1 -1
- package/docs/examples/databases/create-email-attribute.md +1 -1
- package/docs/examples/databases/create-enum-attribute.md +1 -1
- package/docs/examples/databases/create-float-attribute.md +1 -1
- package/docs/examples/databases/create-index.md +1 -1
- package/docs/examples/databases/create-integer-attribute.md +1 -1
- package/docs/examples/databases/create-ip-attribute.md +1 -1
- package/docs/examples/databases/create-relationship-attribute.md +20 -0
- package/docs/examples/databases/create-string-attribute.md +1 -1
- package/docs/examples/databases/create-url-attribute.md +1 -1
- package/docs/examples/databases/create.md +1 -1
- package/docs/examples/databases/delete-attribute.md +1 -1
- package/docs/examples/databases/delete-collection.md +1 -1
- package/docs/examples/databases/delete-document.md +1 -1
- package/docs/examples/databases/delete-index.md +1 -1
- package/docs/examples/databases/delete.md +1 -1
- package/docs/examples/databases/get-attribute.md +1 -1
- package/docs/examples/databases/get-collection.md +1 -1
- package/docs/examples/databases/get-document.md +1 -1
- package/docs/examples/databases/get-index.md +1 -1
- package/docs/examples/databases/get.md +1 -1
- package/docs/examples/databases/list-attributes.md +1 -1
- package/docs/examples/databases/list-collections.md +1 -1
- package/docs/examples/databases/list-documents.md +1 -1
- package/docs/examples/databases/list-indexes.md +1 -1
- package/docs/examples/databases/list.md +1 -1
- package/docs/examples/databases/update-boolean-attribute.md +20 -0
- package/docs/examples/databases/update-collection.md +1 -1
- package/docs/examples/databases/update-datetime-attribute.md +20 -0
- package/docs/examples/databases/update-document.md +1 -1
- package/docs/examples/databases/update-email-attribute.md +20 -0
- package/docs/examples/databases/update-enum-attribute.md +20 -0
- package/docs/examples/databases/update-float-attribute.md +20 -0
- package/docs/examples/databases/update-integer-attribute.md +20 -0
- package/docs/examples/databases/update-ip-attribute.md +20 -0
- package/docs/examples/databases/update-relationship-attribute.md +20 -0
- package/docs/examples/databases/update-string-attribute.md +20 -0
- package/docs/examples/databases/update-url-attribute.md +20 -0
- package/docs/examples/databases/update.md +1 -1
- package/docs/examples/functions/create-build.md +1 -1
- package/docs/examples/functions/create-deployment.md +2 -2
- package/docs/examples/functions/create-execution.md +1 -1
- package/docs/examples/functions/create-variable.md +1 -1
- package/docs/examples/functions/create.md +2 -2
- package/docs/examples/functions/delete-deployment.md +1 -1
- package/docs/examples/functions/delete-variable.md +1 -1
- package/docs/examples/functions/delete.md +1 -1
- package/docs/examples/functions/download-deployment.md +20 -0
- package/docs/examples/functions/get-deployment.md +1 -1
- package/docs/examples/functions/get-execution.md +1 -1
- package/docs/examples/functions/get-variable.md +1 -1
- package/docs/examples/functions/get.md +1 -1
- package/docs/examples/functions/list-deployments.md +1 -1
- package/docs/examples/functions/list-executions.md +1 -1
- package/docs/examples/functions/list-runtimes.md +1 -1
- package/docs/examples/functions/list-variables.md +1 -1
- package/docs/examples/functions/list.md +1 -1
- package/docs/examples/functions/update-deployment.md +1 -1
- package/docs/examples/functions/update-variable.md +1 -1
- package/docs/examples/functions/update.md +2 -2
- package/docs/examples/graphql/mutation.md +1 -1
- package/docs/examples/graphql/query.md +1 -1
- package/docs/examples/health/get-antivirus.md +1 -1
- package/docs/examples/health/get-cache.md +1 -1
- package/docs/examples/health/get-d-b.md +1 -1
- package/docs/examples/health/get-pub-sub.md +20 -0
- package/docs/examples/health/get-queue-certificates.md +1 -1
- package/docs/examples/health/get-queue-functions.md +1 -1
- package/docs/examples/health/get-queue-logs.md +1 -1
- package/docs/examples/health/get-queue-webhooks.md +1 -1
- package/docs/examples/health/get-queue.md +20 -0
- package/docs/examples/health/get-storage-local.md +1 -1
- package/docs/examples/health/get-time.md +1 -1
- package/docs/examples/health/get.md +1 -1
- package/docs/examples/locale/get.md +1 -1
- package/docs/examples/locale/list-codes.md +20 -0
- package/docs/examples/locale/list-continents.md +1 -1
- package/docs/examples/locale/list-countries-e-u.md +1 -1
- package/docs/examples/locale/list-countries-phones.md +1 -1
- package/docs/examples/locale/list-countries.md +1 -1
- package/docs/examples/locale/list-currencies.md +1 -1
- package/docs/examples/locale/list-languages.md +1 -1
- package/docs/examples/storage/create-bucket.md +1 -1
- package/docs/examples/storage/create-file.md +1 -1
- package/docs/examples/storage/delete-bucket.md +1 -1
- package/docs/examples/storage/delete-file.md +1 -1
- package/docs/examples/storage/get-bucket.md +1 -1
- package/docs/examples/storage/get-file-download.md +1 -1
- package/docs/examples/storage/get-file-preview.md +1 -1
- package/docs/examples/storage/get-file-view.md +1 -1
- package/docs/examples/storage/get-file.md +1 -1
- package/docs/examples/storage/list-buckets.md +1 -1
- package/docs/examples/storage/list-files.md +1 -1
- package/docs/examples/storage/update-bucket.md +1 -1
- package/docs/examples/storage/update-file.md +1 -1
- package/docs/examples/teams/create-membership.md +2 -2
- package/docs/examples/teams/create.md +1 -1
- package/docs/examples/teams/delete-membership.md +1 -1
- package/docs/examples/teams/delete.md +1 -1
- package/docs/examples/teams/get-membership.md +1 -1
- package/docs/examples/teams/get-prefs.md +20 -0
- package/docs/examples/teams/get.md +1 -1
- package/docs/examples/teams/list-memberships.md +1 -1
- package/docs/examples/teams/list.md +1 -1
- package/docs/examples/teams/update-membership-status.md +1 -1
- package/docs/examples/teams/{update-membership-roles.md → update-membership.md} +2 -2
- package/docs/examples/teams/{update.md → update-name.md} +2 -2
- package/docs/examples/teams/update-prefs.md +20 -0
- package/docs/examples/users/create-argon2user.md +1 -1
- package/docs/examples/users/create-bcrypt-user.md +1 -1
- package/docs/examples/users/create-m-d5user.md +1 -1
- package/docs/examples/users/create-p-h-pass-user.md +1 -1
- package/docs/examples/users/create-s-h-a-user.md +1 -1
- package/docs/examples/users/create-scrypt-modified-user.md +1 -1
- package/docs/examples/users/create-scrypt-user.md +1 -1
- package/docs/examples/users/create.md +1 -1
- package/docs/examples/users/delete-identity.md +20 -0
- package/docs/examples/users/delete-session.md +1 -1
- package/docs/examples/users/delete-sessions.md +1 -1
- package/docs/examples/users/delete.md +1 -1
- package/docs/examples/users/get-prefs.md +1 -1
- package/docs/examples/users/get.md +1 -1
- package/docs/examples/users/list-identities.md +20 -0
- package/docs/examples/users/list-logs.md +1 -1
- package/docs/examples/users/list-memberships.md +1 -1
- package/docs/examples/users/list-sessions.md +1 -1
- package/docs/examples/users/list.md +1 -1
- package/docs/examples/users/update-email-verification.md +1 -1
- package/docs/examples/users/update-email.md +1 -1
- package/docs/examples/users/update-labels.md +20 -0
- package/docs/examples/users/update-name.md +1 -1
- package/docs/examples/users/update-password.md +2 -2
- package/docs/examples/users/update-phone-verification.md +1 -1
- package/docs/examples/users/update-phone.md +1 -1
- package/docs/examples/users/update-prefs.md +1 -1
- package/docs/examples/users/update-status.md +1 -1
- package/index.d.ts +767 -165
- package/lib/client.js +5 -2
- package/lib/inputFile.js +6 -8
- package/lib/query.js +18 -0
- package/lib/services/account.js +94 -50
- package/lib/services/avatars.js +14 -14
- package/lib/services/databases.js +826 -180
- package/lib/services/functions.js +254 -101
- package/lib/services/graphql.js +4 -4
- package/lib/services/health.js +57 -22
- package/lib/services/locale.js +32 -14
- package/lib/services/storage.js +76 -63
- package/lib/services/teams.js +112 -43
- package/lib/services/users.js +135 -50
- package/package.json +6 -4
|
@@ -26,7 +26,7 @@ class Functions extends Service {
|
|
|
26
26
|
* @returns {Promise}
|
|
27
27
|
*/
|
|
28
28
|
async list(queries, search) {
|
|
29
|
-
|
|
29
|
+
const apiPath = '/functions';
|
|
30
30
|
let payload = {};
|
|
31
31
|
|
|
32
32
|
if (typeof queries !== 'undefined') {
|
|
@@ -37,7 +37,7 @@ class Functions extends Service {
|
|
|
37
37
|
payload['search'] = search;
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
-
return await this.client.call('get',
|
|
40
|
+
return await this.client.call('get', apiPath, {
|
|
41
41
|
'content-type': 'application/json',
|
|
42
42
|
}, payload);
|
|
43
43
|
}
|
|
@@ -51,17 +51,29 @@ class Functions extends Service {
|
|
|
51
51
|
*
|
|
52
52
|
* @param {string} functionId
|
|
53
53
|
* @param {string} name
|
|
54
|
-
* @param {string[]} execute
|
|
55
54
|
* @param {string} runtime
|
|
55
|
+
* @param {string[]} execute
|
|
56
56
|
* @param {string[]} events
|
|
57
57
|
* @param {string} schedule
|
|
58
58
|
* @param {number} timeout
|
|
59
59
|
* @param {boolean} enabled
|
|
60
|
+
* @param {boolean} logging
|
|
61
|
+
* @param {string} entrypoint
|
|
62
|
+
* @param {string} commands
|
|
63
|
+
* @param {string} installationId
|
|
64
|
+
* @param {string} providerRepositoryId
|
|
65
|
+
* @param {string} providerBranch
|
|
66
|
+
* @param {boolean} providerSilentMode
|
|
67
|
+
* @param {string} providerRootDirectory
|
|
68
|
+
* @param {string} templateRepository
|
|
69
|
+
* @param {string} templateOwner
|
|
70
|
+
* @param {string} templateRootDirectory
|
|
71
|
+
* @param {string} templateBranch
|
|
60
72
|
* @throws {AppwriteException}
|
|
61
73
|
* @returns {Promise}
|
|
62
74
|
*/
|
|
63
|
-
async create(functionId, name,
|
|
64
|
-
|
|
75
|
+
async create(functionId, name, runtime, execute, events, schedule, timeout, enabled, logging, entrypoint, commands, installationId, providerRepositoryId, providerBranch, providerSilentMode, providerRootDirectory, templateRepository, templateOwner, templateRootDirectory, templateBranch) {
|
|
76
|
+
const apiPath = '/functions';
|
|
65
77
|
let payload = {};
|
|
66
78
|
if (typeof functionId === 'undefined') {
|
|
67
79
|
throw new AppwriteException('Missing required parameter: "functionId"');
|
|
@@ -71,10 +83,6 @@ class Functions extends Service {
|
|
|
71
83
|
throw new AppwriteException('Missing required parameter: "name"');
|
|
72
84
|
}
|
|
73
85
|
|
|
74
|
-
if (typeof execute === 'undefined') {
|
|
75
|
-
throw new AppwriteException('Missing required parameter: "execute"');
|
|
76
|
-
}
|
|
77
|
-
|
|
78
86
|
if (typeof runtime === 'undefined') {
|
|
79
87
|
throw new AppwriteException('Missing required parameter: "runtime"');
|
|
80
88
|
}
|
|
@@ -88,14 +96,14 @@ class Functions extends Service {
|
|
|
88
96
|
payload['name'] = name;
|
|
89
97
|
}
|
|
90
98
|
|
|
91
|
-
if (typeof execute !== 'undefined') {
|
|
92
|
-
payload['execute'] = execute;
|
|
93
|
-
}
|
|
94
|
-
|
|
95
99
|
if (typeof runtime !== 'undefined') {
|
|
96
100
|
payload['runtime'] = runtime;
|
|
97
101
|
}
|
|
98
102
|
|
|
103
|
+
if (typeof execute !== 'undefined') {
|
|
104
|
+
payload['execute'] = execute;
|
|
105
|
+
}
|
|
106
|
+
|
|
99
107
|
if (typeof events !== 'undefined') {
|
|
100
108
|
payload['events'] = events;
|
|
101
109
|
}
|
|
@@ -112,7 +120,55 @@ class Functions extends Service {
|
|
|
112
120
|
payload['enabled'] = enabled;
|
|
113
121
|
}
|
|
114
122
|
|
|
115
|
-
|
|
123
|
+
if (typeof logging !== 'undefined') {
|
|
124
|
+
payload['logging'] = logging;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
if (typeof entrypoint !== 'undefined') {
|
|
128
|
+
payload['entrypoint'] = entrypoint;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
if (typeof commands !== 'undefined') {
|
|
132
|
+
payload['commands'] = commands;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
if (typeof installationId !== 'undefined') {
|
|
136
|
+
payload['installationId'] = installationId;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
if (typeof providerRepositoryId !== 'undefined') {
|
|
140
|
+
payload['providerRepositoryId'] = providerRepositoryId;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
if (typeof providerBranch !== 'undefined') {
|
|
144
|
+
payload['providerBranch'] = providerBranch;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
if (typeof providerSilentMode !== 'undefined') {
|
|
148
|
+
payload['providerSilentMode'] = providerSilentMode;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
if (typeof providerRootDirectory !== 'undefined') {
|
|
152
|
+
payload['providerRootDirectory'] = providerRootDirectory;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
if (typeof templateRepository !== 'undefined') {
|
|
156
|
+
payload['templateRepository'] = templateRepository;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
if (typeof templateOwner !== 'undefined') {
|
|
160
|
+
payload['templateOwner'] = templateOwner;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
if (typeof templateRootDirectory !== 'undefined') {
|
|
164
|
+
payload['templateRootDirectory'] = templateRootDirectory;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
if (typeof templateBranch !== 'undefined') {
|
|
168
|
+
payload['templateBranch'] = templateBranch;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
return await this.client.call('post', apiPath, {
|
|
116
172
|
'content-type': 'application/json',
|
|
117
173
|
}, payload);
|
|
118
174
|
}
|
|
@@ -126,10 +182,10 @@ class Functions extends Service {
|
|
|
126
182
|
* @returns {Promise}
|
|
127
183
|
*/
|
|
128
184
|
async listRuntimes() {
|
|
129
|
-
|
|
185
|
+
const apiPath = '/functions/runtimes';
|
|
130
186
|
let payload = {};
|
|
131
187
|
|
|
132
|
-
return await this.client.call('get',
|
|
188
|
+
return await this.client.call('get', apiPath, {
|
|
133
189
|
'content-type': 'application/json',
|
|
134
190
|
}, payload);
|
|
135
191
|
}
|
|
@@ -144,14 +200,14 @@ class Functions extends Service {
|
|
|
144
200
|
* @returns {Promise}
|
|
145
201
|
*/
|
|
146
202
|
async get(functionId) {
|
|
147
|
-
|
|
203
|
+
const apiPath = '/functions/{functionId}'.replace('{functionId}', functionId);
|
|
148
204
|
let payload = {};
|
|
149
205
|
if (typeof functionId === 'undefined') {
|
|
150
206
|
throw new AppwriteException('Missing required parameter: "functionId"');
|
|
151
207
|
}
|
|
152
208
|
|
|
153
209
|
|
|
154
|
-
return await this.client.call('get',
|
|
210
|
+
return await this.client.call('get', apiPath, {
|
|
155
211
|
'content-type': 'application/json',
|
|
156
212
|
}, payload);
|
|
157
213
|
}
|
|
@@ -163,16 +219,25 @@ class Functions extends Service {
|
|
|
163
219
|
*
|
|
164
220
|
* @param {string} functionId
|
|
165
221
|
* @param {string} name
|
|
222
|
+
* @param {string} runtime
|
|
166
223
|
* @param {string[]} execute
|
|
167
224
|
* @param {string[]} events
|
|
168
225
|
* @param {string} schedule
|
|
169
226
|
* @param {number} timeout
|
|
170
227
|
* @param {boolean} enabled
|
|
228
|
+
* @param {boolean} logging
|
|
229
|
+
* @param {string} entrypoint
|
|
230
|
+
* @param {string} commands
|
|
231
|
+
* @param {string} installationId
|
|
232
|
+
* @param {string} providerRepositoryId
|
|
233
|
+
* @param {string} providerBranch
|
|
234
|
+
* @param {boolean} providerSilentMode
|
|
235
|
+
* @param {string} providerRootDirectory
|
|
171
236
|
* @throws {AppwriteException}
|
|
172
237
|
* @returns {Promise}
|
|
173
238
|
*/
|
|
174
|
-
async update(functionId, name, execute, events, schedule, timeout, enabled) {
|
|
175
|
-
|
|
239
|
+
async update(functionId, name, runtime, execute, events, schedule, timeout, enabled, logging, entrypoint, commands, installationId, providerRepositoryId, providerBranch, providerSilentMode, providerRootDirectory) {
|
|
240
|
+
const apiPath = '/functions/{functionId}'.replace('{functionId}', functionId);
|
|
176
241
|
let payload = {};
|
|
177
242
|
if (typeof functionId === 'undefined') {
|
|
178
243
|
throw new AppwriteException('Missing required parameter: "functionId"');
|
|
@@ -182,8 +247,8 @@ class Functions extends Service {
|
|
|
182
247
|
throw new AppwriteException('Missing required parameter: "name"');
|
|
183
248
|
}
|
|
184
249
|
|
|
185
|
-
if (typeof
|
|
186
|
-
throw new AppwriteException('Missing required parameter: "
|
|
250
|
+
if (typeof runtime === 'undefined') {
|
|
251
|
+
throw new AppwriteException('Missing required parameter: "runtime"');
|
|
187
252
|
}
|
|
188
253
|
|
|
189
254
|
|
|
@@ -191,6 +256,10 @@ class Functions extends Service {
|
|
|
191
256
|
payload['name'] = name;
|
|
192
257
|
}
|
|
193
258
|
|
|
259
|
+
if (typeof runtime !== 'undefined') {
|
|
260
|
+
payload['runtime'] = runtime;
|
|
261
|
+
}
|
|
262
|
+
|
|
194
263
|
if (typeof execute !== 'undefined') {
|
|
195
264
|
payload['execute'] = execute;
|
|
196
265
|
}
|
|
@@ -211,7 +280,39 @@ class Functions extends Service {
|
|
|
211
280
|
payload['enabled'] = enabled;
|
|
212
281
|
}
|
|
213
282
|
|
|
214
|
-
|
|
283
|
+
if (typeof logging !== 'undefined') {
|
|
284
|
+
payload['logging'] = logging;
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
if (typeof entrypoint !== 'undefined') {
|
|
288
|
+
payload['entrypoint'] = entrypoint;
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
if (typeof commands !== 'undefined') {
|
|
292
|
+
payload['commands'] = commands;
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
if (typeof installationId !== 'undefined') {
|
|
296
|
+
payload['installationId'] = installationId;
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
if (typeof providerRepositoryId !== 'undefined') {
|
|
300
|
+
payload['providerRepositoryId'] = providerRepositoryId;
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
if (typeof providerBranch !== 'undefined') {
|
|
304
|
+
payload['providerBranch'] = providerBranch;
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
if (typeof providerSilentMode !== 'undefined') {
|
|
308
|
+
payload['providerSilentMode'] = providerSilentMode;
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
if (typeof providerRootDirectory !== 'undefined') {
|
|
312
|
+
payload['providerRootDirectory'] = providerRootDirectory;
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
return await this.client.call('put', apiPath, {
|
|
215
316
|
'content-type': 'application/json',
|
|
216
317
|
}, payload);
|
|
217
318
|
}
|
|
@@ -226,14 +327,14 @@ class Functions extends Service {
|
|
|
226
327
|
* @returns {Promise}
|
|
227
328
|
*/
|
|
228
329
|
async delete(functionId) {
|
|
229
|
-
|
|
330
|
+
const apiPath = '/functions/{functionId}'.replace('{functionId}', functionId);
|
|
230
331
|
let payload = {};
|
|
231
332
|
if (typeof functionId === 'undefined') {
|
|
232
333
|
throw new AppwriteException('Missing required parameter: "functionId"');
|
|
233
334
|
}
|
|
234
335
|
|
|
235
336
|
|
|
236
|
-
return await this.client.call('delete',
|
|
337
|
+
return await this.client.call('delete', apiPath, {
|
|
237
338
|
'content-type': 'application/json',
|
|
238
339
|
}, payload);
|
|
239
340
|
}
|
|
@@ -251,7 +352,7 @@ class Functions extends Service {
|
|
|
251
352
|
* @returns {Promise}
|
|
252
353
|
*/
|
|
253
354
|
async listDeployments(functionId, queries, search) {
|
|
254
|
-
|
|
355
|
+
const apiPath = '/functions/{functionId}/deployments'.replace('{functionId}', functionId);
|
|
255
356
|
let payload = {};
|
|
256
357
|
if (typeof functionId === 'undefined') {
|
|
257
358
|
throw new AppwriteException('Missing required parameter: "functionId"');
|
|
@@ -266,7 +367,7 @@ class Functions extends Service {
|
|
|
266
367
|
payload['search'] = search;
|
|
267
368
|
}
|
|
268
369
|
|
|
269
|
-
return await this.client.call('get',
|
|
370
|
+
return await this.client.call('get', apiPath, {
|
|
270
371
|
'content-type': 'application/json',
|
|
271
372
|
}, payload);
|
|
272
373
|
}
|
|
@@ -283,26 +384,23 @@ class Functions extends Service {
|
|
|
283
384
|
* learn more about code packaging in the [Appwrite Cloud Functions
|
|
284
385
|
* tutorial](/docs/functions).
|
|
285
386
|
*
|
|
286
|
-
* Use the "command" param to set the
|
|
387
|
+
* Use the "command" param to set the entrypoint used to execute your code.
|
|
287
388
|
*
|
|
288
389
|
* @param {string} functionId
|
|
289
|
-
* @param {string} entrypoint
|
|
290
390
|
* @param {InputFile} code
|
|
291
391
|
* @param {boolean} activate
|
|
392
|
+
* @param {string} entrypoint
|
|
393
|
+
* @param {string} commands
|
|
292
394
|
* @throws {AppwriteException}
|
|
293
395
|
* @returns {Promise}
|
|
294
396
|
*/
|
|
295
|
-
async createDeployment(functionId,
|
|
296
|
-
|
|
397
|
+
async createDeployment(functionId, code, activate, entrypoint, commands, onProgress = () => {}) {
|
|
398
|
+
const apiPath = '/functions/{functionId}/deployments'.replace('{functionId}', functionId);
|
|
297
399
|
let payload = {};
|
|
298
400
|
if (typeof functionId === 'undefined') {
|
|
299
401
|
throw new AppwriteException('Missing required parameter: "functionId"');
|
|
300
402
|
}
|
|
301
403
|
|
|
302
|
-
if (typeof entrypoint === 'undefined') {
|
|
303
|
-
throw new AppwriteException('Missing required parameter: "entrypoint"');
|
|
304
|
-
}
|
|
305
|
-
|
|
306
404
|
if (typeof code === 'undefined') {
|
|
307
405
|
throw new AppwriteException('Missing required parameter: "code"');
|
|
308
406
|
}
|
|
@@ -316,6 +414,10 @@ class Functions extends Service {
|
|
|
316
414
|
payload['entrypoint'] = entrypoint;
|
|
317
415
|
}
|
|
318
416
|
|
|
417
|
+
if (typeof commands !== 'undefined') {
|
|
418
|
+
payload['commands'] = commands;
|
|
419
|
+
}
|
|
420
|
+
|
|
319
421
|
if (typeof code !== 'undefined') {
|
|
320
422
|
payload['code'] = code;
|
|
321
423
|
}
|
|
@@ -361,7 +463,7 @@ class Functions extends Service {
|
|
|
361
463
|
const stream = Stream.Readable.from(currentChunk);
|
|
362
464
|
payload['code'] = { type: 'file', file: stream, filename: code.filename };
|
|
363
465
|
|
|
364
|
-
response = await selfClient.call('post',
|
|
466
|
+
response = await selfClient.call('post', apiPath, headers, payload);
|
|
365
467
|
|
|
366
468
|
if (!id) {
|
|
367
469
|
id = response['$id'];
|
|
@@ -382,48 +484,56 @@ class Functions extends Service {
|
|
|
382
484
|
|
|
383
485
|
return await new Promise((resolve, reject) => {
|
|
384
486
|
const writeStream = new Stream.Writable();
|
|
385
|
-
writeStream._write = async (mainChunk, encoding,
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
487
|
+
writeStream._write = async (mainChunk, encoding, callback) => {
|
|
488
|
+
try {
|
|
489
|
+
// Segment incoming chunk into up to 5MB chunks
|
|
490
|
+
const mainChunkSize = Buffer.byteLength(mainChunk);
|
|
491
|
+
const chunksCount = Math.ceil(mainChunkSize / client.CHUNK_SIZE);
|
|
492
|
+
const chunks = [];
|
|
493
|
+
|
|
494
|
+
for(let i = 0; i < chunksCount; i++) {
|
|
495
|
+
const chunk = mainChunk.slice(i * client.CHUNK_SIZE, (i + 1) * client.CHUNK_SIZE);
|
|
496
|
+
chunks.push(chunk);
|
|
497
|
+
}
|
|
395
498
|
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
499
|
+
for (const chunk of chunks) {
|
|
500
|
+
const chunkSize = Buffer.byteLength(chunk);
|
|
501
|
+
|
|
502
|
+
if(chunkSize + currentChunkSize == client.CHUNK_SIZE) {
|
|
503
|
+
// Upload chunk
|
|
504
|
+
currentChunk = Buffer.concat([currentChunk, chunk]);
|
|
505
|
+
await uploadChunk();
|
|
506
|
+
currentChunk = Buffer.from('');
|
|
507
|
+
currentChunkSize = 0;
|
|
508
|
+
} else if(chunkSize + currentChunkSize > client.CHUNK_SIZE) {
|
|
509
|
+
// Upload chunk, put rest into next chunk
|
|
510
|
+
const bytesToUpload = client.CHUNK_SIZE - currentChunkSize;
|
|
511
|
+
const newChunkSection = chunk.slice(0, bytesToUpload);
|
|
512
|
+
currentChunk = Buffer.concat([currentChunk, newChunkSection]);
|
|
513
|
+
currentChunkSize = Buffer.byteLength(currentChunk);
|
|
514
|
+
await uploadChunk();
|
|
515
|
+
currentChunk = chunk.slice(bytesToUpload, undefined);
|
|
516
|
+
currentChunkSize = chunkSize - bytesToUpload;
|
|
517
|
+
} else {
|
|
518
|
+
// Append into current chunk
|
|
519
|
+
currentChunk = Buffer.concat([currentChunk, chunk]);
|
|
520
|
+
currentChunkSize = chunkSize + currentChunkSize;
|
|
521
|
+
}
|
|
418
522
|
}
|
|
419
|
-
}
|
|
420
523
|
|
|
421
|
-
|
|
524
|
+
callback();
|
|
525
|
+
} catch (e) {
|
|
526
|
+
callback(e);
|
|
527
|
+
}
|
|
422
528
|
}
|
|
423
529
|
|
|
424
530
|
writeStream.on("finish", async () => {
|
|
425
531
|
if(currentChunkSize > 0) {
|
|
426
|
-
|
|
532
|
+
try {
|
|
533
|
+
await uploadChunk(true);
|
|
534
|
+
} catch (e) {
|
|
535
|
+
reject(e);
|
|
536
|
+
}
|
|
427
537
|
}
|
|
428
538
|
|
|
429
539
|
resolve(response);
|
|
@@ -449,7 +559,7 @@ class Functions extends Service {
|
|
|
449
559
|
* @returns {Promise}
|
|
450
560
|
*/
|
|
451
561
|
async getDeployment(functionId, deploymentId) {
|
|
452
|
-
|
|
562
|
+
const apiPath = '/functions/{functionId}/deployments/{deploymentId}'.replace('{functionId}', functionId).replace('{deploymentId}', deploymentId);
|
|
453
563
|
let payload = {};
|
|
454
564
|
if (typeof functionId === 'undefined') {
|
|
455
565
|
throw new AppwriteException('Missing required parameter: "functionId"');
|
|
@@ -460,7 +570,7 @@ class Functions extends Service {
|
|
|
460
570
|
}
|
|
461
571
|
|
|
462
572
|
|
|
463
|
-
return await this.client.call('get',
|
|
573
|
+
return await this.client.call('get', apiPath, {
|
|
464
574
|
'content-type': 'application/json',
|
|
465
575
|
}, payload);
|
|
466
576
|
}
|
|
@@ -478,7 +588,7 @@ class Functions extends Service {
|
|
|
478
588
|
* @returns {Promise}
|
|
479
589
|
*/
|
|
480
590
|
async updateDeployment(functionId, deploymentId) {
|
|
481
|
-
|
|
591
|
+
const apiPath = '/functions/{functionId}/deployments/{deploymentId}'.replace('{functionId}', functionId).replace('{deploymentId}', deploymentId);
|
|
482
592
|
let payload = {};
|
|
483
593
|
if (typeof functionId === 'undefined') {
|
|
484
594
|
throw new AppwriteException('Missing required parameter: "functionId"');
|
|
@@ -489,7 +599,7 @@ class Functions extends Service {
|
|
|
489
599
|
}
|
|
490
600
|
|
|
491
601
|
|
|
492
|
-
return await this.client.call('patch',
|
|
602
|
+
return await this.client.call('patch', apiPath, {
|
|
493
603
|
'content-type': 'application/json',
|
|
494
604
|
}, payload);
|
|
495
605
|
}
|
|
@@ -505,7 +615,7 @@ class Functions extends Service {
|
|
|
505
615
|
* @returns {Promise}
|
|
506
616
|
*/
|
|
507
617
|
async deleteDeployment(functionId, deploymentId) {
|
|
508
|
-
|
|
618
|
+
const apiPath = '/functions/{functionId}/deployments/{deploymentId}'.replace('{functionId}', functionId).replace('{deploymentId}', deploymentId);
|
|
509
619
|
let payload = {};
|
|
510
620
|
if (typeof functionId === 'undefined') {
|
|
511
621
|
throw new AppwriteException('Missing required parameter: "functionId"');
|
|
@@ -516,7 +626,7 @@ class Functions extends Service {
|
|
|
516
626
|
}
|
|
517
627
|
|
|
518
628
|
|
|
519
|
-
return await this.client.call('delete',
|
|
629
|
+
return await this.client.call('delete', apiPath, {
|
|
520
630
|
'content-type': 'application/json',
|
|
521
631
|
}, payload);
|
|
522
632
|
}
|
|
@@ -524,6 +634,9 @@ class Functions extends Service {
|
|
|
524
634
|
/**
|
|
525
635
|
* Create Build
|
|
526
636
|
*
|
|
637
|
+
* Create a new build for an Appwrite Function deployment. This endpoint can
|
|
638
|
+
* be used to retry a failed build.
|
|
639
|
+
*
|
|
527
640
|
* @param {string} functionId
|
|
528
641
|
* @param {string} deploymentId
|
|
529
642
|
* @param {string} buildId
|
|
@@ -531,7 +644,7 @@ class Functions extends Service {
|
|
|
531
644
|
* @returns {Promise}
|
|
532
645
|
*/
|
|
533
646
|
async createBuild(functionId, deploymentId, buildId) {
|
|
534
|
-
|
|
647
|
+
const apiPath = '/functions/{functionId}/deployments/{deploymentId}/builds/{buildId}'.replace('{functionId}', functionId).replace('{deploymentId}', deploymentId).replace('{buildId}', buildId);
|
|
535
648
|
let payload = {};
|
|
536
649
|
if (typeof functionId === 'undefined') {
|
|
537
650
|
throw new AppwriteException('Missing required parameter: "functionId"');
|
|
@@ -546,11 +659,36 @@ class Functions extends Service {
|
|
|
546
659
|
}
|
|
547
660
|
|
|
548
661
|
|
|
549
|
-
return await this.client.call('post',
|
|
662
|
+
return await this.client.call('post', apiPath, {
|
|
550
663
|
'content-type': 'application/json',
|
|
551
664
|
}, payload);
|
|
552
665
|
}
|
|
553
666
|
|
|
667
|
+
/**
|
|
668
|
+
* Download Deployment
|
|
669
|
+
*
|
|
670
|
+
* @param {string} functionId
|
|
671
|
+
* @param {string} deploymentId
|
|
672
|
+
* @throws {AppwriteException}
|
|
673
|
+
* @returns {Promise}
|
|
674
|
+
*/
|
|
675
|
+
async downloadDeployment(functionId, deploymentId) {
|
|
676
|
+
const apiPath = '/functions/{functionId}/deployments/{deploymentId}/download'.replace('{functionId}', functionId).replace('{deploymentId}', deploymentId);
|
|
677
|
+
let payload = {};
|
|
678
|
+
if (typeof functionId === 'undefined') {
|
|
679
|
+
throw new AppwriteException('Missing required parameter: "functionId"');
|
|
680
|
+
}
|
|
681
|
+
|
|
682
|
+
if (typeof deploymentId === 'undefined') {
|
|
683
|
+
throw new AppwriteException('Missing required parameter: "deploymentId"');
|
|
684
|
+
}
|
|
685
|
+
|
|
686
|
+
|
|
687
|
+
return await this.client.call('get', apiPath, {
|
|
688
|
+
'content-type': 'application/json',
|
|
689
|
+
}, payload, 'arraybuffer');
|
|
690
|
+
}
|
|
691
|
+
|
|
554
692
|
/**
|
|
555
693
|
* List Executions
|
|
556
694
|
*
|
|
@@ -564,7 +702,7 @@ class Functions extends Service {
|
|
|
564
702
|
* @returns {Promise}
|
|
565
703
|
*/
|
|
566
704
|
async listExecutions(functionId, queries, search) {
|
|
567
|
-
|
|
705
|
+
const apiPath = '/functions/{functionId}/executions'.replace('{functionId}', functionId);
|
|
568
706
|
let payload = {};
|
|
569
707
|
if (typeof functionId === 'undefined') {
|
|
570
708
|
throw new AppwriteException('Missing required parameter: "functionId"');
|
|
@@ -579,7 +717,7 @@ class Functions extends Service {
|
|
|
579
717
|
payload['search'] = search;
|
|
580
718
|
}
|
|
581
719
|
|
|
582
|
-
return await this.client.call('get',
|
|
720
|
+
return await this.client.call('get', apiPath, {
|
|
583
721
|
'content-type': 'application/json',
|
|
584
722
|
}, payload);
|
|
585
723
|
}
|
|
@@ -593,28 +731,43 @@ class Functions extends Service {
|
|
|
593
731
|
* function execution process will start asynchronously.
|
|
594
732
|
*
|
|
595
733
|
* @param {string} functionId
|
|
596
|
-
* @param {string}
|
|
734
|
+
* @param {string} body
|
|
597
735
|
* @param {boolean} async
|
|
736
|
+
* @param {string} xpath
|
|
737
|
+
* @param {string} method
|
|
738
|
+
* @param {object} headers
|
|
598
739
|
* @throws {AppwriteException}
|
|
599
740
|
* @returns {Promise}
|
|
600
741
|
*/
|
|
601
|
-
async createExecution(functionId,
|
|
602
|
-
|
|
742
|
+
async createExecution(functionId, body, async, xpath, method, headers) {
|
|
743
|
+
const apiPath = '/functions/{functionId}/executions'.replace('{functionId}', functionId);
|
|
603
744
|
let payload = {};
|
|
604
745
|
if (typeof functionId === 'undefined') {
|
|
605
746
|
throw new AppwriteException('Missing required parameter: "functionId"');
|
|
606
747
|
}
|
|
607
748
|
|
|
608
749
|
|
|
609
|
-
if (typeof
|
|
610
|
-
payload['
|
|
750
|
+
if (typeof body !== 'undefined') {
|
|
751
|
+
payload['body'] = body;
|
|
611
752
|
}
|
|
612
753
|
|
|
613
754
|
if (typeof async !== 'undefined') {
|
|
614
755
|
payload['async'] = async;
|
|
615
756
|
}
|
|
616
757
|
|
|
617
|
-
|
|
758
|
+
if (typeof xpath !== 'undefined') {
|
|
759
|
+
payload['path'] = xpath;
|
|
760
|
+
}
|
|
761
|
+
|
|
762
|
+
if (typeof method !== 'undefined') {
|
|
763
|
+
payload['method'] = method;
|
|
764
|
+
}
|
|
765
|
+
|
|
766
|
+
if (typeof headers !== 'undefined') {
|
|
767
|
+
payload['headers'] = headers;
|
|
768
|
+
}
|
|
769
|
+
|
|
770
|
+
return await this.client.call('post', apiPath, {
|
|
618
771
|
'content-type': 'application/json',
|
|
619
772
|
}, payload);
|
|
620
773
|
}
|
|
@@ -630,7 +783,7 @@ class Functions extends Service {
|
|
|
630
783
|
* @returns {Promise}
|
|
631
784
|
*/
|
|
632
785
|
async getExecution(functionId, executionId) {
|
|
633
|
-
|
|
786
|
+
const apiPath = '/functions/{functionId}/executions/{executionId}'.replace('{functionId}', functionId).replace('{executionId}', executionId);
|
|
634
787
|
let payload = {};
|
|
635
788
|
if (typeof functionId === 'undefined') {
|
|
636
789
|
throw new AppwriteException('Missing required parameter: "functionId"');
|
|
@@ -641,7 +794,7 @@ class Functions extends Service {
|
|
|
641
794
|
}
|
|
642
795
|
|
|
643
796
|
|
|
644
|
-
return await this.client.call('get',
|
|
797
|
+
return await this.client.call('get', apiPath, {
|
|
645
798
|
'content-type': 'application/json',
|
|
646
799
|
}, payload);
|
|
647
800
|
}
|
|
@@ -656,14 +809,14 @@ class Functions extends Service {
|
|
|
656
809
|
* @returns {Promise}
|
|
657
810
|
*/
|
|
658
811
|
async listVariables(functionId) {
|
|
659
|
-
|
|
812
|
+
const apiPath = '/functions/{functionId}/variables'.replace('{functionId}', functionId);
|
|
660
813
|
let payload = {};
|
|
661
814
|
if (typeof functionId === 'undefined') {
|
|
662
815
|
throw new AppwriteException('Missing required parameter: "functionId"');
|
|
663
816
|
}
|
|
664
817
|
|
|
665
818
|
|
|
666
|
-
return await this.client.call('get',
|
|
819
|
+
return await this.client.call('get', apiPath, {
|
|
667
820
|
'content-type': 'application/json',
|
|
668
821
|
}, payload);
|
|
669
822
|
}
|
|
@@ -671,8 +824,8 @@ class Functions extends Service {
|
|
|
671
824
|
/**
|
|
672
825
|
* Create Variable
|
|
673
826
|
*
|
|
674
|
-
* Create a new function variable. These variables can be accessed
|
|
675
|
-
*
|
|
827
|
+
* Create a new function environment variable. These variables can be accessed
|
|
828
|
+
* in the function at runtime as environment variables.
|
|
676
829
|
*
|
|
677
830
|
* @param {string} functionId
|
|
678
831
|
* @param {string} key
|
|
@@ -681,7 +834,7 @@ class Functions extends Service {
|
|
|
681
834
|
* @returns {Promise}
|
|
682
835
|
*/
|
|
683
836
|
async createVariable(functionId, key, value) {
|
|
684
|
-
|
|
837
|
+
const apiPath = '/functions/{functionId}/variables'.replace('{functionId}', functionId);
|
|
685
838
|
let payload = {};
|
|
686
839
|
if (typeof functionId === 'undefined') {
|
|
687
840
|
throw new AppwriteException('Missing required parameter: "functionId"');
|
|
@@ -704,7 +857,7 @@ class Functions extends Service {
|
|
|
704
857
|
payload['value'] = value;
|
|
705
858
|
}
|
|
706
859
|
|
|
707
|
-
return await this.client.call('post',
|
|
860
|
+
return await this.client.call('post', apiPath, {
|
|
708
861
|
'content-type': 'application/json',
|
|
709
862
|
}, payload);
|
|
710
863
|
}
|
|
@@ -720,7 +873,7 @@ class Functions extends Service {
|
|
|
720
873
|
* @returns {Promise}
|
|
721
874
|
*/
|
|
722
875
|
async getVariable(functionId, variableId) {
|
|
723
|
-
|
|
876
|
+
const apiPath = '/functions/{functionId}/variables/{variableId}'.replace('{functionId}', functionId).replace('{variableId}', variableId);
|
|
724
877
|
let payload = {};
|
|
725
878
|
if (typeof functionId === 'undefined') {
|
|
726
879
|
throw new AppwriteException('Missing required parameter: "functionId"');
|
|
@@ -731,7 +884,7 @@ class Functions extends Service {
|
|
|
731
884
|
}
|
|
732
885
|
|
|
733
886
|
|
|
734
|
-
return await this.client.call('get',
|
|
887
|
+
return await this.client.call('get', apiPath, {
|
|
735
888
|
'content-type': 'application/json',
|
|
736
889
|
}, payload);
|
|
737
890
|
}
|
|
@@ -749,7 +902,7 @@ class Functions extends Service {
|
|
|
749
902
|
* @returns {Promise}
|
|
750
903
|
*/
|
|
751
904
|
async updateVariable(functionId, variableId, key, value) {
|
|
752
|
-
|
|
905
|
+
const apiPath = '/functions/{functionId}/variables/{variableId}'.replace('{functionId}', functionId).replace('{variableId}', variableId);
|
|
753
906
|
let payload = {};
|
|
754
907
|
if (typeof functionId === 'undefined') {
|
|
755
908
|
throw new AppwriteException('Missing required parameter: "functionId"');
|
|
@@ -772,7 +925,7 @@ class Functions extends Service {
|
|
|
772
925
|
payload['value'] = value;
|
|
773
926
|
}
|
|
774
927
|
|
|
775
|
-
return await this.client.call('put',
|
|
928
|
+
return await this.client.call('put', apiPath, {
|
|
776
929
|
'content-type': 'application/json',
|
|
777
930
|
}, payload);
|
|
778
931
|
}
|
|
@@ -788,7 +941,7 @@ class Functions extends Service {
|
|
|
788
941
|
* @returns {Promise}
|
|
789
942
|
*/
|
|
790
943
|
async deleteVariable(functionId, variableId) {
|
|
791
|
-
|
|
944
|
+
const apiPath = '/functions/{functionId}/variables/{variableId}'.replace('{functionId}', functionId).replace('{variableId}', variableId);
|
|
792
945
|
let payload = {};
|
|
793
946
|
if (typeof functionId === 'undefined') {
|
|
794
947
|
throw new AppwriteException('Missing required parameter: "functionId"');
|
|
@@ -799,7 +952,7 @@ class Functions extends Service {
|
|
|
799
952
|
}
|
|
800
953
|
|
|
801
954
|
|
|
802
|
-
return await this.client.call('delete',
|
|
955
|
+
return await this.client.call('delete', apiPath, {
|
|
803
956
|
'content-type': 'application/json',
|
|
804
957
|
}, payload);
|
|
805
958
|
}
|