import { AxiosPromise, AxiosProgressEvent } from 'axios'; import Response from '../util/Response'; export type HostingPlanKey = 'free' | 'launch' | 'growth' | 'scale' | 'studio'; export type HostingMode = 'static' | 'server'; export type HostingDatabaseEngine = 'postgresql' | 'mysql' | 'azure_sql' | 'cosmos_nosql' | 'redis'; export type HostingDatabasePlan = 'sandbox' | 'launch' | 'growth' | 'scale' | 'dedicated' | 'cache_sandbox' | 'cache_launch' | 'cache_growth' | 'cache_scale'; export type HostingServiceRole = 'web' | 'api' | 'game' | 'realtime' | 'simulation' | 'worker' | 'scheduled'; export type HostingServiceVisibility = 'public' | 'internal' | 'none'; export type HostingCapacityModel = 'singleton' | 'replicated' | 'serverless'; export type HostingDeliveryChannel = 'glitch_store' | 'glitch_hosted_subdomain' | 'glitch_hosted_custom_domain' | 'external'; export type HostingBillingProvider = 'direct' | 'microsoft_marketplace' | 'aws_marketplace'; export interface HostingAccount { id: string; community_id: string; plan: HostingPlanKey; pending_plan?: HostingPlanKey | null; status: string; billing_provider: HostingBillingProvider; microsoft_marketplace_subscription_id?: string | null; aws_marketplace_subscription_id?: string | null; included_bandwidth_bytes: number; used_bandwidth_bytes: number; remaining_bandwidth_bytes: number; bandwidth_overage_enabled: boolean; bandwidth_spend_limit_cents?: number | null; } export interface HostingRelease { id: string; hosting_site_id: string; game_build_id?: string | null; version: string; status: 'uploading' | 'processing' | 'ready' | 'failed' | 'active' | 'inactive'; source_type: 'upload' | 'cli' | 'game_build' | 'service_stack'; entry_point: string; size_bytes: number; checksum?: string | null; error_message?: string | null; promoted_at?: string | null; service_deployments?: HostingServiceDeployment[]; } export interface HostingDomain { id: string; hostname: string; type: 'generated' | 'custom' | 'managed'; status: 'pending_verification' | 'provisioning' | 'active' | 'failed' | 'expired'; verification_record_type?: string | null; verification_record_name?: string | null; verification_record_value?: string | null; certificate_status?: string | null; error_code?: string | null; incident_id?: string | null; last_error?: string | null; billing_status?: 'active' | 'past_due' | 'unpaid' | 'cancelled' | null; annual_price_cents?: number | null; auto_renew: boolean; } export interface HostingDatabase { id: string; hosting_site_id: string; name: string; engine: HostingDatabaseEngine; plan: HostingDatabasePlan; status: 'awaiting_payment' | 'requested' | 'provisioning' | 'ready' | 'resizing' | 'restoring' | 'failed' | 'deleting' | 'deleted'; deployment_model: 'shared' | 'dedicated' | 'serverless' | 'managed_cache'; azure_region: string; included_storage_bytes: number; current_storage_bytes: number; auto_grow_enabled: boolean; backup_retention_days: number; high_availability_enabled: boolean; endpoint?: string | null; port?: number | null; binding_name: string; billing_status: 'awaiting_payment' | 'active' | 'past_due' | 'unpaid' | 'cancelled' | 'expired' | 'failed'; billing_provider: HostingBillingProvider; billing_active: boolean; last_error?: string | null; } export interface HostingDatabaseCredentials { database_id: string; name: string; engine: HostingDatabaseEngine; binding_name: string; connection_string: string; connection: { driver?: string; host?: string; endpoint?: string; port?: number; database?: string; username?: string; password?: string; key?: string; tls: boolean; }; revealed_at: string; /** UI safety timer only; the database credential itself does not expire after this interval. */ hide_after_seconds: number; } export interface HostingSite { id: string; hosting_account_id: string; community_id: string; title_id: string; name: string; slug: string; community_slug: string; generated_hostname: string; url: string; mode: HostingMode; status: 'draft' | 'provisioning' | 'live' | 'limited' | 'failed' | 'disabled'; server_mode_enabled: boolean; azure_region?: string | null; active_release_id?: string | null; active_release?: HostingRelease | null; domains?: HostingDomain[]; databases?: HostingDatabase[]; services?: HostingService[]; runtime_routes?: Array<{ path_prefix: string; service: string; runtime_origin: string; }>; } export interface HostingServiceVolume { name: string; mount_path: string; size_gb: number; access_mode?: 'ReadOnly' | 'ReadWrite'; } export interface HostingServiceDeployment { id: string; hosting_service_id: string; hosting_release_id: string; game_build_id?: string | null; version: string; status: 'queued' | 'deploying' | 'ready' | 'active' | 'inactive' | 'failed'; image?: string | null; public_url?: string | null; error_message?: string | null; ready_at?: string | null; promoted_at?: string | null; } export interface HostingService { id: string; hosting_site_id: string; name: string; slug: string; role: HostingServiceRole; runtime: 'node' | 'python' | 'rust' | 'container'; visibility: HostingServiceVisibility; status: 'draft' | 'deploying' | 'active' | 'disabled' | 'failed'; is_primary: boolean; target_port?: number | null; transport: 'http' | 'http2' | 'tcp'; health_check_path?: string | null; startup_check_path?: string | null; readiness_check_path?: string | null; liveness_check_path?: string | null; capacity_model: HostingCapacityModel; container_cpu: number; container_memory_mb: number; min_replicas: number; max_replicas: number; schedule_cron?: string | null; termination_grace_seconds: number; depends_on: string[]; public_paths: string[]; volumes: HostingServiceVolume[]; database_bindings: string[]; secret_names: string[]; active_deployment?: HostingServiceDeployment | null; deployments?: HostingServiceDeployment[]; } export interface HostingServiceDefinition { name?: string; slug: string; role?: HostingServiceRole; runtime?: 'node' | 'python' | 'rust' | 'container'; visibility?: HostingServiceVisibility; is_primary?: boolean; target_port?: number; transport?: 'http' | 'http2' | 'tcp'; health_check_path?: string; startup_check_path?: string; readiness_check_path?: string; liveness_check_path?: string; capacity_model?: HostingCapacityModel; container_cpu?: number; container_memory_mb?: number; min_replicas?: number; max_replicas?: number; schedule_cron?: string; termination_grace_seconds?: number; depends_on?: string[]; public_paths?: string[]; volumes?: HostingServiceVolume[]; environment?: Record; database_bindings?: string[]; configuration?: Record; command?: string[]; arguments?: string[]; game_build_id?: string; } export interface HostingServiceStackRequest { preset?: 'single_server' | 'stateful_game_server' | 'web_and_api' | 'authoritative_world' | 'large_realtime_world'; game_build_id?: string; builds?: Record; services?: HostingServiceDefinition[]; } export interface ApplyHostingServiceStackRequest extends HostingServiceStackRequest { version: string; test?: { service: string; command: string[]; }; migration?: { service: string; command: string[]; }; } export interface HostingServiceEstimate { billing_provider: HostingBillingProvider; estimated_monthly_floor_cents: number; estimated_monthly_floor_dollars: number; services: Array>; rates: { vcpu_hour_cents: number; memory_gib_hour_cents: number; requests_million_cents: number; persistent_storage_gib_month_cents: number; }; note: string; } export interface CreateHostingSiteRequest { name: string; slug: string; mode: HostingMode; azure_region?: string; } export interface CreateHostingReleaseRequest { version: string; source_type: 'upload' | 'cli' | 'game_build'; blob_path?: string; game_build_id?: string; /** Proven relative path in the finished artifact. Never guess index.html or package.json. */ entry_point: string; } export interface HostingCheckoutResult { database?: HostingDatabase; action?: string; checkout_url?: string | null; /** Stripe Embedded Checkout client secret for same-page card collection and 3DS. */ checkout_client_secret?: string | null; checkout_mode?: 'embedded' | 'hosted' | null; checkout_session_id?: string | null; billing_provider?: HostingBillingProvider; message?: string; } export interface HostingAiInstructionsRequest extends HostingServiceStackRequest { framework?: string; custom_domain?: string; databases?: Array>; version?: string; /** Candidate only; the generated instructions require proof from the finished artifact. */ entry_point?: string; } export interface CreateHostingDatabaseRequest { name: string; engine: HostingDatabaseEngine; plan: HostingDatabasePlan; azure_region: string; auto_grow_enabled?: boolean; high_availability_enabled?: boolean; } export interface HostingMarketplaceSubscription { id: string; marketplace_subscription_id: string; subscription_name?: string | null; offer_id: string; plan_id: string; plan_key: HostingPlanKey; status: 'PendingFulfillmentStart' | 'Subscribed' | 'Suspended' | 'Unsubscribed'; quantity: number; community_id?: string | null; is_test: boolean; is_free_trial: boolean; auto_renew: boolean; term_starts_at?: string | null; term_ends_at?: string | null; activated_at?: string | null; } export interface HostingAwsMarketplaceSubscription { id: string; customer_aws_account_id?: string | null; plan_dimension?: string | null; plan_key?: Exclude | null; status: 'PendingRegistration' | 'PendingEntitlement' | 'Subscribed' | 'Unsubscribed'; entitlement_value: number; entitlement_expires_at?: string | null; community_id?: string | null; hosting_account_id?: string | null; activated_at?: string | null; last_synced_at?: string | null; manage_url: string; } /** * Typed SDK for game website hosting, managed database add-ons, domains, usage, * deployment instructions, and hosted-play attribution. */ declare class Hosting { static catalog(): AxiosPromise>; static dashboard(title_id: string): AxiosPromise>; static channelAnalytics(title_id: string, params?: Record): AxiosPromise>; /** Start or apply a bandwidth-based Hosting plan, separate from Store distribution. */ static billingCheckout(title_id: string, plan: HostingPlanKey): AxiosPromise>; /** Confirm a paid Stripe Checkout session before provisioning its add-on. */ static confirmBillingCheckout(title_id: string, checkout_session_id: string): AxiosPromise>; /** Resolve the one-hour purchase token passed to Glitch by Microsoft Marketplace. */ static resolveMarketplacePurchase(token: string): AxiosPromise>; /** Link a resolved Microsoft Marketplace subscription to a billable Glitch business account. */ static activateMarketplaceSubscription(subscription_id: string, community_id: string): AxiosPromise>; /** Retrieve safe Microsoft Marketplace entitlement and lifecycle status. */ static marketplaceSubscription(subscription_id: string): AxiosPromise>; /** Claim the one-time Glitch code created after AWS ResolveCustomer succeeds. */ static resolveAwsMarketplacePurchase(activation_code: string): AxiosPromise>; /** Connect a paid AWS Marketplace contract to one Glitch business account. */ static activateAwsMarketplaceSubscription(subscription_id: string, community_id: string): AxiosPromise>; /** Refresh and retrieve the safe AWS Marketplace entitlement state. */ static awsMarketplaceSubscription(subscription_id: string): AxiosPromise>; static createSite(title_id: string, data: CreateHostingSiteRequest): AxiosPromise>; static updateSite(title_id: string, site_id: string, data: Partial & Record): AxiosPromise>; static createUploadUrl(title_id: string, site_id: string): AxiosPromise>; /** Upload directly to the short-lived signed URL returned by createUploadUrl. */ static uploadBuild(uploadUrl: string, file: Blob, requiredHeaders?: Record, onUploadProgress?: (event: AxiosProgressEvent) => void): AxiosPromise; static releases(title_id: string, site_id: string, params?: Record): AxiosPromise>; static createRelease(title_id: string, site_id: string, data: CreateHostingReleaseRequest): AxiosPromise>; static promoteRelease(title_id: string, site_id: string, release_id: string): AxiosPromise>; static connectDomain(title_id: string, site_id: string, hostname: string): AxiosPromise>; static verifyDomain(title_id: string, site_id: string, domain_id: string): AxiosPromise>; static checkDomain(hostname: string): AxiosPromise>; static purchaseDomain(title_id: string, site_id: string, data: Record): AxiosPromise>; static aiInstructions(title_id: string, site_id: string, data?: HostingAiInstructionsRequest): AxiosPromise>; static services(title_id: string, site_id: string): AxiosPromise>; /** Calculate the always-on floor without creating resources or charges. */ static estimateServices(title_id: string, site_id: string, data: HostingServiceStackRequest): AxiosPromise>; /** Queue an immutable multi-service release. Publishing remains a separate operation. */ static applyServices(title_id: string, site_id: string, data: ApplyHostingServiceStackRequest): AxiosPromise>; /** Store or rotate a secret. The API never returns the value. Interactive administrators only. */ static putServiceSecret(title_id: string, site_id: string, service_id: string, name: string, value: string): AxiosPromise>; static deleteServiceSecret(title_id: string, site_id: string, service_id: string, name: string): AxiosPromise>; static resolve(hostname: string, gatewayToken?: string): AxiosPromise>; static startPlaySession(data: Record): AxiosPromise>; static heartbeatPlaySession(session_id: string, sessionToken: string): AxiosPromise>; static databases(title_id: string, site_id: string, params?: Record): AxiosPromise>; static createDatabase(title_id: string, site_id: string, data: CreateHostingDatabaseRequest): AxiosPromise>; static database(title_id: string, site_id: string, database_id: string): AxiosPromise>; /** * Reveal credentials to a signed-in business billing administrator after an * exact database-name confirmation. Hosting and MCP tokens are rejected. */ static databaseCredentials(title_id: string, site_id: string, database_id: string, confirmation: string): AxiosPromise>; static updateDatabase(title_id: string, site_id: string, database_id: string, data: Record): AxiosPromise>; static retryDatabase(title_id: string, site_id: string, database_id: string): AxiosPromise>; static deleteDatabase(title_id: string, site_id: string, database_id: string, confirmation: string): AxiosPromise>; } export default Hosting;