chirag-appwrite-cli 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/workflows/npm-publish.yml +49 -0
- package/CHANGELOG.md +1 -0
- package/Formula/appwrite.rb +19 -0
- package/LICENSE.md +1 -0
- package/README.md +104 -0
- package/appwrite.json +164 -0
- package/docs/examples/account/create-anonymous-session.md +1 -0
- package/docs/examples/account/create-email-password-session.md +3 -0
- package/docs/examples/account/create-email-token.md +4 -0
- package/docs/examples/account/create-j-w-t.md +1 -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-auth2session.md +5 -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-phone-verification.md +1 -0
- package/docs/examples/account/create-push-target.md +4 -0
- package/docs/examples/account/create-recovery.md +3 -0
- package/docs/examples/account/create-session.md +3 -0
- package/docs/examples/account/create-verification.md +2 -0
- package/docs/examples/account/create.md +5 -0
- package/docs/examples/account/delete-identity.md +2 -0
- package/docs/examples/account/delete-mfa-authenticator.md +2 -0
- package/docs/examples/account/delete-push-target.md +2 -0
- package/docs/examples/account/delete-session.md +2 -0
- package/docs/examples/account/delete-sessions.md +1 -0
- package/docs/examples/account/delete.md +1 -0
- package/docs/examples/account/get-mfa-recovery-codes.md +1 -0
- package/docs/examples/account/get-prefs.md +1 -0
- package/docs/examples/account/get-session.md +2 -0
- package/docs/examples/account/get.md +1 -0
- package/docs/examples/account/list-identities.md +2 -0
- package/docs/examples/account/list-logs.md +2 -0
- package/docs/examples/account/list-mfa-factors.md +1 -0
- package/docs/examples/account/list-sessions.md +1 -0
- package/docs/examples/account/update-email.md +3 -0
- package/docs/examples/account/update-m-f-a.md +2 -0
- package/docs/examples/account/update-magic-u-r-l-session.md +3 -0
- 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 +2 -0
- package/docs/examples/account/update-password.md +3 -0
- package/docs/examples/account/update-phone-session.md +3 -0
- package/docs/examples/account/update-phone-verification.md +3 -0
- package/docs/examples/account/update-phone.md +3 -0
- package/docs/examples/account/update-prefs.md +2 -0
- package/docs/examples/account/update-push-target.md +3 -0
- package/docs/examples/account/update-recovery.md +4 -0
- package/docs/examples/account/update-session.md +2 -0
- package/docs/examples/account/update-status.md +1 -0
- package/docs/examples/account/update-verification.md +3 -0
- package/docs/examples/avatars/get-browser.md +5 -0
- package/docs/examples/avatars/get-credit-card.md +5 -0
- package/docs/examples/avatars/get-favicon.md +2 -0
- package/docs/examples/avatars/get-flag.md +5 -0
- package/docs/examples/avatars/get-image.md +4 -0
- package/docs/examples/avatars/get-initials.md +5 -0
- package/docs/examples/avatars/get-q-r.md +5 -0
- package/docs/examples/console/get-resource.md +3 -0
- package/docs/examples/console/variables.md +1 -0
- package/docs/examples/databases/create-boolean-attribute.md +7 -0
- package/docs/examples/databases/create-collection.md +7 -0
- package/docs/examples/databases/create-datetime-attribute.md +7 -0
- package/docs/examples/databases/create-document.md +6 -0
- package/docs/examples/databases/create-documents.md +4 -0
- package/docs/examples/databases/create-email-attribute.md +7 -0
- package/docs/examples/databases/create-enum-attribute.md +8 -0
- package/docs/examples/databases/create-float-attribute.md +9 -0
- package/docs/examples/databases/create-index.md +8 -0
- package/docs/examples/databases/create-integer-attribute.md +9 -0
- package/docs/examples/databases/create-ip-attribute.md +7 -0
- package/docs/examples/databases/create-relationship-attribute.md +9 -0
- package/docs/examples/databases/create-string-attribute.md +9 -0
- package/docs/examples/databases/create-url-attribute.md +7 -0
- package/docs/examples/databases/create.md +4 -0
- package/docs/examples/databases/decrement-document-attribute.md +7 -0
- package/docs/examples/databases/delete-attribute.md +4 -0
- package/docs/examples/databases/delete-collection.md +3 -0
- package/docs/examples/databases/delete-document.md +4 -0
- package/docs/examples/databases/delete-documents.md +4 -0
- package/docs/examples/databases/delete-index.md +4 -0
- package/docs/examples/databases/delete.md +2 -0
- package/docs/examples/databases/get-attribute.md +4 -0
- package/docs/examples/databases/get-collection-usage.md +4 -0
- package/docs/examples/databases/get-collection.md +3 -0
- package/docs/examples/databases/get-database-usage.md +3 -0
- package/docs/examples/databases/get-document.md +5 -0
- package/docs/examples/databases/get-index.md +4 -0
- package/docs/examples/databases/get-usage.md +2 -0
- package/docs/examples/databases/get.md +2 -0
- package/docs/examples/databases/increment-document-attribute.md +7 -0
- package/docs/examples/databases/list-attributes.md +4 -0
- package/docs/examples/databases/list-collection-logs.md +4 -0
- package/docs/examples/databases/list-collections.md +4 -0
- package/docs/examples/databases/list-document-logs.md +5 -0
- package/docs/examples/databases/list-documents.md +4 -0
- package/docs/examples/databases/list-indexes.md +4 -0
- package/docs/examples/databases/list-logs.md +3 -0
- package/docs/examples/databases/list.md +3 -0
- package/docs/examples/databases/update-boolean-attribute.md +7 -0
- package/docs/examples/databases/update-collection.md +7 -0
- package/docs/examples/databases/update-datetime-attribute.md +7 -0
- package/docs/examples/databases/update-document.md +6 -0
- package/docs/examples/databases/update-documents.md +5 -0
- package/docs/examples/databases/update-email-attribute.md +7 -0
- package/docs/examples/databases/update-enum-attribute.md +8 -0
- package/docs/examples/databases/update-float-attribute.md +9 -0
- package/docs/examples/databases/update-integer-attribute.md +9 -0
- package/docs/examples/databases/update-ip-attribute.md +7 -0
- package/docs/examples/databases/update-relationship-attribute.md +6 -0
- package/docs/examples/databases/update-string-attribute.md +8 -0
- package/docs/examples/databases/update-url-attribute.md +7 -0
- package/docs/examples/databases/update.md +4 -0
- package/docs/examples/databases/upsert-document.md +6 -0
- package/docs/examples/databases/upsert-documents.md +4 -0
- package/docs/examples/functions/create-deployment.md +6 -0
- package/docs/examples/functions/create-duplicate-deployment.md +4 -0
- package/docs/examples/functions/create-execution.md +8 -0
- package/docs/examples/functions/create-template-deployment.md +7 -0
- package/docs/examples/functions/create-variable.md +5 -0
- package/docs/examples/functions/create-vcs-deployment.md +5 -0
- package/docs/examples/functions/create.md +19 -0
- package/docs/examples/functions/delete-deployment.md +3 -0
- package/docs/examples/functions/delete-execution.md +3 -0
- package/docs/examples/functions/delete-variable.md +3 -0
- package/docs/examples/functions/delete.md +2 -0
- package/docs/examples/functions/get-deployment-download.md +4 -0
- package/docs/examples/functions/get-deployment.md +3 -0
- package/docs/examples/functions/get-execution.md +3 -0
- package/docs/examples/functions/get-template.md +2 -0
- package/docs/examples/functions/get-usage.md +3 -0
- package/docs/examples/functions/get-variable.md +3 -0
- package/docs/examples/functions/get.md +2 -0
- package/docs/examples/functions/list-deployments.md +4 -0
- package/docs/examples/functions/list-executions.md +3 -0
- package/docs/examples/functions/list-runtimes.md +1 -0
- package/docs/examples/functions/list-specifications.md +1 -0
- package/docs/examples/functions/list-templates.md +5 -0
- package/docs/examples/functions/list-usage.md +2 -0
- package/docs/examples/functions/list-variables.md +2 -0
- package/docs/examples/functions/list.md +3 -0
- package/docs/examples/functions/update-deployment-status.md +3 -0
- package/docs/examples/functions/update-function-deployment.md +3 -0
- package/docs/examples/functions/update-variable.md +6 -0
- package/docs/examples/functions/update.md +19 -0
- package/docs/examples/graphql/mutation.md +2 -0
- package/docs/examples/graphql/query.md +2 -0
- package/docs/examples/health/get-antivirus.md +1 -0
- package/docs/examples/health/get-cache.md +1 -0
- package/docs/examples/health/get-certificate.md +2 -0
- package/docs/examples/health/get-d-b.md +1 -0
- package/docs/examples/health/get-failed-jobs.md +3 -0
- package/docs/examples/health/get-pub-sub.md +1 -0
- package/docs/examples/health/get-queue-builds.md +2 -0
- package/docs/examples/health/get-queue-certificates.md +2 -0
- package/docs/examples/health/get-queue-databases.md +3 -0
- package/docs/examples/health/get-queue-deletes.md +2 -0
- package/docs/examples/health/get-queue-functions.md +2 -0
- package/docs/examples/health/get-queue-logs.md +2 -0
- package/docs/examples/health/get-queue-mails.md +2 -0
- package/docs/examples/health/get-queue-messaging.md +2 -0
- package/docs/examples/health/get-queue-migrations.md +2 -0
- package/docs/examples/health/get-queue-stats-resources.md +2 -0
- package/docs/examples/health/get-queue-usage.md +2 -0
- package/docs/examples/health/get-queue-webhooks.md +2 -0
- package/docs/examples/health/get-storage-local.md +1 -0
- package/docs/examples/health/get-storage.md +1 -0
- package/docs/examples/health/get-time.md +1 -0
- package/docs/examples/health/get.md +1 -0
- package/docs/examples/locale/get.md +1 -0
- package/docs/examples/locale/list-codes.md +1 -0
- package/docs/examples/locale/list-continents.md +1 -0
- package/docs/examples/locale/list-countries-e-u.md +1 -0
- package/docs/examples/locale/list-countries-phones.md +1 -0
- package/docs/examples/locale/list-countries.md +1 -0
- package/docs/examples/locale/list-currencies.md +1 -0
- package/docs/examples/locale/list-languages.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 +20 -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 +13 -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 +20 -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 +5 -0
- package/docs/examples/migrations/create-csv-migration.md +4 -0
- package/docs/examples/migrations/create-firebase-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.md +2 -0
- package/docs/examples/migrations/get-appwrite-report.md +5 -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.md +3 -0
- package/docs/examples/migrations/retry.md +2 -0
- package/docs/examples/project/create-variable.md +4 -0
- package/docs/examples/project/delete-variable.md +2 -0
- package/docs/examples/project/get-usage.md +4 -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 +5 -0
- package/docs/examples/projects/create-dev-key.md +4 -0
- package/docs/examples/projects/create-j-w-t.md +4 -0
- package/docs/examples/projects/create-key.md +5 -0
- package/docs/examples/projects/create-platform.md +7 -0
- package/docs/examples/projects/create-smtp-test.md +11 -0
- package/docs/examples/projects/create-webhook.md +9 -0
- package/docs/examples/projects/create.md +14 -0
- package/docs/examples/projects/delete-dev-key.md +3 -0
- package/docs/examples/projects/delete-email-template.md +4 -0
- package/docs/examples/projects/delete-key.md +3 -0
- package/docs/examples/projects/delete-platform.md +3 -0
- package/docs/examples/projects/delete-sms-template.md +4 -0
- package/docs/examples/projects/delete-webhook.md +3 -0
- package/docs/examples/projects/delete.md +2 -0
- package/docs/examples/projects/get-dev-key.md +3 -0
- package/docs/examples/projects/get-email-template.md +4 -0
- package/docs/examples/projects/get-key.md +3 -0
- package/docs/examples/projects/get-platform.md +3 -0
- package/docs/examples/projects/get-sms-template.md +4 -0
- package/docs/examples/projects/get-webhook.md +3 -0
- package/docs/examples/projects/get.md +2 -0
- package/docs/examples/projects/list-dev-keys.md +3 -0
- package/docs/examples/projects/list-keys.md +2 -0
- package/docs/examples/projects/list-platforms.md +2 -0
- package/docs/examples/projects/list-webhooks.md +2 -0
- package/docs/examples/projects/list.md +3 -0
- 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 +3 -0
- package/docs/examples/projects/update-auth-limit.md +3 -0
- package/docs/examples/projects/update-auth-password-dictionary.md +3 -0
- package/docs/examples/projects/update-auth-password-history.md +3 -0
- package/docs/examples/projects/update-auth-sessions-limit.md +3 -0
- package/docs/examples/projects/update-auth-status.md +4 -0
- package/docs/examples/projects/update-dev-key.md +5 -0
- package/docs/examples/projects/update-email-template.md +9 -0
- package/docs/examples/projects/update-key.md +6 -0
- package/docs/examples/projects/update-memberships-privacy.md +5 -0
- package/docs/examples/projects/update-mock-numbers.md +3 -0
- package/docs/examples/projects/update-o-auth2.md +6 -0
- package/docs/examples/projects/update-personal-data-check.md +3 -0
- package/docs/examples/projects/update-platform.md +7 -0
- package/docs/examples/projects/update-service-status-all.md +3 -0
- package/docs/examples/projects/update-service-status.md +4 -0
- package/docs/examples/projects/update-session-alerts.md +3 -0
- package/docs/examples/projects/update-sms-template.md +5 -0
- package/docs/examples/projects/update-smtp.md +11 -0
- package/docs/examples/projects/update-team.md +3 -0
- package/docs/examples/projects/update-webhook-signature.md +3 -0
- package/docs/examples/projects/update-webhook.md +10 -0
- package/docs/examples/projects/update.md +12 -0
- package/docs/examples/proxy/create-a-p-i-rule.md +2 -0
- package/docs/examples/proxy/create-function-rule.md +4 -0
- package/docs/examples/proxy/create-redirect-rule.md +6 -0
- package/docs/examples/proxy/create-site-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/sites/create-deployment.md +7 -0
- package/docs/examples/sites/create-duplicate-deployment.md +3 -0
- package/docs/examples/sites/create-template-deployment.md +7 -0
- package/docs/examples/sites/create-variable.md +5 -0
- package/docs/examples/sites/create-vcs-deployment.md +5 -0
- package/docs/examples/sites/create.md +19 -0
- package/docs/examples/sites/delete-deployment.md +3 -0
- package/docs/examples/sites/delete-log.md +3 -0
- package/docs/examples/sites/delete-variable.md +3 -0
- package/docs/examples/sites/delete.md +2 -0
- package/docs/examples/sites/get-deployment-download.md +4 -0
- package/docs/examples/sites/get-deployment.md +3 -0
- package/docs/examples/sites/get-log.md +3 -0
- package/docs/examples/sites/get-template.md +2 -0
- package/docs/examples/sites/get-usage.md +3 -0
- package/docs/examples/sites/get-variable.md +3 -0
- package/docs/examples/sites/get.md +2 -0
- package/docs/examples/sites/list-deployments.md +4 -0
- package/docs/examples/sites/list-frameworks.md +1 -0
- package/docs/examples/sites/list-logs.md +3 -0
- package/docs/examples/sites/list-specifications.md +1 -0
- package/docs/examples/sites/list-templates.md +5 -0
- package/docs/examples/sites/list-usage.md +2 -0
- package/docs/examples/sites/list-variables.md +2 -0
- package/docs/examples/sites/list.md +3 -0
- package/docs/examples/sites/update-deployment-status.md +3 -0
- package/docs/examples/sites/update-site-deployment.md +3 -0
- package/docs/examples/sites/update-variable.md +6 -0
- package/docs/examples/sites/update.md +19 -0
- package/docs/examples/storage/create-bucket.md +11 -0
- package/docs/examples/storage/create-file.md +5 -0
- package/docs/examples/storage/delete-bucket.md +2 -0
- package/docs/examples/storage/delete-file.md +3 -0
- package/docs/examples/storage/get-bucket-usage.md +3 -0
- package/docs/examples/storage/get-bucket.md +2 -0
- package/docs/examples/storage/get-file-download.md +4 -0
- package/docs/examples/storage/get-file-preview.md +15 -0
- package/docs/examples/storage/get-file-view.md +4 -0
- package/docs/examples/storage/get-file.md +3 -0
- package/docs/examples/storage/get-usage.md +2 -0
- package/docs/examples/storage/list-buckets.md +3 -0
- package/docs/examples/storage/list-files.md +4 -0
- package/docs/examples/storage/update-bucket.md +11 -0
- package/docs/examples/storage/update-file.md +5 -0
- package/docs/examples/teams/create-membership.md +8 -0
- package/docs/examples/teams/create.md +4 -0
- package/docs/examples/teams/delete-membership.md +3 -0
- package/docs/examples/teams/delete.md +2 -0
- package/docs/examples/teams/get-membership.md +3 -0
- package/docs/examples/teams/get-prefs.md +2 -0
- package/docs/examples/teams/get.md +2 -0
- package/docs/examples/teams/list-logs.md +3 -0
- package/docs/examples/teams/list-memberships.md +4 -0
- package/docs/examples/teams/list.md +3 -0
- package/docs/examples/teams/update-membership-status.md +5 -0
- package/docs/examples/teams/update-membership.md +4 -0
- package/docs/examples/teams/update-name.md +3 -0
- package/docs/examples/teams/update-prefs.md +3 -0
- package/docs/examples/tokens/create-file-token.md +4 -0
- package/docs/examples/tokens/delete.md +2 -0
- package/docs/examples/tokens/get.md +2 -0
- package/docs/examples/tokens/list.md +4 -0
- package/docs/examples/tokens/update.md +3 -0
- package/docs/examples/users/create-argon2user.md +5 -0
- package/docs/examples/users/create-bcrypt-user.md +5 -0
- package/docs/examples/users/create-j-w-t.md +4 -0
- package/docs/examples/users/create-m-d5user.md +5 -0
- package/docs/examples/users/create-mfa-recovery-codes.md +2 -0
- package/docs/examples/users/create-p-h-pass-user.md +5 -0
- package/docs/examples/users/create-s-h-a-user.md +6 -0
- package/docs/examples/users/create-scrypt-modified-user.md +8 -0
- package/docs/examples/users/create-scrypt-user.md +10 -0
- 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 +6 -0
- package/docs/examples/users/delete-identity.md +2 -0
- package/docs/examples/users/delete-mfa-authenticator.md +3 -0
- package/docs/examples/users/delete-session.md +3 -0
- package/docs/examples/users/delete-sessions.md +2 -0
- package/docs/examples/users/delete-target.md +3 -0
- package/docs/examples/users/delete.md +2 -0
- package/docs/examples/users/get-mfa-recovery-codes.md +2 -0
- package/docs/examples/users/get-prefs.md +2 -0
- package/docs/examples/users/get-target.md +3 -0
- package/docs/examples/users/get-usage.md +2 -0
- package/docs/examples/users/get.md +2 -0
- package/docs/examples/users/list-identities.md +3 -0
- package/docs/examples/users/list-logs.md +3 -0
- package/docs/examples/users/list-memberships.md +4 -0
- package/docs/examples/users/list-mfa-factors.md +2 -0
- package/docs/examples/users/list-sessions.md +2 -0
- package/docs/examples/users/list-targets.md +3 -0
- package/docs/examples/users/list.md +3 -0
- package/docs/examples/users/update-email-verification.md +3 -0
- package/docs/examples/users/update-email.md +3 -0
- package/docs/examples/users/update-labels.md +3 -0
- 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 +3 -0
- package/docs/examples/users/update-password.md +3 -0
- package/docs/examples/users/update-phone-verification.md +3 -0
- package/docs/examples/users/update-phone.md +3 -0
- package/docs/examples/users/update-prefs.md +3 -0
- package/docs/examples/users/update-status.md +3 -0
- package/docs/examples/users/update-target.md +6 -0
- package/docs/examples/vcs/create-repository-detection.md +5 -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-contents.md +5 -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 +4 -0
- package/docs/examples/vcs/list-repository-branches.md +3 -0
- package/docs/examples/vcs/update-external-deployments.md +4 -0
- package/functions/Starter function/.prettierrc.json +6 -0
- package/functions/Starter function/README.md +48 -0
- package/functions/Starter function/package-lock.json +60 -0
- package/functions/Starter function/package.json +16 -0
- package/functions/Starter function/src/main.js +35 -0
- package/generate/appwrite.d.ts +18 -0
- package/index.js +109 -0
- package/install.ps1 +98 -0
- package/install.sh +157 -0
- package/lib/client.js +259 -0
- package/lib/commands/account.js +2074 -0
- package/lib/commands/avatars.js +491 -0
- package/lib/commands/console.js +129 -0
- package/lib/commands/databases.js +2972 -0
- package/lib/commands/functions.js +1737 -0
- package/lib/commands/generic.js +328 -0
- package/lib/commands/graphql.js +128 -0
- package/lib/commands/health.js +891 -0
- package/lib/commands/init.js +566 -0
- package/lib/commands/locale.js +324 -0
- package/lib/commands/messaging.js +2970 -0
- package/lib/commands/migrations.js +751 -0
- package/lib/commands/organizations.js +48 -0
- package/lib/commands/project.js +308 -0
- package/lib/commands/projects.js +2615 -0
- package/lib/commands/proxy.js +406 -0
- package/lib/commands/pull.js +474 -0
- package/lib/commands/push.js +2117 -0
- package/lib/commands/run.js +330 -0
- package/lib/commands/sites.js +1663 -0
- package/lib/commands/storage.js +990 -0
- package/lib/commands/teams.js +682 -0
- package/lib/commands/tokens.js +261 -0
- package/lib/commands/types.js +156 -0
- package/lib/commands/users.js +2035 -0
- package/lib/commands/vcs.js +484 -0
- package/lib/config.js +705 -0
- package/lib/emulation/docker.js +264 -0
- package/lib/emulation/utils.js +186 -0
- package/lib/exception.js +9 -0
- package/lib/id.js +30 -0
- package/lib/paginate.js +52 -0
- package/lib/parser.js +246 -0
- package/lib/questions.js +1006 -0
- package/lib/sdks.js +60 -0
- package/lib/spinner.js +104 -0
- package/lib/type-generation/attribute.js +16 -0
- package/lib/type-generation/languages/dart.js +196 -0
- package/lib/type-generation/languages/java.js +130 -0
- package/lib/type-generation/languages/javascript.js +102 -0
- package/lib/type-generation/languages/kotlin.js +84 -0
- package/lib/type-generation/languages/language.js +125 -0
- package/lib/type-generation/languages/php.js +109 -0
- package/lib/type-generation/languages/swift.js +169 -0
- package/lib/type-generation/languages/typescript.js +102 -0
- package/lib/utils.js +289 -0
- package/lib/validations.js +17 -0
- package/package.json +50 -0
- package/scoop/appwrite.json +30 -0
- package/sites/JavaScript starter/.env.example +3 -0
- package/sites/JavaScript starter/LICENSE +21 -0
- package/sites/JavaScript starter/images/appwrite.svg +8 -0
- package/sites/JavaScript starter/images/javascript.svg +5 -0
- package/sites/JavaScript starter/index.html +250 -0
- package/sites/JavaScript starter/lib/appwrite.js +10 -0
- package/sites/JavaScript starter/package-lock.json +1431 -0
- package/sites/JavaScript starter/package.json +21 -0
- package/sites/JavaScript starter/readme.md +26 -0
- package/sites/JavaScript starter/src/javascript.svg +1 -0
- package/sites/JavaScript starter/style/app.css +20 -0
- package/sites/JavaScript starter/vite.config.js +7 -0
|
@@ -0,0 +1,990 @@
|
|
|
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, showConsoleLink } = 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
|
+
const { File } = require('undici');
|
|
13
|
+
const { ReadableStream } = require('stream/web');
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* @param {fs.ReadStream} readStream
|
|
17
|
+
* @returns {ReadableStream}
|
|
18
|
+
*/
|
|
19
|
+
function convertReadStreamToReadableStream(readStream) {
|
|
20
|
+
return new ReadableStream({
|
|
21
|
+
start(controller) {
|
|
22
|
+
readStream.on("data", (chunk) => {
|
|
23
|
+
controller.enqueue(chunk);
|
|
24
|
+
});
|
|
25
|
+
readStream.on("end", () => {
|
|
26
|
+
controller.close();
|
|
27
|
+
});
|
|
28
|
+
readStream.on("error", (err) => {
|
|
29
|
+
controller.error(err);
|
|
30
|
+
});
|
|
31
|
+
},
|
|
32
|
+
cancel() {
|
|
33
|
+
readStream.destroy();
|
|
34
|
+
},
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
const storage = new Command("storage").description(commandDescriptions['storage'] ?? '').configureHelp({
|
|
39
|
+
helpWidth: process.stdout.columns || 80
|
|
40
|
+
})
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* @typedef {Object} StorageListBucketsRequestParams
|
|
44
|
+
* @property {string[]} queries Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: enabled, name, fileSecurity, maximumFileSize, encryption, antivirus
|
|
45
|
+
* @property {string} search Search term to filter your list results. Max length: 256 chars.
|
|
46
|
+
* @property {boolean} overrideForCli
|
|
47
|
+
* @property {boolean} parseOutput
|
|
48
|
+
* @property {libClient | undefined} sdk
|
|
49
|
+
*/
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* @param {StorageListBucketsRequestParams} params
|
|
53
|
+
*/
|
|
54
|
+
const storageListBuckets = async ({queries,search,parseOutput = true, overrideForCli = false, sdk = undefined, console}) => {
|
|
55
|
+
let client = !sdk ? await sdkForProject() :
|
|
56
|
+
sdk;
|
|
57
|
+
let apiPath = '/storage/buckets';
|
|
58
|
+
let payload = {};
|
|
59
|
+
if (typeof queries !== 'undefined') {
|
|
60
|
+
payload['queries'] = queries;
|
|
61
|
+
}
|
|
62
|
+
if (typeof search !== 'undefined') {
|
|
63
|
+
payload['search'] = search;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
let response = undefined;
|
|
67
|
+
|
|
68
|
+
response = await client.call('get', apiPath, {
|
|
69
|
+
}, payload);
|
|
70
|
+
|
|
71
|
+
if (parseOutput) {
|
|
72
|
+
if(console) {
|
|
73
|
+
showConsoleLink('storage', 'listBuckets');
|
|
74
|
+
} else {
|
|
75
|
+
parse(response)
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
return response;
|
|
80
|
+
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* @typedef {Object} StorageCreateBucketRequestParams
|
|
85
|
+
* @property {string} bucketId Unique Id. Choose a custom ID or generate a random ID with 'ID.unique()'. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars.
|
|
86
|
+
* @property {string} name Bucket name
|
|
87
|
+
* @property {string[]} permissions An array of permission strings. By default, no user is granted with any permissions. [Learn more about permissions](https://appwrite.io/docs/permissions).
|
|
88
|
+
* @property {boolean} 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](https://appwrite.io/docs/permissions).
|
|
89
|
+
* @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.
|
|
90
|
+
* @property {number} maximumFileSize Maximum file size allowed in bytes. Maximum allowed value is 30MB.
|
|
91
|
+
* @property {string[]} allowedFileExtensions Allowed file extensions. Maximum of 100 extensions are allowed, each 64 characters long.
|
|
92
|
+
* @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
|
|
93
|
+
* @property {boolean} encryption Is encryption enabled? For file size above 20MB encryption is skipped even if it's enabled
|
|
94
|
+
* @property {boolean} antivirus Is virus scanning enabled? For file size above 20MB AntiVirus scanning is skipped even if it's enabled
|
|
95
|
+
* @property {boolean} overrideForCli
|
|
96
|
+
* @property {boolean} parseOutput
|
|
97
|
+
* @property {libClient | undefined} sdk
|
|
98
|
+
*/
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* @param {StorageCreateBucketRequestParams} params
|
|
102
|
+
*/
|
|
103
|
+
const storageCreateBucket = async ({bucketId,name,permissions,fileSecurity,enabled,maximumFileSize,allowedFileExtensions,compression,encryption,antivirus,parseOutput = true, overrideForCli = false, sdk = undefined}) => {
|
|
104
|
+
let client = !sdk ? await sdkForProject() :
|
|
105
|
+
sdk;
|
|
106
|
+
let apiPath = '/storage/buckets';
|
|
107
|
+
let payload = {};
|
|
108
|
+
if (typeof bucketId !== 'undefined') {
|
|
109
|
+
payload['bucketId'] = bucketId;
|
|
110
|
+
}
|
|
111
|
+
if (typeof name !== 'undefined') {
|
|
112
|
+
payload['name'] = name;
|
|
113
|
+
}
|
|
114
|
+
permissions = permissions === true ? [] : permissions;
|
|
115
|
+
if (typeof permissions !== 'undefined') {
|
|
116
|
+
payload['permissions'] = permissions;
|
|
117
|
+
}
|
|
118
|
+
if (typeof fileSecurity !== 'undefined') {
|
|
119
|
+
payload['fileSecurity'] = fileSecurity;
|
|
120
|
+
}
|
|
121
|
+
if (typeof enabled !== 'undefined') {
|
|
122
|
+
payload['enabled'] = enabled;
|
|
123
|
+
}
|
|
124
|
+
if (typeof maximumFileSize !== 'undefined') {
|
|
125
|
+
payload['maximumFileSize'] = maximumFileSize;
|
|
126
|
+
}
|
|
127
|
+
allowedFileExtensions = allowedFileExtensions === true ? [] : allowedFileExtensions;
|
|
128
|
+
if (typeof allowedFileExtensions !== 'undefined') {
|
|
129
|
+
payload['allowedFileExtensions'] = allowedFileExtensions;
|
|
130
|
+
}
|
|
131
|
+
if (typeof compression !== 'undefined') {
|
|
132
|
+
payload['compression'] = compression;
|
|
133
|
+
}
|
|
134
|
+
if (typeof encryption !== 'undefined') {
|
|
135
|
+
payload['encryption'] = encryption;
|
|
136
|
+
}
|
|
137
|
+
if (typeof antivirus !== 'undefined') {
|
|
138
|
+
payload['antivirus'] = antivirus;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
let response = undefined;
|
|
142
|
+
|
|
143
|
+
response = await client.call('post', apiPath, {
|
|
144
|
+
'content-type': 'application/json',
|
|
145
|
+
}, payload);
|
|
146
|
+
|
|
147
|
+
if (parseOutput) {
|
|
148
|
+
parse(response)
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
return response;
|
|
152
|
+
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
/**
|
|
156
|
+
* @typedef {Object} StorageGetBucketRequestParams
|
|
157
|
+
* @property {string} bucketId Bucket unique ID.
|
|
158
|
+
* @property {boolean} overrideForCli
|
|
159
|
+
* @property {boolean} parseOutput
|
|
160
|
+
* @property {libClient | undefined} sdk
|
|
161
|
+
*/
|
|
162
|
+
|
|
163
|
+
/**
|
|
164
|
+
* @param {StorageGetBucketRequestParams} params
|
|
165
|
+
*/
|
|
166
|
+
const storageGetBucket = async ({bucketId,parseOutput = true, overrideForCli = false, sdk = undefined, console}) => {
|
|
167
|
+
let client = !sdk ? await sdkForProject() :
|
|
168
|
+
sdk;
|
|
169
|
+
let apiPath = '/storage/buckets/{bucketId}'.replace('{bucketId}', bucketId);
|
|
170
|
+
let payload = {};
|
|
171
|
+
|
|
172
|
+
let response = undefined;
|
|
173
|
+
|
|
174
|
+
response = await client.call('get', apiPath, {
|
|
175
|
+
}, payload);
|
|
176
|
+
|
|
177
|
+
if (parseOutput) {
|
|
178
|
+
if(console) {
|
|
179
|
+
showConsoleLink('storage', 'getBucket', bucketId);
|
|
180
|
+
} else {
|
|
181
|
+
parse(response)
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
return response;
|
|
186
|
+
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
/**
|
|
190
|
+
* @typedef {Object} StorageUpdateBucketRequestParams
|
|
191
|
+
* @property {string} bucketId Bucket unique ID.
|
|
192
|
+
* @property {string} name Bucket name
|
|
193
|
+
* @property {string[]} permissions An array of permission strings. By default, the current permissions are inherited. [Learn more about permissions](https://appwrite.io/docs/permissions).
|
|
194
|
+
* @property {boolean} 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](https://appwrite.io/docs/permissions).
|
|
195
|
+
* @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.
|
|
196
|
+
* @property {number} maximumFileSize Maximum file size allowed in bytes. Maximum allowed value is 30MB.
|
|
197
|
+
* @property {string[]} allowedFileExtensions Allowed file extensions. Maximum of 100 extensions are allowed, each 64 characters long.
|
|
198
|
+
* @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
|
|
199
|
+
* @property {boolean} encryption Is encryption enabled? For file size above 20MB encryption is skipped even if it's enabled
|
|
200
|
+
* @property {boolean} antivirus Is virus scanning enabled? For file size above 20MB AntiVirus scanning is skipped even if it's enabled
|
|
201
|
+
* @property {boolean} overrideForCli
|
|
202
|
+
* @property {boolean} parseOutput
|
|
203
|
+
* @property {libClient | undefined} sdk
|
|
204
|
+
*/
|
|
205
|
+
|
|
206
|
+
/**
|
|
207
|
+
* @param {StorageUpdateBucketRequestParams} params
|
|
208
|
+
*/
|
|
209
|
+
const storageUpdateBucket = async ({bucketId,name,permissions,fileSecurity,enabled,maximumFileSize,allowedFileExtensions,compression,encryption,antivirus,parseOutput = true, overrideForCli = false, sdk = undefined}) => {
|
|
210
|
+
let client = !sdk ? await sdkForProject() :
|
|
211
|
+
sdk;
|
|
212
|
+
let apiPath = '/storage/buckets/{bucketId}'.replace('{bucketId}', bucketId);
|
|
213
|
+
let payload = {};
|
|
214
|
+
if (typeof name !== 'undefined') {
|
|
215
|
+
payload['name'] = name;
|
|
216
|
+
}
|
|
217
|
+
permissions = permissions === true ? [] : permissions;
|
|
218
|
+
if (typeof permissions !== 'undefined') {
|
|
219
|
+
payload['permissions'] = permissions;
|
|
220
|
+
}
|
|
221
|
+
if (typeof fileSecurity !== 'undefined') {
|
|
222
|
+
payload['fileSecurity'] = fileSecurity;
|
|
223
|
+
}
|
|
224
|
+
if (typeof enabled !== 'undefined') {
|
|
225
|
+
payload['enabled'] = enabled;
|
|
226
|
+
}
|
|
227
|
+
if (typeof maximumFileSize !== 'undefined') {
|
|
228
|
+
payload['maximumFileSize'] = maximumFileSize;
|
|
229
|
+
}
|
|
230
|
+
allowedFileExtensions = allowedFileExtensions === true ? [] : allowedFileExtensions;
|
|
231
|
+
if (typeof allowedFileExtensions !== 'undefined') {
|
|
232
|
+
payload['allowedFileExtensions'] = allowedFileExtensions;
|
|
233
|
+
}
|
|
234
|
+
if (typeof compression !== 'undefined') {
|
|
235
|
+
payload['compression'] = compression;
|
|
236
|
+
}
|
|
237
|
+
if (typeof encryption !== 'undefined') {
|
|
238
|
+
payload['encryption'] = encryption;
|
|
239
|
+
}
|
|
240
|
+
if (typeof antivirus !== 'undefined') {
|
|
241
|
+
payload['antivirus'] = antivirus;
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
let response = undefined;
|
|
245
|
+
|
|
246
|
+
response = await client.call('put', apiPath, {
|
|
247
|
+
'content-type': 'application/json',
|
|
248
|
+
}, payload);
|
|
249
|
+
|
|
250
|
+
if (parseOutput) {
|
|
251
|
+
parse(response)
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
return response;
|
|
255
|
+
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
/**
|
|
259
|
+
* @typedef {Object} StorageDeleteBucketRequestParams
|
|
260
|
+
* @property {string} bucketId Bucket unique ID.
|
|
261
|
+
* @property {boolean} overrideForCli
|
|
262
|
+
* @property {boolean} parseOutput
|
|
263
|
+
* @property {libClient | undefined} sdk
|
|
264
|
+
*/
|
|
265
|
+
|
|
266
|
+
/**
|
|
267
|
+
* @param {StorageDeleteBucketRequestParams} params
|
|
268
|
+
*/
|
|
269
|
+
const storageDeleteBucket = async ({bucketId,parseOutput = true, overrideForCli = false, sdk = undefined}) => {
|
|
270
|
+
let client = !sdk ? await sdkForProject() :
|
|
271
|
+
sdk;
|
|
272
|
+
let apiPath = '/storage/buckets/{bucketId}'.replace('{bucketId}', bucketId);
|
|
273
|
+
let payload = {};
|
|
274
|
+
|
|
275
|
+
let response = undefined;
|
|
276
|
+
|
|
277
|
+
response = await client.call('delete', apiPath, {
|
|
278
|
+
'content-type': 'application/json',
|
|
279
|
+
}, payload);
|
|
280
|
+
|
|
281
|
+
if (parseOutput) {
|
|
282
|
+
parse(response)
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
return response;
|
|
286
|
+
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
/**
|
|
290
|
+
* @typedef {Object} StorageListFilesRequestParams
|
|
291
|
+
* @property {string} bucketId Storage bucket unique ID. You can create a new storage bucket using the Storage service [server integration](https://appwrite.io/docs/server/storage#createBucket).
|
|
292
|
+
* @property {string[]} queries Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: name, signature, mimeType, sizeOriginal, chunksTotal, chunksUploaded
|
|
293
|
+
* @property {string} search Search term to filter your list results. Max length: 256 chars.
|
|
294
|
+
* @property {boolean} overrideForCli
|
|
295
|
+
* @property {boolean} parseOutput
|
|
296
|
+
* @property {libClient | undefined} sdk
|
|
297
|
+
*/
|
|
298
|
+
|
|
299
|
+
/**
|
|
300
|
+
* @param {StorageListFilesRequestParams} params
|
|
301
|
+
*/
|
|
302
|
+
const storageListFiles = async ({bucketId,queries,search,parseOutput = true, overrideForCli = false, sdk = undefined, console}) => {
|
|
303
|
+
let client = !sdk ? await sdkForProject() :
|
|
304
|
+
sdk;
|
|
305
|
+
let apiPath = '/storage/buckets/{bucketId}/files'.replace('{bucketId}', bucketId);
|
|
306
|
+
let payload = {};
|
|
307
|
+
if (typeof queries !== 'undefined') {
|
|
308
|
+
payload['queries'] = queries;
|
|
309
|
+
}
|
|
310
|
+
if (typeof search !== 'undefined') {
|
|
311
|
+
payload['search'] = search;
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
let response = undefined;
|
|
315
|
+
|
|
316
|
+
response = await client.call('get', apiPath, {
|
|
317
|
+
}, payload);
|
|
318
|
+
|
|
319
|
+
if (parseOutput) {
|
|
320
|
+
if(console) {
|
|
321
|
+
showConsoleLink('storage', 'listFiles', bucketId);
|
|
322
|
+
} else {
|
|
323
|
+
parse(response)
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
return response;
|
|
328
|
+
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
/**
|
|
332
|
+
* @typedef {Object} StorageCreateFileRequestParams
|
|
333
|
+
* @property {string} bucketId Storage bucket unique ID. You can create a new storage bucket using the Storage service [server integration](https://appwrite.io/docs/server/storage#createBucket).
|
|
334
|
+
* @property {string} fileId File ID. Choose a custom ID or generate a random ID with 'ID.unique()'. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars.
|
|
335
|
+
* @property {string} file Binary file. Appwrite SDKs provide helpers to handle file input. [Learn about file input](https://appwrite.io/docs/products/storage/upload-download#input-file).
|
|
336
|
+
* @property {string[]} permissions An array of permission strings. By default, only the current user is granted all permissions. [Learn more about permissions](https://appwrite.io/docs/permissions).
|
|
337
|
+
* @property {boolean} overrideForCli
|
|
338
|
+
* @property {boolean} parseOutput
|
|
339
|
+
* @property {libClient | undefined} sdk
|
|
340
|
+
* @property {CallableFunction} onProgress
|
|
341
|
+
*/
|
|
342
|
+
|
|
343
|
+
/**
|
|
344
|
+
* @param {StorageCreateFileRequestParams} params
|
|
345
|
+
*/
|
|
346
|
+
const storageCreateFile = async ({bucketId,fileId,file,permissions,parseOutput = true, overrideForCli = false, sdk = undefined,onProgress = () => {}}) => {
|
|
347
|
+
let client = !sdk ? await sdkForProject() :
|
|
348
|
+
sdk;
|
|
349
|
+
let apiPath = '/storage/buckets/{bucketId}/files'.replace('{bucketId}', bucketId);
|
|
350
|
+
let payload = {};
|
|
351
|
+
if (typeof fileId !== 'undefined') {
|
|
352
|
+
payload['fileId'] = fileId;
|
|
353
|
+
}
|
|
354
|
+
const filePath = fs.realpathSync(file);
|
|
355
|
+
const nodeStream = fs.createReadStream(filePath);
|
|
356
|
+
const stream = convertReadStreamToReadableStream(nodeStream);
|
|
357
|
+
|
|
358
|
+
if (typeof filePath !== 'undefined') {
|
|
359
|
+
file = { type: 'file', stream, filename: pathLib.basename(filePath), size: fs.statSync(filePath).size };
|
|
360
|
+
payload['file'] = file
|
|
361
|
+
}
|
|
362
|
+
permissions = permissions === true ? [] : permissions;
|
|
363
|
+
if (typeof permissions !== 'undefined') {
|
|
364
|
+
payload['permissions'] = permissions;
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
const size = file.size;
|
|
368
|
+
|
|
369
|
+
const apiHeaders = {
|
|
370
|
+
'content-type': 'multipart/form-data',
|
|
371
|
+
};
|
|
372
|
+
|
|
373
|
+
let id = undefined;
|
|
374
|
+
let response = undefined;
|
|
375
|
+
|
|
376
|
+
let chunksUploaded = 0;
|
|
377
|
+
|
|
378
|
+
if(fileId != 'unique()') {
|
|
379
|
+
try {
|
|
380
|
+
response = await client.call('get', apiPath + '/' + fileId, apiHeaders);
|
|
381
|
+
chunksUploaded = response.chunksUploaded;
|
|
382
|
+
} catch(e) {
|
|
383
|
+
}
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
let currentChunk = 1;
|
|
387
|
+
let currentPosition = 0;
|
|
388
|
+
let uploadableChunk = new Uint8Array(client.CHUNK_SIZE);
|
|
389
|
+
|
|
390
|
+
const uploadChunk = async (lastUpload = false) => {
|
|
391
|
+
if(currentChunk <= chunksUploaded) {
|
|
392
|
+
return;
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
const start = ((currentChunk - 1) * client.CHUNK_SIZE);
|
|
396
|
+
let end = start + currentPosition - 1;
|
|
397
|
+
|
|
398
|
+
if(!lastUpload || currentChunk !== 1) {
|
|
399
|
+
apiHeaders['content-range'] = 'bytes ' + start + '-' + end + '/' + size;
|
|
400
|
+
}
|
|
401
|
+
|
|
402
|
+
let uploadableChunkTrimmed;
|
|
403
|
+
|
|
404
|
+
if(currentPosition + 1 >= client.CHUNK_SIZE) {
|
|
405
|
+
uploadableChunkTrimmed = uploadableChunk;
|
|
406
|
+
} else {
|
|
407
|
+
uploadableChunkTrimmed = new Uint8Array(currentPosition);
|
|
408
|
+
for(let i = 0; i <= currentPosition; i++) {
|
|
409
|
+
uploadableChunkTrimmed[i] = uploadableChunk[i];
|
|
410
|
+
}
|
|
411
|
+
}
|
|
412
|
+
|
|
413
|
+
if (id) {
|
|
414
|
+
apiHeaders['x-appwrite-id'] = id;
|
|
415
|
+
}
|
|
416
|
+
|
|
417
|
+
payload['file'] = { type: 'file', file: new File([uploadableChunkTrimmed], file.filename), filename: file.filename };
|
|
418
|
+
|
|
419
|
+
response = await client.call('post', apiPath, apiHeaders, payload);
|
|
420
|
+
|
|
421
|
+
if (!id) {
|
|
422
|
+
id = response['$id'];
|
|
423
|
+
}
|
|
424
|
+
|
|
425
|
+
if (onProgress !== null) {
|
|
426
|
+
onProgress({
|
|
427
|
+
$id: response['$id'],
|
|
428
|
+
progress: Math.min((currentChunk) * client.CHUNK_SIZE, size) / size * 100,
|
|
429
|
+
sizeUploaded: end+1,
|
|
430
|
+
chunksTotal: response['chunksTotal'],
|
|
431
|
+
chunksUploaded: response['chunksUploaded']
|
|
432
|
+
});
|
|
433
|
+
}
|
|
434
|
+
|
|
435
|
+
uploadableChunk = new Uint8Array(client.CHUNK_SIZE);
|
|
436
|
+
currentChunk++;
|
|
437
|
+
currentPosition = 0;
|
|
438
|
+
}
|
|
439
|
+
|
|
440
|
+
for await (const chunk of file.stream) {
|
|
441
|
+
for(const b of chunk) {
|
|
442
|
+
uploadableChunk[currentPosition] = b;
|
|
443
|
+
|
|
444
|
+
currentPosition++;
|
|
445
|
+
if(currentPosition >= client.CHUNK_SIZE) {
|
|
446
|
+
await uploadChunk();
|
|
447
|
+
currentPosition = 0;
|
|
448
|
+
}
|
|
449
|
+
}
|
|
450
|
+
}
|
|
451
|
+
|
|
452
|
+
if (currentPosition > 0) { // Check if there's any remaining data for the last chunk
|
|
453
|
+
await uploadChunk(true);
|
|
454
|
+
}
|
|
455
|
+
|
|
456
|
+
|
|
457
|
+
if (parseOutput) {
|
|
458
|
+
parse(response)
|
|
459
|
+
}
|
|
460
|
+
|
|
461
|
+
return response;
|
|
462
|
+
}
|
|
463
|
+
|
|
464
|
+
/**
|
|
465
|
+
* @typedef {Object} StorageGetFileRequestParams
|
|
466
|
+
* @property {string} bucketId Storage bucket unique ID. You can create a new storage bucket using the Storage service [server integration](https://appwrite.io/docs/server/storage#createBucket).
|
|
467
|
+
* @property {string} fileId File ID.
|
|
468
|
+
* @property {boolean} overrideForCli
|
|
469
|
+
* @property {boolean} parseOutput
|
|
470
|
+
* @property {libClient | undefined} sdk
|
|
471
|
+
*/
|
|
472
|
+
|
|
473
|
+
/**
|
|
474
|
+
* @param {StorageGetFileRequestParams} params
|
|
475
|
+
*/
|
|
476
|
+
const storageGetFile = async ({bucketId,fileId,parseOutput = true, overrideForCli = false, sdk = undefined, console}) => {
|
|
477
|
+
let client = !sdk ? await sdkForProject() :
|
|
478
|
+
sdk;
|
|
479
|
+
let apiPath = '/storage/buckets/{bucketId}/files/{fileId}'.replace('{bucketId}', bucketId).replace('{fileId}', fileId);
|
|
480
|
+
let payload = {};
|
|
481
|
+
|
|
482
|
+
let response = undefined;
|
|
483
|
+
|
|
484
|
+
response = await client.call('get', apiPath, {
|
|
485
|
+
}, payload);
|
|
486
|
+
|
|
487
|
+
if (parseOutput) {
|
|
488
|
+
if(console) {
|
|
489
|
+
showConsoleLink('storage', 'getFile', bucketId, fileId);
|
|
490
|
+
} else {
|
|
491
|
+
parse(response)
|
|
492
|
+
}
|
|
493
|
+
}
|
|
494
|
+
|
|
495
|
+
return response;
|
|
496
|
+
|
|
497
|
+
}
|
|
498
|
+
|
|
499
|
+
/**
|
|
500
|
+
* @typedef {Object} StorageUpdateFileRequestParams
|
|
501
|
+
* @property {string} bucketId Storage bucket unique ID. You can create a new storage bucket using the Storage service [server integration](https://appwrite.io/docs/server/storage#createBucket).
|
|
502
|
+
* @property {string} fileId File unique ID.
|
|
503
|
+
* @property {string} name Name of the file
|
|
504
|
+
* @property {string[]} permissions An array of permission string. By default, the current permissions are inherited. [Learn more about permissions](https://appwrite.io/docs/permissions).
|
|
505
|
+
* @property {boolean} overrideForCli
|
|
506
|
+
* @property {boolean} parseOutput
|
|
507
|
+
* @property {libClient | undefined} sdk
|
|
508
|
+
*/
|
|
509
|
+
|
|
510
|
+
/**
|
|
511
|
+
* @param {StorageUpdateFileRequestParams} params
|
|
512
|
+
*/
|
|
513
|
+
const storageUpdateFile = async ({bucketId,fileId,name,permissions,parseOutput = true, overrideForCli = false, sdk = undefined}) => {
|
|
514
|
+
let client = !sdk ? await sdkForProject() :
|
|
515
|
+
sdk;
|
|
516
|
+
let apiPath = '/storage/buckets/{bucketId}/files/{fileId}'.replace('{bucketId}', bucketId).replace('{fileId}', fileId);
|
|
517
|
+
let payload = {};
|
|
518
|
+
if (typeof name !== 'undefined') {
|
|
519
|
+
payload['name'] = name;
|
|
520
|
+
}
|
|
521
|
+
permissions = permissions === true ? [] : permissions;
|
|
522
|
+
if (typeof permissions !== 'undefined') {
|
|
523
|
+
payload['permissions'] = permissions;
|
|
524
|
+
}
|
|
525
|
+
|
|
526
|
+
let response = undefined;
|
|
527
|
+
|
|
528
|
+
response = await client.call('put', apiPath, {
|
|
529
|
+
'content-type': 'application/json',
|
|
530
|
+
}, payload);
|
|
531
|
+
|
|
532
|
+
if (parseOutput) {
|
|
533
|
+
parse(response)
|
|
534
|
+
}
|
|
535
|
+
|
|
536
|
+
return response;
|
|
537
|
+
|
|
538
|
+
}
|
|
539
|
+
|
|
540
|
+
/**
|
|
541
|
+
* @typedef {Object} StorageDeleteFileRequestParams
|
|
542
|
+
* @property {string} bucketId Storage bucket unique ID. You can create a new storage bucket using the Storage service [server integration](https://appwrite.io/docs/server/storage#createBucket).
|
|
543
|
+
* @property {string} fileId File ID.
|
|
544
|
+
* @property {boolean} overrideForCli
|
|
545
|
+
* @property {boolean} parseOutput
|
|
546
|
+
* @property {libClient | undefined} sdk
|
|
547
|
+
*/
|
|
548
|
+
|
|
549
|
+
/**
|
|
550
|
+
* @param {StorageDeleteFileRequestParams} params
|
|
551
|
+
*/
|
|
552
|
+
const storageDeleteFile = async ({bucketId,fileId,parseOutput = true, overrideForCli = false, sdk = undefined}) => {
|
|
553
|
+
let client = !sdk ? await sdkForProject() :
|
|
554
|
+
sdk;
|
|
555
|
+
let apiPath = '/storage/buckets/{bucketId}/files/{fileId}'.replace('{bucketId}', bucketId).replace('{fileId}', fileId);
|
|
556
|
+
let payload = {};
|
|
557
|
+
|
|
558
|
+
let response = undefined;
|
|
559
|
+
|
|
560
|
+
response = await client.call('delete', apiPath, {
|
|
561
|
+
'content-type': 'application/json',
|
|
562
|
+
}, payload);
|
|
563
|
+
|
|
564
|
+
if (parseOutput) {
|
|
565
|
+
parse(response)
|
|
566
|
+
}
|
|
567
|
+
|
|
568
|
+
return response;
|
|
569
|
+
|
|
570
|
+
}
|
|
571
|
+
|
|
572
|
+
/**
|
|
573
|
+
* @typedef {Object} StorageGetFileDownloadRequestParams
|
|
574
|
+
* @property {string} bucketId Storage bucket ID. You can create a new storage bucket using the Storage service [server integration](https://appwrite.io/docs/server/storage#createBucket).
|
|
575
|
+
* @property {string} fileId File ID.
|
|
576
|
+
* @property {string} token File token for accessing this file.
|
|
577
|
+
* @property {boolean} overrideForCli
|
|
578
|
+
* @property {boolean} parseOutput
|
|
579
|
+
* @property {libClient | undefined} sdk
|
|
580
|
+
* @property {string} destination
|
|
581
|
+
*/
|
|
582
|
+
|
|
583
|
+
/**
|
|
584
|
+
* @param {StorageGetFileDownloadRequestParams} params
|
|
585
|
+
*/
|
|
586
|
+
const storageGetFileDownload = async ({bucketId,fileId,token,parseOutput = true, overrideForCli = false, sdk = undefined, destination}) => {
|
|
587
|
+
let client = !sdk ? await sdkForProject() :
|
|
588
|
+
sdk;
|
|
589
|
+
let apiPath = '/storage/buckets/{bucketId}/files/{fileId}/download'.replace('{bucketId}', bucketId).replace('{fileId}', fileId);
|
|
590
|
+
let payload = {};
|
|
591
|
+
if (typeof token !== 'undefined') {
|
|
592
|
+
payload['token'] = token;
|
|
593
|
+
}
|
|
594
|
+
if (!overrideForCli) {
|
|
595
|
+
payload['project'] = localConfig.getProject().projectId
|
|
596
|
+
payload['key'] = globalConfig.getKey();
|
|
597
|
+
const queryParams = new URLSearchParams(payload);
|
|
598
|
+
apiPath = `${globalConfig.getEndpoint()}${apiPath}?${queryParams.toString()}`;
|
|
599
|
+
}
|
|
600
|
+
|
|
601
|
+
let response = undefined;
|
|
602
|
+
|
|
603
|
+
response = await client.call('get', apiPath, {
|
|
604
|
+
}, payload, 'arraybuffer');
|
|
605
|
+
|
|
606
|
+
if (overrideForCli) {
|
|
607
|
+
response = Buffer.from(response);
|
|
608
|
+
}
|
|
609
|
+
|
|
610
|
+
fs.writeFileSync(destination, response);
|
|
611
|
+
if (parseOutput) {
|
|
612
|
+
parse(response)
|
|
613
|
+
}
|
|
614
|
+
|
|
615
|
+
return response;
|
|
616
|
+
|
|
617
|
+
}
|
|
618
|
+
|
|
619
|
+
/**
|
|
620
|
+
* @typedef {Object} StorageGetFilePreviewRequestParams
|
|
621
|
+
* @property {string} bucketId Storage bucket unique ID. You can create a new storage bucket using the Storage service [server integration](https://appwrite.io/docs/server/storage#createBucket).
|
|
622
|
+
* @property {string} fileId File ID
|
|
623
|
+
* @property {number} width Resize preview image width, Pass an integer between 0 to 4000.
|
|
624
|
+
* @property {number} height Resize preview image height, Pass an integer between 0 to 4000.
|
|
625
|
+
* @property {ImageGravity} gravity Image crop gravity. Can be one of center,top-left,top,top-right,left,right,bottom-left,bottom,bottom-right
|
|
626
|
+
* @property {number} quality Preview image quality. Pass an integer between 0 to 100. Defaults to keep existing image quality.
|
|
627
|
+
* @property {number} borderWidth Preview image border in pixels. Pass an integer between 0 to 100. Defaults to 0.
|
|
628
|
+
* @property {string} borderColor Preview image border color. Use a valid HEX color, no # is needed for prefix.
|
|
629
|
+
* @property {number} borderRadius Preview image border radius in pixels. Pass an integer between 0 to 4000.
|
|
630
|
+
* @property {number} opacity Preview image opacity. Only works with images having an alpha channel (like png). Pass a number between 0 to 1.
|
|
631
|
+
* @property {number} rotation Preview image rotation in degrees. Pass an integer between -360 and 360.
|
|
632
|
+
* @property {string} background Preview image background color. Only works with transparent images (png). Use a valid HEX color, no # is needed for prefix.
|
|
633
|
+
* @property {ImageFormat} output Output format type (jpeg, jpg, png, gif and webp).
|
|
634
|
+
* @property {string} token File token for accessing this file.
|
|
635
|
+
* @property {boolean} overrideForCli
|
|
636
|
+
* @property {boolean} parseOutput
|
|
637
|
+
* @property {libClient | undefined} sdk
|
|
638
|
+
* @property {string} destination
|
|
639
|
+
*/
|
|
640
|
+
|
|
641
|
+
/**
|
|
642
|
+
* @param {StorageGetFilePreviewRequestParams} params
|
|
643
|
+
*/
|
|
644
|
+
const storageGetFilePreview = async ({bucketId,fileId,width,height,gravity,quality,borderWidth,borderColor,borderRadius,opacity,rotation,background,output,token,parseOutput = true, overrideForCli = false, sdk = undefined, destination}) => {
|
|
645
|
+
let client = !sdk ? await sdkForProject() :
|
|
646
|
+
sdk;
|
|
647
|
+
let apiPath = '/storage/buckets/{bucketId}/files/{fileId}/preview'.replace('{bucketId}', bucketId).replace('{fileId}', fileId);
|
|
648
|
+
let payload = {};
|
|
649
|
+
if (typeof width !== 'undefined') {
|
|
650
|
+
payload['width'] = width;
|
|
651
|
+
}
|
|
652
|
+
if (typeof height !== 'undefined') {
|
|
653
|
+
payload['height'] = height;
|
|
654
|
+
}
|
|
655
|
+
if (typeof gravity !== 'undefined') {
|
|
656
|
+
payload['gravity'] = gravity;
|
|
657
|
+
}
|
|
658
|
+
if (typeof quality !== 'undefined') {
|
|
659
|
+
payload['quality'] = quality;
|
|
660
|
+
}
|
|
661
|
+
if (typeof borderWidth !== 'undefined') {
|
|
662
|
+
payload['borderWidth'] = borderWidth;
|
|
663
|
+
}
|
|
664
|
+
if (typeof borderColor !== 'undefined') {
|
|
665
|
+
payload['borderColor'] = borderColor;
|
|
666
|
+
}
|
|
667
|
+
if (typeof borderRadius !== 'undefined') {
|
|
668
|
+
payload['borderRadius'] = borderRadius;
|
|
669
|
+
}
|
|
670
|
+
if (typeof opacity !== 'undefined') {
|
|
671
|
+
payload['opacity'] = opacity;
|
|
672
|
+
}
|
|
673
|
+
if (typeof rotation !== 'undefined') {
|
|
674
|
+
payload['rotation'] = rotation;
|
|
675
|
+
}
|
|
676
|
+
if (typeof background !== 'undefined') {
|
|
677
|
+
payload['background'] = background;
|
|
678
|
+
}
|
|
679
|
+
if (typeof output !== 'undefined') {
|
|
680
|
+
payload['output'] = output;
|
|
681
|
+
}
|
|
682
|
+
if (typeof token !== 'undefined') {
|
|
683
|
+
payload['token'] = token;
|
|
684
|
+
}
|
|
685
|
+
if (!overrideForCli) {
|
|
686
|
+
payload['project'] = localConfig.getProject().projectId
|
|
687
|
+
payload['key'] = globalConfig.getKey();
|
|
688
|
+
const queryParams = new URLSearchParams(payload);
|
|
689
|
+
apiPath = `${globalConfig.getEndpoint()}${apiPath}?${queryParams.toString()}`;
|
|
690
|
+
}
|
|
691
|
+
|
|
692
|
+
let response = undefined;
|
|
693
|
+
|
|
694
|
+
response = await client.call('get', apiPath, {
|
|
695
|
+
}, payload, 'arraybuffer');
|
|
696
|
+
|
|
697
|
+
if (overrideForCli) {
|
|
698
|
+
response = Buffer.from(response);
|
|
699
|
+
}
|
|
700
|
+
|
|
701
|
+
fs.writeFileSync(destination, response);
|
|
702
|
+
if (parseOutput) {
|
|
703
|
+
parse(response)
|
|
704
|
+
}
|
|
705
|
+
|
|
706
|
+
return response;
|
|
707
|
+
|
|
708
|
+
}
|
|
709
|
+
|
|
710
|
+
/**
|
|
711
|
+
* @typedef {Object} StorageGetFileViewRequestParams
|
|
712
|
+
* @property {string} bucketId Storage bucket unique ID. You can create a new storage bucket using the Storage service [server integration](https://appwrite.io/docs/server/storage#createBucket).
|
|
713
|
+
* @property {string} fileId File ID.
|
|
714
|
+
* @property {string} token File token for accessing this file.
|
|
715
|
+
* @property {boolean} overrideForCli
|
|
716
|
+
* @property {boolean} parseOutput
|
|
717
|
+
* @property {libClient | undefined} sdk
|
|
718
|
+
* @property {string} destination
|
|
719
|
+
*/
|
|
720
|
+
|
|
721
|
+
/**
|
|
722
|
+
* @param {StorageGetFileViewRequestParams} params
|
|
723
|
+
*/
|
|
724
|
+
const storageGetFileView = async ({bucketId,fileId,token,parseOutput = true, overrideForCli = false, sdk = undefined, destination}) => {
|
|
725
|
+
let client = !sdk ? await sdkForProject() :
|
|
726
|
+
sdk;
|
|
727
|
+
let apiPath = '/storage/buckets/{bucketId}/files/{fileId}/view'.replace('{bucketId}', bucketId).replace('{fileId}', fileId);
|
|
728
|
+
let payload = {};
|
|
729
|
+
if (typeof token !== 'undefined') {
|
|
730
|
+
payload['token'] = token;
|
|
731
|
+
}
|
|
732
|
+
if (!overrideForCli) {
|
|
733
|
+
payload['project'] = localConfig.getProject().projectId
|
|
734
|
+
payload['key'] = globalConfig.getKey();
|
|
735
|
+
const queryParams = new URLSearchParams(payload);
|
|
736
|
+
apiPath = `${globalConfig.getEndpoint()}${apiPath}?${queryParams.toString()}`;
|
|
737
|
+
}
|
|
738
|
+
|
|
739
|
+
let response = undefined;
|
|
740
|
+
|
|
741
|
+
response = await client.call('get', apiPath, {
|
|
742
|
+
}, payload, 'arraybuffer');
|
|
743
|
+
|
|
744
|
+
if (overrideForCli) {
|
|
745
|
+
response = Buffer.from(response);
|
|
746
|
+
}
|
|
747
|
+
|
|
748
|
+
fs.writeFileSync(destination, response);
|
|
749
|
+
if (parseOutput) {
|
|
750
|
+
parse(response)
|
|
751
|
+
}
|
|
752
|
+
|
|
753
|
+
return response;
|
|
754
|
+
|
|
755
|
+
}
|
|
756
|
+
|
|
757
|
+
/**
|
|
758
|
+
* @typedef {Object} StorageGetUsageRequestParams
|
|
759
|
+
* @property {StorageUsageRange} range Date range.
|
|
760
|
+
* @property {boolean} overrideForCli
|
|
761
|
+
* @property {boolean} parseOutput
|
|
762
|
+
* @property {libClient | undefined} sdk
|
|
763
|
+
*/
|
|
764
|
+
|
|
765
|
+
/**
|
|
766
|
+
* @param {StorageGetUsageRequestParams} params
|
|
767
|
+
*/
|
|
768
|
+
const storageGetUsage = async ({range,parseOutput = true, overrideForCli = false, sdk = undefined}) => {
|
|
769
|
+
let client = !sdk ? await sdkForProject() :
|
|
770
|
+
sdk;
|
|
771
|
+
let apiPath = '/storage/usage';
|
|
772
|
+
let payload = {};
|
|
773
|
+
if (typeof range !== 'undefined') {
|
|
774
|
+
payload['range'] = range;
|
|
775
|
+
}
|
|
776
|
+
|
|
777
|
+
let response = undefined;
|
|
778
|
+
|
|
779
|
+
response = await client.call('get', apiPath, {
|
|
780
|
+
}, payload);
|
|
781
|
+
|
|
782
|
+
if (parseOutput) {
|
|
783
|
+
parse(response)
|
|
784
|
+
}
|
|
785
|
+
|
|
786
|
+
return response;
|
|
787
|
+
|
|
788
|
+
}
|
|
789
|
+
|
|
790
|
+
/**
|
|
791
|
+
* @typedef {Object} StorageGetBucketUsageRequestParams
|
|
792
|
+
* @property {string} bucketId Bucket ID.
|
|
793
|
+
* @property {StorageUsageRange} range Date range.
|
|
794
|
+
* @property {boolean} overrideForCli
|
|
795
|
+
* @property {boolean} parseOutput
|
|
796
|
+
* @property {libClient | undefined} sdk
|
|
797
|
+
*/
|
|
798
|
+
|
|
799
|
+
/**
|
|
800
|
+
* @param {StorageGetBucketUsageRequestParams} params
|
|
801
|
+
*/
|
|
802
|
+
const storageGetBucketUsage = async ({bucketId,range,parseOutput = true, overrideForCli = false, sdk = undefined, console}) => {
|
|
803
|
+
let client = !sdk ? await sdkForProject() :
|
|
804
|
+
sdk;
|
|
805
|
+
let apiPath = '/storage/{bucketId}/usage'.replace('{bucketId}', bucketId);
|
|
806
|
+
let payload = {};
|
|
807
|
+
if (typeof range !== 'undefined') {
|
|
808
|
+
payload['range'] = range;
|
|
809
|
+
}
|
|
810
|
+
|
|
811
|
+
let response = undefined;
|
|
812
|
+
|
|
813
|
+
response = await client.call('get', apiPath, {
|
|
814
|
+
}, payload);
|
|
815
|
+
|
|
816
|
+
if (parseOutput) {
|
|
817
|
+
if(console) {
|
|
818
|
+
showConsoleLink('storage', 'getBucketUsage', bucketId);
|
|
819
|
+
} else {
|
|
820
|
+
parse(response)
|
|
821
|
+
}
|
|
822
|
+
}
|
|
823
|
+
|
|
824
|
+
return response;
|
|
825
|
+
|
|
826
|
+
}
|
|
827
|
+
|
|
828
|
+
storage
|
|
829
|
+
.command(`list-buckets`)
|
|
830
|
+
.description(`Get a list of all the storage buckets. You can use the query params to filter your results.`)
|
|
831
|
+
.option(`--queries [queries...]`, `Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: enabled, name, fileSecurity, maximumFileSize, encryption, antivirus`)
|
|
832
|
+
.option(`--search <search>`, `Search term to filter your list results. Max length: 256 chars.`)
|
|
833
|
+
.option(`--console`, `Get the resource console url`)
|
|
834
|
+
.action(actionRunner(storageListBuckets))
|
|
835
|
+
|
|
836
|
+
storage
|
|
837
|
+
.command(`create-bucket`)
|
|
838
|
+
.description(`Create a new storage bucket.`)
|
|
839
|
+
.requiredOption(`--bucket-id <bucket-id>`, `Unique Id. Choose a custom ID or generate a random ID with 'ID.unique()'. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars.`)
|
|
840
|
+
.requiredOption(`--name <name>`, `Bucket name`)
|
|
841
|
+
.option(`--permissions [permissions...]`, `An array of permission strings. By default, no user is granted with any permissions. [Learn more about permissions](https://appwrite.io/docs/permissions).`)
|
|
842
|
+
.option(`--file-security [value]`, `Enables configuring permissions for individual file. A user needs one of file or bucket level permissions to access a file. [Learn more about permissions](https://appwrite.io/docs/permissions).`, (value) => value === undefined ? true : parseBool(value))
|
|
843
|
+
.option(`--enabled [value]`, `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.`, (value) => value === undefined ? true : parseBool(value))
|
|
844
|
+
.option(`--maximum-file-size <maximum-file-size>`, `Maximum file size allowed in bytes. Maximum allowed value is 30MB.`, parseInteger)
|
|
845
|
+
.option(`--allowed-file-extensions [allowed-file-extensions...]`, `Allowed file extensions. Maximum of 100 extensions are allowed, each 64 characters long.`)
|
|
846
|
+
.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`)
|
|
847
|
+
.option(`--encryption [value]`, `Is encryption enabled? For file size above 20MB encryption is skipped even if it's enabled`, (value) => value === undefined ? true : parseBool(value))
|
|
848
|
+
.option(`--antivirus [value]`, `Is virus scanning enabled? For file size above 20MB AntiVirus scanning is skipped even if it's enabled`, (value) => value === undefined ? true : parseBool(value))
|
|
849
|
+
.action(actionRunner(storageCreateBucket))
|
|
850
|
+
|
|
851
|
+
storage
|
|
852
|
+
.command(`get-bucket`)
|
|
853
|
+
.description(`Get a storage bucket by its unique ID. This endpoint response returns a JSON object with the storage bucket metadata.`)
|
|
854
|
+
.requiredOption(`--bucket-id <bucket-id>`, `Bucket unique ID.`)
|
|
855
|
+
.option(`--console`, `Get the resource console url`)
|
|
856
|
+
.action(actionRunner(storageGetBucket))
|
|
857
|
+
|
|
858
|
+
storage
|
|
859
|
+
.command(`update-bucket`)
|
|
860
|
+
.description(`Update a storage bucket by its unique ID.`)
|
|
861
|
+
.requiredOption(`--bucket-id <bucket-id>`, `Bucket unique ID.`)
|
|
862
|
+
.requiredOption(`--name <name>`, `Bucket name`)
|
|
863
|
+
.option(`--permissions [permissions...]`, `An array of permission strings. By default, the current permissions are inherited. [Learn more about permissions](https://appwrite.io/docs/permissions).`)
|
|
864
|
+
.option(`--file-security [value]`, `Enables configuring permissions for individual file. A user needs one of file or bucket level permissions to access a file. [Learn more about permissions](https://appwrite.io/docs/permissions).`, (value) => value === undefined ? true : parseBool(value))
|
|
865
|
+
.option(`--enabled [value]`, `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.`, (value) => value === undefined ? true : parseBool(value))
|
|
866
|
+
.option(`--maximum-file-size <maximum-file-size>`, `Maximum file size allowed in bytes. Maximum allowed value is 30MB.`, parseInteger)
|
|
867
|
+
.option(`--allowed-file-extensions [allowed-file-extensions...]`, `Allowed file extensions. Maximum of 100 extensions are allowed, each 64 characters long.`)
|
|
868
|
+
.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`)
|
|
869
|
+
.option(`--encryption [value]`, `Is encryption enabled? For file size above 20MB encryption is skipped even if it's enabled`, (value) => value === undefined ? true : parseBool(value))
|
|
870
|
+
.option(`--antivirus [value]`, `Is virus scanning enabled? For file size above 20MB AntiVirus scanning is skipped even if it's enabled`, (value) => value === undefined ? true : parseBool(value))
|
|
871
|
+
.action(actionRunner(storageUpdateBucket))
|
|
872
|
+
|
|
873
|
+
storage
|
|
874
|
+
.command(`delete-bucket`)
|
|
875
|
+
.description(`Delete a storage bucket by its unique ID.`)
|
|
876
|
+
.requiredOption(`--bucket-id <bucket-id>`, `Bucket unique ID.`)
|
|
877
|
+
.action(actionRunner(storageDeleteBucket))
|
|
878
|
+
|
|
879
|
+
storage
|
|
880
|
+
.command(`list-files`)
|
|
881
|
+
.description(`Get a list of all the user files. You can use the query params to filter your results.`)
|
|
882
|
+
.requiredOption(`--bucket-id <bucket-id>`, `Storage bucket unique ID. You can create a new storage bucket using the Storage service [server integration](https://appwrite.io/docs/server/storage#createBucket).`)
|
|
883
|
+
.option(`--queries [queries...]`, `Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: name, signature, mimeType, sizeOriginal, chunksTotal, chunksUploaded`)
|
|
884
|
+
.option(`--search <search>`, `Search term to filter your list results. Max length: 256 chars.`)
|
|
885
|
+
.option(`--console`, `Get the resource console url`)
|
|
886
|
+
.action(actionRunner(storageListFiles))
|
|
887
|
+
|
|
888
|
+
storage
|
|
889
|
+
.command(`create-file`)
|
|
890
|
+
.description(`Create a new file. Before using this route, you should create a new bucket resource using either a [server integration](https://appwrite.io/docs/server/storage#storageCreateBucket) API or directly from your Appwrite console. Larger files should be uploaded using multiple requests with the [content-range](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Range) header to send a partial request with a maximum supported chunk of '5MB'. The 'content-range' header values should always be in bytes. When the first request is sent, the server will return the **File** object, and the subsequent part request must include the file's **id** in 'x-appwrite-id' header to allow the server to know that the partial upload is for the existing file and not for a new one. If you're creating a new file using one of the Appwrite SDKs, all the chunking logic will be managed by the SDK internally. `)
|
|
891
|
+
.requiredOption(`--bucket-id <bucket-id>`, `Storage bucket unique ID. You can create a new storage bucket using the Storage service [server integration](https://appwrite.io/docs/server/storage#createBucket).`)
|
|
892
|
+
.requiredOption(`--file-id <file-id>`, `File ID. Choose a custom ID or generate a random ID with 'ID.unique()'. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars.`)
|
|
893
|
+
.requiredOption(`--file <file>`, `Binary file. Appwrite SDKs provide helpers to handle file input. [Learn about file input](https://appwrite.io/docs/products/storage/upload-download#input-file).`)
|
|
894
|
+
.option(`--permissions [permissions...]`, `An array of permission strings. By default, only the current user is granted all permissions. [Learn more about permissions](https://appwrite.io/docs/permissions).`)
|
|
895
|
+
.action(actionRunner(storageCreateFile))
|
|
896
|
+
|
|
897
|
+
storage
|
|
898
|
+
.command(`get-file`)
|
|
899
|
+
.description(`Get a file by its unique ID. This endpoint response returns a JSON object with the file metadata.`)
|
|
900
|
+
.requiredOption(`--bucket-id <bucket-id>`, `Storage bucket unique ID. You can create a new storage bucket using the Storage service [server integration](https://appwrite.io/docs/server/storage#createBucket).`)
|
|
901
|
+
.requiredOption(`--file-id <file-id>`, `File ID.`)
|
|
902
|
+
.option(`--console`, `Get the resource console url`)
|
|
903
|
+
.action(actionRunner(storageGetFile))
|
|
904
|
+
|
|
905
|
+
storage
|
|
906
|
+
.command(`update-file`)
|
|
907
|
+
.description(`Update a file by its unique ID. Only users with write permissions have access to update this resource.`)
|
|
908
|
+
.requiredOption(`--bucket-id <bucket-id>`, `Storage bucket unique ID. You can create a new storage bucket using the Storage service [server integration](https://appwrite.io/docs/server/storage#createBucket).`)
|
|
909
|
+
.requiredOption(`--file-id <file-id>`, `File unique ID.`)
|
|
910
|
+
.option(`--name <name>`, `Name of the file`)
|
|
911
|
+
.option(`--permissions [permissions...]`, `An array of permission string. By default, the current permissions are inherited. [Learn more about permissions](https://appwrite.io/docs/permissions).`)
|
|
912
|
+
.action(actionRunner(storageUpdateFile))
|
|
913
|
+
|
|
914
|
+
storage
|
|
915
|
+
.command(`delete-file`)
|
|
916
|
+
.description(`Delete a file by its unique ID. Only users with write permissions have access to delete this resource.`)
|
|
917
|
+
.requiredOption(`--bucket-id <bucket-id>`, `Storage bucket unique ID. You can create a new storage bucket using the Storage service [server integration](https://appwrite.io/docs/server/storage#createBucket).`)
|
|
918
|
+
.requiredOption(`--file-id <file-id>`, `File ID.`)
|
|
919
|
+
.action(actionRunner(storageDeleteFile))
|
|
920
|
+
|
|
921
|
+
storage
|
|
922
|
+
.command(`get-file-download`)
|
|
923
|
+
.description(`Get a file content by its unique ID. The endpoint response return with a 'Content-Disposition: attachment' header that tells the browser to start downloading the file to user downloads directory.`)
|
|
924
|
+
.requiredOption(`--bucket-id <bucket-id>`, `Storage bucket ID. You can create a new storage bucket using the Storage service [server integration](https://appwrite.io/docs/server/storage#createBucket).`)
|
|
925
|
+
.requiredOption(`--file-id <file-id>`, `File ID.`)
|
|
926
|
+
.option(`--token <token>`, `File token for accessing this file.`)
|
|
927
|
+
.requiredOption(`--destination <path>`, `output file path.`)
|
|
928
|
+
.action(actionRunner(storageGetFileDownload))
|
|
929
|
+
|
|
930
|
+
storage
|
|
931
|
+
.command(`get-file-preview`)
|
|
932
|
+
.description(`Get a file preview image. Currently, this method supports preview for image files (jpg, png, and gif), other supported formats, like pdf, docs, slides, and spreadsheets, will return the file icon image. You can also pass query string arguments for cutting and resizing your preview image. Preview is supported only for image files smaller than 10MB.`)
|
|
933
|
+
.requiredOption(`--bucket-id <bucket-id>`, `Storage bucket unique ID. You can create a new storage bucket using the Storage service [server integration](https://appwrite.io/docs/server/storage#createBucket).`)
|
|
934
|
+
.requiredOption(`--file-id <file-id>`, `File ID`)
|
|
935
|
+
.option(`--width <width>`, `Resize preview image width, Pass an integer between 0 to 4000.`, parseInteger)
|
|
936
|
+
.option(`--height <height>`, `Resize preview image height, Pass an integer between 0 to 4000.`, parseInteger)
|
|
937
|
+
.option(`--gravity <gravity>`, `Image crop gravity. Can be one of center,top-left,top,top-right,left,right,bottom-left,bottom,bottom-right`)
|
|
938
|
+
.option(`--quality <quality>`, `Preview image quality. Pass an integer between 0 to 100. Defaults to keep existing image quality.`, parseInteger)
|
|
939
|
+
.option(`--border-width <border-width>`, `Preview image border in pixels. Pass an integer between 0 to 100. Defaults to 0.`, parseInteger)
|
|
940
|
+
.option(`--border-color <border-color>`, `Preview image border color. Use a valid HEX color, no # is needed for prefix.`)
|
|
941
|
+
.option(`--border-radius <border-radius>`, `Preview image border radius in pixels. Pass an integer between 0 to 4000.`, parseInteger)
|
|
942
|
+
.option(`--opacity <opacity>`, `Preview image opacity. Only works with images having an alpha channel (like png). Pass a number between 0 to 1.`, parseInteger)
|
|
943
|
+
.option(`--rotation <rotation>`, `Preview image rotation in degrees. Pass an integer between -360 and 360.`, parseInteger)
|
|
944
|
+
.option(`--background <background>`, `Preview image background color. Only works with transparent images (png). Use a valid HEX color, no # is needed for prefix.`)
|
|
945
|
+
.option(`--output <output>`, `Output format type (jpeg, jpg, png, gif and webp).`)
|
|
946
|
+
.option(`--token <token>`, `File token for accessing this file.`)
|
|
947
|
+
.requiredOption(`--destination <path>`, `output file path.`)
|
|
948
|
+
.action(actionRunner(storageGetFilePreview))
|
|
949
|
+
|
|
950
|
+
storage
|
|
951
|
+
.command(`get-file-view`)
|
|
952
|
+
.description(`Get a file content by its unique ID. This endpoint is similar to the download method but returns with no 'Content-Disposition: attachment' header.`)
|
|
953
|
+
.requiredOption(`--bucket-id <bucket-id>`, `Storage bucket unique ID. You can create a new storage bucket using the Storage service [server integration](https://appwrite.io/docs/server/storage#createBucket).`)
|
|
954
|
+
.requiredOption(`--file-id <file-id>`, `File ID.`)
|
|
955
|
+
.option(`--token <token>`, `File token for accessing this file.`)
|
|
956
|
+
.requiredOption(`--destination <path>`, `output file path.`)
|
|
957
|
+
.action(actionRunner(storageGetFileView))
|
|
958
|
+
|
|
959
|
+
storage
|
|
960
|
+
.command(`get-usage`)
|
|
961
|
+
.description(`Get usage metrics and statistics for all buckets in the project. You can view the total number of buckets, files, storage usage. The response includes both current totals and historical data over time. Use the optional range parameter to specify the time window for historical data: 24h (last 24 hours), 30d (last 30 days), or 90d (last 90 days). If not specified, range defaults to 30 days. `)
|
|
962
|
+
.option(`--range <range>`, `Date range.`)
|
|
963
|
+
.action(actionRunner(storageGetUsage))
|
|
964
|
+
|
|
965
|
+
storage
|
|
966
|
+
.command(`get-bucket-usage`)
|
|
967
|
+
.description(`Get usage metrics and statistics a specific bucket in the project. You can view the total number of files, storage usage. The response includes both current totals and historical data over time. Use the optional range parameter to specify the time window for historical data: 24h (last 24 hours), 30d (last 30 days), or 90d (last 90 days). If not specified, range defaults to 30 days. `)
|
|
968
|
+
.requiredOption(`--bucket-id <bucket-id>`, `Bucket ID.`)
|
|
969
|
+
.option(`--range <range>`, `Date range.`)
|
|
970
|
+
.option(`--console`, `Get the resource console url`)
|
|
971
|
+
.action(actionRunner(storageGetBucketUsage))
|
|
972
|
+
|
|
973
|
+
module.exports = {
|
|
974
|
+
storage,
|
|
975
|
+
storageListBuckets,
|
|
976
|
+
storageCreateBucket,
|
|
977
|
+
storageGetBucket,
|
|
978
|
+
storageUpdateBucket,
|
|
979
|
+
storageDeleteBucket,
|
|
980
|
+
storageListFiles,
|
|
981
|
+
storageCreateFile,
|
|
982
|
+
storageGetFile,
|
|
983
|
+
storageUpdateFile,
|
|
984
|
+
storageDeleteFile,
|
|
985
|
+
storageGetFileDownload,
|
|
986
|
+
storageGetFilePreview,
|
|
987
|
+
storageGetFileView,
|
|
988
|
+
storageGetUsage,
|
|
989
|
+
storageGetBucketUsage
|
|
990
|
+
};
|