appwrite-cli 2.0.1 → 3.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 +12 -0
- 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/{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/functions.js +277 -70
- package/lib/commands/generic.js +1 -0
- package/lib/commands/graphql.js +4 -4
- package/lib/commands/health.js +68 -22
- 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 +47 -40
- package/lib/commands/teams.js +33 -33
- package/lib/commands/users.js +147 -52
- package/lib/commands/vcs.js +305 -0
- package/lib/config.js +1 -2
- package/lib/parser.js +2 -2
- package/package.json +1 -1
- 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,7 +295,7 @@ 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 {
|
|
@@ -311,7 +311,7 @@ const storageCreateFile = async ({ bucketId, fileId, file, permissions, parseOut
|
|
|
311
311
|
|
|
312
312
|
if(fileId != 'unique()') {
|
|
313
313
|
try {
|
|
314
|
-
response = await client.call('get',
|
|
314
|
+
response = await client.call('get', apiPath + '/' + fileId, headers);
|
|
315
315
|
counter = response.chunksUploaded;
|
|
316
316
|
} catch(e) {
|
|
317
317
|
}
|
|
@@ -333,7 +333,7 @@ const storageCreateFile = async ({ bucketId, fileId, file, permissions, parseOut
|
|
|
333
333
|
});
|
|
334
334
|
payload['file'] = stream;
|
|
335
335
|
|
|
336
|
-
response = await client.call('post',
|
|
336
|
+
response = await client.call('post', apiPath, headers, payload);
|
|
337
337
|
|
|
338
338
|
if (!id) {
|
|
339
339
|
id = response['$id'];
|
|
@@ -363,10 +363,10 @@ const storageGetFile = async ({ bucketId, fileId, parseOutput = true, sdk = unde
|
|
|
363
363
|
/* @param {string} fileId */
|
|
364
364
|
|
|
365
365
|
let client = !sdk ? await sdkForProject() : sdk;
|
|
366
|
-
let
|
|
366
|
+
let apiPath = '/storage/buckets/{bucketId}/files/{fileId}'.replace('{bucketId}', bucketId).replace('{fileId}', fileId);
|
|
367
367
|
let payload = {};
|
|
368
368
|
let response = undefined;
|
|
369
|
-
response = await client.call('get',
|
|
369
|
+
response = await client.call('get', apiPath, {
|
|
370
370
|
'content-type': 'application/json',
|
|
371
371
|
}, payload);
|
|
372
372
|
|
|
@@ -377,16 +377,22 @@ const storageGetFile = async ({ bucketId, fileId, parseOutput = true, sdk = unde
|
|
|
377
377
|
return response;
|
|
378
378
|
}
|
|
379
379
|
|
|
380
|
-
const storageUpdateFile = async ({ bucketId, fileId, permissions, parseOutput = true, sdk = undefined}) => {
|
|
380
|
+
const storageUpdateFile = async ({ bucketId, fileId, name, permissions, parseOutput = true, sdk = undefined}) => {
|
|
381
381
|
/* @param {string} bucketId */
|
|
382
382
|
/* @param {string} fileId */
|
|
383
|
+
/* @param {string} name */
|
|
383
384
|
/* @param {string[]} permissions */
|
|
384
385
|
|
|
385
386
|
let client = !sdk ? await sdkForProject() : sdk;
|
|
386
|
-
let
|
|
387
|
+
let apiPath = '/storage/buckets/{bucketId}/files/{fileId}'.replace('{bucketId}', bucketId).replace('{fileId}', fileId);
|
|
387
388
|
let payload = {};
|
|
388
389
|
|
|
389
390
|
/** Body Params */
|
|
391
|
+
|
|
392
|
+
if (typeof name !== 'undefined') {
|
|
393
|
+
payload['name'] = name;
|
|
394
|
+
}
|
|
395
|
+
|
|
390
396
|
permissions = permissions === true ? [] : permissions;
|
|
391
397
|
|
|
392
398
|
if (typeof permissions !== 'undefined') {
|
|
@@ -394,7 +400,7 @@ const storageUpdateFile = async ({ bucketId, fileId, permissions, parseOutput =
|
|
|
394
400
|
}
|
|
395
401
|
|
|
396
402
|
let response = undefined;
|
|
397
|
-
response = await client.call('put',
|
|
403
|
+
response = await client.call('put', apiPath, {
|
|
398
404
|
'content-type': 'application/json',
|
|
399
405
|
}, payload);
|
|
400
406
|
|
|
@@ -410,10 +416,10 @@ const storageDeleteFile = async ({ bucketId, fileId, parseOutput = true, sdk = u
|
|
|
410
416
|
/* @param {string} fileId */
|
|
411
417
|
|
|
412
418
|
let client = !sdk ? await sdkForProject() : sdk;
|
|
413
|
-
let
|
|
419
|
+
let apiPath = '/storage/buckets/{bucketId}/files/{fileId}'.replace('{bucketId}', bucketId).replace('{fileId}', fileId);
|
|
414
420
|
let payload = {};
|
|
415
421
|
let response = undefined;
|
|
416
|
-
response = await client.call('delete',
|
|
422
|
+
response = await client.call('delete', apiPath, {
|
|
417
423
|
'content-type': 'application/json',
|
|
418
424
|
}, payload);
|
|
419
425
|
|
|
@@ -429,14 +435,14 @@ const storageGetFileDownload = async ({ bucketId, fileId, parseOutput = true, sd
|
|
|
429
435
|
/* @param {string} fileId */
|
|
430
436
|
|
|
431
437
|
let client = !sdk ? await sdkForProject() : sdk;
|
|
432
|
-
let
|
|
438
|
+
let apiPath = '/storage/buckets/{bucketId}/files/{fileId}/download'.replace('{bucketId}', bucketId).replace('{fileId}', fileId);
|
|
433
439
|
let payload = {};
|
|
434
440
|
payload['project'] = localConfig.getProject().projectId
|
|
435
441
|
payload['key'] = globalConfig.getKey();
|
|
436
442
|
const queryParams = new URLSearchParams(payload);
|
|
437
|
-
|
|
443
|
+
apiPath = `${globalConfig.getEndpoint()}${apiPath}?${queryParams.toString()}`;
|
|
438
444
|
|
|
439
|
-
const response = await client.call('get',
|
|
445
|
+
const response = await client.call('get', apiPath, {
|
|
440
446
|
'content-type': 'application/json',
|
|
441
447
|
}, payload, 'arraybuffer');
|
|
442
448
|
|
|
@@ -464,7 +470,7 @@ const storageGetFilePreview = async ({ bucketId, fileId, width, height, gravity,
|
|
|
464
470
|
/* @param {string} output */
|
|
465
471
|
|
|
466
472
|
let client = !sdk ? await sdkForProject() : sdk;
|
|
467
|
-
let
|
|
473
|
+
let apiPath = '/storage/buckets/{bucketId}/files/{fileId}/preview'.replace('{bucketId}', bucketId).replace('{fileId}', fileId);
|
|
468
474
|
let payload = {};
|
|
469
475
|
|
|
470
476
|
/** Query Params */
|
|
@@ -504,9 +510,9 @@ const storageGetFilePreview = async ({ bucketId, fileId, width, height, gravity,
|
|
|
504
510
|
payload['project'] = localConfig.getProject().projectId
|
|
505
511
|
payload['key'] = globalConfig.getKey();
|
|
506
512
|
const queryParams = new URLSearchParams(payload);
|
|
507
|
-
|
|
513
|
+
apiPath = `${globalConfig.getEndpoint()}${apiPath}?${queryParams.toString()}`;
|
|
508
514
|
|
|
509
|
-
const response = await client.call('get',
|
|
515
|
+
const response = await client.call('get', apiPath, {
|
|
510
516
|
'content-type': 'application/json',
|
|
511
517
|
}, payload, 'arraybuffer');
|
|
512
518
|
|
|
@@ -523,14 +529,14 @@ const storageGetFileView = async ({ bucketId, fileId, parseOutput = true, sdk =
|
|
|
523
529
|
/* @param {string} fileId */
|
|
524
530
|
|
|
525
531
|
let client = !sdk ? await sdkForProject() : sdk;
|
|
526
|
-
let
|
|
532
|
+
let apiPath = '/storage/buckets/{bucketId}/files/{fileId}/view'.replace('{bucketId}', bucketId).replace('{fileId}', fileId);
|
|
527
533
|
let payload = {};
|
|
528
534
|
payload['project'] = localConfig.getProject().projectId
|
|
529
535
|
payload['key'] = globalConfig.getKey();
|
|
530
536
|
const queryParams = new URLSearchParams(payload);
|
|
531
|
-
|
|
537
|
+
apiPath = `${globalConfig.getEndpoint()}${apiPath}?${queryParams.toString()}`;
|
|
532
538
|
|
|
533
|
-
const response = await client.call('get',
|
|
539
|
+
const response = await client.call('get', apiPath, {
|
|
534
540
|
'content-type': 'application/json',
|
|
535
541
|
}, payload, 'arraybuffer');
|
|
536
542
|
|
|
@@ -546,7 +552,7 @@ const storageGetUsage = async ({ range, parseOutput = true, sdk = undefined}) =>
|
|
|
546
552
|
/* @param {string} range */
|
|
547
553
|
|
|
548
554
|
let client = !sdk ? await sdkForProject() : sdk;
|
|
549
|
-
let
|
|
555
|
+
let apiPath = '/storage/usage';
|
|
550
556
|
let payload = {};
|
|
551
557
|
|
|
552
558
|
/** Query Params */
|
|
@@ -554,7 +560,7 @@ const storageGetUsage = async ({ range, parseOutput = true, sdk = undefined}) =>
|
|
|
554
560
|
payload['range'] = range;
|
|
555
561
|
}
|
|
556
562
|
let response = undefined;
|
|
557
|
-
response = await client.call('get',
|
|
563
|
+
response = await client.call('get', apiPath, {
|
|
558
564
|
'content-type': 'application/json',
|
|
559
565
|
}, payload);
|
|
560
566
|
|
|
@@ -570,7 +576,7 @@ const storageGetBucketUsage = async ({ bucketId, range, parseOutput = true, sdk
|
|
|
570
576
|
/* @param {string} range */
|
|
571
577
|
|
|
572
578
|
let client = !sdk ? await sdkForProject() : sdk;
|
|
573
|
-
let
|
|
579
|
+
let apiPath = '/storage/{bucketId}/usage'.replace('{bucketId}', bucketId);
|
|
574
580
|
let payload = {};
|
|
575
581
|
|
|
576
582
|
/** Query Params */
|
|
@@ -578,7 +584,7 @@ const storageGetBucketUsage = async ({ bucketId, range, parseOutput = true, sdk
|
|
|
578
584
|
payload['range'] = range;
|
|
579
585
|
}
|
|
580
586
|
let response = undefined;
|
|
581
|
-
response = await client.call('get',
|
|
587
|
+
response = await client.call('get', apiPath, {
|
|
582
588
|
'content-type': 'application/json',
|
|
583
589
|
}, payload);
|
|
584
590
|
|
|
@@ -604,8 +610,8 @@ storage
|
|
|
604
610
|
.requiredOption(`--name <name>`, `Bucket name`)
|
|
605
611
|
.option(`--permissions [permissions...]`, `An array of permission strings. By default, no user is granted with any permissions. [Learn more about permissions](/docs/permissions).`)
|
|
606
612
|
.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
|
|
613
|
+
.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)
|
|
614
|
+
.option(`--maximumFileSize <maximumFileSize>`, `Maximum file size allowed in bytes. Maximum allowed value is 30MB.`, parseInteger)
|
|
609
615
|
.option(`--allowedFileExtensions [allowedFileExtensions...]`, `Allowed file extensions. Maximum of 100 extensions are allowed, each 64 characters long.`)
|
|
610
616
|
.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
617
|
.option(`--encryption <encryption>`, `Is encryption enabled? For file size above 20MB encryption is skipped even if it's enabled`, parseBool)
|
|
@@ -625,8 +631,8 @@ storage
|
|
|
625
631
|
.requiredOption(`--name <name>`, `Bucket name`)
|
|
626
632
|
.option(`--permissions [permissions...]`, `An array of permission strings. By default, the current permissions are inherited. [Learn more about permissions](/docs/permissions).`)
|
|
627
633
|
.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
|
|
634
|
+
.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)
|
|
635
|
+
.option(`--maximumFileSize <maximumFileSize>`, `Maximum file size allowed in bytes. Maximum allowed value is 30MB.`, parseInteger)
|
|
630
636
|
.option(`--allowedFileExtensions [allowedFileExtensions...]`, `Allowed file extensions. Maximum of 100 extensions are allowed, each 64 characters long.`)
|
|
631
637
|
.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
638
|
.option(`--encryption <encryption>`, `Is encryption enabled? For file size above 20MB encryption is skipped even if it's enabled`, parseBool)
|
|
@@ -668,6 +674,7 @@ storage
|
|
|
668
674
|
.description(`Update a file by its unique ID. Only users with write permissions have access to update this resource.`)
|
|
669
675
|
.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
676
|
.requiredOption(`--fileId <fileId>`, `File unique ID.`)
|
|
677
|
+
.option(`--name <name>`, `Name of the file`)
|
|
671
678
|
.option(`--permissions [permissions...]`, `An array of permission string. By default, the current permissions are inherited. [Learn more about permissions](/docs/permissions).`)
|
|
672
679
|
.action(actionRunner(storageUpdateFile))
|
|
673
680
|
|