@appconda/nextjs 1.0.12
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/autoclose.yml +11 -0
- package/.github/workflows/publish.yml +42 -0
- package/.travis.yml +32 -0
- package/CHANGELOG.md +1 -0
- package/LICENSE +12 -0
- package/README.md +0 -0
- package/dist/cjs/sdk.js +10608 -0
- package/dist/cjs/sdk.js.map +1 -0
- package/dist/esm/sdk.js +10589 -0
- package/dist/esm/sdk.js.map +1 -0
- package/dist/iife/sdk.js +10609 -0
- package/docs/examples/account/create-anonymous-session.md +11 -0
- package/docs/examples/account/create-email-password-session.md +14 -0
- package/docs/examples/account/create-email-token.md +15 -0
- package/docs/examples/account/create-j-w-t.md +11 -0
- package/docs/examples/account/create-magic-u-r-l-token.md +16 -0
- package/docs/examples/account/create-mfa-authenticator.md +13 -0
- package/docs/examples/account/create-mfa-challenge.md +13 -0
- package/docs/examples/account/create-mfa-recovery-codes.md +11 -0
- package/docs/examples/account/create-o-auth2session.md +15 -0
- package/docs/examples/account/create-o-auth2token.md +15 -0
- package/docs/examples/account/create-phone-token.md +14 -0
- package/docs/examples/account/create-phone-verification.md +11 -0
- package/docs/examples/account/create-push-target.md +15 -0
- package/docs/examples/account/create-recovery.md +14 -0
- package/docs/examples/account/create-session.md +14 -0
- package/docs/examples/account/create-verification.md +13 -0
- package/docs/examples/account/create.md +16 -0
- package/docs/examples/account/delete-identity.md +13 -0
- package/docs/examples/account/delete-mfa-authenticator.md +13 -0
- package/docs/examples/account/delete-push-target.md +13 -0
- package/docs/examples/account/delete-session.md +13 -0
- package/docs/examples/account/delete-sessions.md +11 -0
- package/docs/examples/account/delete.md +11 -0
- package/docs/examples/account/get-mfa-recovery-codes.md +11 -0
- package/docs/examples/account/get-prefs.md +11 -0
- package/docs/examples/account/get-session.md +13 -0
- package/docs/examples/account/get.md +11 -0
- package/docs/examples/account/list-identities.md +13 -0
- package/docs/examples/account/list-logs.md +13 -0
- package/docs/examples/account/list-mfa-factors.md +11 -0
- package/docs/examples/account/list-sessions.md +11 -0
- package/docs/examples/account/update-email.md +14 -0
- package/docs/examples/account/update-m-f-a.md +13 -0
- package/docs/examples/account/update-magic-u-r-l-session.md +14 -0
- package/docs/examples/account/update-mfa-authenticator.md +14 -0
- package/docs/examples/account/update-mfa-challenge.md +14 -0
- package/docs/examples/account/update-mfa-recovery-codes.md +11 -0
- package/docs/examples/account/update-name.md +13 -0
- package/docs/examples/account/update-password.md +14 -0
- package/docs/examples/account/update-phone-session.md +14 -0
- package/docs/examples/account/update-phone-verification.md +14 -0
- package/docs/examples/account/update-phone.md +14 -0
- package/docs/examples/account/update-prefs.md +13 -0
- package/docs/examples/account/update-push-target.md +14 -0
- package/docs/examples/account/update-recovery.md +15 -0
- package/docs/examples/account/update-session.md +13 -0
- package/docs/examples/account/update-status.md +11 -0
- package/docs/examples/account/update-verification.md +14 -0
- package/docs/examples/assistant/chat.md +13 -0
- package/docs/examples/avatars/get-browser.md +16 -0
- package/docs/examples/avatars/get-credit-card.md +16 -0
- package/docs/examples/avatars/get-favicon.md +13 -0
- package/docs/examples/avatars/get-flag.md +16 -0
- package/docs/examples/avatars/get-image.md +15 -0
- package/docs/examples/avatars/get-initials.md +16 -0
- package/docs/examples/avatars/get-q-r.md +16 -0
- package/docs/examples/console/variables.md +11 -0
- package/docs/examples/databases/create-boolean-attribute.md +18 -0
- package/docs/examples/databases/create-collection.md +18 -0
- package/docs/examples/databases/create-datetime-attribute.md +18 -0
- package/docs/examples/databases/create-document.md +17 -0
- package/docs/examples/databases/create-email-attribute.md +18 -0
- package/docs/examples/databases/create-enum-attribute.md +19 -0
- package/docs/examples/databases/create-float-attribute.md +20 -0
- package/docs/examples/databases/create-index.md +18 -0
- package/docs/examples/databases/create-integer-attribute.md +20 -0
- package/docs/examples/databases/create-ip-attribute.md +18 -0
- package/docs/examples/databases/create-relationship-attribute.md +20 -0
- package/docs/examples/databases/create-string-attribute.md +20 -0
- package/docs/examples/databases/create-url-attribute.md +18 -0
- package/docs/examples/databases/create.md +15 -0
- package/docs/examples/databases/delete-attribute.md +15 -0
- package/docs/examples/databases/delete-collection.md +14 -0
- package/docs/examples/databases/delete-document.md +15 -0
- package/docs/examples/databases/delete-index.md +15 -0
- package/docs/examples/databases/delete.md +13 -0
- package/docs/examples/databases/get-attribute.md +15 -0
- package/docs/examples/databases/get-collection-usage.md +15 -0
- package/docs/examples/databases/get-collection.md +14 -0
- package/docs/examples/databases/get-database-usage.md +14 -0
- package/docs/examples/databases/get-document.md +16 -0
- package/docs/examples/databases/get-index.md +15 -0
- package/docs/examples/databases/get-usage.md +13 -0
- package/docs/examples/databases/get.md +13 -0
- package/docs/examples/databases/list-attributes.md +15 -0
- package/docs/examples/databases/list-collection-logs.md +15 -0
- package/docs/examples/databases/list-collections.md +15 -0
- package/docs/examples/databases/list-document-logs.md +16 -0
- package/docs/examples/databases/list-documents.md +15 -0
- package/docs/examples/databases/list-indexes.md +15 -0
- package/docs/examples/databases/list-logs.md +14 -0
- package/docs/examples/databases/list.md +14 -0
- package/docs/examples/databases/update-boolean-attribute.md +17 -0
- package/docs/examples/databases/update-collection.md +18 -0
- package/docs/examples/databases/update-datetime-attribute.md +17 -0
- package/docs/examples/databases/update-document.md +17 -0
- package/docs/examples/databases/update-email-attribute.md +17 -0
- package/docs/examples/databases/update-enum-attribute.md +18 -0
- package/docs/examples/databases/update-float-attribute.md +19 -0
- package/docs/examples/databases/update-integer-attribute.md +19 -0
- package/docs/examples/databases/update-ip-attribute.md +17 -0
- package/docs/examples/databases/update-relationship-attribute.md +16 -0
- package/docs/examples/databases/update-string-attribute.md +17 -0
- package/docs/examples/databases/update-url-attribute.md +17 -0
- package/docs/examples/databases/update.md +15 -0
- package/docs/examples/functions/create-build.md +15 -0
- package/docs/examples/functions/create-deployment.md +17 -0
- package/docs/examples/functions/create-execution.md +19 -0
- package/docs/examples/functions/create-variable.md +15 -0
- package/docs/examples/functions/create.md +34 -0
- package/docs/examples/functions/delete-deployment.md +14 -0
- package/docs/examples/functions/delete-execution.md +14 -0
- package/docs/examples/functions/delete-variable.md +14 -0
- package/docs/examples/functions/delete.md +13 -0
- package/docs/examples/functions/get-deployment-download.md +14 -0
- package/docs/examples/functions/get-deployment.md +14 -0
- package/docs/examples/functions/get-execution.md +14 -0
- package/docs/examples/functions/get-function-usage.md +14 -0
- package/docs/examples/functions/get-template.md +13 -0
- package/docs/examples/functions/get-usage.md +13 -0
- package/docs/examples/functions/get-variable.md +14 -0
- package/docs/examples/functions/get.md +13 -0
- package/docs/examples/functions/list-deployments.md +15 -0
- package/docs/examples/functions/list-executions.md +15 -0
- package/docs/examples/functions/list-runtimes.md +11 -0
- package/docs/examples/functions/list-specifications.md +11 -0
- package/docs/examples/functions/list-templates.md +16 -0
- package/docs/examples/functions/list-variables.md +13 -0
- package/docs/examples/functions/list.md +14 -0
- package/docs/examples/functions/update-deployment-build.md +14 -0
- package/docs/examples/functions/update-deployment.md +14 -0
- package/docs/examples/functions/update-variable.md +16 -0
- package/docs/examples/functions/update.md +30 -0
- package/docs/examples/graphql/mutation.md +13 -0
- package/docs/examples/graphql/query.md +13 -0
- package/docs/examples/health/get-antivirus.md +11 -0
- package/docs/examples/health/get-cache.md +11 -0
- package/docs/examples/health/get-certificate.md +13 -0
- package/docs/examples/health/get-d-b.md +11 -0
- package/docs/examples/health/get-failed-jobs.md +14 -0
- package/docs/examples/health/get-pub-sub.md +11 -0
- package/docs/examples/health/get-queue-builds.md +13 -0
- package/docs/examples/health/get-queue-certificates.md +13 -0
- package/docs/examples/health/get-queue-databases.md +14 -0
- package/docs/examples/health/get-queue-deletes.md +13 -0
- package/docs/examples/health/get-queue-functions.md +13 -0
- package/docs/examples/health/get-queue-logs.md +13 -0
- package/docs/examples/health/get-queue-mails.md +13 -0
- package/docs/examples/health/get-queue-messaging.md +13 -0
- package/docs/examples/health/get-queue-migrations.md +13 -0
- package/docs/examples/health/get-queue-usage-dump.md +13 -0
- package/docs/examples/health/get-queue-usage.md +13 -0
- package/docs/examples/health/get-queue-webhooks.md +13 -0
- package/docs/examples/health/get-queue.md +11 -0
- package/docs/examples/health/get-storage-local.md +11 -0
- package/docs/examples/health/get-storage.md +11 -0
- package/docs/examples/health/get-time.md +11 -0
- package/docs/examples/health/get.md +11 -0
- package/docs/examples/locale/get.md +11 -0
- package/docs/examples/locale/list-codes.md +11 -0
- package/docs/examples/locale/list-continents.md +11 -0
- package/docs/examples/locale/list-countries-e-u.md +11 -0
- package/docs/examples/locale/list-countries-phones.md +11 -0
- package/docs/examples/locale/list-countries.md +11 -0
- package/docs/examples/locale/list-currencies.md +11 -0
- package/docs/examples/locale/list-languages.md +11 -0
- package/docs/examples/messaging/create-apns-provider.md +20 -0
- package/docs/examples/messaging/create-email.md +24 -0
- package/docs/examples/messaging/create-fcm-provider.md +16 -0
- package/docs/examples/messaging/create-mailgun-provider.md +22 -0
- package/docs/examples/messaging/create-msg91provider.md +18 -0
- package/docs/examples/messaging/create-push.md +28 -0
- package/docs/examples/messaging/create-sendgrid-provider.md +20 -0
- package/docs/examples/messaging/create-sms.md +19 -0
- package/docs/examples/messaging/create-smtp-provider.md +26 -0
- package/docs/examples/messaging/create-subscriber.md +15 -0
- package/docs/examples/messaging/create-telesign-provider.md +18 -0
- package/docs/examples/messaging/create-textmagic-provider.md +18 -0
- package/docs/examples/messaging/create-topic.md +15 -0
- package/docs/examples/messaging/create-twilio-provider.md +18 -0
- package/docs/examples/messaging/create-vonage-provider.md +18 -0
- package/docs/examples/messaging/delete-provider.md +13 -0
- package/docs/examples/messaging/delete-subscriber.md +14 -0
- package/docs/examples/messaging/delete-topic.md +13 -0
- package/docs/examples/messaging/delete.md +13 -0
- package/docs/examples/messaging/get-message.md +13 -0
- package/docs/examples/messaging/get-provider.md +13 -0
- package/docs/examples/messaging/get-subscriber.md +14 -0
- package/docs/examples/messaging/get-topic.md +13 -0
- package/docs/examples/messaging/list-message-logs.md +14 -0
- package/docs/examples/messaging/list-messages.md +14 -0
- package/docs/examples/messaging/list-provider-logs.md +14 -0
- package/docs/examples/messaging/list-providers.md +14 -0
- package/docs/examples/messaging/list-subscriber-logs.md +14 -0
- package/docs/examples/messaging/list-subscribers.md +15 -0
- package/docs/examples/messaging/list-targets.md +14 -0
- package/docs/examples/messaging/list-topic-logs.md +14 -0
- package/docs/examples/messaging/list-topics.md +14 -0
- package/docs/examples/messaging/update-apns-provider.md +20 -0
- package/docs/examples/messaging/update-email.md +24 -0
- package/docs/examples/messaging/update-fcm-provider.md +16 -0
- package/docs/examples/messaging/update-mailgun-provider.md +22 -0
- package/docs/examples/messaging/update-msg91provider.md +18 -0
- package/docs/examples/messaging/update-push.md +28 -0
- package/docs/examples/messaging/update-sendgrid-provider.md +20 -0
- package/docs/examples/messaging/update-sms.md +19 -0
- package/docs/examples/messaging/update-smtp-provider.md +26 -0
- package/docs/examples/messaging/update-telesign-provider.md +18 -0
- package/docs/examples/messaging/update-textmagic-provider.md +18 -0
- package/docs/examples/messaging/update-topic.md +15 -0
- package/docs/examples/messaging/update-twilio-provider.md +18 -0
- package/docs/examples/messaging/update-vonage-provider.md +18 -0
- package/docs/examples/migrations/create-appwrite-migration.md +16 -0
- package/docs/examples/migrations/create-firebase-migration.md +14 -0
- package/docs/examples/migrations/create-firebase-o-auth-migration.md +14 -0
- package/docs/examples/migrations/create-n-host-migration.md +20 -0
- package/docs/examples/migrations/create-supabase-migration.md +19 -0
- package/docs/examples/migrations/delete-firebase-auth.md +11 -0
- package/docs/examples/migrations/delete.md +13 -0
- package/docs/examples/migrations/get-appwrite-report.md +16 -0
- package/docs/examples/migrations/get-firebase-report-o-auth.md +14 -0
- package/docs/examples/migrations/get-firebase-report.md +14 -0
- package/docs/examples/migrations/get-n-host-report.md +20 -0
- package/docs/examples/migrations/get-supabase-report.md +19 -0
- package/docs/examples/migrations/get.md +13 -0
- package/docs/examples/migrations/list-firebase-projects.md +11 -0
- package/docs/examples/migrations/list.md +14 -0
- package/docs/examples/migrations/retry.md +13 -0
- package/docs/examples/project/create-variable.md +14 -0
- package/docs/examples/project/delete-variable.md +13 -0
- package/docs/examples/project/get-usage.md +15 -0
- package/docs/examples/project/get-variable.md +13 -0
- package/docs/examples/project/list-variables.md +11 -0
- package/docs/examples/project/update-variable.md +15 -0
- package/docs/examples/projects/create-j-w-t.md +15 -0
- package/docs/examples/projects/create-key.md +16 -0
- package/docs/examples/projects/create-platform.md +18 -0
- package/docs/examples/projects/create-smtp-test.md +22 -0
- package/docs/examples/projects/create-webhook.md +20 -0
- package/docs/examples/projects/create.md +25 -0
- package/docs/examples/projects/delete-email-template.md +15 -0
- package/docs/examples/projects/delete-key.md +14 -0
- package/docs/examples/projects/delete-platform.md +14 -0
- package/docs/examples/projects/delete-sms-template.md +15 -0
- package/docs/examples/projects/delete-webhook.md +14 -0
- package/docs/examples/projects/delete.md +13 -0
- package/docs/examples/projects/get-email-template.md +15 -0
- package/docs/examples/projects/get-key.md +14 -0
- package/docs/examples/projects/get-platform.md +14 -0
- package/docs/examples/projects/get-sms-template.md +15 -0
- package/docs/examples/projects/get-webhook.md +14 -0
- package/docs/examples/projects/get.md +13 -0
- package/docs/examples/projects/list-keys.md +13 -0
- package/docs/examples/projects/list-platforms.md +13 -0
- package/docs/examples/projects/list-webhooks.md +13 -0
- package/docs/examples/projects/list.md +14 -0
- package/docs/examples/projects/update-api-status-all.md +14 -0
- package/docs/examples/projects/update-api-status.md +15 -0
- package/docs/examples/projects/update-auth-duration.md +14 -0
- package/docs/examples/projects/update-auth-limit.md +14 -0
- package/docs/examples/projects/update-auth-password-dictionary.md +14 -0
- package/docs/examples/projects/update-auth-password-history.md +14 -0
- package/docs/examples/projects/update-auth-sessions-limit.md +14 -0
- package/docs/examples/projects/update-auth-status.md +15 -0
- package/docs/examples/projects/update-email-template.md +20 -0
- package/docs/examples/projects/update-key.md +17 -0
- package/docs/examples/projects/update-mock-numbers.md +14 -0
- package/docs/examples/projects/update-o-auth2.md +17 -0
- package/docs/examples/projects/update-personal-data-check.md +14 -0
- package/docs/examples/projects/update-platform.md +18 -0
- package/docs/examples/projects/update-service-status-all.md +14 -0
- package/docs/examples/projects/update-service-status.md +15 -0
- package/docs/examples/projects/update-session-alerts.md +14 -0
- package/docs/examples/projects/update-sms-template.md +16 -0
- package/docs/examples/projects/update-smtp.md +22 -0
- package/docs/examples/projects/update-team.md +14 -0
- package/docs/examples/projects/update-webhook-signature.md +14 -0
- package/docs/examples/projects/update-webhook.md +21 -0
- package/docs/examples/projects/update.md +23 -0
- package/docs/examples/proxy/create-rule.md +15 -0
- package/docs/examples/proxy/delete-rule.md +13 -0
- package/docs/examples/proxy/get-rule.md +13 -0
- package/docs/examples/proxy/list-rules.md +14 -0
- package/docs/examples/proxy/update-rule-verification.md +13 -0
- package/docs/examples/storage/create-bucket.md +22 -0
- package/docs/examples/storage/create-file.md +16 -0
- package/docs/examples/storage/delete-bucket.md +13 -0
- package/docs/examples/storage/delete-file.md +14 -0
- package/docs/examples/storage/get-bucket-usage.md +14 -0
- package/docs/examples/storage/get-bucket.md +13 -0
- package/docs/examples/storage/get-file-download.md +14 -0
- package/docs/examples/storage/get-file-preview.md +25 -0
- package/docs/examples/storage/get-file-view.md +14 -0
- package/docs/examples/storage/get-file.md +14 -0
- package/docs/examples/storage/get-usage.md +13 -0
- package/docs/examples/storage/list-buckets.md +14 -0
- package/docs/examples/storage/list-files.md +15 -0
- package/docs/examples/storage/update-bucket.md +22 -0
- package/docs/examples/storage/update-file.md +16 -0
- package/docs/examples/teams/create-membership.md +19 -0
- package/docs/examples/teams/create.md +15 -0
- package/docs/examples/teams/delete-membership.md +14 -0
- package/docs/examples/teams/delete.md +13 -0
- package/docs/examples/teams/get-membership.md +14 -0
- package/docs/examples/teams/get-prefs.md +13 -0
- package/docs/examples/teams/get.md +13 -0
- package/docs/examples/teams/list-logs.md +14 -0
- package/docs/examples/teams/list-memberships.md +15 -0
- package/docs/examples/teams/list.md +14 -0
- package/docs/examples/teams/update-membership-status.md +16 -0
- package/docs/examples/teams/update-membership.md +15 -0
- package/docs/examples/teams/update-name.md +14 -0
- package/docs/examples/teams/update-prefs.md +14 -0
- package/docs/examples/users/create-argon2user.md +16 -0
- package/docs/examples/users/create-bcrypt-user.md +16 -0
- package/docs/examples/users/create-j-w-t.md +15 -0
- package/docs/examples/users/create-m-d5user.md +16 -0
- package/docs/examples/users/create-mfa-recovery-codes.md +13 -0
- package/docs/examples/users/create-p-h-pass-user.md +16 -0
- package/docs/examples/users/create-s-h-a-user.md +17 -0
- package/docs/examples/users/create-scrypt-modified-user.md +19 -0
- package/docs/examples/users/create-scrypt-user.md +21 -0
- package/docs/examples/users/create-session.md +13 -0
- package/docs/examples/users/create-target.md +18 -0
- package/docs/examples/users/create-token.md +15 -0
- package/docs/examples/users/create.md +17 -0
- package/docs/examples/users/delete-identity.md +13 -0
- package/docs/examples/users/delete-mfa-authenticator.md +14 -0
- package/docs/examples/users/delete-session.md +14 -0
- package/docs/examples/users/delete-sessions.md +13 -0
- package/docs/examples/users/delete-target.md +14 -0
- package/docs/examples/users/delete.md +13 -0
- package/docs/examples/users/get-mfa-recovery-codes.md +13 -0
- package/docs/examples/users/get-prefs.md +13 -0
- package/docs/examples/users/get-target.md +14 -0
- package/docs/examples/users/get-usage.md +13 -0
- package/docs/examples/users/get.md +13 -0
- package/docs/examples/users/list-identities.md +14 -0
- package/docs/examples/users/list-logs.md +14 -0
- package/docs/examples/users/list-memberships.md +13 -0
- package/docs/examples/users/list-mfa-factors.md +13 -0
- package/docs/examples/users/list-sessions.md +13 -0
- package/docs/examples/users/list-targets.md +14 -0
- package/docs/examples/users/list.md +14 -0
- package/docs/examples/users/update-email-verification.md +14 -0
- package/docs/examples/users/update-email.md +14 -0
- package/docs/examples/users/update-labels.md +14 -0
- package/docs/examples/users/update-mfa-recovery-codes.md +13 -0
- package/docs/examples/users/update-mfa.md +14 -0
- package/docs/examples/users/update-name.md +14 -0
- package/docs/examples/users/update-password.md +14 -0
- package/docs/examples/users/update-phone-verification.md +14 -0
- package/docs/examples/users/update-phone.md +14 -0
- package/docs/examples/users/update-prefs.md +14 -0
- package/docs/examples/users/update-status.md +14 -0
- package/docs/examples/users/update-target.md +17 -0
- package/docs/examples/vcs/create-repository-detection.md +15 -0
- package/docs/examples/vcs/create-repository.md +15 -0
- package/docs/examples/vcs/delete-installation.md +13 -0
- package/docs/examples/vcs/get-installation.md +13 -0
- package/docs/examples/vcs/get-repository-contents.md +15 -0
- package/docs/examples/vcs/get-repository.md +14 -0
- package/docs/examples/vcs/list-installations.md +14 -0
- package/docs/examples/vcs/list-repositories.md +14 -0
- package/docs/examples/vcs/list-repository-branches.md +14 -0
- package/docs/examples/vcs/update-external-deployments.md +15 -0
- package/package.json +42 -0
- package/publish.sh +4 -0
- package/rollup.config.js +27 -0
- package/src/Cache/Adapter.ts +11 -0
- package/src/Cache/Adapters/Filesystem.ts +126 -0
- package/src/Cache/Adapters/Memory.ts +57 -0
- package/src/Cache/Adapters/None.ts +36 -0
- package/src/Cache/Adapters/Redis.ts +106 -0
- package/src/Cache/Adapters/Sharding.ts +87 -0
- package/src/Cache/Cache.ts +75 -0
- package/src/Cache/index.ts +5 -0
- package/src/Cache/test.ts +0 -0
- package/src/Services.ts +41 -0
- package/src/client.ts +397 -0
- package/src/decorators/Cache.ts +102 -0
- package/src/decorators/CacheKey.ts +9 -0
- package/src/decorators/Invalidate.ts +68 -0
- package/src/enums/api-service.ts +13 -0
- package/src/enums/api.ts +5 -0
- package/src/enums/auth-method.ts +9 -0
- package/src/enums/authentication-factor.ts +6 -0
- package/src/enums/authenticator-type.ts +3 -0
- package/src/enums/browser.ts +16 -0
- package/src/enums/compression.ts +5 -0
- package/src/enums/credit-card.ts +18 -0
- package/src/enums/database-usage-range.ts +5 -0
- package/src/enums/email-template-locale.ts +133 -0
- package/src/enums/email-template-type.ts +9 -0
- package/src/enums/entities/EntityLimitType.ts +4 -0
- package/src/enums/entities/PropertyAttributeName.ts +27 -0
- package/src/enums/entities/PropertyCondition.ts +8 -0
- package/src/enums/entities/PropertyType.ts +16 -0
- package/src/enums/entities/PropertyValueType.ts +6 -0
- package/src/enums/entities/RowAccess.ts +2 -0
- package/src/enums/entities/ViewFilterCondition.ts +12 -0
- package/src/enums/execution-method.ts +8 -0
- package/src/enums/flag.ts +197 -0
- package/src/enums/function-usage-range.ts +5 -0
- package/src/enums/image-format.ts +7 -0
- package/src/enums/image-gravity.ts +11 -0
- package/src/enums/index-type.ts +5 -0
- package/src/enums/messaging-provider-type.ts +5 -0
- package/src/enums/name.ts +14 -0
- package/src/enums/o-auth-provider copy.ts +41 -0
- package/src/enums/o-auth-provider.ts +41 -0
- package/src/enums/password-hash.ts +13 -0
- package/src/enums/platform-type.ts +17 -0
- package/src/enums/project-usage-range.ts +4 -0
- package/src/enums/region.ts +4 -0
- package/src/enums/relation-mutate.ts +5 -0
- package/src/enums/relationship-type.ts +6 -0
- package/src/enums/resource-type.ts +4 -0
- package/src/enums/runtime.ts +48 -0
- package/src/enums/s-m-t-p-secure.ts +3 -0
- package/src/enums/shared/ApplicationLayout.ts +4 -0
- package/src/enums/shared/Colors.ts +24 -0
- package/src/enums/shared/InputType.ts +6 -0
- package/src/enums/shared/Periodicity.ts +7 -0
- package/src/enums/shared/SvgIcon.ts +37 -0
- package/src/enums/shared/Theme.ts +4 -0
- package/src/enums/sms-template-locale.ts +133 -0
- package/src/enums/sms-template-type.ts +6 -0
- package/src/enums/smtp-encryption.ts +5 -0
- package/src/enums/storage-usage-range.ts +5 -0
- package/src/enums/subscriptions/PricingModel.ts +14 -0
- package/src/enums/subscriptions/SubscriptionBillingPeriod.ts +15 -0
- package/src/enums/subscriptions/SubscriptionFeatureLimitType.ts +16 -0
- package/src/enums/subscriptions/SubscriptionPriceType.ts +10 -0
- package/src/enums/tenants/LinkedAccountStatus.ts +5 -0
- package/src/enums/tenants/TenantUserJoined.ts +6 -0
- package/src/enums/tenants/TenantUserStatus.ts +6 -0
- package/src/enums/tenants/TenantUserType.ts +5 -0
- package/src/enums/user-usage-range.ts +5 -0
- package/src/id.ts +47 -0
- package/src/index.ts +36 -0
- package/src/inputFile.ts +23 -0
- package/src/lib/Registry/Registry.ts +66 -0
- package/src/lib/Registry/index.ts +1 -0
- package/src/models.ts +3339 -0
- package/src/permission.ts +57 -0
- package/src/query.ts +261 -0
- package/src/role.ts +100 -0
- package/src/service-client.ts +29 -0
- package/src/service.ts +30 -0
- package/src/services/account.ts +1643 -0
- package/src/services/applets.ts +75 -0
- package/src/services/avatars.ts +314 -0
- package/src/services/community.ts +102 -0
- package/src/services/configuration.ts +15 -0
- package/src/services/databases.ts +2037 -0
- package/src/services/functions.ts +986 -0
- package/src/services/graphql.ts +75 -0
- package/src/services/health.ts +629 -0
- package/src/services/locale.ts +205 -0
- package/src/services/messaging.ts +2247 -0
- package/src/services/node.ts +15 -0
- package/src/services/permissions.ts +131 -0
- package/src/services/pricing.ts +30 -0
- package/src/services/projects.ts +1901 -0
- package/src/services/roles.ts +101 -0
- package/src/services/schema.ts +65 -0
- package/src/services/storage.ts +576 -0
- package/src/services/subscription.ts +40 -0
- package/src/services/teams.ts +490 -0
- package/src/services/tenant-subscription.ts +93 -0
- package/src/services/tenant.ts +194 -0
- package/src/services/users.ts +1584 -0
- package/tsconfig.json +29 -0
- package/types/Cache/Adapter.d.ts +10 -0
- package/types/Cache/Adapters/Filesystem.d.ts +16 -0
- package/types/Cache/Adapters/Memory.d.ts +18 -0
- package/types/Cache/Adapters/None.d.ts +12 -0
- package/types/Cache/Adapters/Redis.d.ts +14 -0
- package/types/Cache/Adapters/Sharding.d.ts +17 -0
- package/types/Cache/Cache.d.ts +16 -0
- package/types/Cache/index.d.ts +5 -0
- package/types/Cache/test.d.ts +0 -0
- package/types/Services.d.ts +6 -0
- package/types/client.d.ts +141 -0
- package/types/decorators/Cache.d.ts +1 -0
- package/types/decorators/CacheKey.d.ts +1 -0
- package/types/decorators/Invalidate.d.ts +1 -0
- package/types/enums/api-service.d.ts +13 -0
- package/types/enums/api.d.ts +5 -0
- package/types/enums/auth-method.d.ts +9 -0
- package/types/enums/authentication-factor.d.ts +6 -0
- package/types/enums/authenticator-type.d.ts +3 -0
- package/types/enums/browser.d.ts +16 -0
- package/types/enums/compression.d.ts +5 -0
- package/types/enums/credit-card.d.ts +18 -0
- package/types/enums/database-usage-range.d.ts +5 -0
- package/types/enums/email-template-locale.d.ts +133 -0
- package/types/enums/email-template-type.d.ts +9 -0
- package/types/enums/entities/EntityLimitType.d.ts +4 -0
- package/types/enums/entities/PropertyAttributeName.d.ts +27 -0
- package/types/enums/entities/PropertyCondition.d.ts +7 -0
- package/types/enums/entities/PropertyType.d.ts +12 -0
- package/types/enums/entities/PropertyValueType.d.ts +6 -0
- package/types/enums/entities/RowAccess.d.ts +2 -0
- package/types/enums/entities/ViewFilterCondition.d.ts +12 -0
- package/types/enums/execution-method.d.ts +8 -0
- package/types/enums/flag.d.ts +197 -0
- package/types/enums/function-usage-range.d.ts +5 -0
- package/types/enums/image-format.d.ts +7 -0
- package/types/enums/image-gravity.d.ts +11 -0
- package/types/enums/index-type.d.ts +5 -0
- package/types/enums/messaging-provider-type.d.ts +5 -0
- package/types/enums/name.d.ts +14 -0
- package/types/enums/o-auth-provider copy.d.ts +41 -0
- package/types/enums/o-auth-provider.d.ts +41 -0
- package/types/enums/password-hash.d.ts +13 -0
- package/types/enums/platform-type.d.ts +17 -0
- package/types/enums/project-usage-range.d.ts +4 -0
- package/types/enums/region.d.ts +4 -0
- package/types/enums/relation-mutate.d.ts +5 -0
- package/types/enums/relationship-type.d.ts +6 -0
- package/types/enums/resource-type.d.ts +4 -0
- package/types/enums/runtime.d.ts +48 -0
- package/types/enums/s-m-t-p-secure.d.ts +3 -0
- package/types/enums/shared/ApplicationLayout.d.ts +4 -0
- package/types/enums/shared/Colors.d.ts +24 -0
- package/types/enums/shared/InputType.d.ts +6 -0
- package/types/enums/shared/Periodicity.d.ts +7 -0
- package/types/enums/shared/SvgIcon.d.ts +37 -0
- package/types/enums/shared/Theme.d.ts +4 -0
- package/types/enums/sms-template-locale.d.ts +133 -0
- package/types/enums/sms-template-type.d.ts +6 -0
- package/types/enums/smtp-encryption.d.ts +5 -0
- package/types/enums/storage-usage-range.d.ts +5 -0
- package/types/enums/subscriptions/PricingModel.d.ts +11 -0
- package/types/enums/subscriptions/SubscriptionBillingPeriod.d.ts +10 -0
- package/types/enums/subscriptions/SubscriptionFeatureLimitType.d.ts +10 -0
- package/types/enums/subscriptions/SubscriptionPriceType.d.ts +7 -0
- package/types/enums/tenants/LinkedAccountStatus.d.ts +5 -0
- package/types/enums/tenants/TenantUserJoined.d.ts +6 -0
- package/types/enums/tenants/TenantUserStatus.d.ts +6 -0
- package/types/enums/tenants/TenantUserType.d.ts +5 -0
- package/types/enums/user-usage-range.d.ts +5 -0
- package/types/id.d.ts +20 -0
- package/types/index.d.ts +36 -0
- package/types/inputFile.d.ts +6 -0
- package/types/lib/Registry/Registry.d.ts +38 -0
- package/types/lib/Registry/index.d.ts +1 -0
- package/types/models.d.ts +3272 -0
- package/types/permission.d.ts +43 -0
- package/types/query.d.ts +194 -0
- package/types/role.d.ts +70 -0
- package/types/service-client.d.ts +7 -0
- package/types/service.d.ts +11 -0
- package/types/services/account.d.ts +530 -0
- package/types/services/acl.d.ts +28 -0
- package/types/services/applets.d.ts +9 -0
- package/types/services/assistant.d.ts +14 -0
- package/types/services/avatars.d.ts +115 -0
- package/types/services/community.d.ts +19 -0
- package/types/services/configuration.d.ts +5 -0
- package/types/services/console.d.ts +15 -0
- package/types/services/databases.d.ts +613 -0
- package/types/services/functions.d.ts +319 -0
- package/types/services/graphql.d.ts +25 -0
- package/types/services/health.d.ts +231 -0
- package/types/services/locale.d.ts +80 -0
- package/types/services/messaging.d.ts +685 -0
- package/types/services/migrations.d.ts +185 -0
- package/types/services/node.d.ts +5 -0
- package/types/services/permissions.d.ts +20 -0
- package/types/services/pricing.d.ts +15 -0
- package/types/services/project.d.ts +70 -0
- package/types/services/projects.d.ts +542 -0
- package/types/services/proxy.d.ts +59 -0
- package/types/services/roles.d.ts +19 -0
- package/types/services/schema.d.ts +17 -0
- package/types/services/storage.d.ts +189 -0
- package/types/services/subscription-product.d.ts +77 -0
- package/types/services/subscription.d.ts +15 -0
- package/types/services/teams.d.ts +167 -0
- package/types/services/tenant-subscription.d.ts +12 -0
- package/types/services/tenant.d.ts +32 -0
- package/types/services/users.d.ts +499 -0
- package/types/services/vcs.d.ts +108 -0
@@ -0,0 +1,87 @@
|
|
1
|
+
import { Adapter } from "../Adapter";
|
2
|
+
|
3
|
+
export class Sharding implements Adapter {
|
4
|
+
protected adapters: Adapter[];
|
5
|
+
protected count: number = 0;
|
6
|
+
|
7
|
+
constructor(adapters: Adapter[]) {
|
8
|
+
if (adapters.length === 0) {
|
9
|
+
throw new Error('No adapters provided');
|
10
|
+
}
|
11
|
+
|
12
|
+
this.count = adapters.length;
|
13
|
+
this.adapters = adapters;
|
14
|
+
}
|
15
|
+
delWithStart(pattern: string): Promise<number> {
|
16
|
+
throw new Error("Method not implemented.");
|
17
|
+
}
|
18
|
+
|
19
|
+
async load(key: string, ttl: number, hash: string = ''): Promise<any> {
|
20
|
+
const adapter = this.getAdapter(key);
|
21
|
+
return await adapter.load(key, ttl, hash);
|
22
|
+
}
|
23
|
+
|
24
|
+
async save(key: string, data: any, hash: string = ''): Promise<boolean | string | any[]> {
|
25
|
+
return this.getAdapter(key).save(key, data, hash);
|
26
|
+
}
|
27
|
+
|
28
|
+
async list(key: string): Promise<string[]> {
|
29
|
+
return this.getAdapter(key).list(key);
|
30
|
+
}
|
31
|
+
|
32
|
+
async purge(key: string, hash: string = ''): Promise<boolean> {
|
33
|
+
return this.getAdapter(key).purge(key, hash);
|
34
|
+
}
|
35
|
+
|
36
|
+
async flush(): Promise<boolean> {
|
37
|
+
let result = true;
|
38
|
+
for (const adapter of this.adapters) {
|
39
|
+
result = await adapter.flush() ? result : false;
|
40
|
+
}
|
41
|
+
return result;
|
42
|
+
}
|
43
|
+
|
44
|
+
async ping(): Promise<boolean> {
|
45
|
+
for (const adapter of this.adapters) {
|
46
|
+
if (!adapter.ping()) {
|
47
|
+
return false;
|
48
|
+
}
|
49
|
+
}
|
50
|
+
return true;
|
51
|
+
}
|
52
|
+
|
53
|
+
async getSize(): Promise<number> {
|
54
|
+
let size = 0;
|
55
|
+
for (const adapter of this.adapters) {
|
56
|
+
size += await adapter.getSize();
|
57
|
+
}
|
58
|
+
return size;
|
59
|
+
}
|
60
|
+
|
61
|
+
protected getAdapter(key: string): Adapter {
|
62
|
+
const hash = this.crc32(key);
|
63
|
+
const index = hash % this.count;
|
64
|
+
return this.adapters[index];
|
65
|
+
}
|
66
|
+
|
67
|
+
private crc32(str: string): number {
|
68
|
+
let crc = 0 ^ (-1);
|
69
|
+
for (let i = 0; i < str.length; i++) {
|
70
|
+
crc = (crc >>> 8) ^ this.crc32Table[(crc ^ str.charCodeAt(i)) & 0xff];
|
71
|
+
}
|
72
|
+
return (crc ^ (-1)) >>> 0;
|
73
|
+
}
|
74
|
+
|
75
|
+
private crc32Table = (() => {
|
76
|
+
let c: number;
|
77
|
+
const table: number[] = [];
|
78
|
+
for (let n = 0; n < 256; n++) {
|
79
|
+
c = n;
|
80
|
+
for (let k = 0; k < 8; k++) {
|
81
|
+
c = ((c & 1) ? (0xEDB88320 ^ (c >>> 1)) : (c >>> 1));
|
82
|
+
}
|
83
|
+
table[n] = c;
|
84
|
+
}
|
85
|
+
return table;
|
86
|
+
})();
|
87
|
+
}
|
@@ -0,0 +1,75 @@
|
|
1
|
+
import { Adapter } from "./Adapter";
|
2
|
+
|
3
|
+
|
4
|
+
export class Cache {
|
5
|
+
private adapter: Adapter;
|
6
|
+
public static caseSensitive: boolean = false;
|
7
|
+
|
8
|
+
constructor(adapter: Adapter) {
|
9
|
+
this.adapter = adapter;
|
10
|
+
}
|
11
|
+
|
12
|
+
private constructKey(key: any): string {
|
13
|
+
if (Array.isArray(key)) {
|
14
|
+
key = key.join(':');
|
15
|
+
}
|
16
|
+
|
17
|
+
return key;
|
18
|
+
}
|
19
|
+
|
20
|
+
public static setCaseSensitivity(value: boolean): boolean {
|
21
|
+
return this.caseSensitive = value;
|
22
|
+
}
|
23
|
+
|
24
|
+
public async load(key: string | string[], ttl: number = 60 * 60 * 24, hash: string = ''): Promise<any> {
|
25
|
+
key = this.constructKey(key);
|
26
|
+
key = Cache.caseSensitive ? key : key.toLowerCase();
|
27
|
+
hash = Cache.caseSensitive ? hash : hash.toLowerCase();
|
28
|
+
|
29
|
+
return await this.adapter.load(key, ttl, hash);
|
30
|
+
}
|
31
|
+
|
32
|
+
public async save(key: string | string[], data: any, hash: string = ''): Promise<boolean | string | any[]> {
|
33
|
+
|
34
|
+
key = this.constructKey(key);
|
35
|
+
|
36
|
+
key = Cache.caseSensitive ? key : key.toLowerCase();
|
37
|
+
hash = Cache.caseSensitive ? hash : hash.toLowerCase();
|
38
|
+
|
39
|
+
return this.adapter.save(key, data, hash);
|
40
|
+
}
|
41
|
+
|
42
|
+
public async list(key: string | string[]): Promise<string[]> {
|
43
|
+
key = this.constructKey(key);
|
44
|
+
key = Cache.caseSensitive ? key : key.toLowerCase();
|
45
|
+
|
46
|
+
return this.adapter.list(key);
|
47
|
+
}
|
48
|
+
|
49
|
+
public async purge(key: string | string[], hash: string = ''): Promise<boolean> {
|
50
|
+
|
51
|
+
key = this.constructKey(key);
|
52
|
+
|
53
|
+
key = Cache.caseSensitive ? key : key.toLowerCase();
|
54
|
+
hash = Cache.caseSensitive ? hash : hash.toLowerCase();
|
55
|
+
|
56
|
+
return this.adapter.purge(key, hash);
|
57
|
+
}
|
58
|
+
|
59
|
+
public async flush(): Promise<boolean> {
|
60
|
+
return this.adapter.flush();
|
61
|
+
}
|
62
|
+
|
63
|
+
public async ping(): Promise<boolean> {
|
64
|
+
return this.adapter.ping();
|
65
|
+
}
|
66
|
+
|
67
|
+
public async getSize(): Promise<number> {
|
68
|
+
return this.adapter.getSize();
|
69
|
+
}
|
70
|
+
|
71
|
+
public async delWithStart(keys: string | string[]): Promise<number> {
|
72
|
+
const pattern = this.constructKey(keys);
|
73
|
+
return this.adapter.delWithStart(pattern);
|
74
|
+
}
|
75
|
+
}
|
File without changes
|
package/src/Services.ts
ADDED
@@ -0,0 +1,41 @@
|
|
1
|
+
import { Registry } from "@/lib/Registry";
|
2
|
+
import { createClient } from 'redis';
|
3
|
+
import { Redis } from "./Cache/Adapters/Redis";
|
4
|
+
import { Cache } from "./Cache";
|
5
|
+
|
6
|
+
|
7
|
+
export const registry = new Registry();
|
8
|
+
|
9
|
+
registry.set('cache', () => {
|
10
|
+
const client = createClient({
|
11
|
+
socket: {
|
12
|
+
host: process.env._APP_REDIS_HOST ?? 'localhost',
|
13
|
+
port: Number.parseInt(process.env._APP_REDIS_PORT ?? '6379'),
|
14
|
+
|
15
|
+
},
|
16
|
+
password: undefined,
|
17
|
+
});
|
18
|
+
|
19
|
+
// Bağlantı hatalarını ele al
|
20
|
+
client.on('error', (err) => {
|
21
|
+
|
22
|
+
console.error('Redis Client Error', err);
|
23
|
+
});
|
24
|
+
|
25
|
+
// Connect to Redis
|
26
|
+
client.connect();
|
27
|
+
|
28
|
+
const redisAdapter = new Redis(client as any);
|
29
|
+
|
30
|
+
const cacheProvider = new Cache(redisAdapter);
|
31
|
+
|
32
|
+
return cacheProvider;
|
33
|
+
|
34
|
+
})
|
35
|
+
|
36
|
+
export class Services {
|
37
|
+
public static get Cache(): Cache {
|
38
|
+
return registry.get('cache');
|
39
|
+
}
|
40
|
+
|
41
|
+
}
|
package/src/client.ts
ADDED
@@ -0,0 +1,397 @@
|
|
1
|
+
import { fetch, FormData, File } from 'node-fetch-native-with-agent';
|
2
|
+
import { createAgent } from 'node-fetch-native-with-agent/agent';
|
3
|
+
import { Models } from './models';
|
4
|
+
|
5
|
+
type Payload = {
|
6
|
+
[key: string]: any;
|
7
|
+
}
|
8
|
+
|
9
|
+
type UploadProgress = {
|
10
|
+
$id: string;
|
11
|
+
progress: number;
|
12
|
+
sizeUploaded: number;
|
13
|
+
chunksTotal: number;
|
14
|
+
chunksUploaded: number;
|
15
|
+
}
|
16
|
+
|
17
|
+
type Headers = {
|
18
|
+
[key: string]: string;
|
19
|
+
}
|
20
|
+
|
21
|
+
class AppcondaException extends Error {
|
22
|
+
code: number;
|
23
|
+
response: string;
|
24
|
+
type: string;
|
25
|
+
constructor(message: string, code: number = 0, type: string = '', response: string = '') {
|
26
|
+
super(message);
|
27
|
+
this.name = 'AppcondaException';
|
28
|
+
this.message = message;
|
29
|
+
this.code = code;
|
30
|
+
this.type = type;
|
31
|
+
this.response = response;
|
32
|
+
}
|
33
|
+
}
|
34
|
+
|
35
|
+
function getUserAgent() {
|
36
|
+
let ua = 'AppcondaNodeJSSDK/14.1.0';
|
37
|
+
|
38
|
+
// `process` is a global in Node.js, but not fully available in all runtimes.
|
39
|
+
const platform: string[] = [];
|
40
|
+
if (typeof process !== 'undefined') {
|
41
|
+
if (typeof process.platform === 'string') platform.push(process.platform);
|
42
|
+
if (typeof process.arch === 'string') platform.push(process.arch);
|
43
|
+
}
|
44
|
+
if (platform.length > 0) {
|
45
|
+
ua += ` (${platform.join('; ')})`;
|
46
|
+
}
|
47
|
+
|
48
|
+
// `navigator.userAgent` is available in Node.js 21 and later.
|
49
|
+
// It's also part of the WinterCG spec, so many edge runtimes provide it.
|
50
|
+
// https://common-min-api.proposal.wintercg.org/#requirements-for-navigatoruseragent
|
51
|
+
// @ts-ignore
|
52
|
+
if (typeof navigator !== 'undefined' && typeof navigator.userAgent === 'string') {
|
53
|
+
// @ts-ignore
|
54
|
+
ua += ` ${navigator.userAgent}`;
|
55
|
+
|
56
|
+
// @ts-ignore
|
57
|
+
} else if (typeof globalThis.EdgeRuntime === 'string') {
|
58
|
+
ua += ` EdgeRuntime`;
|
59
|
+
|
60
|
+
// Older Node.js versions don't have `navigator.userAgent`, so we have to use `process.version`.
|
61
|
+
} else if (typeof process !== 'undefined' && typeof process.version === 'string') {
|
62
|
+
ua += ` Node.js/${process.version}`;
|
63
|
+
}
|
64
|
+
|
65
|
+
return ua;
|
66
|
+
}
|
67
|
+
|
68
|
+
class Client {
|
69
|
+
static CHUNK_SIZE = 1024 * 1024 * 5;
|
70
|
+
|
71
|
+
config = {
|
72
|
+
endpoint: 'https://cloud.appconda.io/v1',
|
73
|
+
selfSigned: false,
|
74
|
+
project: '',
|
75
|
+
mode: '',
|
76
|
+
key: '',
|
77
|
+
jwt: '',
|
78
|
+
locale: '',
|
79
|
+
session: '',
|
80
|
+
forwardeduseragent: '',
|
81
|
+
};
|
82
|
+
headers: Headers = {
|
83
|
+
'x-sdk-name': 'Node.js',
|
84
|
+
'x-sdk-platform': 'server',
|
85
|
+
'x-sdk-language': 'nodejs',
|
86
|
+
'x-sdk-version': '14.1.0',
|
87
|
+
'user-agent': getUserAgent(),
|
88
|
+
'X-Appconda-Response-Format': '1.6.0',
|
89
|
+
};
|
90
|
+
|
91
|
+
/**
|
92
|
+
* Set Endpoint
|
93
|
+
*
|
94
|
+
* Your project endpoint
|
95
|
+
*
|
96
|
+
* @param {string} endpoint
|
97
|
+
*
|
98
|
+
* @returns {this}
|
99
|
+
*/
|
100
|
+
setEndpoint(endpoint: string): this {
|
101
|
+
this.config.endpoint = endpoint;
|
102
|
+
|
103
|
+
return this;
|
104
|
+
}
|
105
|
+
|
106
|
+
/**
|
107
|
+
* Set self-signed
|
108
|
+
*
|
109
|
+
* @param {boolean} selfSigned
|
110
|
+
*
|
111
|
+
* @returns {this}
|
112
|
+
*/
|
113
|
+
setSelfSigned(selfSigned: boolean): this {
|
114
|
+
// @ts-ignore
|
115
|
+
if (typeof globalThis.EdgeRuntime !== 'undefined') {
|
116
|
+
console.warn('setSelfSigned is not supported in edge runtimes.');
|
117
|
+
}
|
118
|
+
|
119
|
+
this.config.selfSigned = selfSigned;
|
120
|
+
|
121
|
+
return this;
|
122
|
+
}
|
123
|
+
|
124
|
+
/**
|
125
|
+
* Add header
|
126
|
+
*
|
127
|
+
* @param {string} header
|
128
|
+
* @param {string} value
|
129
|
+
*
|
130
|
+
* @returns {this}
|
131
|
+
*/
|
132
|
+
addHeader(header: string, value: string): this {
|
133
|
+
this.headers[header.toLowerCase()] = value;
|
134
|
+
|
135
|
+
return this;
|
136
|
+
}
|
137
|
+
|
138
|
+
/**
|
139
|
+
* Set Project
|
140
|
+
*
|
141
|
+
* Your project ID
|
142
|
+
*
|
143
|
+
* @param value string
|
144
|
+
*
|
145
|
+
* @return {this}
|
146
|
+
*/
|
147
|
+
setProject(value: string): this {
|
148
|
+
this.headers['X-Appconda-Project'] = value;
|
149
|
+
this.config.project = value;
|
150
|
+
return this;
|
151
|
+
}
|
152
|
+
|
153
|
+
/**
|
154
|
+
* Set Mode
|
155
|
+
*
|
156
|
+
* @param value string
|
157
|
+
*
|
158
|
+
* @return {this}
|
159
|
+
*/
|
160
|
+
setMode(value: string): this {
|
161
|
+
this.headers['X-Appconda-Mode'] = value;
|
162
|
+
this.config.mode = value;
|
163
|
+
return this;
|
164
|
+
}
|
165
|
+
|
166
|
+
/**
|
167
|
+
* Set Key
|
168
|
+
*
|
169
|
+
* Your secret API key
|
170
|
+
*
|
171
|
+
* @param value string
|
172
|
+
*
|
173
|
+
* @return {this}
|
174
|
+
*/
|
175
|
+
setKey(value: string): this {
|
176
|
+
this.headers['X-Appconda-Key'] = value;
|
177
|
+
this.config.key = value;
|
178
|
+
return this;
|
179
|
+
}
|
180
|
+
/**
|
181
|
+
* Set JWT
|
182
|
+
*
|
183
|
+
* Your secret JSON Web Token
|
184
|
+
*
|
185
|
+
* @param value string
|
186
|
+
*
|
187
|
+
* @return {this}
|
188
|
+
*/
|
189
|
+
setJWT(value: string): this {
|
190
|
+
this.headers['X-Appconda-JWT'] = value;
|
191
|
+
this.config.jwt = value;
|
192
|
+
return this;
|
193
|
+
}
|
194
|
+
/**
|
195
|
+
* Set Locale
|
196
|
+
*
|
197
|
+
* @param value string
|
198
|
+
*
|
199
|
+
* @return {this}
|
200
|
+
*/
|
201
|
+
setLocale(value: string): this {
|
202
|
+
this.headers['X-Appconda-Locale'] = value;
|
203
|
+
this.config.locale = value;
|
204
|
+
return this;
|
205
|
+
}
|
206
|
+
/**
|
207
|
+
* Set Session
|
208
|
+
*
|
209
|
+
* The user session to authenticate with
|
210
|
+
*
|
211
|
+
* @param value string
|
212
|
+
*
|
213
|
+
* @return {this}
|
214
|
+
*/
|
215
|
+
setSession(value: string): this {
|
216
|
+
this.headers['X-Appconda-Session'] = value;
|
217
|
+
this.config.session = value;
|
218
|
+
return this;
|
219
|
+
}
|
220
|
+
/**
|
221
|
+
* Set ForwardedUserAgent
|
222
|
+
*
|
223
|
+
* The user agent string of the client that made the request
|
224
|
+
*
|
225
|
+
* @param value string
|
226
|
+
*
|
227
|
+
* @return {this}
|
228
|
+
*/
|
229
|
+
setForwardedUserAgent(value: string): this {
|
230
|
+
this.headers['X-Forwarded-User-Agent'] = value;
|
231
|
+
this.config.forwardeduseragent = value;
|
232
|
+
return this;
|
233
|
+
}
|
234
|
+
|
235
|
+
setFallbackCookies(value: string): this {
|
236
|
+
this.headers['X-Fallback-Cookies'] = value;
|
237
|
+
//this.config.forwardeduseragent = value;
|
238
|
+
return this;
|
239
|
+
}
|
240
|
+
|
241
|
+
prepareRequest(method: string, url: URL, headers: Headers = {}, params: Payload = {}): { uri: string, options: RequestInit } {
|
242
|
+
method = method.toUpperCase();
|
243
|
+
|
244
|
+
headers = Object.assign({}, this.headers, headers);
|
245
|
+
|
246
|
+
let options: RequestInit = {
|
247
|
+
method,
|
248
|
+
headers,
|
249
|
+
...createAgent(this.config.endpoint, { rejectUnauthorized: !this.config.selfSigned }),
|
250
|
+
};
|
251
|
+
|
252
|
+
if (method === 'GET') {
|
253
|
+
for (const [key, value] of Object.entries(Client.flatten(params))) {
|
254
|
+
url.searchParams.append(key, value);
|
255
|
+
}
|
256
|
+
} else {
|
257
|
+
switch (headers['content-type']) {
|
258
|
+
case 'application/json':
|
259
|
+
options.body = JSON.stringify(params);
|
260
|
+
break;
|
261
|
+
|
262
|
+
case 'multipart/form-data':
|
263
|
+
const formData = new FormData();
|
264
|
+
|
265
|
+
for (const [key, value] of Object.entries(params)) {
|
266
|
+
if (value instanceof File) {
|
267
|
+
formData.append(key, value, value.name);
|
268
|
+
} else if (Array.isArray(value)) {
|
269
|
+
for (const nestedValue of value) {
|
270
|
+
formData.append(`${key}[]`, nestedValue);
|
271
|
+
}
|
272
|
+
} else {
|
273
|
+
formData.append(key, value);
|
274
|
+
}
|
275
|
+
}
|
276
|
+
|
277
|
+
options.body = formData;
|
278
|
+
delete headers['content-type'];
|
279
|
+
break;
|
280
|
+
}
|
281
|
+
}
|
282
|
+
|
283
|
+
return { uri: url.toString(), options };
|
284
|
+
}
|
285
|
+
|
286
|
+
async chunkedUpload(method: string, url: URL, headers: Headers = {}, originalPayload: Payload = {}, onProgress: (progress: UploadProgress) => void) {
|
287
|
+
const file: any = Object.values(originalPayload).find((value) => value instanceof File);
|
288
|
+
|
289
|
+
if (file.size <= Client.CHUNK_SIZE) {
|
290
|
+
return await this.call(method, url, headers, originalPayload);
|
291
|
+
}
|
292
|
+
|
293
|
+
let start = 0;
|
294
|
+
let response = null;
|
295
|
+
|
296
|
+
while (start < file.size) {
|
297
|
+
let end = start + Client.CHUNK_SIZE; // Prepare end for the next chunk
|
298
|
+
if (end >= file.size) {
|
299
|
+
end = file.size; // Adjust for the last chunk to include the last byte
|
300
|
+
}
|
301
|
+
|
302
|
+
headers['content-range'] = `bytes ${start}-${end - 1}/${file.size}`;
|
303
|
+
const chunk = file.slice(start, end);
|
304
|
+
|
305
|
+
let payload = { ...originalPayload, file: new File([chunk], file.name) };
|
306
|
+
|
307
|
+
response = await this.call(method, url, headers, payload);
|
308
|
+
|
309
|
+
if (onProgress && typeof onProgress === 'function') {
|
310
|
+
onProgress({
|
311
|
+
$id: response.$id,
|
312
|
+
progress: Math.round((end / file.size) * 100),
|
313
|
+
sizeUploaded: end,
|
314
|
+
chunksTotal: Math.ceil(file.size / Client.CHUNK_SIZE),
|
315
|
+
chunksUploaded: Math.ceil(end / Client.CHUNK_SIZE)
|
316
|
+
});
|
317
|
+
}
|
318
|
+
|
319
|
+
if (response && response.$id) {
|
320
|
+
headers['x-appconda-id'] = response.$id;
|
321
|
+
}
|
322
|
+
|
323
|
+
start = end;
|
324
|
+
}
|
325
|
+
|
326
|
+
return response;
|
327
|
+
}
|
328
|
+
|
329
|
+
async redirect(method: string, url: URL, headers: Headers = {}, params: Payload = {}): Promise<string> {
|
330
|
+
const { uri, options } = this.prepareRequest(method, url, headers, params);
|
331
|
+
|
332
|
+
const response = await fetch(uri, {
|
333
|
+
...options,
|
334
|
+
redirect: 'manual'
|
335
|
+
});
|
336
|
+
|
337
|
+
if (response.status !== 301 && response.status !== 302) {
|
338
|
+
throw new AppcondaException('Invalid redirect', response.status);
|
339
|
+
}
|
340
|
+
|
341
|
+
return response.headers.get('location') || '';
|
342
|
+
}
|
343
|
+
|
344
|
+
async call(method: string, url: URL, headers: Headers = {}, params: Payload = {}, responseType = 'json'): Promise<any> {
|
345
|
+
const { uri, options } = this.prepareRequest(method, url, headers, params);
|
346
|
+
|
347
|
+
let data: any = null;
|
348
|
+
|
349
|
+
try {
|
350
|
+
const response = await fetch(uri, options);
|
351
|
+
|
352
|
+
const warnings = response.headers.get('x-appconda-warning');
|
353
|
+
if (warnings) {
|
354
|
+
warnings.split(';').forEach((warning: string) => console.warn('Warning: ' + warning));
|
355
|
+
}
|
356
|
+
|
357
|
+
if (response.headers.get('content-type')?.includes('application/json')) {
|
358
|
+
data = await response.json();
|
359
|
+
} else if (responseType === 'arrayBuffer') {
|
360
|
+
data = await response.arrayBuffer();
|
361
|
+
} else {
|
362
|
+
data = {
|
363
|
+
message: await response.text()
|
364
|
+
};
|
365
|
+
}
|
366
|
+
|
367
|
+
if (400 <= response.status) {
|
368
|
+
throw new AppcondaException(data?.message, response.status, data?.type, data);
|
369
|
+
}
|
370
|
+
|
371
|
+
return data;
|
372
|
+
} catch (e) {
|
373
|
+
console.error(e);
|
374
|
+
throw e;
|
375
|
+
}
|
376
|
+
}
|
377
|
+
|
378
|
+
static flatten(data: Payload, prefix = ''): Payload {
|
379
|
+
let output: Payload = {};
|
380
|
+
|
381
|
+
for (const [key, value] of Object.entries(data)) {
|
382
|
+
let finalKey = prefix ? prefix + '[' + key + ']' : key;
|
383
|
+
if (Array.isArray(value)) {
|
384
|
+
output = { ...output, ...Client.flatten(value, finalKey) };
|
385
|
+
} else {
|
386
|
+
output[finalKey] = value;
|
387
|
+
}
|
388
|
+
}
|
389
|
+
|
390
|
+
return output;
|
391
|
+
}
|
392
|
+
}
|
393
|
+
|
394
|
+
export { Client, AppcondaException };
|
395
|
+
export { Query } from './query';
|
396
|
+
export type { Models, Payload, UploadProgress };
|
397
|
+
export type { QueryTypes, QueryTypesList } from './query';
|
@@ -0,0 +1,102 @@
|
|
1
|
+
import { Services } from "@/Services";
|
2
|
+
|
3
|
+
function stableStringify(obj: any): string {
|
4
|
+
if (obj && typeof obj === "object" && !Array.isArray(obj)) {
|
5
|
+
return `{${Object.keys(obj).sort().map(key => `"${key}":${stableStringify(obj[key])}`).join(",")}}`;
|
6
|
+
}
|
7
|
+
return JSON.stringify(obj);
|
8
|
+
}
|
9
|
+
|
10
|
+
function generateCacheKey(...args: any[]): string {
|
11
|
+
return stableStringify(args);
|
12
|
+
}
|
13
|
+
|
14
|
+
|
15
|
+
// console.log(generateCacheKey("user", 123, true, { role: "admin", permissions: ["read", "write"] }));
|
16
|
+
// console.log(generateCacheKey("user", 123, true, { permissions: ["read", "write"], role: "admin" }));
|
17
|
+
|
18
|
+
|
19
|
+
|
20
|
+
export function Cache(/* cacheKey?: string | string[] */) {
|
21
|
+
return function (
|
22
|
+
target: any,
|
23
|
+
propertyKey: string,
|
24
|
+
descriptor: PropertyDescriptor
|
25
|
+
) {
|
26
|
+
const originalMethod = descriptor.value;
|
27
|
+
|
28
|
+
descriptor.value = async function (...args: any[]) {
|
29
|
+
|
30
|
+
const className = target.constructor.name.toLowerCase();
|
31
|
+
|
32
|
+
// Metod adı
|
33
|
+
const methodName = propertyKey.toLowerCase();
|
34
|
+
|
35
|
+
const cacheKeys: any[] = [target.__cacheKeys || []].reverse();
|
36
|
+
console.log("Defined cache keys:", cacheKeys);
|
37
|
+
|
38
|
+
const cacheKey = ['admin', className, propertyKey];
|
39
|
+
|
40
|
+
if (cacheKeys.length > 0) {
|
41
|
+
for (let i = 0; i < cacheKeys.length; i++) {
|
42
|
+
const keyIndex = cacheKeys[i]['parameterIndex'];
|
43
|
+
if (args != null && args[keyIndex] != null) {
|
44
|
+
const key = args[keyIndex].toString();
|
45
|
+
cacheKey.push(key);
|
46
|
+
}
|
47
|
+
}
|
48
|
+
} else if (args.length > 0) { //cacheKey belirtilmemisse tum parametreleri kullan
|
49
|
+
for (let i = 0; i < args.length; i++) {
|
50
|
+
const key = args[i].toString();
|
51
|
+
cacheKey.push(key);
|
52
|
+
}
|
53
|
+
}
|
54
|
+
|
55
|
+
// Cache key'i dizeye dönüştür
|
56
|
+
// const key = Array.isArray(cacheKey) ? cacheKey.join(':') : cacheKey;
|
57
|
+
|
58
|
+
// Cache'ten veri al
|
59
|
+
let cachedData = await Services.Cache.load(cacheKey);
|
60
|
+
|
61
|
+
if (cachedData != null) {
|
62
|
+
return cachedData; // Cache'teki veriyi döndür
|
63
|
+
}
|
64
|
+
|
65
|
+
// Orijinal metodu çağır ve dönen değeri cache'e kaydet
|
66
|
+
const result = await originalMethod.apply(this, args);
|
67
|
+
|
68
|
+
// Cache'e kaydet (asenkron yapılır, beklenmez)
|
69
|
+
Services.Cache.save(cacheKey, result);
|
70
|
+
console.log('------------------------------Cache executed..')
|
71
|
+
return result;
|
72
|
+
};
|
73
|
+
|
74
|
+
return descriptor;
|
75
|
+
};
|
76
|
+
}
|
77
|
+
|
78
|
+
|
79
|
+
/* const cacheKeys: any[] = target.__cacheKeys || [];
|
80
|
+
console.log("Defined cache keys:", [...cacheKeys].reverse());
|
81
|
+
|
82
|
+
const className = target.constructor.name.toLowerCase();
|
83
|
+
|
84
|
+
// Metod adı
|
85
|
+
const methodName = propertyKey.toLowerCase();
|
86
|
+
|
87
|
+
debugger
|
88
|
+
const cacheKey = ['admin', className, propertyKey];
|
89
|
+
if (cacheKey.length > 0) {
|
90
|
+
for (let i = 0; i < cacheKeys.length; i++) {
|
91
|
+
const keyIndex = cacheKeys[i]['parameterIndex'];
|
92
|
+
if (args != null && args[keyIndex] != null) {
|
93
|
+
const key = args[keyIndex].toString();
|
94
|
+
cacheKey.push(key);
|
95
|
+
}
|
96
|
+
}
|
97
|
+
} else if (args.length > 0) { //cacheKey belirtilmemisse tum parametreleri kullan
|
98
|
+
for (let i = 0; i < args.length; i++) {
|
99
|
+
const key = args[i].toString();
|
100
|
+
cacheKey.push(key);
|
101
|
+
}
|
102
|
+
} */
|