appwrite-cli 2.0.2 → 4.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/README.md +11 -6
- package/docs/examples/account/delete-identity.md +2 -0
- package/docs/examples/account/list-identities.md +2 -0
- package/docs/examples/assistant/chat.md +2 -0
- package/docs/examples/databases/create-collection.md +1 -0
- package/docs/examples/databases/create-string-attribute.md +1 -0
- package/docs/examples/databases/create.md +2 -1
- package/docs/examples/databases/list-attributes.md +2 -1
- package/docs/examples/databases/list-indexes.md +2 -1
- package/docs/examples/databases/update.md +2 -1
- package/docs/examples/functions/create-deployment.md +3 -2
- package/docs/examples/functions/create-execution.md +3 -0
- package/docs/examples/functions/create.md +13 -1
- package/docs/examples/functions/download-deployment.md +3 -0
- package/docs/examples/functions/update.md +9 -0
- package/docs/examples/health/get-pub-sub.md +1 -0
- package/docs/examples/health/get-queue.md +1 -0
- package/docs/examples/locale/list-codes.md +1 -0
- package/docs/examples/migrations/create-appwrite-migration.md +5 -0
- package/docs/examples/migrations/create-firebase-migration.md +3 -0
- package/docs/examples/migrations/create-firebase-o-auth-migration.md +3 -0
- package/docs/examples/migrations/create-n-host-migration.md +9 -0
- package/docs/examples/migrations/create-supabase-migration.md +8 -0
- package/docs/examples/migrations/delete-firebase-auth.md +1 -0
- package/docs/examples/migrations/delete.md +2 -0
- package/docs/examples/migrations/get-appwrite-report.md +5 -0
- package/docs/examples/migrations/get-firebase-report-o-auth.md +3 -0
- package/docs/examples/migrations/get-firebase-report.md +3 -0
- package/docs/examples/migrations/get-n-host-report.md +9 -0
- package/docs/examples/migrations/get-supabase-report.md +8 -0
- package/docs/examples/migrations/get.md +2 -0
- package/docs/examples/migrations/list-firebase-projects.md +1 -0
- package/docs/examples/migrations/list.md +3 -0
- package/docs/examples/migrations/retry.md +2 -0
- package/docs/examples/project/create-variable.md +3 -0
- package/docs/examples/project/delete-variable.md +2 -0
- package/docs/examples/project/get-usage.md +2 -0
- package/docs/examples/project/get-variable.md +2 -0
- package/docs/examples/project/list-variables.md +1 -0
- package/docs/examples/project/update-variable.md +4 -0
- package/docs/examples/projects/create.md +1 -1
- package/docs/examples/projects/delete-email-template.md +4 -0
- package/docs/examples/projects/delete-sms-template.md +4 -0
- package/docs/examples/projects/delete.md +1 -2
- package/docs/examples/projects/get-email-template.md +4 -0
- package/docs/examples/projects/get-sms-template.md +4 -0
- package/docs/examples/projects/update-email-template.md +9 -0
- package/docs/examples/projects/update-personal-data-check.md +3 -0
- package/docs/examples/projects/update-service-status-all.md +3 -0
- package/docs/examples/projects/update-sms-template.md +5 -0
- package/docs/examples/projects/update-smtp-configuration.md +11 -0
- package/docs/examples/projects/update-team.md +3 -0
- package/docs/examples/proxy/create-rule.md +4 -0
- package/docs/examples/proxy/delete-rule.md +2 -0
- package/docs/examples/proxy/get-rule.md +2 -0
- package/docs/examples/proxy/list-rules.md +3 -0
- package/docs/examples/proxy/update-rule-verification.md +2 -0
- package/docs/examples/storage/update-file.md +1 -0
- package/docs/examples/teams/create-membership.md +1 -1
- package/docs/examples/teams/{update-membership-roles.md → update-membership.md} +1 -1
- package/docs/examples/users/delete-identity.md +2 -0
- package/docs/examples/users/list-identities.md +3 -0
- package/docs/examples/users/update-labels.md +3 -0
- package/docs/examples/vcs/create-repository-detection.md +4 -0
- package/docs/examples/vcs/create-repository.md +4 -0
- package/docs/examples/vcs/delete-installation.md +2 -0
- package/docs/examples/vcs/get-installation.md +2 -0
- package/docs/examples/vcs/get-repository.md +3 -0
- package/docs/examples/vcs/list-installations.md +3 -0
- package/docs/examples/vcs/list-repositories.md +3 -0
- package/docs/examples/vcs/list-repository-branches.md +3 -0
- package/docs/examples/vcs/update-external-deployments.md +4 -0
- package/index.js +10 -0
- package/install.ps1 +2 -2
- package/install.sh +1 -1
- package/lib/client.js +3 -3
- package/lib/commands/account.js +122 -67
- package/lib/commands/assistant.js +53 -0
- package/lib/commands/avatars.js +21 -21
- package/lib/commands/console.js +2 -2
- package/lib/commands/databases.js +146 -104
- package/lib/commands/deploy.js +11 -2
- package/lib/commands/functions.js +292 -94
- package/lib/commands/generic.js +1 -0
- package/lib/commands/graphql.js +4 -4
- package/lib/commands/health.js +68 -22
- package/lib/commands/init.js +13 -4
- package/lib/commands/locale.js +37 -14
- package/lib/commands/migrations.js +708 -0
- package/lib/commands/project.js +204 -0
- package/lib/commands/projects.js +459 -196
- package/lib/commands/proxy.js +177 -0
- package/lib/commands/storage.js +63 -65
- package/lib/commands/teams.js +36 -36
- package/lib/commands/users.js +147 -52
- package/lib/commands/vcs.js +305 -0
- package/lib/config.js +1 -2
- package/lib/parser.js +7 -2
- package/lib/questions.js +45 -10
- package/package.json +2 -2
- package/scoop/appwrite.json +30 -0
- package/docs/examples/projects/create-domain.md +0 -3
- package/docs/examples/projects/delete-domain.md +0 -3
- package/docs/examples/projects/get-domain.md +0 -3
- package/docs/examples/projects/list-domains.md +0 -2
- package/docs/examples/projects/update-domain-verification.md +0 -3
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
const fs = require('fs');
|
|
2
|
+
const pathLib = require('path');
|
|
3
|
+
const tar = require("tar");
|
|
4
|
+
const ignore = require("ignore");
|
|
5
|
+
const { promisify } = require('util');
|
|
6
|
+
const libClient = require('../client.js');
|
|
7
|
+
const { getAllFiles } = require('../utils.js');
|
|
8
|
+
const { Command } = require('commander');
|
|
9
|
+
const { sdkForProject, sdkForConsole } = require('../sdks')
|
|
10
|
+
const { parse, actionRunner, parseInteger, parseBool, commandDescriptions, success, log } = require('../parser')
|
|
11
|
+
const { localConfig, globalConfig } = require("../config");
|
|
12
|
+
|
|
13
|
+
const proxy = new Command("proxy").description(commandDescriptions['proxy']).configureHelp({
|
|
14
|
+
helpWidth: process.stdout.columns || 80
|
|
15
|
+
})
|
|
16
|
+
|
|
17
|
+
const proxyListRules = async ({ queries, search, parseOutput = true, sdk = undefined}) => {
|
|
18
|
+
/* @param {string[]} queries */
|
|
19
|
+
/* @param {string} search */
|
|
20
|
+
|
|
21
|
+
let client = !sdk ? await sdkForProject() : sdk;
|
|
22
|
+
let apiPath = '/proxy/rules';
|
|
23
|
+
let payload = {};
|
|
24
|
+
|
|
25
|
+
/** Query Params */
|
|
26
|
+
if (typeof queries !== 'undefined') {
|
|
27
|
+
payload['queries'] = queries;
|
|
28
|
+
}
|
|
29
|
+
if (typeof search !== 'undefined') {
|
|
30
|
+
payload['search'] = search;
|
|
31
|
+
}
|
|
32
|
+
let response = undefined;
|
|
33
|
+
response = await client.call('get', apiPath, {
|
|
34
|
+
'content-type': 'application/json',
|
|
35
|
+
}, payload);
|
|
36
|
+
|
|
37
|
+
if (parseOutput) {
|
|
38
|
+
parse(response)
|
|
39
|
+
success()
|
|
40
|
+
}
|
|
41
|
+
return response;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
const proxyCreateRule = async ({ domain, resourceType, resourceId, parseOutput = true, sdk = undefined}) => {
|
|
45
|
+
/* @param {string} domain */
|
|
46
|
+
/* @param {string} resourceType */
|
|
47
|
+
/* @param {string} resourceId */
|
|
48
|
+
|
|
49
|
+
let client = !sdk ? await sdkForProject() : sdk;
|
|
50
|
+
let apiPath = '/proxy/rules';
|
|
51
|
+
let payload = {};
|
|
52
|
+
|
|
53
|
+
/** Body Params */
|
|
54
|
+
|
|
55
|
+
if (typeof domain !== 'undefined') {
|
|
56
|
+
payload['domain'] = domain;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
if (typeof resourceType !== 'undefined') {
|
|
61
|
+
payload['resourceType'] = resourceType;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
if (typeof resourceId !== 'undefined') {
|
|
66
|
+
payload['resourceId'] = resourceId;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
let response = undefined;
|
|
70
|
+
response = await client.call('post', apiPath, {
|
|
71
|
+
'content-type': 'application/json',
|
|
72
|
+
}, payload);
|
|
73
|
+
|
|
74
|
+
if (parseOutput) {
|
|
75
|
+
parse(response)
|
|
76
|
+
success()
|
|
77
|
+
}
|
|
78
|
+
return response;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
const proxyGetRule = async ({ ruleId, parseOutput = true, sdk = undefined}) => {
|
|
82
|
+
/* @param {string} ruleId */
|
|
83
|
+
|
|
84
|
+
let client = !sdk ? await sdkForProject() : sdk;
|
|
85
|
+
let apiPath = '/proxy/rules/{ruleId}'.replace('{ruleId}', ruleId);
|
|
86
|
+
let payload = {};
|
|
87
|
+
let response = undefined;
|
|
88
|
+
response = await client.call('get', apiPath, {
|
|
89
|
+
'content-type': 'application/json',
|
|
90
|
+
}, payload);
|
|
91
|
+
|
|
92
|
+
if (parseOutput) {
|
|
93
|
+
parse(response)
|
|
94
|
+
success()
|
|
95
|
+
}
|
|
96
|
+
return response;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
const proxyDeleteRule = async ({ ruleId, parseOutput = true, sdk = undefined}) => {
|
|
100
|
+
/* @param {string} ruleId */
|
|
101
|
+
|
|
102
|
+
let client = !sdk ? await sdkForProject() : sdk;
|
|
103
|
+
let apiPath = '/proxy/rules/{ruleId}'.replace('{ruleId}', ruleId);
|
|
104
|
+
let payload = {};
|
|
105
|
+
let response = undefined;
|
|
106
|
+
response = await client.call('delete', apiPath, {
|
|
107
|
+
'content-type': 'application/json',
|
|
108
|
+
}, payload);
|
|
109
|
+
|
|
110
|
+
if (parseOutput) {
|
|
111
|
+
parse(response)
|
|
112
|
+
success()
|
|
113
|
+
}
|
|
114
|
+
return response;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
const proxyUpdateRuleVerification = async ({ ruleId, parseOutput = true, sdk = undefined}) => {
|
|
118
|
+
/* @param {string} ruleId */
|
|
119
|
+
|
|
120
|
+
let client = !sdk ? await sdkForProject() : sdk;
|
|
121
|
+
let apiPath = '/proxy/rules/{ruleId}/verification'.replace('{ruleId}', ruleId);
|
|
122
|
+
let payload = {};
|
|
123
|
+
let response = undefined;
|
|
124
|
+
response = await client.call('patch', apiPath, {
|
|
125
|
+
'content-type': 'application/json',
|
|
126
|
+
}, payload);
|
|
127
|
+
|
|
128
|
+
if (parseOutput) {
|
|
129
|
+
parse(response)
|
|
130
|
+
success()
|
|
131
|
+
}
|
|
132
|
+
return response;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
|
|
136
|
+
proxy
|
|
137
|
+
.command(`listRules`)
|
|
138
|
+
.description(`Get a list of all the proxy rules. You can use the query params to filter your results.`)
|
|
139
|
+
.option(`--queries [queries...]`, `Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/databases#querying-documents). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: domain, resourceType, resourceId, url`)
|
|
140
|
+
.option(`--search <search>`, `Search term to filter your list results. Max length: 256 chars.`)
|
|
141
|
+
.action(actionRunner(proxyListRules))
|
|
142
|
+
|
|
143
|
+
proxy
|
|
144
|
+
.command(`createRule`)
|
|
145
|
+
.description(`Create a new proxy rule.`)
|
|
146
|
+
.requiredOption(`--domain <domain>`, `Domain name.`)
|
|
147
|
+
.requiredOption(`--resourceType <resourceType>`, `Action definition for the rule. Possible values are "api", "function"`)
|
|
148
|
+
.option(`--resourceId <resourceId>`, `ID of resource for the action type. If resourceType is "api", leave empty. If resourceType is "function", provide ID of the function.`)
|
|
149
|
+
.action(actionRunner(proxyCreateRule))
|
|
150
|
+
|
|
151
|
+
proxy
|
|
152
|
+
.command(`getRule`)
|
|
153
|
+
.description(`Get a proxy rule by its unique ID.`)
|
|
154
|
+
.requiredOption(`--ruleId <ruleId>`, `Rule ID.`)
|
|
155
|
+
.action(actionRunner(proxyGetRule))
|
|
156
|
+
|
|
157
|
+
proxy
|
|
158
|
+
.command(`deleteRule`)
|
|
159
|
+
.description(`Delete a proxy rule by its unique ID.`)
|
|
160
|
+
.requiredOption(`--ruleId <ruleId>`, `Rule ID.`)
|
|
161
|
+
.action(actionRunner(proxyDeleteRule))
|
|
162
|
+
|
|
163
|
+
proxy
|
|
164
|
+
.command(`updateRuleVerification`)
|
|
165
|
+
.description(``)
|
|
166
|
+
.requiredOption(`--ruleId <ruleId>`, `Rule ID.`)
|
|
167
|
+
.action(actionRunner(proxyUpdateRuleVerification))
|
|
168
|
+
|
|
169
|
+
|
|
170
|
+
module.exports = {
|
|
171
|
+
proxy,
|
|
172
|
+
proxyListRules,
|
|
173
|
+
proxyCreateRule,
|
|
174
|
+
proxyGetRule,
|
|
175
|
+
proxyDeleteRule,
|
|
176
|
+
proxyUpdateRuleVerification
|
|
177
|
+
};
|
package/lib/commands/storage.js
CHANGED
|
@@ -19,7 +19,7 @@ const storageListBuckets = async ({ queries, search, parseOutput = true, sdk = u
|
|
|
19
19
|
/* @param {string} search */
|
|
20
20
|
|
|
21
21
|
let client = !sdk ? await sdkForProject() : sdk;
|
|
22
|
-
let
|
|
22
|
+
let apiPath = '/storage/buckets';
|
|
23
23
|
let payload = {};
|
|
24
24
|
|
|
25
25
|
/** Query Params */
|
|
@@ -30,7 +30,7 @@ const storageListBuckets = async ({ queries, search, parseOutput = true, sdk = u
|
|
|
30
30
|
payload['search'] = search;
|
|
31
31
|
}
|
|
32
32
|
let response = undefined;
|
|
33
|
-
response = await client.call('get',
|
|
33
|
+
response = await client.call('get', apiPath, {
|
|
34
34
|
'content-type': 'application/json',
|
|
35
35
|
}, payload);
|
|
36
36
|
|
|
@@ -54,7 +54,7 @@ const storageCreateBucket = async ({ bucketId, name, permissions, fileSecurity,
|
|
|
54
54
|
/* @param {boolean} antivirus */
|
|
55
55
|
|
|
56
56
|
let client = !sdk ? await sdkForProject() : sdk;
|
|
57
|
-
let
|
|
57
|
+
let apiPath = '/storage/buckets';
|
|
58
58
|
let payload = {};
|
|
59
59
|
|
|
60
60
|
/** Body Params */
|
|
@@ -111,7 +111,7 @@ const storageCreateBucket = async ({ bucketId, name, permissions, fileSecurity,
|
|
|
111
111
|
}
|
|
112
112
|
|
|
113
113
|
let response = undefined;
|
|
114
|
-
response = await client.call('post',
|
|
114
|
+
response = await client.call('post', apiPath, {
|
|
115
115
|
'content-type': 'application/json',
|
|
116
116
|
}, payload);
|
|
117
117
|
|
|
@@ -126,10 +126,10 @@ const storageGetBucket = async ({ bucketId, parseOutput = true, sdk = undefined}
|
|
|
126
126
|
/* @param {string} bucketId */
|
|
127
127
|
|
|
128
128
|
let client = !sdk ? await sdkForProject() : sdk;
|
|
129
|
-
let
|
|
129
|
+
let apiPath = '/storage/buckets/{bucketId}'.replace('{bucketId}', bucketId);
|
|
130
130
|
let payload = {};
|
|
131
131
|
let response = undefined;
|
|
132
|
-
response = await client.call('get',
|
|
132
|
+
response = await client.call('get', apiPath, {
|
|
133
133
|
'content-type': 'application/json',
|
|
134
134
|
}, payload);
|
|
135
135
|
|
|
@@ -153,7 +153,7 @@ const storageUpdateBucket = async ({ bucketId, name, permissions, fileSecurity,
|
|
|
153
153
|
/* @param {boolean} antivirus */
|
|
154
154
|
|
|
155
155
|
let client = !sdk ? await sdkForProject() : sdk;
|
|
156
|
-
let
|
|
156
|
+
let apiPath = '/storage/buckets/{bucketId}'.replace('{bucketId}', bucketId);
|
|
157
157
|
let payload = {};
|
|
158
158
|
|
|
159
159
|
/** Body Params */
|
|
@@ -205,7 +205,7 @@ const storageUpdateBucket = async ({ bucketId, name, permissions, fileSecurity,
|
|
|
205
205
|
}
|
|
206
206
|
|
|
207
207
|
let response = undefined;
|
|
208
|
-
response = await client.call('put',
|
|
208
|
+
response = await client.call('put', apiPath, {
|
|
209
209
|
'content-type': 'application/json',
|
|
210
210
|
}, payload);
|
|
211
211
|
|
|
@@ -220,10 +220,10 @@ const storageDeleteBucket = async ({ bucketId, parseOutput = true, sdk = undefin
|
|
|
220
220
|
/* @param {string} bucketId */
|
|
221
221
|
|
|
222
222
|
let client = !sdk ? await sdkForProject() : sdk;
|
|
223
|
-
let
|
|
223
|
+
let apiPath = '/storage/buckets/{bucketId}'.replace('{bucketId}', bucketId);
|
|
224
224
|
let payload = {};
|
|
225
225
|
let response = undefined;
|
|
226
|
-
response = await client.call('delete',
|
|
226
|
+
response = await client.call('delete', apiPath, {
|
|
227
227
|
'content-type': 'application/json',
|
|
228
228
|
}, payload);
|
|
229
229
|
|
|
@@ -240,7 +240,7 @@ const storageListFiles = async ({ bucketId, queries, search, parseOutput = true,
|
|
|
240
240
|
/* @param {string} search */
|
|
241
241
|
|
|
242
242
|
let client = !sdk ? await sdkForProject() : sdk;
|
|
243
|
-
let
|
|
243
|
+
let apiPath = '/storage/buckets/{bucketId}/files'.replace('{bucketId}', bucketId);
|
|
244
244
|
let payload = {};
|
|
245
245
|
|
|
246
246
|
/** Query Params */
|
|
@@ -251,7 +251,7 @@ const storageListFiles = async ({ bucketId, queries, search, parseOutput = true,
|
|
|
251
251
|
payload['search'] = search;
|
|
252
252
|
}
|
|
253
253
|
let response = undefined;
|
|
254
|
-
response = await client.call('get',
|
|
254
|
+
response = await client.call('get', apiPath, {
|
|
255
255
|
'content-type': 'application/json',
|
|
256
256
|
}, payload);
|
|
257
257
|
|
|
@@ -269,7 +269,7 @@ const storageCreateFile = async ({ bucketId, fileId, file, permissions, parseOut
|
|
|
269
269
|
/* @param {string[]} permissions */
|
|
270
270
|
|
|
271
271
|
let client = !sdk ? await sdkForProject() : sdk;
|
|
272
|
-
let
|
|
272
|
+
let apiPath = '/storage/buckets/{bucketId}/files'.replace('{bucketId}', bucketId);
|
|
273
273
|
let payload = {};
|
|
274
274
|
|
|
275
275
|
/** Body Params */
|
|
@@ -295,59 +295,50 @@ const storageCreateFile = async ({ bucketId, fileId, file, permissions, parseOut
|
|
|
295
295
|
if (size <= libClient.CHUNK_SIZE) {
|
|
296
296
|
payload['file'] = fs.createReadStream(payload['file']);
|
|
297
297
|
|
|
298
|
-
response = await client.call('post',
|
|
298
|
+
response = await client.call('post', apiPath, {
|
|
299
299
|
'content-type': 'multipart/form-data',
|
|
300
300
|
}, payload)
|
|
301
301
|
} else {
|
|
302
302
|
const streamFilePath = payload['file'];
|
|
303
|
-
let id = undefined;
|
|
304
303
|
|
|
305
|
-
|
|
306
|
-
const totalCounters = Math.ceil(size / libClient.CHUNK_SIZE);
|
|
307
|
-
|
|
308
|
-
const headers = {
|
|
304
|
+
const apiHeaders = {
|
|
309
305
|
'content-type': 'multipart/form-data',
|
|
310
306
|
};
|
|
311
307
|
|
|
308
|
+
let offset = 0;
|
|
312
309
|
if(fileId != 'unique()') {
|
|
313
310
|
try {
|
|
314
|
-
response = await client.call('get',
|
|
315
|
-
|
|
311
|
+
response = await client.call('get', apiPath + '/' + fileId, apiHeaders);
|
|
312
|
+
offset = response.chunksUploaded * libClient.CHUNK_SIZE;
|
|
316
313
|
} catch(e) {
|
|
317
314
|
}
|
|
318
315
|
}
|
|
319
316
|
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
const end = Math.min((((counter * libClient.CHUNK_SIZE) + libClient.CHUNK_SIZE) - 1), size);
|
|
323
|
-
|
|
324
|
-
headers['content-range'] = 'bytes ' + start + '-' + end + '/' + size;
|
|
317
|
+
while (offset < size) {
|
|
318
|
+
let end = Math.min(offset + libClient.CHUNK_SIZE - 1, size - 1);
|
|
325
319
|
|
|
326
|
-
|
|
327
|
-
|
|
320
|
+
apiHeaders['content-range'] = 'bytes ' + offset + '-' + end + '/' + size;
|
|
321
|
+
if (response && response.$id) {
|
|
322
|
+
apiHeaders['x-appwrite-id'] = response.$id;
|
|
328
323
|
}
|
|
329
324
|
|
|
330
325
|
const stream = fs.createReadStream(streamFilePath, {
|
|
331
|
-
start,
|
|
326
|
+
start: offset,
|
|
332
327
|
end
|
|
333
328
|
});
|
|
334
329
|
payload['file'] = stream;
|
|
330
|
+
response = await client.call('post', apiPath, apiHeaders, payload);
|
|
335
331
|
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
if (!id) {
|
|
339
|
-
id = response['$id'];
|
|
340
|
-
}
|
|
341
|
-
|
|
342
|
-
if (onProgress !== null) {
|
|
332
|
+
if (onProgress) {
|
|
343
333
|
onProgress({
|
|
344
|
-
$id: response
|
|
345
|
-
progress:
|
|
346
|
-
sizeUploaded:
|
|
347
|
-
chunksTotal: response
|
|
348
|
-
chunksUploaded: response
|
|
334
|
+
$id: response.$id,
|
|
335
|
+
progress: ( offset / size ) * 100,
|
|
336
|
+
sizeUploaded: offset,
|
|
337
|
+
chunksTotal: response.chunksTotal,
|
|
338
|
+
chunksUploaded: response.chunksUploaded
|
|
349
339
|
});
|
|
350
340
|
}
|
|
341
|
+
offset += libClient.CHUNK_SIZE;
|
|
351
342
|
}
|
|
352
343
|
}
|
|
353
344
|
|
|
@@ -363,10 +354,10 @@ const storageGetFile = async ({ bucketId, fileId, parseOutput = true, sdk = unde
|
|
|
363
354
|
/* @param {string} fileId */
|
|
364
355
|
|
|
365
356
|
let client = !sdk ? await sdkForProject() : sdk;
|
|
366
|
-
let
|
|
357
|
+
let apiPath = '/storage/buckets/{bucketId}/files/{fileId}'.replace('{bucketId}', bucketId).replace('{fileId}', fileId);
|
|
367
358
|
let payload = {};
|
|
368
359
|
let response = undefined;
|
|
369
|
-
response = await client.call('get',
|
|
360
|
+
response = await client.call('get', apiPath, {
|
|
370
361
|
'content-type': 'application/json',
|
|
371
362
|
}, payload);
|
|
372
363
|
|
|
@@ -377,16 +368,22 @@ const storageGetFile = async ({ bucketId, fileId, parseOutput = true, sdk = unde
|
|
|
377
368
|
return response;
|
|
378
369
|
}
|
|
379
370
|
|
|
380
|
-
const storageUpdateFile = async ({ bucketId, fileId, permissions, parseOutput = true, sdk = undefined}) => {
|
|
371
|
+
const storageUpdateFile = async ({ bucketId, fileId, name, permissions, parseOutput = true, sdk = undefined}) => {
|
|
381
372
|
/* @param {string} bucketId */
|
|
382
373
|
/* @param {string} fileId */
|
|
374
|
+
/* @param {string} name */
|
|
383
375
|
/* @param {string[]} permissions */
|
|
384
376
|
|
|
385
377
|
let client = !sdk ? await sdkForProject() : sdk;
|
|
386
|
-
let
|
|
378
|
+
let apiPath = '/storage/buckets/{bucketId}/files/{fileId}'.replace('{bucketId}', bucketId).replace('{fileId}', fileId);
|
|
387
379
|
let payload = {};
|
|
388
380
|
|
|
389
381
|
/** Body Params */
|
|
382
|
+
|
|
383
|
+
if (typeof name !== 'undefined') {
|
|
384
|
+
payload['name'] = name;
|
|
385
|
+
}
|
|
386
|
+
|
|
390
387
|
permissions = permissions === true ? [] : permissions;
|
|
391
388
|
|
|
392
389
|
if (typeof permissions !== 'undefined') {
|
|
@@ -394,7 +391,7 @@ const storageUpdateFile = async ({ bucketId, fileId, permissions, parseOutput =
|
|
|
394
391
|
}
|
|
395
392
|
|
|
396
393
|
let response = undefined;
|
|
397
|
-
response = await client.call('put',
|
|
394
|
+
response = await client.call('put', apiPath, {
|
|
398
395
|
'content-type': 'application/json',
|
|
399
396
|
}, payload);
|
|
400
397
|
|
|
@@ -410,10 +407,10 @@ const storageDeleteFile = async ({ bucketId, fileId, parseOutput = true, sdk = u
|
|
|
410
407
|
/* @param {string} fileId */
|
|
411
408
|
|
|
412
409
|
let client = !sdk ? await sdkForProject() : sdk;
|
|
413
|
-
let
|
|
410
|
+
let apiPath = '/storage/buckets/{bucketId}/files/{fileId}'.replace('{bucketId}', bucketId).replace('{fileId}', fileId);
|
|
414
411
|
let payload = {};
|
|
415
412
|
let response = undefined;
|
|
416
|
-
response = await client.call('delete',
|
|
413
|
+
response = await client.call('delete', apiPath, {
|
|
417
414
|
'content-type': 'application/json',
|
|
418
415
|
}, payload);
|
|
419
416
|
|
|
@@ -429,14 +426,14 @@ const storageGetFileDownload = async ({ bucketId, fileId, parseOutput = true, sd
|
|
|
429
426
|
/* @param {string} fileId */
|
|
430
427
|
|
|
431
428
|
let client = !sdk ? await sdkForProject() : sdk;
|
|
432
|
-
let
|
|
429
|
+
let apiPath = '/storage/buckets/{bucketId}/files/{fileId}/download'.replace('{bucketId}', bucketId).replace('{fileId}', fileId);
|
|
433
430
|
let payload = {};
|
|
434
431
|
payload['project'] = localConfig.getProject().projectId
|
|
435
432
|
payload['key'] = globalConfig.getKey();
|
|
436
433
|
const queryParams = new URLSearchParams(payload);
|
|
437
|
-
|
|
434
|
+
apiPath = `${globalConfig.getEndpoint()}${apiPath}?${queryParams.toString()}`;
|
|
438
435
|
|
|
439
|
-
const response = await client.call('get',
|
|
436
|
+
const response = await client.call('get', apiPath, {
|
|
440
437
|
'content-type': 'application/json',
|
|
441
438
|
}, payload, 'arraybuffer');
|
|
442
439
|
|
|
@@ -464,7 +461,7 @@ const storageGetFilePreview = async ({ bucketId, fileId, width, height, gravity,
|
|
|
464
461
|
/* @param {string} output */
|
|
465
462
|
|
|
466
463
|
let client = !sdk ? await sdkForProject() : sdk;
|
|
467
|
-
let
|
|
464
|
+
let apiPath = '/storage/buckets/{bucketId}/files/{fileId}/preview'.replace('{bucketId}', bucketId).replace('{fileId}', fileId);
|
|
468
465
|
let payload = {};
|
|
469
466
|
|
|
470
467
|
/** Query Params */
|
|
@@ -504,9 +501,9 @@ const storageGetFilePreview = async ({ bucketId, fileId, width, height, gravity,
|
|
|
504
501
|
payload['project'] = localConfig.getProject().projectId
|
|
505
502
|
payload['key'] = globalConfig.getKey();
|
|
506
503
|
const queryParams = new URLSearchParams(payload);
|
|
507
|
-
|
|
504
|
+
apiPath = `${globalConfig.getEndpoint()}${apiPath}?${queryParams.toString()}`;
|
|
508
505
|
|
|
509
|
-
const response = await client.call('get',
|
|
506
|
+
const response = await client.call('get', apiPath, {
|
|
510
507
|
'content-type': 'application/json',
|
|
511
508
|
}, payload, 'arraybuffer');
|
|
512
509
|
|
|
@@ -523,14 +520,14 @@ const storageGetFileView = async ({ bucketId, fileId, parseOutput = true, sdk =
|
|
|
523
520
|
/* @param {string} fileId */
|
|
524
521
|
|
|
525
522
|
let client = !sdk ? await sdkForProject() : sdk;
|
|
526
|
-
let
|
|
523
|
+
let apiPath = '/storage/buckets/{bucketId}/files/{fileId}/view'.replace('{bucketId}', bucketId).replace('{fileId}', fileId);
|
|
527
524
|
let payload = {};
|
|
528
525
|
payload['project'] = localConfig.getProject().projectId
|
|
529
526
|
payload['key'] = globalConfig.getKey();
|
|
530
527
|
const queryParams = new URLSearchParams(payload);
|
|
531
|
-
|
|
528
|
+
apiPath = `${globalConfig.getEndpoint()}${apiPath}?${queryParams.toString()}`;
|
|
532
529
|
|
|
533
|
-
const response = await client.call('get',
|
|
530
|
+
const response = await client.call('get', apiPath, {
|
|
534
531
|
'content-type': 'application/json',
|
|
535
532
|
}, payload, 'arraybuffer');
|
|
536
533
|
|
|
@@ -546,7 +543,7 @@ const storageGetUsage = async ({ range, parseOutput = true, sdk = undefined}) =>
|
|
|
546
543
|
/* @param {string} range */
|
|
547
544
|
|
|
548
545
|
let client = !sdk ? await sdkForProject() : sdk;
|
|
549
|
-
let
|
|
546
|
+
let apiPath = '/storage/usage';
|
|
550
547
|
let payload = {};
|
|
551
548
|
|
|
552
549
|
/** Query Params */
|
|
@@ -554,7 +551,7 @@ const storageGetUsage = async ({ range, parseOutput = true, sdk = undefined}) =>
|
|
|
554
551
|
payload['range'] = range;
|
|
555
552
|
}
|
|
556
553
|
let response = undefined;
|
|
557
|
-
response = await client.call('get',
|
|
554
|
+
response = await client.call('get', apiPath, {
|
|
558
555
|
'content-type': 'application/json',
|
|
559
556
|
}, payload);
|
|
560
557
|
|
|
@@ -570,7 +567,7 @@ const storageGetBucketUsage = async ({ bucketId, range, parseOutput = true, sdk
|
|
|
570
567
|
/* @param {string} range */
|
|
571
568
|
|
|
572
569
|
let client = !sdk ? await sdkForProject() : sdk;
|
|
573
|
-
let
|
|
570
|
+
let apiPath = '/storage/{bucketId}/usage'.replace('{bucketId}', bucketId);
|
|
574
571
|
let payload = {};
|
|
575
572
|
|
|
576
573
|
/** Query Params */
|
|
@@ -578,7 +575,7 @@ const storageGetBucketUsage = async ({ bucketId, range, parseOutput = true, sdk
|
|
|
578
575
|
payload['range'] = range;
|
|
579
576
|
}
|
|
580
577
|
let response = undefined;
|
|
581
|
-
response = await client.call('get',
|
|
578
|
+
response = await client.call('get', apiPath, {
|
|
582
579
|
'content-type': 'application/json',
|
|
583
580
|
}, payload);
|
|
584
581
|
|
|
@@ -604,8 +601,8 @@ storage
|
|
|
604
601
|
.requiredOption(`--name <name>`, `Bucket name`)
|
|
605
602
|
.option(`--permissions [permissions...]`, `An array of permission strings. By default, no user is granted with any permissions. [Learn more about permissions](/docs/permissions).`)
|
|
606
603
|
.option(`--fileSecurity <fileSecurity>`, `Enables configuring permissions for individual file. A user needs one of file or bucket level permissions to access a file. [Learn more about permissions](/docs/permissions).`, parseBool)
|
|
607
|
-
.option(`--enabled <enabled>`, `Is bucket enabled
|
|
608
|
-
.option(`--maximumFileSize <maximumFileSize>`, `Maximum file size allowed in bytes. Maximum allowed value is 30MB
|
|
604
|
+
.option(`--enabled <enabled>`, `Is bucket enabled? When set to 'disabled', users cannot access the files in this bucket but Server SDKs with and API key can still access the bucket. No files are lost when this is toggled.`, parseBool)
|
|
605
|
+
.option(`--maximumFileSize <maximumFileSize>`, `Maximum file size allowed in bytes. Maximum allowed value is 30MB.`, parseInteger)
|
|
609
606
|
.option(`--allowedFileExtensions [allowedFileExtensions...]`, `Allowed file extensions. Maximum of 100 extensions are allowed, each 64 characters long.`)
|
|
610
607
|
.option(`--compression <compression>`, `Compression algorithm choosen for compression. Can be one of none, [gzip](https://en.wikipedia.org/wiki/Gzip), or [zstd](https://en.wikipedia.org/wiki/Zstd), For file size above 20MB compression is skipped even if it's enabled`)
|
|
611
608
|
.option(`--encryption <encryption>`, `Is encryption enabled? For file size above 20MB encryption is skipped even if it's enabled`, parseBool)
|
|
@@ -625,8 +622,8 @@ storage
|
|
|
625
622
|
.requiredOption(`--name <name>`, `Bucket name`)
|
|
626
623
|
.option(`--permissions [permissions...]`, `An array of permission strings. By default, the current permissions are inherited. [Learn more about permissions](/docs/permissions).`)
|
|
627
624
|
.option(`--fileSecurity <fileSecurity>`, `Enables configuring permissions for individual file. A user needs one of file or bucket level permissions to access a file. [Learn more about permissions](/docs/permissions).`, parseBool)
|
|
628
|
-
.option(`--enabled <enabled>`, `Is bucket enabled
|
|
629
|
-
.option(`--maximumFileSize <maximumFileSize>`, `Maximum file size allowed in bytes. Maximum allowed value is 30MB
|
|
625
|
+
.option(`--enabled <enabled>`, `Is bucket enabled? When set to 'disabled', users cannot access the files in this bucket but Server SDKs with and API key can still access the bucket. No files are lost when this is toggled.`, parseBool)
|
|
626
|
+
.option(`--maximumFileSize <maximumFileSize>`, `Maximum file size allowed in bytes. Maximum allowed value is 30MB.`, parseInteger)
|
|
630
627
|
.option(`--allowedFileExtensions [allowedFileExtensions...]`, `Allowed file extensions. Maximum of 100 extensions are allowed, each 64 characters long.`)
|
|
631
628
|
.option(`--compression <compression>`, `Compression algorithm choosen for compression. Can be one of none, [gzip](https://en.wikipedia.org/wiki/Gzip), or [zstd](https://en.wikipedia.org/wiki/Zstd), For file size above 20MB compression is skipped even if it's enabled`)
|
|
632
629
|
.option(`--encryption <encryption>`, `Is encryption enabled? For file size above 20MB encryption is skipped even if it's enabled`, parseBool)
|
|
@@ -668,6 +665,7 @@ storage
|
|
|
668
665
|
.description(`Update a file by its unique ID. Only users with write permissions have access to update this resource.`)
|
|
669
666
|
.requiredOption(`--bucketId <bucketId>`, `Storage bucket unique ID. You can create a new storage bucket using the Storage service [server integration](/docs/server/storage#createBucket).`)
|
|
670
667
|
.requiredOption(`--fileId <fileId>`, `File unique ID.`)
|
|
668
|
+
.option(`--name <name>`, `Name of the file`)
|
|
671
669
|
.option(`--permissions [permissions...]`, `An array of permission string. By default, the current permissions are inherited. [Learn more about permissions](/docs/permissions).`)
|
|
672
670
|
.action(actionRunner(storageUpdateFile))
|
|
673
671
|
|