appwrite-cli 4.2.1 → 5.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/.github/workflows/npm-publish.yml +1 -1
- package/README.md +6 -9
- package/docs/examples/account/{create-email-session.md → create-email-password-session.md} +1 -1
- package/docs/examples/account/create-email-token.md +4 -0
- package/docs/examples/account/create-magic-u-r-l-token.md +5 -0
- package/docs/examples/account/create-mfa-authenticator.md +2 -0
- package/docs/examples/account/create-mfa-challenge.md +2 -0
- package/docs/examples/account/create-mfa-recovery-codes.md +1 -0
- package/docs/examples/account/create-o-auth2token.md +5 -0
- package/docs/examples/account/create-phone-token.md +3 -0
- package/docs/examples/account/create-push-target.md +4 -0
- package/docs/examples/account/create-session.md +3 -0
- package/docs/examples/account/create.md +1 -1
- package/docs/examples/account/delete-identity.md +1 -1
- package/docs/examples/account/delete-mfa-authenticator.md +3 -0
- package/docs/examples/account/delete-push-target.md +2 -0
- package/docs/examples/account/delete-session.md +1 -1
- package/docs/examples/account/delete.md +1 -0
- package/docs/examples/account/get-mfa-recovery-codes.md +1 -0
- package/docs/examples/account/get-session.md +1 -1
- package/docs/examples/account/list-mfa-factors.md +1 -0
- package/docs/examples/account/update-m-f-a.md +2 -0
- package/docs/examples/account/update-magic-u-r-l-session.md +2 -2
- package/docs/examples/account/update-mfa-authenticator.md +3 -0
- package/docs/examples/account/update-mfa-challenge.md +3 -0
- package/docs/examples/account/update-mfa-recovery-codes.md +1 -0
- package/docs/examples/account/update-name.md +1 -1
- package/docs/examples/account/update-phone-session.md +2 -2
- package/docs/examples/account/update-phone-verification.md +2 -2
- package/docs/examples/account/update-push-target.md +3 -0
- package/docs/examples/account/update-recovery.md +3 -4
- package/docs/examples/account/update-session.md +1 -1
- package/docs/examples/account/update-verification.md +2 -2
- package/docs/examples/assistant/chat.md +1 -1
- package/docs/examples/avatars/get-q-r.md +1 -1
- package/docs/examples/databases/create-boolean-attribute.md +2 -2
- package/docs/examples/databases/create-collection.md +3 -3
- package/docs/examples/databases/create-datetime-attribute.md +2 -2
- package/docs/examples/databases/create-document.md +3 -3
- package/docs/examples/databases/create-email-attribute.md +2 -2
- package/docs/examples/databases/create-enum-attribute.md +2 -2
- package/docs/examples/databases/create-float-attribute.md +2 -2
- package/docs/examples/databases/create-index.md +2 -2
- package/docs/examples/databases/create-integer-attribute.md +2 -2
- package/docs/examples/databases/create-ip-attribute.md +2 -2
- package/docs/examples/databases/create-relationship-attribute.md +3 -3
- package/docs/examples/databases/create-string-attribute.md +2 -2
- package/docs/examples/databases/create-url-attribute.md +2 -2
- package/docs/examples/databases/create.md +2 -2
- package/docs/examples/databases/delete-attribute.md +2 -2
- package/docs/examples/databases/delete-collection.md +2 -2
- package/docs/examples/databases/delete-document.md +3 -3
- package/docs/examples/databases/delete-index.md +2 -2
- package/docs/examples/databases/delete.md +1 -1
- package/docs/examples/databases/get-attribute.md +2 -2
- package/docs/examples/databases/get-collection-usage.md +2 -2
- package/docs/examples/databases/get-collection.md +2 -2
- package/docs/examples/databases/get-database-usage.md +1 -1
- package/docs/examples/databases/get-document.md +3 -3
- package/docs/examples/databases/get-index.md +2 -2
- package/docs/examples/databases/get.md +1 -1
- package/docs/examples/databases/list-attributes.md +2 -2
- package/docs/examples/databases/list-collection-logs.md +2 -2
- package/docs/examples/databases/list-collections.md +1 -1
- package/docs/examples/databases/list-document-logs.md +3 -3
- package/docs/examples/databases/list-documents.md +2 -2
- package/docs/examples/databases/list-indexes.md +2 -2
- package/docs/examples/databases/list-logs.md +1 -1
- package/docs/examples/databases/update-boolean-attribute.md +2 -2
- package/docs/examples/databases/update-collection.md +3 -3
- package/docs/examples/databases/update-datetime-attribute.md +2 -2
- package/docs/examples/databases/update-document.md +3 -3
- package/docs/examples/databases/update-email-attribute.md +2 -2
- package/docs/examples/databases/update-enum-attribute.md +3 -3
- package/docs/examples/databases/update-float-attribute.md +2 -2
- package/docs/examples/databases/update-integer-attribute.md +2 -2
- package/docs/examples/databases/update-ip-attribute.md +2 -2
- package/docs/examples/databases/update-relationship-attribute.md +2 -2
- package/docs/examples/databases/update-string-attribute.md +3 -3
- package/docs/examples/databases/update-url-attribute.md +2 -2
- package/docs/examples/databases/update.md +2 -2
- package/docs/examples/functions/create-build.md +3 -3
- package/docs/examples/functions/create-deployment.md +1 -1
- package/docs/examples/functions/create-execution.md +1 -1
- package/docs/examples/functions/create-variable.md +3 -3
- package/docs/examples/functions/create.md +3 -3
- package/docs/examples/functions/delete-deployment.md +2 -2
- package/docs/examples/functions/delete-variable.md +2 -2
- package/docs/examples/functions/delete.md +1 -1
- package/docs/examples/functions/download-deployment.md +2 -2
- package/docs/examples/functions/get-deployment.md +2 -2
- package/docs/examples/functions/get-execution.md +2 -2
- package/docs/examples/functions/get-function-usage.md +1 -1
- package/docs/examples/functions/get-variable.md +2 -2
- 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-variables.md +1 -1
- package/docs/examples/functions/update-deployment.md +2 -2
- package/docs/examples/functions/update-variable.md +3 -3
- package/docs/examples/functions/update.md +2 -2
- package/docs/examples/health/get-certificate.md +2 -0
- package/docs/examples/health/get-failed-jobs.md +3 -0
- package/docs/examples/health/get-queue-usage-dump.md +2 -0
- package/docs/examples/health/get-queue-usage.md +2 -0
- package/docs/examples/health/get-storage.md +1 -0
- package/docs/examples/messaging/create-apns-provider.md +9 -0
- package/docs/examples/messaging/create-email.md +13 -0
- package/docs/examples/messaging/create-fcm-provider.md +5 -0
- package/docs/examples/messaging/create-mailgun-provider.md +11 -0
- package/docs/examples/messaging/create-msg91provider.md +7 -0
- package/docs/examples/messaging/create-push.md +17 -0
- package/docs/examples/messaging/create-sendgrid-provider.md +9 -0
- package/docs/examples/messaging/create-sms.md +8 -0
- package/docs/examples/messaging/create-smtp-provider.md +15 -0
- package/docs/examples/messaging/create-subscriber.md +4 -0
- package/docs/examples/messaging/create-telesign-provider.md +7 -0
- package/docs/examples/messaging/create-textmagic-provider.md +7 -0
- package/docs/examples/messaging/create-topic.md +4 -0
- package/docs/examples/messaging/create-twilio-provider.md +7 -0
- package/docs/examples/messaging/create-vonage-provider.md +7 -0
- package/docs/examples/messaging/delete-provider.md +2 -0
- package/docs/examples/messaging/delete-subscriber.md +3 -0
- package/docs/examples/messaging/delete-topic.md +2 -0
- package/docs/examples/messaging/delete.md +2 -0
- package/docs/examples/messaging/get-message.md +2 -0
- package/docs/examples/messaging/get-provider.md +2 -0
- package/docs/examples/messaging/get-subscriber.md +3 -0
- package/docs/examples/messaging/get-topic.md +2 -0
- package/docs/examples/messaging/list-message-logs.md +3 -0
- package/docs/examples/messaging/list-messages.md +3 -0
- package/docs/examples/messaging/list-provider-logs.md +3 -0
- package/docs/examples/messaging/list-providers.md +3 -0
- package/docs/examples/messaging/list-subscriber-logs.md +3 -0
- package/docs/examples/messaging/list-subscribers.md +4 -0
- package/docs/examples/messaging/list-targets.md +3 -0
- package/docs/examples/messaging/list-topic-logs.md +3 -0
- package/docs/examples/messaging/list-topics.md +3 -0
- package/docs/examples/messaging/update-apns-provider.md +9 -0
- package/docs/examples/messaging/update-email.md +12 -0
- package/docs/examples/messaging/update-fcm-provider.md +5 -0
- package/docs/examples/messaging/update-mailgun-provider.md +11 -0
- package/docs/examples/messaging/update-msg91provider.md +7 -0
- package/docs/examples/messaging/update-push.md +17 -0
- package/docs/examples/messaging/update-sendgrid-provider.md +9 -0
- package/docs/examples/messaging/update-sms.md +8 -0
- package/docs/examples/messaging/update-smtp-provider.md +15 -0
- package/docs/examples/messaging/update-telesign-provider.md +7 -0
- package/docs/examples/messaging/update-textmagic-provider.md +7 -0
- package/docs/examples/messaging/update-topic.md +4 -0
- package/docs/examples/messaging/update-twilio-provider.md +7 -0
- package/docs/examples/messaging/update-vonage-provider.md +7 -0
- package/docs/examples/migrations/create-appwrite-migration.md +2 -2
- package/docs/examples/migrations/create-firebase-migration.md +1 -1
- package/docs/examples/migrations/create-firebase-o-auth-migration.md +1 -1
- package/docs/examples/migrations/create-n-host-migration.md +6 -6
- package/docs/examples/migrations/create-supabase-migration.md +4 -4
- package/docs/examples/migrations/delete.md +1 -1
- package/docs/examples/migrations/get-appwrite-report.md +2 -2
- package/docs/examples/migrations/get-firebase-report-o-auth.md +1 -1
- package/docs/examples/migrations/get-firebase-report.md +1 -1
- package/docs/examples/migrations/get-n-host-report.md +6 -6
- package/docs/examples/migrations/get-supabase-report.md +4 -4
- package/docs/examples/migrations/get.md +1 -1
- package/docs/examples/migrations/retry.md +1 -1
- package/docs/examples/project/create-variable.md +2 -2
- package/docs/examples/project/delete-variable.md +1 -1
- package/docs/examples/project/get-usage.md +2 -0
- package/docs/examples/project/get-variable.md +1 -1
- package/docs/examples/project/update-variable.md +2 -2
- package/docs/examples/projects/create-key.md +2 -2
- package/docs/examples/projects/create-platform.md +2 -2
- package/docs/examples/projects/create-smtp-test.md +11 -0
- package/docs/examples/projects/create-webhook.md +4 -3
- package/docs/examples/projects/create.md +2 -2
- package/docs/examples/projects/delete-email-template.md +1 -1
- package/docs/examples/projects/delete-key.md +2 -2
- package/docs/examples/projects/delete-platform.md +2 -2
- package/docs/examples/projects/delete-sms-template.md +1 -1
- package/docs/examples/projects/delete-webhook.md +2 -2
- package/docs/examples/projects/delete.md +1 -1
- package/docs/examples/projects/get-email-template.md +1 -1
- package/docs/examples/projects/get-key.md +2 -2
- package/docs/examples/projects/get-platform.md +2 -2
- package/docs/examples/projects/get-sms-template.md +1 -1
- package/docs/examples/projects/get-webhook.md +2 -2
- package/docs/examples/projects/get.md +1 -1
- package/docs/examples/projects/list-keys.md +1 -1
- package/docs/examples/projects/list-platforms.md +1 -1
- package/docs/examples/projects/list-webhooks.md +1 -1
- package/docs/examples/projects/update-api-status-all.md +3 -0
- package/docs/examples/projects/update-api-status.md +4 -0
- package/docs/examples/projects/update-auth-duration.md +1 -1
- package/docs/examples/projects/update-auth-limit.md +1 -1
- package/docs/examples/projects/update-auth-password-dictionary.md +1 -1
- package/docs/examples/projects/update-auth-password-history.md +1 -1
- package/docs/examples/projects/update-auth-sessions-limit.md +1 -1
- package/docs/examples/projects/update-auth-status.md +1 -1
- package/docs/examples/projects/update-email-template.md +3 -3
- package/docs/examples/projects/update-key.md +3 -3
- package/docs/examples/projects/update-o-auth2.md +1 -1
- package/docs/examples/projects/update-personal-data-check.md +1 -1
- package/docs/examples/projects/update-platform.md +3 -3
- package/docs/examples/projects/update-service-status-all.md +1 -1
- package/docs/examples/projects/update-service-status.md +1 -1
- package/docs/examples/projects/update-sms-template.md +2 -2
- package/docs/examples/projects/update-smtp.md +11 -0
- package/docs/examples/projects/update-team.md +2 -2
- package/docs/examples/projects/update-webhook-signature.md +2 -2
- package/docs/examples/projects/update-webhook.md +5 -4
- package/docs/examples/projects/update.md +2 -2
- package/docs/examples/proxy/delete-rule.md +1 -1
- package/docs/examples/proxy/get-rule.md +1 -1
- package/docs/examples/proxy/update-rule-verification.md +1 -1
- package/docs/examples/storage/create-bucket.md +2 -2
- package/docs/examples/storage/create-file.md +2 -2
- package/docs/examples/storage/delete-bucket.md +1 -1
- package/docs/examples/storage/delete-file.md +2 -2
- package/docs/examples/storage/get-bucket-usage.md +1 -1
- package/docs/examples/storage/get-bucket.md +1 -1
- package/docs/examples/storage/get-file-download.md +2 -2
- package/docs/examples/storage/get-file-preview.md +2 -2
- package/docs/examples/storage/get-file-view.md +2 -2
- package/docs/examples/storage/get-file.md +2 -2
- package/docs/examples/storage/list-files.md +1 -1
- package/docs/examples/storage/update-bucket.md +2 -2
- package/docs/examples/storage/update-file.md +2 -2
- package/docs/examples/teams/create-membership.md +1 -1
- package/docs/examples/teams/create.md +2 -2
- package/docs/examples/teams/delete-membership.md +2 -2
- package/docs/examples/teams/delete.md +1 -1
- package/docs/examples/teams/get-membership.md +2 -2
- package/docs/examples/teams/get-prefs.md +1 -1
- package/docs/examples/teams/get.md +1 -1
- package/docs/examples/teams/list-logs.md +1 -1
- package/docs/examples/teams/list-memberships.md +1 -1
- package/docs/examples/teams/update-membership-status.md +4 -4
- package/docs/examples/teams/update-membership.md +2 -2
- package/docs/examples/teams/update-name.md +2 -2
- package/docs/examples/teams/update-prefs.md +1 -1
- 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-mfa-recovery-codes.md +2 -0
- 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 +4 -4
- package/docs/examples/users/create-scrypt-user.md +2 -2
- package/docs/examples/users/create-session.md +2 -0
- package/docs/examples/users/create-target.md +7 -0
- package/docs/examples/users/create-token.md +4 -0
- package/docs/examples/users/create.md +1 -1
- package/docs/examples/users/delete-identity.md +1 -1
- package/docs/examples/users/delete-mfa-authenticator.md +3 -0
- package/docs/examples/users/delete-session.md +2 -2
- package/docs/examples/users/delete-sessions.md +1 -1
- package/docs/examples/users/delete-target.md +3 -0
- package/docs/examples/users/delete.md +1 -1
- package/docs/examples/users/get-mfa-recovery-codes.md +2 -0
- package/docs/examples/users/get-prefs.md +1 -1
- package/docs/examples/users/get-target.md +3 -0
- package/docs/examples/users/get-usage.md +0 -1
- package/docs/examples/users/get.md +1 -1
- package/docs/examples/users/list-logs.md +1 -1
- package/docs/examples/users/list-memberships.md +1 -1
- package/docs/examples/users/list-mfa-factors.md +2 -0
- package/docs/examples/users/list-sessions.md +1 -1
- package/docs/examples/users/list-targets.md +3 -0
- 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 +1 -1
- package/docs/examples/users/update-mfa-recovery-codes.md +2 -0
- package/docs/examples/users/update-mfa.md +3 -0
- package/docs/examples/users/update-name.md +2 -2
- package/docs/examples/users/update-password.md +1 -1
- 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/docs/examples/users/update-target.md +6 -0
- package/docs/examples/vcs/create-repository-detection.md +2 -2
- package/docs/examples/vcs/create-repository.md +2 -2
- package/docs/examples/vcs/delete-installation.md +1 -1
- package/docs/examples/vcs/get-installation.md +1 -1
- package/docs/examples/vcs/get-repository.md +2 -2
- package/docs/examples/vcs/list-repositories.md +1 -1
- package/docs/examples/vcs/list-repository-branches.md +2 -2
- package/docs/examples/vcs/update-external-deployments.md +3 -3
- package/index.js +2 -0
- package/install.ps1 +2 -2
- package/install.sh +1 -1
- package/lib/client.js +9 -4
- package/lib/commands/account.js +966 -381
- package/lib/commands/assistant.js +3 -8
- package/lib/commands/avatars.js +32 -48
- package/lib/commands/console.js +3 -8
- package/lib/commands/databases.js +119 -265
- package/lib/commands/deploy.js +45 -6
- package/lib/commands/functions.js +59 -124
- package/lib/commands/generic.js +0 -1
- package/lib/commands/graphql.js +5 -13
- package/lib/commands/health.js +225 -89
- package/lib/commands/locale.js +17 -43
- package/lib/commands/messaging.js +2815 -0
- package/lib/commands/migrations.js +35 -85
- package/lib/commands/project.js +28 -38
- package/lib/commands/projects.js +286 -270
- package/lib/commands/proxy.js +12 -29
- package/lib/commands/storage.js +42 -87
- package/lib/commands/teams.js +31 -75
- package/lib/commands/users.js +677 -235
- package/lib/commands/vcs.js +19 -48
- package/lib/paginate.js +2 -2
- package/lib/parser.js +1 -0
- package/package.json +1 -1
- package/scoop/appwrite.json +3 -3
- package/docs/examples/account/create-magic-u-r-l-session.md +0 -4
- package/docs/examples/account/create-phone-session.md +0 -3
- package/docs/examples/projects/get-usage.md +0 -3
- package/docs/examples/projects/update-smtp-configuration.md +0 -11
package/lib/commands/proxy.js
CHANGED
|
@@ -37,7 +37,7 @@ function convertReadStreamToReadableStream(readStream) {
|
|
|
37
37
|
|
|
38
38
|
const proxy = new Command("proxy").description(commandDescriptions['proxy']).configureHelp({
|
|
39
39
|
helpWidth: process.stdout.columns || 80
|
|
40
|
-
|
|
40
|
+
})
|
|
41
41
|
|
|
42
42
|
/**
|
|
43
43
|
* @typedef {Object} ProxyListRulesRequestParams
|
|
@@ -52,7 +52,6 @@ const proxy = new Command("proxy").description(commandDescriptions['proxy']).con
|
|
|
52
52
|
*/
|
|
53
53
|
const proxyListRules = async ({ queries, search, parseOutput = true, sdk = undefined}) => {
|
|
54
54
|
let client = !sdk ? await sdkForProject() : sdk;
|
|
55
|
-
|
|
56
55
|
let apiPath = '/proxy/rules';
|
|
57
56
|
let payload = {};
|
|
58
57
|
if (typeof queries !== 'undefined') {
|
|
@@ -62,14 +61,12 @@ const proxyListRules = async ({ queries, search, parseOutput = true, sdk = undef
|
|
|
62
61
|
payload['search'] = search;
|
|
63
62
|
}
|
|
64
63
|
|
|
65
|
-
|
|
66
64
|
let response = undefined;
|
|
67
|
-
|
|
65
|
+
|
|
68
66
|
response = await client.call('get', apiPath, {
|
|
69
67
|
'content-type': 'application/json',
|
|
70
68
|
}, payload);
|
|
71
69
|
|
|
72
|
-
|
|
73
70
|
if (parseOutput) {
|
|
74
71
|
parse(response)
|
|
75
72
|
success()
|
|
@@ -81,7 +78,7 @@ const proxyListRules = async ({ queries, search, parseOutput = true, sdk = undef
|
|
|
81
78
|
/**
|
|
82
79
|
* @typedef {Object} ProxyCreateRuleRequestParams
|
|
83
80
|
* @property {string} domain Domain name.
|
|
84
|
-
* @property {
|
|
81
|
+
* @property {ResourceType} resourceType Action definition for the rule. Possible values are "api", "function"
|
|
85
82
|
* @property {string} resourceId ID of resource for the action type. If resourceType is "api", leave empty. If resourceType is "function", provide ID of the function.
|
|
86
83
|
* @property {boolean} parseOutput
|
|
87
84
|
* @property {libClient | undefined} sdk
|
|
@@ -92,7 +89,6 @@ const proxyListRules = async ({ queries, search, parseOutput = true, sdk = undef
|
|
|
92
89
|
*/
|
|
93
90
|
const proxyCreateRule = async ({ domain, resourceType, resourceId, parseOutput = true, sdk = undefined}) => {
|
|
94
91
|
let client = !sdk ? await sdkForProject() : sdk;
|
|
95
|
-
|
|
96
92
|
let apiPath = '/proxy/rules';
|
|
97
93
|
let payload = {};
|
|
98
94
|
if (typeof domain !== 'undefined') {
|
|
@@ -105,14 +101,12 @@ const proxyCreateRule = async ({ domain, resourceType, resourceId, parseOutput =
|
|
|
105
101
|
payload['resourceId'] = resourceId;
|
|
106
102
|
}
|
|
107
103
|
|
|
108
|
-
|
|
109
104
|
let response = undefined;
|
|
110
|
-
|
|
105
|
+
|
|
111
106
|
response = await client.call('post', apiPath, {
|
|
112
107
|
'content-type': 'application/json',
|
|
113
108
|
}, payload);
|
|
114
109
|
|
|
115
|
-
|
|
116
110
|
if (parseOutput) {
|
|
117
111
|
parse(response)
|
|
118
112
|
success()
|
|
@@ -133,18 +127,15 @@ const proxyCreateRule = async ({ domain, resourceType, resourceId, parseOutput =
|
|
|
133
127
|
*/
|
|
134
128
|
const proxyGetRule = async ({ ruleId, parseOutput = true, sdk = undefined}) => {
|
|
135
129
|
let client = !sdk ? await sdkForProject() : sdk;
|
|
136
|
-
|
|
137
130
|
let apiPath = '/proxy/rules/{ruleId}'.replace('{ruleId}', ruleId);
|
|
138
131
|
let payload = {};
|
|
139
132
|
|
|
140
|
-
|
|
141
133
|
let response = undefined;
|
|
142
|
-
|
|
134
|
+
|
|
143
135
|
response = await client.call('get', apiPath, {
|
|
144
136
|
'content-type': 'application/json',
|
|
145
137
|
}, payload);
|
|
146
138
|
|
|
147
|
-
|
|
148
139
|
if (parseOutput) {
|
|
149
140
|
parse(response)
|
|
150
141
|
success()
|
|
@@ -165,18 +156,15 @@ const proxyGetRule = async ({ ruleId, parseOutput = true, sdk = undefined}) => {
|
|
|
165
156
|
*/
|
|
166
157
|
const proxyDeleteRule = async ({ ruleId, parseOutput = true, sdk = undefined}) => {
|
|
167
158
|
let client = !sdk ? await sdkForProject() : sdk;
|
|
168
|
-
|
|
169
159
|
let apiPath = '/proxy/rules/{ruleId}'.replace('{ruleId}', ruleId);
|
|
170
160
|
let payload = {};
|
|
171
161
|
|
|
172
|
-
|
|
173
162
|
let response = undefined;
|
|
174
|
-
|
|
163
|
+
|
|
175
164
|
response = await client.call('delete', apiPath, {
|
|
176
165
|
'content-type': 'application/json',
|
|
177
166
|
}, payload);
|
|
178
167
|
|
|
179
|
-
|
|
180
168
|
if (parseOutput) {
|
|
181
169
|
parse(response)
|
|
182
170
|
success()
|
|
@@ -197,18 +185,15 @@ const proxyDeleteRule = async ({ ruleId, parseOutput = true, sdk = undefined}) =
|
|
|
197
185
|
*/
|
|
198
186
|
const proxyUpdateRuleVerification = async ({ ruleId, parseOutput = true, sdk = undefined}) => {
|
|
199
187
|
let client = !sdk ? await sdkForProject() : sdk;
|
|
200
|
-
|
|
201
188
|
let apiPath = '/proxy/rules/{ruleId}/verification'.replace('{ruleId}', ruleId);
|
|
202
189
|
let payload = {};
|
|
203
190
|
|
|
204
|
-
|
|
205
191
|
let response = undefined;
|
|
206
|
-
|
|
192
|
+
|
|
207
193
|
response = await client.call('patch', apiPath, {
|
|
208
194
|
'content-type': 'application/json',
|
|
209
195
|
}, payload);
|
|
210
196
|
|
|
211
|
-
|
|
212
197
|
if (parseOutput) {
|
|
213
198
|
parse(response)
|
|
214
199
|
success()
|
|
@@ -217,7 +202,6 @@ const proxyUpdateRuleVerification = async ({ ruleId, parseOutput = true, sdk = u
|
|
|
217
202
|
return response;
|
|
218
203
|
}
|
|
219
204
|
|
|
220
|
-
|
|
221
205
|
proxy
|
|
222
206
|
.command(`listRules`)
|
|
223
207
|
.description(`Get a list of all the proxy rules. You can use the query params to filter your results.`)
|
|
@@ -251,12 +235,11 @@ proxy
|
|
|
251
235
|
.requiredOption(`--ruleId <ruleId>`, `Rule ID.`)
|
|
252
236
|
.action(actionRunner(proxyUpdateRuleVerification))
|
|
253
237
|
|
|
254
|
-
|
|
255
238
|
module.exports = {
|
|
256
239
|
proxy,
|
|
257
|
-
proxyListRules,
|
|
258
|
-
proxyCreateRule,
|
|
259
|
-
proxyGetRule,
|
|
260
|
-
proxyDeleteRule,
|
|
261
|
-
proxyUpdateRuleVerification
|
|
240
|
+
proxyListRules,
|
|
241
|
+
proxyCreateRule,
|
|
242
|
+
proxyGetRule,
|
|
243
|
+
proxyDeleteRule,
|
|
244
|
+
proxyUpdateRuleVerification
|
|
262
245
|
};
|
package/lib/commands/storage.js
CHANGED
|
@@ -37,7 +37,7 @@ function convertReadStreamToReadableStream(readStream) {
|
|
|
37
37
|
|
|
38
38
|
const storage = new Command("storage").description(commandDescriptions['storage']).configureHelp({
|
|
39
39
|
helpWidth: process.stdout.columns || 80
|
|
40
|
-
|
|
40
|
+
})
|
|
41
41
|
|
|
42
42
|
/**
|
|
43
43
|
* @typedef {Object} StorageListBucketsRequestParams
|
|
@@ -52,7 +52,6 @@ const storage = new Command("storage").description(commandDescriptions['storage'
|
|
|
52
52
|
*/
|
|
53
53
|
const storageListBuckets = async ({ queries, search, parseOutput = true, sdk = undefined}) => {
|
|
54
54
|
let client = !sdk ? await sdkForProject() : sdk;
|
|
55
|
-
|
|
56
55
|
let apiPath = '/storage/buckets';
|
|
57
56
|
let payload = {};
|
|
58
57
|
if (typeof queries !== 'undefined') {
|
|
@@ -62,14 +61,12 @@ const storageListBuckets = async ({ queries, search, parseOutput = true, sdk = u
|
|
|
62
61
|
payload['search'] = search;
|
|
63
62
|
}
|
|
64
63
|
|
|
65
|
-
|
|
66
64
|
let response = undefined;
|
|
67
|
-
|
|
65
|
+
|
|
68
66
|
response = await client.call('get', apiPath, {
|
|
69
67
|
'content-type': 'application/json',
|
|
70
68
|
}, payload);
|
|
71
69
|
|
|
72
|
-
|
|
73
70
|
if (parseOutput) {
|
|
74
71
|
parse(response)
|
|
75
72
|
success()
|
|
@@ -87,7 +84,7 @@ const storageListBuckets = async ({ queries, search, parseOutput = true, sdk = u
|
|
|
87
84
|
* @property {boolean} 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.
|
|
88
85
|
* @property {number} maximumFileSize Maximum file size allowed in bytes. Maximum allowed value is 30MB.
|
|
89
86
|
* @property {string[]} allowedFileExtensions Allowed file extensions. Maximum of 100 extensions are allowed, each 64 characters long.
|
|
90
|
-
* @property {
|
|
87
|
+
* @property {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
|
|
91
88
|
* @property {boolean} encryption Is encryption enabled? For file size above 20MB encryption is skipped even if it's enabled
|
|
92
89
|
* @property {boolean} antivirus Is virus scanning enabled? For file size above 20MB AntiVirus scanning is skipped even if it's enabled
|
|
93
90
|
* @property {boolean} parseOutput
|
|
@@ -99,7 +96,6 @@ const storageListBuckets = async ({ queries, search, parseOutput = true, sdk = u
|
|
|
99
96
|
*/
|
|
100
97
|
const storageCreateBucket = async ({ bucketId, name, permissions, fileSecurity, enabled, maximumFileSize, allowedFileExtensions, compression, encryption, antivirus, parseOutput = true, sdk = undefined}) => {
|
|
101
98
|
let client = !sdk ? await sdkForProject() : sdk;
|
|
102
|
-
|
|
103
99
|
let apiPath = '/storage/buckets';
|
|
104
100
|
let payload = {};
|
|
105
101
|
if (typeof bucketId !== 'undefined') {
|
|
@@ -135,14 +131,12 @@ const storageCreateBucket = async ({ bucketId, name, permissions, fileSecurity,
|
|
|
135
131
|
payload['antivirus'] = antivirus;
|
|
136
132
|
}
|
|
137
133
|
|
|
138
|
-
|
|
139
134
|
let response = undefined;
|
|
140
|
-
|
|
135
|
+
|
|
141
136
|
response = await client.call('post', apiPath, {
|
|
142
137
|
'content-type': 'application/json',
|
|
143
138
|
}, payload);
|
|
144
139
|
|
|
145
|
-
|
|
146
140
|
if (parseOutput) {
|
|
147
141
|
parse(response)
|
|
148
142
|
success()
|
|
@@ -163,18 +157,15 @@ const storageCreateBucket = async ({ bucketId, name, permissions, fileSecurity,
|
|
|
163
157
|
*/
|
|
164
158
|
const storageGetBucket = async ({ bucketId, parseOutput = true, sdk = undefined}) => {
|
|
165
159
|
let client = !sdk ? await sdkForProject() : sdk;
|
|
166
|
-
|
|
167
160
|
let apiPath = '/storage/buckets/{bucketId}'.replace('{bucketId}', bucketId);
|
|
168
161
|
let payload = {};
|
|
169
162
|
|
|
170
|
-
|
|
171
163
|
let response = undefined;
|
|
172
|
-
|
|
164
|
+
|
|
173
165
|
response = await client.call('get', apiPath, {
|
|
174
166
|
'content-type': 'application/json',
|
|
175
167
|
}, payload);
|
|
176
168
|
|
|
177
|
-
|
|
178
169
|
if (parseOutput) {
|
|
179
170
|
parse(response)
|
|
180
171
|
success()
|
|
@@ -192,7 +183,7 @@ const storageGetBucket = async ({ bucketId, parseOutput = true, sdk = undefined}
|
|
|
192
183
|
* @property {boolean} 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.
|
|
193
184
|
* @property {number} maximumFileSize Maximum file size allowed in bytes. Maximum allowed value is 30MB.
|
|
194
185
|
* @property {string[]} allowedFileExtensions Allowed file extensions. Maximum of 100 extensions are allowed, each 64 characters long.
|
|
195
|
-
* @property {
|
|
186
|
+
* @property {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
|
|
196
187
|
* @property {boolean} encryption Is encryption enabled? For file size above 20MB encryption is skipped even if it's enabled
|
|
197
188
|
* @property {boolean} antivirus Is virus scanning enabled? For file size above 20MB AntiVirus scanning is skipped even if it's enabled
|
|
198
189
|
* @property {boolean} parseOutput
|
|
@@ -204,7 +195,6 @@ const storageGetBucket = async ({ bucketId, parseOutput = true, sdk = undefined}
|
|
|
204
195
|
*/
|
|
205
196
|
const storageUpdateBucket = async ({ bucketId, name, permissions, fileSecurity, enabled, maximumFileSize, allowedFileExtensions, compression, encryption, antivirus, parseOutput = true, sdk = undefined}) => {
|
|
206
197
|
let client = !sdk ? await sdkForProject() : sdk;
|
|
207
|
-
|
|
208
198
|
let apiPath = '/storage/buckets/{bucketId}'.replace('{bucketId}', bucketId);
|
|
209
199
|
let payload = {};
|
|
210
200
|
if (typeof name !== 'undefined') {
|
|
@@ -237,14 +227,12 @@ const storageUpdateBucket = async ({ bucketId, name, permissions, fileSecurity,
|
|
|
237
227
|
payload['antivirus'] = antivirus;
|
|
238
228
|
}
|
|
239
229
|
|
|
240
|
-
|
|
241
230
|
let response = undefined;
|
|
242
|
-
|
|
231
|
+
|
|
243
232
|
response = await client.call('put', apiPath, {
|
|
244
233
|
'content-type': 'application/json',
|
|
245
234
|
}, payload);
|
|
246
235
|
|
|
247
|
-
|
|
248
236
|
if (parseOutput) {
|
|
249
237
|
parse(response)
|
|
250
238
|
success()
|
|
@@ -265,18 +253,15 @@ const storageUpdateBucket = async ({ bucketId, name, permissions, fileSecurity,
|
|
|
265
253
|
*/
|
|
266
254
|
const storageDeleteBucket = async ({ bucketId, parseOutput = true, sdk = undefined}) => {
|
|
267
255
|
let client = !sdk ? await sdkForProject() : sdk;
|
|
268
|
-
|
|
269
256
|
let apiPath = '/storage/buckets/{bucketId}'.replace('{bucketId}', bucketId);
|
|
270
257
|
let payload = {};
|
|
271
258
|
|
|
272
|
-
|
|
273
259
|
let response = undefined;
|
|
274
|
-
|
|
260
|
+
|
|
275
261
|
response = await client.call('delete', apiPath, {
|
|
276
262
|
'content-type': 'application/json',
|
|
277
263
|
}, payload);
|
|
278
264
|
|
|
279
|
-
|
|
280
265
|
if (parseOutput) {
|
|
281
266
|
parse(response)
|
|
282
267
|
success()
|
|
@@ -299,7 +284,6 @@ const storageDeleteBucket = async ({ bucketId, parseOutput = true, sdk = undefin
|
|
|
299
284
|
*/
|
|
300
285
|
const storageListFiles = async ({ bucketId, queries, search, parseOutput = true, sdk = undefined}) => {
|
|
301
286
|
let client = !sdk ? await sdkForProject() : sdk;
|
|
302
|
-
|
|
303
287
|
let apiPath = '/storage/buckets/{bucketId}/files'.replace('{bucketId}', bucketId);
|
|
304
288
|
let payload = {};
|
|
305
289
|
if (typeof queries !== 'undefined') {
|
|
@@ -309,14 +293,12 @@ const storageListFiles = async ({ bucketId, queries, search, parseOutput = true,
|
|
|
309
293
|
payload['search'] = search;
|
|
310
294
|
}
|
|
311
295
|
|
|
312
|
-
|
|
313
296
|
let response = undefined;
|
|
314
|
-
|
|
297
|
+
|
|
315
298
|
response = await client.call('get', apiPath, {
|
|
316
299
|
'content-type': 'application/json',
|
|
317
300
|
}, payload);
|
|
318
301
|
|
|
319
|
-
|
|
320
302
|
if (parseOutput) {
|
|
321
303
|
parse(response)
|
|
322
304
|
success()
|
|
@@ -341,7 +323,6 @@ const storageListFiles = async ({ bucketId, queries, search, parseOutput = true,
|
|
|
341
323
|
*/
|
|
342
324
|
const storageCreateFile = async ({ bucketId, fileId, file, permissions, parseOutput = true, sdk = undefined, onProgress = () => {}}) => {
|
|
343
325
|
let client = !sdk ? await sdkForProject() : sdk;
|
|
344
|
-
|
|
345
326
|
let apiPath = '/storage/buckets/{bucketId}/files'.replace('{bucketId}', bucketId);
|
|
346
327
|
let payload = {};
|
|
347
328
|
if (typeof fileId !== 'undefined') {
|
|
@@ -360,8 +341,6 @@ const storageCreateFile = async ({ bucketId, fileId, file, permissions, parseOut
|
|
|
360
341
|
payload['permissions'] = permissions;
|
|
361
342
|
}
|
|
362
343
|
|
|
363
|
-
|
|
364
|
-
|
|
365
344
|
const size = file.size;
|
|
366
345
|
|
|
367
346
|
const apiHeaders = {
|
|
@@ -458,7 +437,6 @@ const storageCreateFile = async ({ bucketId, fileId, file, permissions, parseOut
|
|
|
458
437
|
}
|
|
459
438
|
|
|
460
439
|
return response;
|
|
461
|
-
|
|
462
440
|
}
|
|
463
441
|
|
|
464
442
|
/**
|
|
@@ -474,18 +452,15 @@ const storageCreateFile = async ({ bucketId, fileId, file, permissions, parseOut
|
|
|
474
452
|
*/
|
|
475
453
|
const storageGetFile = async ({ bucketId, fileId, parseOutput = true, sdk = undefined}) => {
|
|
476
454
|
let client = !sdk ? await sdkForProject() : sdk;
|
|
477
|
-
|
|
478
455
|
let apiPath = '/storage/buckets/{bucketId}/files/{fileId}'.replace('{bucketId}', bucketId).replace('{fileId}', fileId);
|
|
479
456
|
let payload = {};
|
|
480
457
|
|
|
481
|
-
|
|
482
458
|
let response = undefined;
|
|
483
|
-
|
|
459
|
+
|
|
484
460
|
response = await client.call('get', apiPath, {
|
|
485
461
|
'content-type': 'application/json',
|
|
486
462
|
}, payload);
|
|
487
463
|
|
|
488
|
-
|
|
489
464
|
if (parseOutput) {
|
|
490
465
|
parse(response)
|
|
491
466
|
success()
|
|
@@ -509,7 +484,6 @@ const storageGetFile = async ({ bucketId, fileId, parseOutput = true, sdk = unde
|
|
|
509
484
|
*/
|
|
510
485
|
const storageUpdateFile = async ({ bucketId, fileId, name, permissions, parseOutput = true, sdk = undefined}) => {
|
|
511
486
|
let client = !sdk ? await sdkForProject() : sdk;
|
|
512
|
-
|
|
513
487
|
let apiPath = '/storage/buckets/{bucketId}/files/{fileId}'.replace('{bucketId}', bucketId).replace('{fileId}', fileId);
|
|
514
488
|
let payload = {};
|
|
515
489
|
if (typeof name !== 'undefined') {
|
|
@@ -520,14 +494,12 @@ const storageUpdateFile = async ({ bucketId, fileId, name, permissions, parseOut
|
|
|
520
494
|
payload['permissions'] = permissions;
|
|
521
495
|
}
|
|
522
496
|
|
|
523
|
-
|
|
524
497
|
let response = undefined;
|
|
525
|
-
|
|
498
|
+
|
|
526
499
|
response = await client.call('put', apiPath, {
|
|
527
500
|
'content-type': 'application/json',
|
|
528
501
|
}, payload);
|
|
529
502
|
|
|
530
|
-
|
|
531
503
|
if (parseOutput) {
|
|
532
504
|
parse(response)
|
|
533
505
|
success()
|
|
@@ -549,18 +521,15 @@ const storageUpdateFile = async ({ bucketId, fileId, name, permissions, parseOut
|
|
|
549
521
|
*/
|
|
550
522
|
const storageDeleteFile = async ({ bucketId, fileId, parseOutput = true, sdk = undefined}) => {
|
|
551
523
|
let client = !sdk ? await sdkForProject() : sdk;
|
|
552
|
-
|
|
553
524
|
let apiPath = '/storage/buckets/{bucketId}/files/{fileId}'.replace('{bucketId}', bucketId).replace('{fileId}', fileId);
|
|
554
525
|
let payload = {};
|
|
555
526
|
|
|
556
|
-
|
|
557
527
|
let response = undefined;
|
|
558
|
-
|
|
528
|
+
|
|
559
529
|
response = await client.call('delete', apiPath, {
|
|
560
530
|
'content-type': 'application/json',
|
|
561
531
|
}, payload);
|
|
562
532
|
|
|
563
|
-
|
|
564
533
|
if (parseOutput) {
|
|
565
534
|
parse(response)
|
|
566
535
|
success()
|
|
@@ -575,7 +544,7 @@ const storageDeleteFile = async ({ bucketId, fileId, parseOutput = true, sdk = u
|
|
|
575
544
|
* @property {string} fileId File ID.
|
|
576
545
|
* @property {boolean} parseOutput
|
|
577
546
|
* @property {libClient | undefined} sdk
|
|
578
|
-
* @property {string} destination
|
|
547
|
+
* @property {string} destination
|
|
579
548
|
*/
|
|
580
549
|
|
|
581
550
|
/**
|
|
@@ -583,23 +552,21 @@ const storageDeleteFile = async ({ bucketId, fileId, parseOutput = true, sdk = u
|
|
|
583
552
|
*/
|
|
584
553
|
const storageGetFileDownload = async ({ bucketId, fileId, parseOutput = true, sdk = undefined, destination}) => {
|
|
585
554
|
let client = !sdk ? await sdkForProject() : sdk;
|
|
586
|
-
|
|
587
555
|
let apiPath = '/storage/buckets/{bucketId}/files/{fileId}/download'.replace('{bucketId}', bucketId).replace('{fileId}', fileId);
|
|
588
556
|
let payload = {};
|
|
589
|
-
|
|
590
557
|
payload['project'] = localConfig.getProject().projectId
|
|
591
558
|
payload['key'] = globalConfig.getKey();
|
|
592
559
|
const queryParams = new URLSearchParams(payload);
|
|
593
560
|
apiPath = `${globalConfig.getEndpoint()}${apiPath}?${queryParams.toString()}`;
|
|
594
561
|
|
|
595
562
|
let response = undefined;
|
|
596
|
-
|
|
563
|
+
|
|
597
564
|
response = await client.call('get', apiPath, {
|
|
598
565
|
'content-type': 'application/json',
|
|
599
566
|
}, payload, 'arraybuffer');
|
|
600
567
|
|
|
601
568
|
fs.writeFileSync(destination, response);
|
|
602
|
-
|
|
569
|
+
|
|
603
570
|
if (parseOutput) {
|
|
604
571
|
parse(response)
|
|
605
572
|
success()
|
|
@@ -614,7 +581,7 @@ const storageGetFileDownload = async ({ bucketId, fileId, parseOutput = true, sd
|
|
|
614
581
|
* @property {string} fileId File ID
|
|
615
582
|
* @property {number} width Resize preview image width, Pass an integer between 0 to 4000.
|
|
616
583
|
* @property {number} height Resize preview image height, Pass an integer between 0 to 4000.
|
|
617
|
-
* @property {
|
|
584
|
+
* @property {ImageGravity} gravity Image crop gravity. Can be one of center,top-left,top,top-right,left,right,bottom-left,bottom,bottom-right
|
|
618
585
|
* @property {number} quality Preview image quality. Pass an integer between 0 to 100. Defaults to 100.
|
|
619
586
|
* @property {number} borderWidth Preview image border in pixels. Pass an integer between 0 to 100. Defaults to 0.
|
|
620
587
|
* @property {string} borderColor Preview image border color. Use a valid HEX color, no # is needed for prefix.
|
|
@@ -622,10 +589,10 @@ const storageGetFileDownload = async ({ bucketId, fileId, parseOutput = true, sd
|
|
|
622
589
|
* @property {number} opacity Preview image opacity. Only works with images having an alpha channel (like png). Pass a number between 0 to 1.
|
|
623
590
|
* @property {number} rotation Preview image rotation in degrees. Pass an integer between -360 and 360.
|
|
624
591
|
* @property {string} background Preview image background color. Only works with transparent images (png). Use a valid HEX color, no # is needed for prefix.
|
|
625
|
-
* @property {
|
|
592
|
+
* @property {ImageFormat} output Output format type (jpeg, jpg, png, gif and webp).
|
|
626
593
|
* @property {boolean} parseOutput
|
|
627
594
|
* @property {libClient | undefined} sdk
|
|
628
|
-
* @property {string} destination
|
|
595
|
+
* @property {string} destination
|
|
629
596
|
*/
|
|
630
597
|
|
|
631
598
|
/**
|
|
@@ -633,7 +600,6 @@ const storageGetFileDownload = async ({ bucketId, fileId, parseOutput = true, sd
|
|
|
633
600
|
*/
|
|
634
601
|
const storageGetFilePreview = async ({ bucketId, fileId, width, height, gravity, quality, borderWidth, borderColor, borderRadius, opacity, rotation, background, output, parseOutput = true, sdk = undefined, destination}) => {
|
|
635
602
|
let client = !sdk ? await sdkForProject() : sdk;
|
|
636
|
-
|
|
637
603
|
let apiPath = '/storage/buckets/{bucketId}/files/{fileId}/preview'.replace('{bucketId}', bucketId).replace('{fileId}', fileId);
|
|
638
604
|
let payload = {};
|
|
639
605
|
if (typeof width !== 'undefined') {
|
|
@@ -669,20 +635,19 @@ const storageGetFilePreview = async ({ bucketId, fileId, width, height, gravity,
|
|
|
669
635
|
if (typeof output !== 'undefined') {
|
|
670
636
|
payload['output'] = output;
|
|
671
637
|
}
|
|
672
|
-
|
|
673
638
|
payload['project'] = localConfig.getProject().projectId
|
|
674
639
|
payload['key'] = globalConfig.getKey();
|
|
675
640
|
const queryParams = new URLSearchParams(payload);
|
|
676
641
|
apiPath = `${globalConfig.getEndpoint()}${apiPath}?${queryParams.toString()}`;
|
|
677
642
|
|
|
678
643
|
let response = undefined;
|
|
679
|
-
|
|
644
|
+
|
|
680
645
|
response = await client.call('get', apiPath, {
|
|
681
646
|
'content-type': 'application/json',
|
|
682
647
|
}, payload, 'arraybuffer');
|
|
683
648
|
|
|
684
649
|
fs.writeFileSync(destination, response);
|
|
685
|
-
|
|
650
|
+
|
|
686
651
|
if (parseOutput) {
|
|
687
652
|
parse(response)
|
|
688
653
|
success()
|
|
@@ -697,7 +662,7 @@ const storageGetFilePreview = async ({ bucketId, fileId, width, height, gravity,
|
|
|
697
662
|
* @property {string} fileId File ID.
|
|
698
663
|
* @property {boolean} parseOutput
|
|
699
664
|
* @property {libClient | undefined} sdk
|
|
700
|
-
* @property {string} destination
|
|
665
|
+
* @property {string} destination
|
|
701
666
|
*/
|
|
702
667
|
|
|
703
668
|
/**
|
|
@@ -705,23 +670,21 @@ const storageGetFilePreview = async ({ bucketId, fileId, width, height, gravity,
|
|
|
705
670
|
*/
|
|
706
671
|
const storageGetFileView = async ({ bucketId, fileId, parseOutput = true, sdk = undefined, destination}) => {
|
|
707
672
|
let client = !sdk ? await sdkForProject() : sdk;
|
|
708
|
-
|
|
709
673
|
let apiPath = '/storage/buckets/{bucketId}/files/{fileId}/view'.replace('{bucketId}', bucketId).replace('{fileId}', fileId);
|
|
710
674
|
let payload = {};
|
|
711
|
-
|
|
712
675
|
payload['project'] = localConfig.getProject().projectId
|
|
713
676
|
payload['key'] = globalConfig.getKey();
|
|
714
677
|
const queryParams = new URLSearchParams(payload);
|
|
715
678
|
apiPath = `${globalConfig.getEndpoint()}${apiPath}?${queryParams.toString()}`;
|
|
716
679
|
|
|
717
680
|
let response = undefined;
|
|
718
|
-
|
|
681
|
+
|
|
719
682
|
response = await client.call('get', apiPath, {
|
|
720
683
|
'content-type': 'application/json',
|
|
721
684
|
}, payload, 'arraybuffer');
|
|
722
685
|
|
|
723
686
|
fs.writeFileSync(destination, response);
|
|
724
|
-
|
|
687
|
+
|
|
725
688
|
if (parseOutput) {
|
|
726
689
|
parse(response)
|
|
727
690
|
success()
|
|
@@ -732,7 +695,7 @@ const storageGetFileView = async ({ bucketId, fileId, parseOutput = true, sdk =
|
|
|
732
695
|
|
|
733
696
|
/**
|
|
734
697
|
* @typedef {Object} StorageGetUsageRequestParams
|
|
735
|
-
* @property {
|
|
698
|
+
* @property {StorageUsageRange} range Date range.
|
|
736
699
|
* @property {boolean} parseOutput
|
|
737
700
|
* @property {libClient | undefined} sdk
|
|
738
701
|
*/
|
|
@@ -742,21 +705,18 @@ const storageGetFileView = async ({ bucketId, fileId, parseOutput = true, sdk =
|
|
|
742
705
|
*/
|
|
743
706
|
const storageGetUsage = async ({ range, parseOutput = true, sdk = undefined}) => {
|
|
744
707
|
let client = !sdk ? await sdkForProject() : sdk;
|
|
745
|
-
|
|
746
708
|
let apiPath = '/storage/usage';
|
|
747
709
|
let payload = {};
|
|
748
710
|
if (typeof range !== 'undefined') {
|
|
749
711
|
payload['range'] = range;
|
|
750
712
|
}
|
|
751
713
|
|
|
752
|
-
|
|
753
714
|
let response = undefined;
|
|
754
|
-
|
|
715
|
+
|
|
755
716
|
response = await client.call('get', apiPath, {
|
|
756
717
|
'content-type': 'application/json',
|
|
757
718
|
}, payload);
|
|
758
719
|
|
|
759
|
-
|
|
760
720
|
if (parseOutput) {
|
|
761
721
|
parse(response)
|
|
762
722
|
success()
|
|
@@ -768,7 +728,7 @@ const storageGetUsage = async ({ range, parseOutput = true, sdk = undefined}) =>
|
|
|
768
728
|
/**
|
|
769
729
|
* @typedef {Object} StorageGetBucketUsageRequestParams
|
|
770
730
|
* @property {string} bucketId Bucket ID.
|
|
771
|
-
* @property {
|
|
731
|
+
* @property {StorageUsageRange} range Date range.
|
|
772
732
|
* @property {boolean} parseOutput
|
|
773
733
|
* @property {libClient | undefined} sdk
|
|
774
734
|
*/
|
|
@@ -778,21 +738,18 @@ const storageGetUsage = async ({ range, parseOutput = true, sdk = undefined}) =>
|
|
|
778
738
|
*/
|
|
779
739
|
const storageGetBucketUsage = async ({ bucketId, range, parseOutput = true, sdk = undefined}) => {
|
|
780
740
|
let client = !sdk ? await sdkForProject() : sdk;
|
|
781
|
-
|
|
782
741
|
let apiPath = '/storage/{bucketId}/usage'.replace('{bucketId}', bucketId);
|
|
783
742
|
let payload = {};
|
|
784
743
|
if (typeof range !== 'undefined') {
|
|
785
744
|
payload['range'] = range;
|
|
786
745
|
}
|
|
787
746
|
|
|
788
|
-
|
|
789
747
|
let response = undefined;
|
|
790
|
-
|
|
748
|
+
|
|
791
749
|
response = await client.call('get', apiPath, {
|
|
792
750
|
'content-type': 'application/json',
|
|
793
751
|
}, payload);
|
|
794
752
|
|
|
795
|
-
|
|
796
753
|
if (parseOutput) {
|
|
797
754
|
parse(response)
|
|
798
755
|
success()
|
|
@@ -801,7 +758,6 @@ const storageGetBucketUsage = async ({ bucketId, range, parseOutput = true, sdk
|
|
|
801
758
|
return response;
|
|
802
759
|
}
|
|
803
760
|
|
|
804
|
-
|
|
805
761
|
storage
|
|
806
762
|
.command(`listBuckets`)
|
|
807
763
|
.description(`Get a list of all the storage buckets. You can use the query params to filter your results.`)
|
|
@@ -939,22 +895,21 @@ storage
|
|
|
939
895
|
.option(`--range <range>`, `Date range.`)
|
|
940
896
|
.action(actionRunner(storageGetBucketUsage))
|
|
941
897
|
|
|
942
|
-
|
|
943
898
|
module.exports = {
|
|
944
899
|
storage,
|
|
945
|
-
storageListBuckets,
|
|
946
|
-
storageCreateBucket,
|
|
947
|
-
storageGetBucket,
|
|
948
|
-
storageUpdateBucket,
|
|
949
|
-
storageDeleteBucket,
|
|
950
|
-
storageListFiles,
|
|
951
|
-
storageCreateFile,
|
|
952
|
-
storageGetFile,
|
|
953
|
-
storageUpdateFile,
|
|
954
|
-
storageDeleteFile,
|
|
955
|
-
storageGetFileDownload,
|
|
956
|
-
storageGetFilePreview,
|
|
957
|
-
storageGetFileView,
|
|
958
|
-
storageGetUsage,
|
|
959
|
-
storageGetBucketUsage
|
|
900
|
+
storageListBuckets,
|
|
901
|
+
storageCreateBucket,
|
|
902
|
+
storageGetBucket,
|
|
903
|
+
storageUpdateBucket,
|
|
904
|
+
storageDeleteBucket,
|
|
905
|
+
storageListFiles,
|
|
906
|
+
storageCreateFile,
|
|
907
|
+
storageGetFile,
|
|
908
|
+
storageUpdateFile,
|
|
909
|
+
storageDeleteFile,
|
|
910
|
+
storageGetFileDownload,
|
|
911
|
+
storageGetFilePreview,
|
|
912
|
+
storageGetFileView,
|
|
913
|
+
storageGetUsage,
|
|
914
|
+
storageGetBucketUsage
|
|
960
915
|
};
|