@appwrite.io/console 8.0.0 → 8.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/cjs/sdk.js +12 -1
- package/dist/cjs/sdk.js.map +1 -1
- package/dist/esm/sdk.js +12 -1
- package/dist/esm/sdk.js.map +1 -1
- package/dist/iife/sdk.js +12 -1
- package/package.json +5 -1
- package/types/client.d.ts +9 -0
- package/types/models.d.ts +119 -0
- package/types/services/vcs.d.ts +8 -8
- package/.github/workflows/autoclose.yml +0 -11
- package/.github/workflows/publish.yml +0 -43
- package/CHANGELOG.md +0 -161
- package/docs/examples/account/create-anonymous-session.md +0 -13
- package/docs/examples/account/create-billing-address.md +0 -20
- package/docs/examples/account/create-email-password-session.md +0 -16
- package/docs/examples/account/create-email-token.md +0 -17
- package/docs/examples/account/create-email-verification.md +0 -15
- package/docs/examples/account/create-jwt.md +0 -15
- package/docs/examples/account/create-key.md +0 -17
- package/docs/examples/account/create-magic-url-token.md +0 -18
- package/docs/examples/account/create-mfa-authenticator.md +0 -15
- package/docs/examples/account/create-mfa-challenge.md +0 -15
- package/docs/examples/account/create-mfa-recovery-codes.md +0 -13
- package/docs/examples/account/create-o-auth-2-session.md +0 -17
- package/docs/examples/account/create-o-auth-2-token.md +0 -17
- package/docs/examples/account/create-payment-method.md +0 -13
- package/docs/examples/account/create-phone-token.md +0 -16
- package/docs/examples/account/create-phone-verification.md +0 -13
- package/docs/examples/account/create-push-target.md +0 -17
- package/docs/examples/account/create-recovery.md +0 -16
- package/docs/examples/account/create-session.md +0 -16
- package/docs/examples/account/create-verification.md +0 -15
- package/docs/examples/account/create.md +0 -18
- package/docs/examples/account/delete-billing-address.md +0 -15
- package/docs/examples/account/delete-identity.md +0 -15
- package/docs/examples/account/delete-key.md +0 -15
- package/docs/examples/account/delete-mfa-authenticator.md +0 -15
- package/docs/examples/account/delete-payment-method.md +0 -15
- package/docs/examples/account/delete-push-target.md +0 -15
- package/docs/examples/account/delete-session.md +0 -15
- package/docs/examples/account/delete-sessions.md +0 -13
- package/docs/examples/account/delete.md +0 -13
- package/docs/examples/account/get-billing-address.md +0 -15
- package/docs/examples/account/get-coupon.md +0 -15
- package/docs/examples/account/get-key.md +0 -15
- package/docs/examples/account/get-mfa-recovery-codes.md +0 -13
- package/docs/examples/account/get-payment-method.md +0 -15
- package/docs/examples/account/get-prefs.md +0 -13
- package/docs/examples/account/get-session.md +0 -15
- package/docs/examples/account/get.md +0 -13
- package/docs/examples/account/list-billing-addresses.md +0 -15
- package/docs/examples/account/list-identities.md +0 -16
- package/docs/examples/account/list-invoices.md +0 -15
- package/docs/examples/account/list-keys.md +0 -15
- package/docs/examples/account/list-logs.md +0 -16
- package/docs/examples/account/list-mfa-factors.md +0 -13
- package/docs/examples/account/list-payment-methods.md +0 -15
- package/docs/examples/account/list-sessions.md +0 -13
- package/docs/examples/account/update-billing-address.md +0 -21
- package/docs/examples/account/update-email-verification.md +0 -16
- package/docs/examples/account/update-email.md +0 -16
- package/docs/examples/account/update-key.md +0 -18
- package/docs/examples/account/update-magic-url-session.md +0 -16
- package/docs/examples/account/update-mfa-authenticator.md +0 -16
- package/docs/examples/account/update-mfa-challenge.md +0 -16
- package/docs/examples/account/update-mfa-recovery-codes.md +0 -13
- package/docs/examples/account/update-mfa.md +0 -15
- package/docs/examples/account/update-name.md +0 -15
- package/docs/examples/account/update-password.md +0 -16
- package/docs/examples/account/update-payment-method-mandate-options.md +0 -15
- package/docs/examples/account/update-payment-method-provider.md +0 -18
- package/docs/examples/account/update-payment-method.md +0 -18
- package/docs/examples/account/update-phone-session.md +0 -16
- package/docs/examples/account/update-phone-verification.md +0 -16
- package/docs/examples/account/update-phone.md +0 -16
- package/docs/examples/account/update-prefs.md +0 -19
- package/docs/examples/account/update-push-target.md +0 -16
- package/docs/examples/account/update-recovery.md +0 -17
- package/docs/examples/account/update-session.md +0 -15
- package/docs/examples/account/update-status.md +0 -13
- package/docs/examples/account/update-verification.md +0 -16
- package/docs/examples/activities/get-event.md +0 -15
- package/docs/examples/activities/list-events.md +0 -15
- package/docs/examples/assistant/chat.md +0 -15
- package/docs/examples/avatars/get-browser.md +0 -18
- package/docs/examples/avatars/get-credit-card.md +0 -18
- package/docs/examples/avatars/get-favicon.md +0 -15
- package/docs/examples/avatars/get-flag.md +0 -18
- package/docs/examples/avatars/get-image.md +0 -17
- package/docs/examples/avatars/get-initials.md +0 -18
- package/docs/examples/avatars/get-qr.md +0 -18
- package/docs/examples/avatars/get-screenshot.md +0 -37
- package/docs/examples/backups/create-archive.md +0 -16
- package/docs/examples/backups/create-policy.md +0 -21
- package/docs/examples/backups/create-restoration.md +0 -18
- package/docs/examples/backups/delete-archive.md +0 -15
- package/docs/examples/backups/delete-policy.md +0 -15
- package/docs/examples/backups/get-archive.md +0 -15
- package/docs/examples/backups/get-policy.md +0 -15
- package/docs/examples/backups/get-restoration.md +0 -15
- package/docs/examples/backups/list-archives.md +0 -15
- package/docs/examples/backups/list-policies.md +0 -15
- package/docs/examples/backups/list-restorations.md +0 -15
- package/docs/examples/backups/update-policy.md +0 -19
- package/docs/examples/console/create-program-membership.md +0 -15
- package/docs/examples/console/create-source.md +0 -19
- package/docs/examples/console/get-campaign.md +0 -15
- package/docs/examples/console/get-coupon.md +0 -15
- package/docs/examples/console/get-plan.md +0 -15
- package/docs/examples/console/get-plans.md +0 -15
- package/docs/examples/console/get-program.md +0 -15
- package/docs/examples/console/get-resource.md +0 -16
- package/docs/examples/console/list-regions.md +0 -13
- package/docs/examples/console/suggest-columns.md +0 -19
- package/docs/examples/console/suggest-indexes.md +0 -18
- package/docs/examples/console/variables.md +0 -13
- package/docs/examples/databases/create-boolean-attribute.md +0 -20
- package/docs/examples/databases/create-collection.md +0 -22
- package/docs/examples/databases/create-datetime-attribute.md +0 -20
- package/docs/examples/databases/create-document.md +0 -26
- package/docs/examples/databases/create-documents.md +0 -18
- package/docs/examples/databases/create-email-attribute.md +0 -20
- package/docs/examples/databases/create-enum-attribute.md +0 -21
- package/docs/examples/databases/create-float-attribute.md +0 -22
- package/docs/examples/databases/create-index.md +0 -21
- package/docs/examples/databases/create-integer-attribute.md +0 -22
- package/docs/examples/databases/create-ip-attribute.md +0 -20
- package/docs/examples/databases/create-line-attribute.md +0 -19
- package/docs/examples/databases/create-longtext-attribute.md +0 -21
- package/docs/examples/databases/create-mediumtext-attribute.md +0 -21
- package/docs/examples/databases/create-operations.md +0 -26
- package/docs/examples/databases/create-point-attribute.md +0 -19
- package/docs/examples/databases/create-polygon-attribute.md +0 -19
- package/docs/examples/databases/create-relationship-attribute.md +0 -22
- package/docs/examples/databases/create-string-attribute.md +0 -22
- package/docs/examples/databases/create-text-attribute.md +0 -21
- package/docs/examples/databases/create-transaction.md +0 -15
- package/docs/examples/databases/create-url-attribute.md +0 -20
- package/docs/examples/databases/create-varchar-attribute.md +0 -22
- package/docs/examples/databases/create.md +0 -17
- package/docs/examples/databases/decrement-document-attribute.md +0 -21
- package/docs/examples/databases/delete-attribute.md +0 -17
- package/docs/examples/databases/delete-collection.md +0 -16
- package/docs/examples/databases/delete-document.md +0 -18
- package/docs/examples/databases/delete-documents.md +0 -18
- package/docs/examples/databases/delete-index.md +0 -17
- package/docs/examples/databases/delete-transaction.md +0 -15
- package/docs/examples/databases/delete.md +0 -15
- package/docs/examples/databases/get-attribute.md +0 -17
- package/docs/examples/databases/get-collection-usage.md +0 -17
- package/docs/examples/databases/get-collection.md +0 -16
- package/docs/examples/databases/get-document.md +0 -19
- package/docs/examples/databases/get-index.md +0 -17
- package/docs/examples/databases/get-transaction.md +0 -15
- package/docs/examples/databases/get-usage.md +0 -16
- package/docs/examples/databases/get.md +0 -15
- package/docs/examples/databases/increment-document-attribute.md +0 -21
- package/docs/examples/databases/list-attributes.md +0 -18
- package/docs/examples/databases/list-collection-logs.md +0 -17
- package/docs/examples/databases/list-collections.md +0 -18
- package/docs/examples/databases/list-document-logs.md +0 -18
- package/docs/examples/databases/list-documents.md +0 -20
- package/docs/examples/databases/list-indexes.md +0 -18
- package/docs/examples/databases/list-logs.md +0 -16
- package/docs/examples/databases/list-transactions.md +0 -15
- package/docs/examples/databases/list-usage.md +0 -15
- package/docs/examples/databases/list.md +0 -17
- package/docs/examples/databases/update-boolean-attribute.md +0 -20
- package/docs/examples/databases/update-collection.md +0 -20
- package/docs/examples/databases/update-datetime-attribute.md +0 -20
- package/docs/examples/databases/update-document.md +0 -26
- package/docs/examples/databases/update-documents.md +0 -25
- package/docs/examples/databases/update-email-attribute.md +0 -20
- package/docs/examples/databases/update-enum-attribute.md +0 -21
- package/docs/examples/databases/update-float-attribute.md +0 -22
- package/docs/examples/databases/update-integer-attribute.md +0 -22
- package/docs/examples/databases/update-ip-attribute.md +0 -20
- package/docs/examples/databases/update-line-attribute.md +0 -20
- package/docs/examples/databases/update-longtext-attribute.md +0 -20
- package/docs/examples/databases/update-mediumtext-attribute.md +0 -20
- package/docs/examples/databases/update-point-attribute.md +0 -20
- package/docs/examples/databases/update-polygon-attribute.md +0 -20
- package/docs/examples/databases/update-relationship-attribute.md +0 -19
- package/docs/examples/databases/update-string-attribute.md +0 -21
- package/docs/examples/databases/update-text-attribute.md +0 -20
- package/docs/examples/databases/update-transaction.md +0 -17
- package/docs/examples/databases/update-url-attribute.md +0 -20
- package/docs/examples/databases/update-varchar-attribute.md +0 -21
- package/docs/examples/databases/update.md +0 -17
- package/docs/examples/databases/upsert-document.md +0 -26
- package/docs/examples/databases/upsert-documents.md +0 -18
- package/docs/examples/domains/create-preset-google-workspace.md +0 -15
- package/docs/examples/domains/create-preset-i-cloud.md +0 -15
- package/docs/examples/domains/create-preset-mailgun.md +0 -15
- package/docs/examples/domains/create-preset-outlook.md +0 -15
- package/docs/examples/domains/create-preset-proton-mail.md +0 -15
- package/docs/examples/domains/create-preset-zoho.md +0 -15
- package/docs/examples/domains/create-purchase.md +0 -26
- package/docs/examples/domains/create-record-a.md +0 -19
- package/docs/examples/domains/create-record-aaaa.md +0 -19
- package/docs/examples/domains/create-record-alias.md +0 -19
- package/docs/examples/domains/create-record-caa.md +0 -19
- package/docs/examples/domains/create-record-cname.md +0 -19
- package/docs/examples/domains/create-record-https.md +0 -19
- package/docs/examples/domains/create-record-mx.md +0 -20
- package/docs/examples/domains/create-record-ns.md +0 -19
- package/docs/examples/domains/create-record-srv.md +0 -22
- package/docs/examples/domains/create-record-txt.md +0 -19
- package/docs/examples/domains/create-transfer-in.md +0 -19
- package/docs/examples/domains/create-transfer-out.md +0 -16
- package/docs/examples/domains/create.md +0 -16
- package/docs/examples/domains/delete-record.md +0 -16
- package/docs/examples/domains/delete.md +0 -15
- package/docs/examples/domains/get-preset-google-workspace.md +0 -15
- package/docs/examples/domains/get-preset-i-cloud.md +0 -15
- package/docs/examples/domains/get-preset-mailgun.md +0 -15
- package/docs/examples/domains/get-preset-outlook.md +0 -15
- package/docs/examples/domains/get-preset-proton-mail.md +0 -15
- package/docs/examples/domains/get-preset-zoho.md +0 -15
- package/docs/examples/domains/get-price.md +0 -17
- package/docs/examples/domains/get-record.md +0 -16
- package/docs/examples/domains/get-transfer-status.md +0 -15
- package/docs/examples/domains/get-zone.md +0 -15
- package/docs/examples/domains/get.md +0 -15
- package/docs/examples/domains/list-records.md +0 -16
- package/docs/examples/domains/list-suggestions.md +0 -20
- package/docs/examples/domains/list.md +0 -16
- package/docs/examples/domains/update-auto-renewal.md +0 -16
- package/docs/examples/domains/update-nameservers.md +0 -15
- package/docs/examples/domains/update-purchase.md +0 -16
- package/docs/examples/domains/update-record-a.md +0 -20
- package/docs/examples/domains/update-record-aaaa.md +0 -20
- package/docs/examples/domains/update-record-alias.md +0 -20
- package/docs/examples/domains/update-record-caa.md +0 -20
- package/docs/examples/domains/update-record-cname.md +0 -20
- package/docs/examples/domains/update-record-https.md +0 -20
- package/docs/examples/domains/update-record-mx.md +0 -21
- package/docs/examples/domains/update-record-ns.md +0 -20
- package/docs/examples/domains/update-record-srv.md +0 -23
- package/docs/examples/domains/update-record-txt.md +0 -20
- package/docs/examples/domains/update-team.md +0 -16
- package/docs/examples/domains/update-transfer-in.md +0 -16
- package/docs/examples/domains/update-zone.md +0 -16
- package/docs/examples/functions/create-deployment.md +0 -19
- package/docs/examples/functions/create-duplicate-deployment.md +0 -17
- package/docs/examples/functions/create-execution.md +0 -21
- package/docs/examples/functions/create-template-deployment.md +0 -21
- package/docs/examples/functions/create-variable.md +0 -18
- package/docs/examples/functions/create-vcs-deployment.md +0 -18
- package/docs/examples/functions/create.md +0 -34
- package/docs/examples/functions/delete-deployment.md +0 -16
- package/docs/examples/functions/delete-execution.md +0 -16
- package/docs/examples/functions/delete-variable.md +0 -16
- package/docs/examples/functions/delete.md +0 -15
- package/docs/examples/functions/get-deployment-download.md +0 -17
- package/docs/examples/functions/get-deployment.md +0 -16
- package/docs/examples/functions/get-execution.md +0 -16
- package/docs/examples/functions/get-template.md +0 -15
- package/docs/examples/functions/get-usage.md +0 -16
- package/docs/examples/functions/get-variable.md +0 -16
- package/docs/examples/functions/get.md +0 -15
- package/docs/examples/functions/list-deployments.md +0 -18
- package/docs/examples/functions/list-executions.md +0 -17
- package/docs/examples/functions/list-runtimes.md +0 -13
- package/docs/examples/functions/list-specifications.md +0 -13
- package/docs/examples/functions/list-templates.md +0 -19
- package/docs/examples/functions/list-usage.md +0 -15
- package/docs/examples/functions/list-variables.md +0 -15
- package/docs/examples/functions/list.md +0 -17
- package/docs/examples/functions/update-deployment-status.md +0 -16
- package/docs/examples/functions/update-function-deployment.md +0 -16
- package/docs/examples/functions/update-variable.md +0 -19
- package/docs/examples/functions/update.md +0 -34
- package/docs/examples/graphql/mutation.md +0 -15
- package/docs/examples/graphql/query.md +0 -15
- package/docs/examples/health/get-antivirus.md +0 -13
- package/docs/examples/health/get-cache.md +0 -13
- package/docs/examples/health/get-certificate.md +0 -15
- package/docs/examples/health/get-console-pausing.md +0 -16
- package/docs/examples/health/get-db.md +0 -13
- package/docs/examples/health/get-failed-jobs.md +0 -16
- package/docs/examples/health/get-pub-sub.md +0 -13
- package/docs/examples/health/get-queue-audits.md +0 -15
- package/docs/examples/health/get-queue-billing-project-aggregation.md +0 -15
- package/docs/examples/health/get-queue-billing-team-aggregation.md +0 -15
- package/docs/examples/health/get-queue-builds.md +0 -15
- package/docs/examples/health/get-queue-certificates.md +0 -15
- package/docs/examples/health/get-queue-databases.md +0 -16
- package/docs/examples/health/get-queue-deletes.md +0 -15
- package/docs/examples/health/get-queue-functions.md +0 -15
- package/docs/examples/health/get-queue-logs.md +0 -15
- package/docs/examples/health/get-queue-mails.md +0 -15
- package/docs/examples/health/get-queue-messaging.md +0 -15
- package/docs/examples/health/get-queue-migrations.md +0 -15
- package/docs/examples/health/get-queue-priority-builds.md +0 -15
- package/docs/examples/health/get-queue-region-manager.md +0 -15
- package/docs/examples/health/get-queue-stats-resources.md +0 -15
- package/docs/examples/health/get-queue-threats.md +0 -15
- package/docs/examples/health/get-queue-usage.md +0 -15
- package/docs/examples/health/get-queue-webhooks.md +0 -15
- package/docs/examples/health/get-storage-local.md +0 -13
- package/docs/examples/health/get-storage.md +0 -13
- package/docs/examples/health/get-time.md +0 -13
- package/docs/examples/health/get.md +0 -13
- package/docs/examples/locale/get.md +0 -13
- package/docs/examples/locale/list-codes.md +0 -13
- package/docs/examples/locale/list-continents.md +0 -13
- package/docs/examples/locale/list-countries-eu.md +0 -13
- package/docs/examples/locale/list-countries-phones.md +0 -13
- package/docs/examples/locale/list-countries.md +0 -13
- package/docs/examples/locale/list-currencies.md +0 -13
- package/docs/examples/locale/list-languages.md +0 -13
- package/docs/examples/messaging/create-apns-provider.md +0 -22
- package/docs/examples/messaging/create-email.md +0 -26
- package/docs/examples/messaging/create-fcm-provider.md +0 -18
- package/docs/examples/messaging/create-mailgun-provider.md +0 -24
- package/docs/examples/messaging/create-msg-91-provider.md +0 -20
- package/docs/examples/messaging/create-push.md +0 -33
- package/docs/examples/messaging/create-resend-provider.md +0 -22
- package/docs/examples/messaging/create-sendgrid-provider.md +0 -22
- package/docs/examples/messaging/create-sms.md +0 -21
- package/docs/examples/messaging/create-smtp-provider.md +0 -28
- package/docs/examples/messaging/create-subscriber.md +0 -17
- package/docs/examples/messaging/create-telesign-provider.md +0 -20
- package/docs/examples/messaging/create-textmagic-provider.md +0 -20
- package/docs/examples/messaging/create-topic.md +0 -17
- package/docs/examples/messaging/create-twilio-provider.md +0 -20
- package/docs/examples/messaging/create-vonage-provider.md +0 -20
- package/docs/examples/messaging/delete-provider.md +0 -15
- package/docs/examples/messaging/delete-subscriber.md +0 -16
- package/docs/examples/messaging/delete-topic.md +0 -15
- package/docs/examples/messaging/delete.md +0 -15
- package/docs/examples/messaging/get-message.md +0 -15
- package/docs/examples/messaging/get-provider.md +0 -15
- package/docs/examples/messaging/get-subscriber.md +0 -16
- package/docs/examples/messaging/get-topic.md +0 -15
- package/docs/examples/messaging/list-message-logs.md +0 -17
- package/docs/examples/messaging/list-messages.md +0 -17
- package/docs/examples/messaging/list-provider-logs.md +0 -17
- package/docs/examples/messaging/list-providers.md +0 -17
- package/docs/examples/messaging/list-subscriber-logs.md +0 -17
- package/docs/examples/messaging/list-subscribers.md +0 -18
- package/docs/examples/messaging/list-targets.md +0 -17
- package/docs/examples/messaging/list-topic-logs.md +0 -17
- package/docs/examples/messaging/list-topics.md +0 -17
- package/docs/examples/messaging/update-apns-provider.md +0 -22
- package/docs/examples/messaging/update-email.md +0 -26
- package/docs/examples/messaging/update-fcm-provider.md +0 -18
- package/docs/examples/messaging/update-mailgun-provider.md +0 -24
- package/docs/examples/messaging/update-msg-91-provider.md +0 -20
- package/docs/examples/messaging/update-push.md +0 -33
- package/docs/examples/messaging/update-resend-provider.md +0 -22
- package/docs/examples/messaging/update-sendgrid-provider.md +0 -22
- package/docs/examples/messaging/update-sms.md +0 -21
- package/docs/examples/messaging/update-smtp-provider.md +0 -28
- package/docs/examples/messaging/update-telesign-provider.md +0 -20
- package/docs/examples/messaging/update-textmagic-provider.md +0 -20
- package/docs/examples/messaging/update-topic.md +0 -17
- package/docs/examples/messaging/update-twilio-provider.md +0 -20
- package/docs/examples/messaging/update-vonage-provider.md +0 -20
- package/docs/examples/migrations/create-appwrite-migration.md +0 -18
- package/docs/examples/migrations/create-csv-export.md +0 -23
- package/docs/examples/migrations/create-csv-import.md +0 -18
- package/docs/examples/migrations/create-firebase-migration.md +0 -16
- package/docs/examples/migrations/create-n-host-migration.md +0 -22
- package/docs/examples/migrations/create-supabase-migration.md +0 -21
- package/docs/examples/migrations/delete.md +0 -15
- package/docs/examples/migrations/get-appwrite-report.md +0 -18
- package/docs/examples/migrations/get-firebase-report.md +0 -16
- package/docs/examples/migrations/get-n-host-report.md +0 -22
- package/docs/examples/migrations/get-supabase-report.md +0 -21
- package/docs/examples/migrations/get.md +0 -15
- package/docs/examples/migrations/list.md +0 -17
- package/docs/examples/migrations/retry.md +0 -15
- package/docs/examples/organizations/add-credit.md +0 -16
- package/docs/examples/organizations/cancel-downgrade.md +0 -15
- package/docs/examples/organizations/create-downgrade-feedback.md +0 -19
- package/docs/examples/organizations/create-invoice-payment.md +0 -17
- package/docs/examples/organizations/create-key.md +0 -18
- package/docs/examples/organizations/create.md +0 -24
- package/docs/examples/organizations/delete-backup-payment-method.md +0 -15
- package/docs/examples/organizations/delete-billing-address.md +0 -15
- package/docs/examples/organizations/delete-default-payment-method.md +0 -15
- package/docs/examples/organizations/delete-key.md +0 -16
- package/docs/examples/organizations/delete.md +0 -15
- package/docs/examples/organizations/estimation-create-organization.md +0 -19
- package/docs/examples/organizations/estimation-delete-organization.md +0 -15
- package/docs/examples/organizations/estimation-update-plan.md +0 -18
- package/docs/examples/organizations/get-aggregation.md +0 -18
- package/docs/examples/organizations/get-available-credits.md +0 -15
- package/docs/examples/organizations/get-billing-address.md +0 -16
- package/docs/examples/organizations/get-credit.md +0 -16
- package/docs/examples/organizations/get-invoice-download.md +0 -16
- package/docs/examples/organizations/get-invoice-view.md +0 -16
- package/docs/examples/organizations/get-invoice.md +0 -16
- package/docs/examples/organizations/get-key.md +0 -16
- package/docs/examples/organizations/get-payment-method.md +0 -16
- package/docs/examples/organizations/get-plan.md +0 -15
- package/docs/examples/organizations/get-scopes.md +0 -16
- package/docs/examples/organizations/get-usage.md +0 -17
- package/docs/examples/organizations/list-aggregations.md +0 -16
- package/docs/examples/organizations/list-credits.md +0 -16
- package/docs/examples/organizations/list-invoices.md +0 -16
- package/docs/examples/organizations/list-keys.md +0 -16
- package/docs/examples/organizations/list-regions.md +0 -15
- package/docs/examples/organizations/list.md +0 -16
- package/docs/examples/organizations/set-backup-payment-method.md +0 -16
- package/docs/examples/organizations/set-billing-address.md +0 -16
- package/docs/examples/organizations/set-billing-email.md +0 -16
- package/docs/examples/organizations/set-billing-tax-id.md +0 -16
- package/docs/examples/organizations/set-default-payment-method.md +0 -16
- package/docs/examples/organizations/update-budget.md +0 -17
- package/docs/examples/organizations/update-key.md +0 -19
- package/docs/examples/organizations/update-plan.md +0 -22
- package/docs/examples/organizations/validate-invoice.md +0 -16
- package/docs/examples/organizations/validate-payment.md +0 -16
- package/docs/examples/project/create-variable.md +0 -18
- package/docs/examples/project/delete-variable.md +0 -15
- package/docs/examples/project/get-usage.md +0 -17
- package/docs/examples/project/get-variable.md +0 -15
- package/docs/examples/project/list-variables.md +0 -16
- package/docs/examples/project/update-variable.md +0 -18
- package/docs/examples/projects/create-dev-key.md +0 -17
- package/docs/examples/projects/create-jwt.md +0 -17
- package/docs/examples/projects/create-key.md +0 -19
- package/docs/examples/projects/create-platform.md +0 -20
- package/docs/examples/projects/create-schedule.md +0 -20
- package/docs/examples/projects/create-smtp-test.md +0 -24
- package/docs/examples/projects/create.md +0 -27
- package/docs/examples/projects/delete-dev-key.md +0 -16
- package/docs/examples/projects/delete-email-template.md +0 -17
- package/docs/examples/projects/delete-key.md +0 -16
- package/docs/examples/projects/delete-platform.md +0 -16
- package/docs/examples/projects/delete-sms-template.md +0 -17
- package/docs/examples/projects/delete.md +0 -15
- package/docs/examples/projects/get-dev-key.md +0 -16
- package/docs/examples/projects/get-email-template.md +0 -17
- package/docs/examples/projects/get-key.md +0 -16
- package/docs/examples/projects/get-platform.md +0 -16
- package/docs/examples/projects/get-schedule.md +0 -16
- package/docs/examples/projects/get-sms-template.md +0 -17
- package/docs/examples/projects/get.md +0 -15
- package/docs/examples/projects/list-dev-keys.md +0 -16
- package/docs/examples/projects/list-keys.md +0 -17
- package/docs/examples/projects/list-platforms.md +0 -16
- package/docs/examples/projects/list-schedules.md +0 -17
- package/docs/examples/projects/list.md +0 -17
- package/docs/examples/projects/update-api-status-all.md +0 -16
- package/docs/examples/projects/update-api-status.md +0 -17
- package/docs/examples/projects/update-auth-duration.md +0 -16
- package/docs/examples/projects/update-auth-limit.md +0 -16
- package/docs/examples/projects/update-auth-password-dictionary.md +0 -16
- package/docs/examples/projects/update-auth-password-history.md +0 -16
- package/docs/examples/projects/update-auth-sessions-limit.md +0 -16
- package/docs/examples/projects/update-auth-status.md +0 -17
- package/docs/examples/projects/update-console-access.md +0 -15
- package/docs/examples/projects/update-dev-key.md +0 -18
- package/docs/examples/projects/update-email-template.md +0 -22
- package/docs/examples/projects/update-key.md +0 -19
- package/docs/examples/projects/update-labels.md +0 -16
- package/docs/examples/projects/update-memberships-privacy.md +0 -18
- package/docs/examples/projects/update-mock-numbers.md +0 -16
- package/docs/examples/projects/update-o-auth-2.md +0 -19
- package/docs/examples/projects/update-personal-data-check.md +0 -16
- package/docs/examples/projects/update-platform.md +0 -20
- package/docs/examples/projects/update-service-status-all.md +0 -16
- package/docs/examples/projects/update-service-status.md +0 -17
- package/docs/examples/projects/update-session-alerts.md +0 -16
- package/docs/examples/projects/update-session-invalidation.md +0 -16
- package/docs/examples/projects/update-sms-template.md +0 -18
- package/docs/examples/projects/update-smtp.md +0 -24
- package/docs/examples/projects/update-status.md +0 -16
- package/docs/examples/projects/update-team.md +0 -16
- package/docs/examples/projects/update.md +0 -25
- package/docs/examples/proxy/create-api-rule.md +0 -15
- package/docs/examples/proxy/create-function-rule.md +0 -17
- package/docs/examples/proxy/create-redirect-rule.md +0 -19
- package/docs/examples/proxy/create-site-rule.md +0 -17
- package/docs/examples/proxy/delete-rule.md +0 -15
- package/docs/examples/proxy/get-rule.md +0 -15
- package/docs/examples/proxy/list-rules.md +0 -17
- package/docs/examples/proxy/update-rule-verification.md +0 -15
- package/docs/examples/sites/create-deployment.md +0 -20
- package/docs/examples/sites/create-duplicate-deployment.md +0 -16
- package/docs/examples/sites/create-template-deployment.md +0 -21
- package/docs/examples/sites/create-variable.md +0 -18
- package/docs/examples/sites/create-vcs-deployment.md +0 -18
- package/docs/examples/sites/create.md +0 -35
- package/docs/examples/sites/delete-deployment.md +0 -16
- package/docs/examples/sites/delete-log.md +0 -16
- package/docs/examples/sites/delete-variable.md +0 -16
- package/docs/examples/sites/delete.md +0 -15
- package/docs/examples/sites/get-deployment-download.md +0 -17
- package/docs/examples/sites/get-deployment.md +0 -16
- package/docs/examples/sites/get-log.md +0 -16
- package/docs/examples/sites/get-template.md +0 -15
- package/docs/examples/sites/get-usage.md +0 -16
- package/docs/examples/sites/get-variable.md +0 -16
- package/docs/examples/sites/get.md +0 -15
- package/docs/examples/sites/list-deployments.md +0 -18
- package/docs/examples/sites/list-frameworks.md +0 -13
- package/docs/examples/sites/list-logs.md +0 -17
- package/docs/examples/sites/list-specifications.md +0 -13
- package/docs/examples/sites/list-templates.md +0 -18
- package/docs/examples/sites/list-usage.md +0 -15
- package/docs/examples/sites/list-variables.md +0 -15
- package/docs/examples/sites/list.md +0 -17
- package/docs/examples/sites/update-deployment-status.md +0 -16
- package/docs/examples/sites/update-site-deployment.md +0 -16
- package/docs/examples/sites/update-variable.md +0 -19
- package/docs/examples/sites/update.md +0 -35
- package/docs/examples/storage/create-bucket.md +0 -25
- package/docs/examples/storage/create-file.md +0 -18
- package/docs/examples/storage/delete-bucket.md +0 -15
- package/docs/examples/storage/delete-file.md +0 -16
- package/docs/examples/storage/get-bucket-usage.md +0 -16
- package/docs/examples/storage/get-bucket.md +0 -15
- package/docs/examples/storage/get-file-download.md +0 -17
- package/docs/examples/storage/get-file-preview.md +0 -28
- package/docs/examples/storage/get-file-view.md +0 -17
- package/docs/examples/storage/get-file.md +0 -16
- package/docs/examples/storage/get-usage.md +0 -15
- package/docs/examples/storage/list-buckets.md +0 -17
- package/docs/examples/storage/list-files.md +0 -18
- package/docs/examples/storage/update-bucket.md +0 -25
- package/docs/examples/storage/update-file.md +0 -18
- package/docs/examples/tablesdb/create-boolean-column.md +0 -20
- package/docs/examples/tablesdb/create-datetime-column.md +0 -20
- package/docs/examples/tablesdb/create-email-column.md +0 -20
- package/docs/examples/tablesdb/create-enum-column.md +0 -21
- package/docs/examples/tablesdb/create-float-column.md +0 -22
- package/docs/examples/tablesdb/create-index.md +0 -21
- package/docs/examples/tablesdb/create-integer-column.md +0 -22
- package/docs/examples/tablesdb/create-ip-column.md +0 -20
- package/docs/examples/tablesdb/create-line-column.md +0 -19
- package/docs/examples/tablesdb/create-longtext-column.md +0 -21
- package/docs/examples/tablesdb/create-mediumtext-column.md +0 -21
- package/docs/examples/tablesdb/create-operations.md +0 -26
- package/docs/examples/tablesdb/create-point-column.md +0 -19
- package/docs/examples/tablesdb/create-polygon-column.md +0 -19
- package/docs/examples/tablesdb/create-relationship-column.md +0 -22
- package/docs/examples/tablesdb/create-row.md +0 -26
- package/docs/examples/tablesdb/create-rows.md +0 -18
- package/docs/examples/tablesdb/create-string-column.md +0 -22
- package/docs/examples/tablesdb/create-table.md +0 -22
- package/docs/examples/tablesdb/create-text-column.md +0 -21
- package/docs/examples/tablesdb/create-transaction.md +0 -15
- package/docs/examples/tablesdb/create-url-column.md +0 -20
- package/docs/examples/tablesdb/create-varchar-column.md +0 -22
- package/docs/examples/tablesdb/create.md +0 -17
- package/docs/examples/tablesdb/decrement-row-column.md +0 -21
- package/docs/examples/tablesdb/delete-column.md +0 -17
- package/docs/examples/tablesdb/delete-index.md +0 -17
- package/docs/examples/tablesdb/delete-row.md +0 -18
- package/docs/examples/tablesdb/delete-rows.md +0 -18
- package/docs/examples/tablesdb/delete-table.md +0 -16
- package/docs/examples/tablesdb/delete-transaction.md +0 -15
- package/docs/examples/tablesdb/delete.md +0 -15
- package/docs/examples/tablesdb/get-column.md +0 -17
- package/docs/examples/tablesdb/get-index.md +0 -17
- package/docs/examples/tablesdb/get-row.md +0 -19
- package/docs/examples/tablesdb/get-table-usage.md +0 -17
- package/docs/examples/tablesdb/get-table.md +0 -16
- package/docs/examples/tablesdb/get-transaction.md +0 -15
- package/docs/examples/tablesdb/get-usage.md +0 -16
- package/docs/examples/tablesdb/get.md +0 -15
- package/docs/examples/tablesdb/increment-row-column.md +0 -21
- package/docs/examples/tablesdb/list-columns.md +0 -18
- package/docs/examples/tablesdb/list-indexes.md +0 -18
- package/docs/examples/tablesdb/list-row-logs.md +0 -18
- package/docs/examples/tablesdb/list-rows.md +0 -20
- package/docs/examples/tablesdb/list-table-logs.md +0 -17
- package/docs/examples/tablesdb/list-tables.md +0 -18
- package/docs/examples/tablesdb/list-transactions.md +0 -15
- package/docs/examples/tablesdb/list-usage.md +0 -15
- package/docs/examples/tablesdb/list.md +0 -17
- package/docs/examples/tablesdb/update-boolean-column.md +0 -20
- package/docs/examples/tablesdb/update-datetime-column.md +0 -20
- package/docs/examples/tablesdb/update-email-column.md +0 -20
- package/docs/examples/tablesdb/update-enum-column.md +0 -21
- package/docs/examples/tablesdb/update-float-column.md +0 -22
- package/docs/examples/tablesdb/update-integer-column.md +0 -22
- package/docs/examples/tablesdb/update-ip-column.md +0 -20
- package/docs/examples/tablesdb/update-line-column.md +0 -20
- package/docs/examples/tablesdb/update-longtext-column.md +0 -20
- package/docs/examples/tablesdb/update-mediumtext-column.md +0 -20
- package/docs/examples/tablesdb/update-point-column.md +0 -20
- package/docs/examples/tablesdb/update-polygon-column.md +0 -20
- package/docs/examples/tablesdb/update-relationship-column.md +0 -19
- package/docs/examples/tablesdb/update-row.md +0 -26
- package/docs/examples/tablesdb/update-rows.md +0 -25
- package/docs/examples/tablesdb/update-string-column.md +0 -21
- package/docs/examples/tablesdb/update-table.md +0 -20
- package/docs/examples/tablesdb/update-text-column.md +0 -20
- package/docs/examples/tablesdb/update-transaction.md +0 -17
- package/docs/examples/tablesdb/update-url-column.md +0 -20
- package/docs/examples/tablesdb/update-varchar-column.md +0 -21
- package/docs/examples/tablesdb/update.md +0 -17
- package/docs/examples/tablesdb/upsert-row.md +0 -26
- package/docs/examples/tablesdb/upsert-rows.md +0 -18
- package/docs/examples/teams/create-membership.md +0 -21
- package/docs/examples/teams/create.md +0 -17
- package/docs/examples/teams/delete-membership.md +0 -16
- package/docs/examples/teams/delete.md +0 -15
- package/docs/examples/teams/get-membership.md +0 -16
- package/docs/examples/teams/get-prefs.md +0 -15
- package/docs/examples/teams/get.md +0 -15
- package/docs/examples/teams/list-logs.md +0 -17
- package/docs/examples/teams/list-memberships.md +0 -18
- package/docs/examples/teams/list.md +0 -17
- package/docs/examples/teams/update-membership-status.md +0 -18
- package/docs/examples/teams/update-membership.md +0 -17
- package/docs/examples/teams/update-name.md +0 -16
- package/docs/examples/teams/update-prefs.md +0 -16
- package/docs/examples/tokens/create-file-token.md +0 -17
- package/docs/examples/tokens/delete.md +0 -15
- package/docs/examples/tokens/get.md +0 -15
- package/docs/examples/tokens/list.md +0 -18
- package/docs/examples/tokens/update.md +0 -16
- package/docs/examples/users/create-argon-2-user.md +0 -18
- package/docs/examples/users/create-bcrypt-user.md +0 -18
- package/docs/examples/users/create-jwt.md +0 -17
- package/docs/examples/users/create-md-5-user.md +0 -18
- package/docs/examples/users/create-mfa-recovery-codes.md +0 -15
- package/docs/examples/users/create-ph-pass-user.md +0 -18
- package/docs/examples/users/create-scrypt-modified-user.md +0 -21
- package/docs/examples/users/create-scrypt-user.md +0 -23
- package/docs/examples/users/create-session.md +0 -15
- package/docs/examples/users/create-sha-user.md +0 -19
- package/docs/examples/users/create-target.md +0 -20
- package/docs/examples/users/create-token.md +0 -17
- package/docs/examples/users/create.md +0 -19
- package/docs/examples/users/delete-identity.md +0 -15
- package/docs/examples/users/delete-mfa-authenticator.md +0 -16
- package/docs/examples/users/delete-session.md +0 -16
- package/docs/examples/users/delete-sessions.md +0 -15
- package/docs/examples/users/delete-target.md +0 -16
- package/docs/examples/users/delete.md +0 -15
- package/docs/examples/users/get-mfa-recovery-codes.md +0 -15
- package/docs/examples/users/get-prefs.md +0 -15
- package/docs/examples/users/get-target.md +0 -16
- package/docs/examples/users/get-usage.md +0 -15
- package/docs/examples/users/get.md +0 -15
- package/docs/examples/users/list-identities.md +0 -17
- package/docs/examples/users/list-logs.md +0 -17
- package/docs/examples/users/list-memberships.md +0 -18
- package/docs/examples/users/list-mfa-factors.md +0 -15
- package/docs/examples/users/list-sessions.md +0 -16
- package/docs/examples/users/list-targets.md +0 -17
- package/docs/examples/users/list.md +0 -17
- package/docs/examples/users/update-email-verification.md +0 -16
- package/docs/examples/users/update-email.md +0 -16
- package/docs/examples/users/update-impersonator.md +0 -16
- package/docs/examples/users/update-labels.md +0 -16
- package/docs/examples/users/update-mfa-recovery-codes.md +0 -15
- package/docs/examples/users/update-mfa.md +0 -16
- package/docs/examples/users/update-name.md +0 -16
- package/docs/examples/users/update-password.md +0 -16
- package/docs/examples/users/update-phone-verification.md +0 -16
- package/docs/examples/users/update-phone.md +0 -16
- package/docs/examples/users/update-prefs.md +0 -16
- package/docs/examples/users/update-status.md +0 -16
- package/docs/examples/users/update-target.md +0 -19
- package/docs/examples/vcs/create-repository-detection.md +0 -18
- package/docs/examples/vcs/create-repository.md +0 -17
- package/docs/examples/vcs/delete-installation.md +0 -15
- package/docs/examples/vcs/get-installation.md +0 -15
- package/docs/examples/vcs/get-repository-contents.md +0 -18
- package/docs/examples/vcs/get-repository.md +0 -16
- package/docs/examples/vcs/list-installations.md +0 -17
- package/docs/examples/vcs/list-repositories.md +0 -18
- package/docs/examples/vcs/list-repository-branches.md +0 -16
- package/docs/examples/vcs/update-external-deployments.md +0 -17
- package/docs/examples/webhooks/create.md +0 -22
- package/docs/examples/webhooks/delete.md +0 -15
- package/docs/examples/webhooks/get.md +0 -15
- package/docs/examples/webhooks/list.md +0 -16
- package/docs/examples/webhooks/update-signature.md +0 -15
- package/docs/examples/webhooks/update.md +0 -22
- package/rollup.config.js +0 -44
- package/src/channel.ts +0 -158
- package/src/client.ts +0 -1073
- package/src/enums/adapter.ts +0 -4
- package/src/enums/api-service.ts +0 -15
- package/src/enums/api.ts +0 -5
- package/src/enums/appwrite-migration-resource.ts +0 -27
- package/src/enums/attribute-status.ts +0 -7
- package/src/enums/auth-method.ts +0 -9
- package/src/enums/authentication-factor.ts +0 -6
- package/src/enums/authenticator-type.ts +0 -3
- package/src/enums/backup-services.ts +0 -8
- package/src/enums/billing-plan-group.ts +0 -5
- package/src/enums/browser-permission.ts +0 -22
- package/src/enums/browser.ts +0 -16
- package/src/enums/build-runtime.ts +0 -88
- package/src/enums/column-status.ts +0 -7
- package/src/enums/compression.ts +0 -5
- package/src/enums/console-resource-type.ts +0 -3
- package/src/enums/credit-card.ts +0 -19
- package/src/enums/database-type.ts +0 -6
- package/src/enums/databases-index-type.ts +0 -6
- package/src/enums/deployment-download-type.ts +0 -4
- package/src/enums/deployment-status.ts +0 -8
- package/src/enums/domain-purchase-status.ts +0 -6
- package/src/enums/domain-transfer-status-enum.ts +0 -10
- package/src/enums/email-template-locale.ts +0 -133
- package/src/enums/email-template-type.ts +0 -9
- package/src/enums/execution-method.ts +0 -9
- package/src/enums/execution-status.ts +0 -7
- package/src/enums/execution-trigger.ts +0 -5
- package/src/enums/filter-type.ts +0 -4
- package/src/enums/firebase-migration-resource.ts +0 -12
- package/src/enums/flag.ts +0 -197
- package/src/enums/framework.ts +0 -17
- package/src/enums/frameworks.ts +0 -17
- package/src/enums/health-antivirus-status.ts +0 -5
- package/src/enums/health-check-status.ts +0 -4
- package/src/enums/image-format.ts +0 -9
- package/src/enums/image-gravity.ts +0 -11
- package/src/enums/index-status.ts +0 -7
- package/src/enums/message-priority.ts +0 -4
- package/src/enums/message-status.ts +0 -7
- package/src/enums/messaging-provider-type.ts +0 -5
- package/src/enums/n-host-migration-resource.ts +0 -13
- package/src/enums/name.ts +0 -15
- package/src/enums/o-auth-provider.ts +0 -41
- package/src/enums/order-by.ts +0 -4
- package/src/enums/password-hash.ts +0 -13
- package/src/enums/platform-type.ts +0 -17
- package/src/enums/platform.ts +0 -4
- package/src/enums/project-usage-range.ts +0 -4
- package/src/enums/proxy-resource-type.ts +0 -4
- package/src/enums/proxy-rule-deployment-resource-type.ts +0 -4
- package/src/enums/proxy-rule-status.ts +0 -6
- package/src/enums/region.ts +0 -8
- package/src/enums/registration-type.ts +0 -6
- package/src/enums/relation-mutate.ts +0 -5
- package/src/enums/relationship-type.ts +0 -6
- package/src/enums/resource-type.ts +0 -6
- package/src/enums/runtime.ts +0 -88
- package/src/enums/runtimes.ts +0 -88
- package/src/enums/scopes.ts +0 -81
- package/src/enums/sms-template-locale.ts +0 -133
- package/src/enums/sms-template-type.ts +0 -6
- package/src/enums/smtp-encryption.ts +0 -5
- package/src/enums/smtp-secure.ts +0 -4
- package/src/enums/status-code.ts +0 -6
- package/src/enums/status.ts +0 -3
- package/src/enums/supabase-migration-resource.ts +0 -13
- package/src/enums/tables-db-index-type.ts +0 -6
- package/src/enums/template-reference-type.ts +0 -5
- package/src/enums/theme.ts +0 -4
- package/src/enums/timezone.ts +0 -421
- package/src/enums/usage-range.ts +0 -5
- package/src/enums/use-cases.ts +0 -16
- package/src/enums/vcs-detection-type.ts +0 -4
- package/src/enums/vcs-reference-type.ts +0 -5
- package/src/id.ts +0 -47
- package/src/index.ts +0 -118
- package/src/models.ts +0 -9367
- package/src/operator.ts +0 -308
- package/src/permission.ts +0 -57
- package/src/query.ts +0 -576
- package/src/role.ts +0 -100
- package/src/service.ts +0 -30
- package/src/services/account.ts +0 -4293
- package/src/services/activities.ts +0 -116
- package/src/services/assistant.ts +0 -67
- package/src/services/avatars.ts +0 -754
- package/src/services/backups.ts +0 -754
- package/src/services/console.ts +0 -678
- package/src/services/databases.ts +0 -6376
- package/src/services/domains.ts +0 -4064
- package/src/services/functions.ts +0 -2224
- package/src/services/graphql.ts +0 -124
- package/src/services/health.ts +0 -1296
- package/src/services/locale.ts +0 -198
- package/src/services/messaging.ts +0 -5194
- package/src/services/migrations.ts +0 -1207
- package/src/services/organizations.ts +0 -2742
- package/src/services/project.ts +0 -404
- package/src/services/projects.ts +0 -4431
- package/src/services/proxy.ts +0 -532
- package/src/services/realtime.ts +0 -537
- package/src/services/sites.ts +0 -2131
- package/src/services/storage.ts +0 -1196
- package/src/services/tables-db.ts +0 -6256
- package/src/services/teams.ts +0 -959
- package/src/services/tokens.ts +0 -315
- package/src/services/users.ts +0 -3324
- package/src/services/vcs.ts +0 -676
- package/src/services/webhooks.ts +0 -451
- package/tsconfig.json +0 -24
package/src/services/realtime.ts
DELETED
|
@@ -1,537 +0,0 @@
|
|
|
1
|
-
import { AppwriteException, Client } from '../client';
|
|
2
|
-
import { Channel, ActionableChannel, ResolvedChannel } from '../channel';
|
|
3
|
-
import { Query } from '../query';
|
|
4
|
-
|
|
5
|
-
export type RealtimeSubscription = {
|
|
6
|
-
close: () => Promise<void>;
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
export type RealtimeCallback<T = any> = {
|
|
10
|
-
channels: Set<string>;
|
|
11
|
-
queries: string[]; // Array of query strings
|
|
12
|
-
callback: (event: RealtimeResponseEvent<T>) => void;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
export type RealtimeResponse = {
|
|
16
|
-
type: string;
|
|
17
|
-
data?: any;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
export type RealtimeResponseEvent<T = any> = {
|
|
21
|
-
events: string[];
|
|
22
|
-
channels: string[];
|
|
23
|
-
timestamp: string;
|
|
24
|
-
payload: T;
|
|
25
|
-
subscriptions: string[]; // Backend-provided subscription IDs
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
export type RealtimeResponseConnected = {
|
|
29
|
-
channels: string[];
|
|
30
|
-
user?: object;
|
|
31
|
-
subscriptions?: { [slot: string]: string }; // Map slot index -> subscriptionId
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
export type RealtimeRequest = {
|
|
35
|
-
type: 'authentication';
|
|
36
|
-
data: {
|
|
37
|
-
session: string;
|
|
38
|
-
};
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
export enum RealtimeCode {
|
|
42
|
-
NORMAL_CLOSURE = 1000,
|
|
43
|
-
POLICY_VIOLATION = 1008,
|
|
44
|
-
UNKNOWN_ERROR = -1
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
export class Realtime {
|
|
48
|
-
private readonly TYPE_ERROR = 'error';
|
|
49
|
-
private readonly TYPE_EVENT = 'event';
|
|
50
|
-
private readonly TYPE_PONG = 'pong';
|
|
51
|
-
private readonly TYPE_CONNECTED = 'connected';
|
|
52
|
-
private readonly DEBOUNCE_MS = 1;
|
|
53
|
-
private readonly HEARTBEAT_INTERVAL = 20000; // 20 seconds in milliseconds
|
|
54
|
-
|
|
55
|
-
private client: Client;
|
|
56
|
-
private socket?: WebSocket;
|
|
57
|
-
// Slot-centric state: Map<slot, { channels: Set<string>, queries: string[], callback: Function }>
|
|
58
|
-
private activeSubscriptions = new Map<number, RealtimeCallback<any>>();
|
|
59
|
-
// Map slot index -> subscriptionId (from backend)
|
|
60
|
-
private slotToSubscriptionId = new Map<number, string>();
|
|
61
|
-
// Inverse map: subscriptionId -> slot index (for O(1) lookup)
|
|
62
|
-
private subscriptionIdToSlot = new Map<string, number>();
|
|
63
|
-
private heartbeatTimer?: number;
|
|
64
|
-
|
|
65
|
-
private subCallDepth = 0;
|
|
66
|
-
private reconnectAttempts = 0;
|
|
67
|
-
private subscriptionsCounter = 0;
|
|
68
|
-
private connectionId = 0;
|
|
69
|
-
private reconnect = true;
|
|
70
|
-
|
|
71
|
-
private onErrorCallbacks: Array<(error?: Error, statusCode?: number) => void> = [];
|
|
72
|
-
private onCloseCallbacks: Array<() => void> = [];
|
|
73
|
-
private onOpenCallbacks: Array<() => void> = [];
|
|
74
|
-
|
|
75
|
-
constructor(client: Client) {
|
|
76
|
-
this.client = client;
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
/**
|
|
80
|
-
* Register a callback function to be called when an error occurs
|
|
81
|
-
*
|
|
82
|
-
* @param {Function} callback - Callback function to handle errors
|
|
83
|
-
* @returns {void}
|
|
84
|
-
*/
|
|
85
|
-
public onError(callback: (error?: Error, statusCode?: number) => void): void {
|
|
86
|
-
this.onErrorCallbacks.push(callback);
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
/**
|
|
90
|
-
* Register a callback function to be called when the connection closes
|
|
91
|
-
*
|
|
92
|
-
* @param {Function} callback - Callback function to handle connection close
|
|
93
|
-
* @returns {void}
|
|
94
|
-
*/
|
|
95
|
-
public onClose(callback: () => void): void {
|
|
96
|
-
this.onCloseCallbacks.push(callback);
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
/**
|
|
100
|
-
* Register a callback function to be called when the connection opens
|
|
101
|
-
*
|
|
102
|
-
* @param {Function} callback - Callback function to handle connection open
|
|
103
|
-
* @returns {void}
|
|
104
|
-
*/
|
|
105
|
-
public onOpen(callback: () => void): void {
|
|
106
|
-
this.onOpenCallbacks.push(callback);
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
private startHeartbeat(): void {
|
|
110
|
-
this.stopHeartbeat();
|
|
111
|
-
this.heartbeatTimer = window.setInterval(() => {
|
|
112
|
-
if (this.socket && this.socket.readyState === WebSocket.OPEN) {
|
|
113
|
-
this.socket.send(JSON.stringify({ type: 'ping' }));
|
|
114
|
-
}
|
|
115
|
-
}, this.HEARTBEAT_INTERVAL);
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
private stopHeartbeat(): void {
|
|
119
|
-
if (this.heartbeatTimer) {
|
|
120
|
-
window.clearInterval(this.heartbeatTimer);
|
|
121
|
-
this.heartbeatTimer = undefined;
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
private async createSocket(): Promise<void> {
|
|
126
|
-
if (this.activeSubscriptions.size === 0) {
|
|
127
|
-
this.reconnect = false;
|
|
128
|
-
await this.closeSocket();
|
|
129
|
-
return;
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
const projectId = this.client.config.project;
|
|
133
|
-
if (!projectId) {
|
|
134
|
-
throw new AppwriteException('Missing project ID');
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
// Collect all unique channels from all slots
|
|
138
|
-
const allChannels = new Set<string>();
|
|
139
|
-
for (const subscription of this.activeSubscriptions.values()) {
|
|
140
|
-
for (const channel of subscription.channels) {
|
|
141
|
-
allChannels.add(channel);
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
let queryParams = `project=${projectId}`;
|
|
146
|
-
for (const channel of allChannels) {
|
|
147
|
-
queryParams += `&channels[]=${encodeURIComponent(channel)}`;
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
// Build query string from slots → channels → queries
|
|
151
|
-
// Format: channel[slot][]=query
|
|
152
|
-
// For each slot, repeat its queries under each channel it subscribes to
|
|
153
|
-
// Example: slot 1 → channels [tests, prod], queries [q1, q2]
|
|
154
|
-
// Produces: tests[1][]=q1&tests[1][]=q2&prod[1][]=q1&prod[1][]=q2
|
|
155
|
-
const selectAllQuery = Query.select(['*']).toString();
|
|
156
|
-
for (const [slot, subscription] of this.activeSubscriptions) {
|
|
157
|
-
// queries is string[] - iterate over each query string
|
|
158
|
-
const queries = subscription.queries.length === 0
|
|
159
|
-
? [selectAllQuery]
|
|
160
|
-
: subscription.queries;
|
|
161
|
-
|
|
162
|
-
// Repeat this slot's queries under each channel it subscribes to
|
|
163
|
-
// Each query is sent as a separate parameter: channel[slot][]=q1&channel[slot][]=q2
|
|
164
|
-
for (const channel of subscription.channels) {
|
|
165
|
-
for (const query of queries) {
|
|
166
|
-
queryParams += `&${encodeURIComponent(channel)}[${slot}][]=${encodeURIComponent(query)}`;
|
|
167
|
-
}
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
const endpoint =
|
|
172
|
-
this.client.config.endpointRealtime !== ''
|
|
173
|
-
? this.client.config.endpointRealtime
|
|
174
|
-
: this.client.config.endpoint || '';
|
|
175
|
-
const realtimeEndpoint = endpoint
|
|
176
|
-
.replace('https://', 'wss://')
|
|
177
|
-
.replace('http://', 'ws://');
|
|
178
|
-
const url = `${realtimeEndpoint}/realtime?${queryParams}`;
|
|
179
|
-
|
|
180
|
-
if (this.socket) {
|
|
181
|
-
this.reconnect = false;
|
|
182
|
-
if (this.socket.readyState < WebSocket.CLOSING) {
|
|
183
|
-
await this.closeSocket();
|
|
184
|
-
}
|
|
185
|
-
// Ensure reconnect isn't stuck false if close event was missed.
|
|
186
|
-
this.reconnect = true;
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
return new Promise((resolve, reject) => {
|
|
190
|
-
try {
|
|
191
|
-
const connectionId = ++this.connectionId;
|
|
192
|
-
const socket = (this.socket = new WebSocket(url));
|
|
193
|
-
|
|
194
|
-
socket.addEventListener('open', () => {
|
|
195
|
-
if (connectionId !== this.connectionId) {
|
|
196
|
-
return;
|
|
197
|
-
}
|
|
198
|
-
this.reconnectAttempts = 0;
|
|
199
|
-
this.onOpenCallbacks.forEach(callback => callback());
|
|
200
|
-
this.startHeartbeat();
|
|
201
|
-
resolve();
|
|
202
|
-
});
|
|
203
|
-
|
|
204
|
-
socket.addEventListener('message', (event: MessageEvent) => {
|
|
205
|
-
if (connectionId !== this.connectionId) {
|
|
206
|
-
return;
|
|
207
|
-
}
|
|
208
|
-
try {
|
|
209
|
-
const message = JSON.parse(event.data) as RealtimeResponse;
|
|
210
|
-
this.handleMessage(message);
|
|
211
|
-
} catch (error) {
|
|
212
|
-
console.error('Failed to parse message:', error);
|
|
213
|
-
}
|
|
214
|
-
});
|
|
215
|
-
|
|
216
|
-
socket.addEventListener('close', async (event: CloseEvent) => {
|
|
217
|
-
if (connectionId !== this.connectionId || socket !== this.socket) {
|
|
218
|
-
return;
|
|
219
|
-
}
|
|
220
|
-
this.stopHeartbeat();
|
|
221
|
-
this.onCloseCallbacks.forEach(callback => callback());
|
|
222
|
-
|
|
223
|
-
if (!this.reconnect || event.code === RealtimeCode.POLICY_VIOLATION) {
|
|
224
|
-
this.reconnect = true;
|
|
225
|
-
return;
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
-
const timeout = this.getTimeout();
|
|
229
|
-
console.log(`Realtime disconnected. Re-connecting in ${timeout / 1000} seconds.`);
|
|
230
|
-
|
|
231
|
-
await this.sleep(timeout);
|
|
232
|
-
this.reconnectAttempts++;
|
|
233
|
-
|
|
234
|
-
try {
|
|
235
|
-
await this.createSocket();
|
|
236
|
-
} catch (error) {
|
|
237
|
-
console.error('Failed to reconnect:', error);
|
|
238
|
-
}
|
|
239
|
-
});
|
|
240
|
-
|
|
241
|
-
socket.addEventListener('error', (event: Event) => {
|
|
242
|
-
if (connectionId !== this.connectionId || socket !== this.socket) {
|
|
243
|
-
return;
|
|
244
|
-
}
|
|
245
|
-
this.stopHeartbeat();
|
|
246
|
-
const error = new Error('WebSocket error');
|
|
247
|
-
console.error('WebSocket error:', error.message);
|
|
248
|
-
this.onErrorCallbacks.forEach(callback => callback(error));
|
|
249
|
-
reject(error);
|
|
250
|
-
});
|
|
251
|
-
} catch (error) {
|
|
252
|
-
reject(error);
|
|
253
|
-
}
|
|
254
|
-
});
|
|
255
|
-
}
|
|
256
|
-
|
|
257
|
-
private async closeSocket(): Promise<void> {
|
|
258
|
-
this.stopHeartbeat();
|
|
259
|
-
|
|
260
|
-
if (this.socket) {
|
|
261
|
-
return new Promise((resolve) => {
|
|
262
|
-
if (!this.socket) {
|
|
263
|
-
resolve();
|
|
264
|
-
return;
|
|
265
|
-
}
|
|
266
|
-
|
|
267
|
-
if (this.socket.readyState === WebSocket.OPEN ||
|
|
268
|
-
this.socket.readyState === WebSocket.CONNECTING) {
|
|
269
|
-
this.socket.addEventListener('close', () => {
|
|
270
|
-
resolve();
|
|
271
|
-
}, { once: true });
|
|
272
|
-
this.socket.close(RealtimeCode.NORMAL_CLOSURE);
|
|
273
|
-
} else {
|
|
274
|
-
resolve();
|
|
275
|
-
}
|
|
276
|
-
});
|
|
277
|
-
}
|
|
278
|
-
}
|
|
279
|
-
|
|
280
|
-
private getTimeout(): number {
|
|
281
|
-
if (this.reconnectAttempts < 5) {
|
|
282
|
-
return 1000;
|
|
283
|
-
} else if (this.reconnectAttempts < 15) {
|
|
284
|
-
return 5000;
|
|
285
|
-
} else if (this.reconnectAttempts < 100) {
|
|
286
|
-
return 10000;
|
|
287
|
-
} else {
|
|
288
|
-
return 60000;
|
|
289
|
-
}
|
|
290
|
-
}
|
|
291
|
-
|
|
292
|
-
private sleep(ms: number): Promise<void> {
|
|
293
|
-
return new Promise(resolve => setTimeout(resolve, ms));
|
|
294
|
-
}
|
|
295
|
-
|
|
296
|
-
/**
|
|
297
|
-
* Convert a channel value to a string
|
|
298
|
-
*
|
|
299
|
-
* @private
|
|
300
|
-
* @param {string | Channel<any> | ActionableChannel | ResolvedChannel} channel - Channel value (string or Channel builder instance)
|
|
301
|
-
* @returns {string} Channel string representation
|
|
302
|
-
*/
|
|
303
|
-
private channelToString(channel: string | Channel<any> | ActionableChannel | ResolvedChannel): string {
|
|
304
|
-
if (typeof channel === 'string') {
|
|
305
|
-
return channel;
|
|
306
|
-
}
|
|
307
|
-
// All Channel instances have toString() method
|
|
308
|
-
if (channel && typeof (channel as Channel<any>).toString === 'function') {
|
|
309
|
-
return (channel as Channel<any>).toString();
|
|
310
|
-
}
|
|
311
|
-
return String(channel);
|
|
312
|
-
}
|
|
313
|
-
|
|
314
|
-
/**
|
|
315
|
-
* Subscribe to a single channel
|
|
316
|
-
*
|
|
317
|
-
* @param {string | Channel<any> | ActionableChannel | ResolvedChannel} channel - Channel name to subscribe to (string or Channel builder instance)
|
|
318
|
-
* @param {Function} callback - Callback function to handle events
|
|
319
|
-
* @returns {Promise<RealtimeSubscription>} Subscription object with close method
|
|
320
|
-
*/
|
|
321
|
-
public async subscribe(
|
|
322
|
-
channel: string | Channel<any> | ActionableChannel | ResolvedChannel,
|
|
323
|
-
callback: (event: RealtimeResponseEvent<any>) => void,
|
|
324
|
-
queries?: (string | Query)[]
|
|
325
|
-
): Promise<RealtimeSubscription>;
|
|
326
|
-
|
|
327
|
-
/**
|
|
328
|
-
* Subscribe to multiple channels
|
|
329
|
-
*
|
|
330
|
-
* @param {(string | Channel<any> | ActionableChannel | ResolvedChannel)[]} channels - Array of channel names to subscribe to (strings or Channel builder instances)
|
|
331
|
-
* @param {Function} callback - Callback function to handle events
|
|
332
|
-
* @returns {Promise<RealtimeSubscription>} Subscription object with close method
|
|
333
|
-
*/
|
|
334
|
-
public async subscribe(
|
|
335
|
-
channels: (string | Channel<any> | ActionableChannel | ResolvedChannel)[],
|
|
336
|
-
callback: (event: RealtimeResponseEvent<any>) => void,
|
|
337
|
-
queries?: (string | Query)[]
|
|
338
|
-
): Promise<RealtimeSubscription>;
|
|
339
|
-
|
|
340
|
-
/**
|
|
341
|
-
* Subscribe to a single channel with typed payload
|
|
342
|
-
*
|
|
343
|
-
* @param {string | Channel<any> | ActionableChannel | ResolvedChannel} channel - Channel name to subscribe to (string or Channel builder instance)
|
|
344
|
-
* @param {Function} callback - Callback function to handle events with typed payload
|
|
345
|
-
* @returns {Promise<RealtimeSubscription>} Subscription object with close method
|
|
346
|
-
*/
|
|
347
|
-
public async subscribe<T>(
|
|
348
|
-
channel: string | Channel<any> | ActionableChannel | ResolvedChannel,
|
|
349
|
-
callback: (event: RealtimeResponseEvent<T>) => void,
|
|
350
|
-
queries?: (string | Query)[]
|
|
351
|
-
): Promise<RealtimeSubscription>;
|
|
352
|
-
|
|
353
|
-
/**
|
|
354
|
-
* Subscribe to multiple channels with typed payload
|
|
355
|
-
*
|
|
356
|
-
* @param {(string | Channel<any> | ActionableChannel | ResolvedChannel)[]} channels - Array of channel names to subscribe to (strings or Channel builder instances)
|
|
357
|
-
* @param {Function} callback - Callback function to handle events with typed payload
|
|
358
|
-
* @returns {Promise<RealtimeSubscription>} Subscription object with close method
|
|
359
|
-
*/
|
|
360
|
-
public async subscribe<T>(
|
|
361
|
-
channels: (string | Channel<any> | ActionableChannel | ResolvedChannel)[],
|
|
362
|
-
callback: (event: RealtimeResponseEvent<T>) => void,
|
|
363
|
-
queries?: (string | Query)[]
|
|
364
|
-
): Promise<RealtimeSubscription>;
|
|
365
|
-
|
|
366
|
-
public async subscribe<T = any>(
|
|
367
|
-
channelsOrChannel: string | Channel<any> | ActionableChannel | ResolvedChannel | (string | Channel<any> | ActionableChannel | ResolvedChannel)[],
|
|
368
|
-
callback: (event: RealtimeResponseEvent<T>) => void,
|
|
369
|
-
queries: (string | Query)[] = []
|
|
370
|
-
): Promise<RealtimeSubscription> {
|
|
371
|
-
const channelArray = Array.isArray(channelsOrChannel)
|
|
372
|
-
? channelsOrChannel
|
|
373
|
-
: [channelsOrChannel];
|
|
374
|
-
|
|
375
|
-
// Convert all channels to strings
|
|
376
|
-
const channelStrings = channelArray.map(ch => this.channelToString(ch));
|
|
377
|
-
const channels = new Set(channelStrings);
|
|
378
|
-
|
|
379
|
-
// Convert queries to array of strings
|
|
380
|
-
// Ensure each query is a separate string in the array
|
|
381
|
-
const queryStrings: string[] = [];
|
|
382
|
-
for (const q of (queries ?? [])) {
|
|
383
|
-
if (Array.isArray(q)) {
|
|
384
|
-
// Handle nested arrays: [[q1, q2]] -> [q1, q2]
|
|
385
|
-
for (const inner of q) {
|
|
386
|
-
queryStrings.push(typeof inner === 'string' ? inner : inner.toString());
|
|
387
|
-
}
|
|
388
|
-
} else {
|
|
389
|
-
queryStrings.push(typeof q === 'string' ? q : q.toString());
|
|
390
|
-
}
|
|
391
|
-
}
|
|
392
|
-
|
|
393
|
-
// Allocate a new slot index
|
|
394
|
-
this.subscriptionsCounter++;
|
|
395
|
-
const slot = this.subscriptionsCounter;
|
|
396
|
-
|
|
397
|
-
// Store slot-centric data: channels, queries, and callback belong to the slot
|
|
398
|
-
// queries is stored as string[] (array of query strings)
|
|
399
|
-
// No channel mutation occurs here - channels are derived from slots in createSocket()
|
|
400
|
-
this.activeSubscriptions.set(slot, {
|
|
401
|
-
channels,
|
|
402
|
-
queries: queryStrings,
|
|
403
|
-
callback
|
|
404
|
-
});
|
|
405
|
-
|
|
406
|
-
this.subCallDepth++;
|
|
407
|
-
|
|
408
|
-
await this.sleep(this.DEBOUNCE_MS);
|
|
409
|
-
|
|
410
|
-
if (this.subCallDepth === 1) {
|
|
411
|
-
await this.createSocket();
|
|
412
|
-
}
|
|
413
|
-
|
|
414
|
-
this.subCallDepth--;
|
|
415
|
-
|
|
416
|
-
return {
|
|
417
|
-
close: async () => {
|
|
418
|
-
const subscriptionId = this.slotToSubscriptionId.get(slot);
|
|
419
|
-
this.activeSubscriptions.delete(slot);
|
|
420
|
-
this.slotToSubscriptionId.delete(slot);
|
|
421
|
-
if (subscriptionId) {
|
|
422
|
-
this.subscriptionIdToSlot.delete(subscriptionId);
|
|
423
|
-
}
|
|
424
|
-
await this.createSocket();
|
|
425
|
-
}
|
|
426
|
-
};
|
|
427
|
-
}
|
|
428
|
-
|
|
429
|
-
// cleanUp is no longer needed - slots are removed directly in subscribe().close()
|
|
430
|
-
// Channels are automatically rebuilt from remaining slots in createSocket()
|
|
431
|
-
|
|
432
|
-
private handleMessage(message: RealtimeResponse): void {
|
|
433
|
-
if (!message.type) {
|
|
434
|
-
return;
|
|
435
|
-
}
|
|
436
|
-
|
|
437
|
-
switch (message.type) {
|
|
438
|
-
case this.TYPE_CONNECTED:
|
|
439
|
-
this.handleResponseConnected(message);
|
|
440
|
-
break;
|
|
441
|
-
case this.TYPE_ERROR:
|
|
442
|
-
this.handleResponseError(message);
|
|
443
|
-
break;
|
|
444
|
-
case this.TYPE_EVENT:
|
|
445
|
-
this.handleResponseEvent(message);
|
|
446
|
-
break;
|
|
447
|
-
case this.TYPE_PONG:
|
|
448
|
-
// Handle pong response if needed
|
|
449
|
-
break;
|
|
450
|
-
}
|
|
451
|
-
}
|
|
452
|
-
|
|
453
|
-
private handleResponseConnected(message: RealtimeResponse): void {
|
|
454
|
-
if (!message.data) {
|
|
455
|
-
return;
|
|
456
|
-
}
|
|
457
|
-
|
|
458
|
-
const messageData = message.data as RealtimeResponseConnected;
|
|
459
|
-
|
|
460
|
-
// Store subscription ID mappings from backend
|
|
461
|
-
// Format: { "0": "sub_a1f9", "1": "sub_b83c", ... }
|
|
462
|
-
if (messageData.subscriptions) {
|
|
463
|
-
this.slotToSubscriptionId.clear();
|
|
464
|
-
this.subscriptionIdToSlot.clear();
|
|
465
|
-
for (const [slotStr, subscriptionId] of Object.entries(messageData.subscriptions)) {
|
|
466
|
-
const slot = Number(slotStr);
|
|
467
|
-
if (!isNaN(slot)) {
|
|
468
|
-
this.slotToSubscriptionId.set(slot, subscriptionId);
|
|
469
|
-
this.subscriptionIdToSlot.set(subscriptionId, slot);
|
|
470
|
-
}
|
|
471
|
-
}
|
|
472
|
-
}
|
|
473
|
-
|
|
474
|
-
let session = this.client.config.session;
|
|
475
|
-
if (!session) {
|
|
476
|
-
try {
|
|
477
|
-
const cookie = JSON.parse(window.localStorage.getItem('cookieFallback') ?? '{}');
|
|
478
|
-
session = cookie?.[`a_session_${this.client.config.project}`];
|
|
479
|
-
} catch (error) {
|
|
480
|
-
console.error('Failed to parse cookie fallback:', error);
|
|
481
|
-
}
|
|
482
|
-
}
|
|
483
|
-
|
|
484
|
-
if (session && !messageData.user) {
|
|
485
|
-
this.socket?.send(JSON.stringify(<RealtimeRequest>{
|
|
486
|
-
type: 'authentication',
|
|
487
|
-
data: {
|
|
488
|
-
session
|
|
489
|
-
}
|
|
490
|
-
}));
|
|
491
|
-
}
|
|
492
|
-
}
|
|
493
|
-
|
|
494
|
-
private handleResponseError(message: RealtimeResponse): void {
|
|
495
|
-
const error = new AppwriteException(
|
|
496
|
-
message.data?.message || 'Unknown error'
|
|
497
|
-
);
|
|
498
|
-
const statusCode = message.data?.code;
|
|
499
|
-
this.onErrorCallbacks.forEach(callback => callback(error, statusCode));
|
|
500
|
-
}
|
|
501
|
-
|
|
502
|
-
private handleResponseEvent(message: RealtimeResponse): void {
|
|
503
|
-
const data = message.data;
|
|
504
|
-
if (!data) {
|
|
505
|
-
return;
|
|
506
|
-
}
|
|
507
|
-
|
|
508
|
-
const channels = data.channels as string[];
|
|
509
|
-
const events = data.events as string[];
|
|
510
|
-
const payload = data.payload;
|
|
511
|
-
const timestamp = data.timestamp as string;
|
|
512
|
-
const subscriptions = data.subscriptions as string[] | undefined;
|
|
513
|
-
|
|
514
|
-
if (!channels || !events || !payload || !subscriptions || subscriptions.length === 0) {
|
|
515
|
-
return;
|
|
516
|
-
}
|
|
517
|
-
|
|
518
|
-
// Iterate over all matching subscriptionIds and call callback for each
|
|
519
|
-
for (const subscriptionId of subscriptions) {
|
|
520
|
-
// O(1) lookup using subscriptionId
|
|
521
|
-
const slot = this.subscriptionIdToSlot.get(subscriptionId);
|
|
522
|
-
if (slot !== undefined) {
|
|
523
|
-
const subscription = this.activeSubscriptions.get(slot);
|
|
524
|
-
if (subscription) {
|
|
525
|
-
const response: RealtimeResponseEvent<any> = {
|
|
526
|
-
events,
|
|
527
|
-
channels,
|
|
528
|
-
timestamp,
|
|
529
|
-
payload,
|
|
530
|
-
subscriptions
|
|
531
|
-
};
|
|
532
|
-
subscription.callback(response);
|
|
533
|
-
}
|
|
534
|
-
}
|
|
535
|
-
}
|
|
536
|
-
}
|
|
537
|
-
}
|