glitch-javascript-sdk 3.8.14 → 3.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/index.js +123 -0
- package/dist/cjs/index.js.map +1 -1
- package/dist/esm/api/Hosting.d.ts +133 -0
- package/dist/esm/api/index.d.ts +2 -0
- package/dist/esm/index.d.ts +2 -0
- package/dist/esm/index.js +115 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/routes/HostingRoute.d.ts +8 -0
- package/dist/index.d.ts +57 -0
- package/package.json +2 -2
- package/src/api/Hosting.ts +223 -0
- package/src/api/index.ts +2 -0
- package/src/index.ts +2 -0
- package/src/routes/HostingRoute.ts +33 -0
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
import { AxiosPromise, AxiosProgressEvent } from 'axios';
|
|
2
|
+
import Response from '../util/Response';
|
|
3
|
+
export type HostingPlanKey = 'free' | 'launch' | 'growth' | 'scale' | 'studio';
|
|
4
|
+
export type HostingMode = 'static' | 'server';
|
|
5
|
+
export type HostingDatabaseEngine = 'postgresql' | 'mysql' | 'azure_sql' | 'cosmos_nosql';
|
|
6
|
+
export type HostingDatabasePlan = 'sandbox' | 'launch' | 'growth' | 'scale' | 'dedicated';
|
|
7
|
+
export type HostingDeliveryChannel = 'glitch_store' | 'glitch_hosted_subdomain' | 'glitch_hosted_custom_domain' | 'external';
|
|
8
|
+
export interface HostingAccount {
|
|
9
|
+
id: string;
|
|
10
|
+
community_id: string;
|
|
11
|
+
plan: HostingPlanKey;
|
|
12
|
+
status: string;
|
|
13
|
+
included_bandwidth_bytes: number;
|
|
14
|
+
used_bandwidth_bytes: number;
|
|
15
|
+
remaining_bandwidth_bytes: number;
|
|
16
|
+
bandwidth_overage_enabled: boolean;
|
|
17
|
+
bandwidth_spend_limit_cents?: number | null;
|
|
18
|
+
}
|
|
19
|
+
export interface HostingRelease {
|
|
20
|
+
id: string;
|
|
21
|
+
hosting_site_id: string;
|
|
22
|
+
game_build_id?: string | null;
|
|
23
|
+
version: string;
|
|
24
|
+
status: 'uploading' | 'processing' | 'ready' | 'failed' | 'active' | 'inactive';
|
|
25
|
+
source_type: 'upload' | 'cli' | 'game_build';
|
|
26
|
+
entry_point: string;
|
|
27
|
+
size_bytes: number;
|
|
28
|
+
checksum?: string | null;
|
|
29
|
+
error_message?: string | null;
|
|
30
|
+
promoted_at?: string | null;
|
|
31
|
+
}
|
|
32
|
+
export interface HostingDomain {
|
|
33
|
+
id: string;
|
|
34
|
+
hostname: string;
|
|
35
|
+
type: 'generated' | 'custom' | 'managed';
|
|
36
|
+
status: 'pending_verification' | 'provisioning' | 'active' | 'failed' | 'expired';
|
|
37
|
+
verification_record_type?: string | null;
|
|
38
|
+
verification_record_name?: string | null;
|
|
39
|
+
verification_record_value?: string | null;
|
|
40
|
+
certificate_status?: string | null;
|
|
41
|
+
annual_price_cents?: number | null;
|
|
42
|
+
auto_renew: boolean;
|
|
43
|
+
}
|
|
44
|
+
export interface HostingDatabase {
|
|
45
|
+
id: string;
|
|
46
|
+
hosting_site_id: string;
|
|
47
|
+
name: string;
|
|
48
|
+
engine: HostingDatabaseEngine;
|
|
49
|
+
plan: HostingDatabasePlan;
|
|
50
|
+
status: 'awaiting_payment' | 'requested' | 'provisioning' | 'ready' | 'resizing' | 'restoring' | 'failed' | 'deleting' | 'deleted';
|
|
51
|
+
deployment_model: 'shared' | 'dedicated' | 'serverless';
|
|
52
|
+
azure_region: string;
|
|
53
|
+
included_storage_bytes: number;
|
|
54
|
+
current_storage_bytes: number;
|
|
55
|
+
auto_grow_enabled: boolean;
|
|
56
|
+
backup_retention_days: number;
|
|
57
|
+
high_availability_enabled: boolean;
|
|
58
|
+
endpoint?: string | null;
|
|
59
|
+
port?: number | null;
|
|
60
|
+
binding_name: 'DATABASE_URL' | 'COSMOS_DATABASE';
|
|
61
|
+
last_error?: string | null;
|
|
62
|
+
}
|
|
63
|
+
export interface HostingSite {
|
|
64
|
+
id: string;
|
|
65
|
+
hosting_account_id: string;
|
|
66
|
+
community_id: string;
|
|
67
|
+
title_id: string;
|
|
68
|
+
name: string;
|
|
69
|
+
slug: string;
|
|
70
|
+
community_slug: string;
|
|
71
|
+
generated_hostname: string;
|
|
72
|
+
url: string;
|
|
73
|
+
mode: HostingMode;
|
|
74
|
+
status: 'draft' | 'provisioning' | 'live' | 'limited' | 'failed' | 'disabled';
|
|
75
|
+
server_mode_enabled: boolean;
|
|
76
|
+
azure_region?: string | null;
|
|
77
|
+
active_release?: HostingRelease | null;
|
|
78
|
+
domains?: HostingDomain[];
|
|
79
|
+
databases?: HostingDatabase[];
|
|
80
|
+
}
|
|
81
|
+
export interface CreateHostingSiteRequest {
|
|
82
|
+
name: string;
|
|
83
|
+
slug: string;
|
|
84
|
+
mode: HostingMode;
|
|
85
|
+
azure_region?: string;
|
|
86
|
+
}
|
|
87
|
+
export interface CreateHostingReleaseRequest {
|
|
88
|
+
version: string;
|
|
89
|
+
source_type: 'upload' | 'cli' | 'game_build';
|
|
90
|
+
blob_path?: string;
|
|
91
|
+
game_build_id?: string;
|
|
92
|
+
entry_point?: string;
|
|
93
|
+
}
|
|
94
|
+
export interface CreateHostingDatabaseRequest {
|
|
95
|
+
name: string;
|
|
96
|
+
engine: HostingDatabaseEngine;
|
|
97
|
+
plan: HostingDatabasePlan;
|
|
98
|
+
azure_region: string;
|
|
99
|
+
auto_grow_enabled?: boolean;
|
|
100
|
+
high_availability_enabled?: boolean;
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Typed SDK for game website hosting, Azure database add-ons, domains, usage,
|
|
104
|
+
* deployment instructions, and hosted-play attribution.
|
|
105
|
+
*/
|
|
106
|
+
declare class Hosting {
|
|
107
|
+
static catalog<T>(): AxiosPromise<Response<T>>;
|
|
108
|
+
static dashboard<T>(title_id: string): AxiosPromise<Response<T>>;
|
|
109
|
+
static channelAnalytics<T>(title_id: string, params?: Record<string, any>): AxiosPromise<Response<T>>;
|
|
110
|
+
static createSite<T>(title_id: string, data: CreateHostingSiteRequest): AxiosPromise<Response<T>>;
|
|
111
|
+
static updateSite<T>(title_id: string, site_id: string, data: Partial<CreateHostingSiteRequest> & Record<string, any>): AxiosPromise<Response<T>>;
|
|
112
|
+
static createUploadUrl<T>(title_id: string, site_id: string): AxiosPromise<Response<T>>;
|
|
113
|
+
/** Upload directly to the short-lived Azure URL returned by createUploadUrl. */
|
|
114
|
+
static uploadBuild(uploadUrl: string, file: Blob, requiredHeaders?: Record<string, string>, onUploadProgress?: (event: AxiosProgressEvent) => void): AxiosPromise<void>;
|
|
115
|
+
static releases<T>(title_id: string, site_id: string, params?: Record<string, any>): AxiosPromise<Response<T>>;
|
|
116
|
+
static createRelease<T>(title_id: string, site_id: string, data: CreateHostingReleaseRequest): AxiosPromise<Response<T>>;
|
|
117
|
+
static promoteRelease<T>(title_id: string, site_id: string, release_id: string): AxiosPromise<Response<T>>;
|
|
118
|
+
static connectDomain<T>(title_id: string, site_id: string, hostname: string): AxiosPromise<Response<T>>;
|
|
119
|
+
static verifyDomain<T>(title_id: string, site_id: string, domain_id: string): AxiosPromise<Response<T>>;
|
|
120
|
+
static checkDomain<T>(hostname: string): AxiosPromise<Response<T>>;
|
|
121
|
+
static purchaseDomain<T>(title_id: string, site_id: string, data: Record<string, any>): AxiosPromise<Response<T>>;
|
|
122
|
+
static aiInstructions<T>(title_id: string, site_id: string, data?: Record<string, any>): AxiosPromise<Response<T>>;
|
|
123
|
+
static resolve<T>(hostname: string): AxiosPromise<Response<T>>;
|
|
124
|
+
static startPlaySession<T>(data: Record<string, any>): AxiosPromise<Response<T>>;
|
|
125
|
+
static heartbeatPlaySession<T>(session_id: string, sessionToken: string): AxiosPromise<Response<T>>;
|
|
126
|
+
static databases<T>(title_id: string, site_id: string, params?: Record<string, any>): AxiosPromise<Response<T>>;
|
|
127
|
+
static createDatabase<T>(title_id: string, site_id: string, data: CreateHostingDatabaseRequest): AxiosPromise<Response<T>>;
|
|
128
|
+
static database<T>(title_id: string, site_id: string, database_id: string): AxiosPromise<Response<T>>;
|
|
129
|
+
static updateDatabase<T>(title_id: string, site_id: string, database_id: string, data: Record<string, any>): AxiosPromise<Response<T>>;
|
|
130
|
+
static retryDatabase<T>(title_id: string, site_id: string, database_id: string): AxiosPromise<Response<T>>;
|
|
131
|
+
static deleteDatabase<T>(title_id: string, site_id: string, database_id: string, confirmation: string): AxiosPromise<Response<T>>;
|
|
132
|
+
}
|
|
133
|
+
export default Hosting;
|
package/dist/esm/api/index.d.ts
CHANGED
|
@@ -52,6 +52,7 @@ import AdminReports from "./AdminReports";
|
|
|
52
52
|
import AdminUsers from "./AdminUsers";
|
|
53
53
|
import MarketResearch from "./MarketResearch";
|
|
54
54
|
import GameAdvertising from './GameAdvertising';
|
|
55
|
+
import Hosting from './Hosting';
|
|
55
56
|
export { Ads };
|
|
56
57
|
export { AccessKeys };
|
|
57
58
|
export { Auth };
|
|
@@ -106,3 +107,4 @@ export { AdminReports };
|
|
|
106
107
|
export { AdminUsers };
|
|
107
108
|
export { MarketResearch };
|
|
108
109
|
export { GameAdvertising };
|
|
110
|
+
export { Hosting };
|
package/dist/esm/index.d.ts
CHANGED
|
@@ -52,6 +52,7 @@ import { AdminReports } from './api';
|
|
|
52
52
|
import { AdminUsers } from './api';
|
|
53
53
|
import { MarketResearch } from './api';
|
|
54
54
|
import { GameAdvertising } from './api';
|
|
55
|
+
import { Hosting } from './api';
|
|
55
56
|
import Requests from "./util/Requests";
|
|
56
57
|
import Parser from "./util/Parser";
|
|
57
58
|
import Session from "./util/Session";
|
|
@@ -125,6 +126,7 @@ declare class Glitch {
|
|
|
125
126
|
AdminUsers: typeof AdminUsers;
|
|
126
127
|
MarketResearch: typeof MarketResearch;
|
|
127
128
|
GameAdvertising: typeof GameAdvertising;
|
|
129
|
+
Hosting: typeof Hosting;
|
|
128
130
|
};
|
|
129
131
|
static util: {
|
|
130
132
|
Requests: typeof Requests;
|
package/dist/esm/index.js
CHANGED
|
@@ -20881,6 +20881,120 @@ class GameAdvertising {
|
|
|
20881
20881
|
}
|
|
20882
20882
|
}
|
|
20883
20883
|
|
|
20884
|
+
/** Route catalog for Azure-backed game website hosting. */
|
|
20885
|
+
class HostingRoute {
|
|
20886
|
+
}
|
|
20887
|
+
HostingRoute.routes = {
|
|
20888
|
+
catalog: { url: '/hosting/catalog', method: HTTP_METHODS.GET },
|
|
20889
|
+
dashboard: { url: '/titles/{title_id}/hosting', method: HTTP_METHODS.GET },
|
|
20890
|
+
channelAnalytics: { url: '/titles/{title_id}/hosting/analytics/channels', method: HTTP_METHODS.GET },
|
|
20891
|
+
createSite: { url: '/titles/{title_id}/hosting/sites', method: HTTP_METHODS.POST },
|
|
20892
|
+
updateSite: { url: '/titles/{title_id}/hosting/sites/{site_id}', method: HTTP_METHODS.PUT },
|
|
20893
|
+
uploadUrl: { url: '/titles/{title_id}/hosting/sites/{site_id}/upload-url', method: HTTP_METHODS.POST },
|
|
20894
|
+
releases: { url: '/titles/{title_id}/hosting/sites/{site_id}/releases', method: HTTP_METHODS.GET },
|
|
20895
|
+
createRelease: { url: '/titles/{title_id}/hosting/sites/{site_id}/releases', method: HTTP_METHODS.POST },
|
|
20896
|
+
promoteRelease: { url: '/titles/{title_id}/hosting/sites/{site_id}/releases/{release_id}/promote', method: HTTP_METHODS.POST },
|
|
20897
|
+
connectDomain: { url: '/titles/{title_id}/hosting/sites/{site_id}/domains', method: HTTP_METHODS.POST },
|
|
20898
|
+
verifyDomain: { url: '/titles/{title_id}/hosting/sites/{site_id}/domains/{domain_id}/verify', method: HTTP_METHODS.POST },
|
|
20899
|
+
checkDomain: { url: '/hosting/domains/check', method: HTTP_METHODS.POST },
|
|
20900
|
+
purchaseDomain: { url: '/titles/{title_id}/hosting/sites/{site_id}/domains/purchase', method: HTTP_METHODS.POST },
|
|
20901
|
+
aiInstructions: { url: '/titles/{title_id}/hosting/sites/{site_id}/ai-instructions', method: HTTP_METHODS.POST },
|
|
20902
|
+
resolve: { url: '/hosting/resolve', method: HTTP_METHODS.GET },
|
|
20903
|
+
startPlaySession: { url: '/hosting/play-sessions', method: HTTP_METHODS.POST },
|
|
20904
|
+
heartbeatPlaySession: { url: '/hosting/play-sessions/{session_id}/heartbeat', method: HTTP_METHODS.POST },
|
|
20905
|
+
databases: { url: '/titles/{title_id}/hosting/sites/{site_id}/databases', method: HTTP_METHODS.GET },
|
|
20906
|
+
createDatabase: { url: '/titles/{title_id}/hosting/sites/{site_id}/databases', method: HTTP_METHODS.POST },
|
|
20907
|
+
database: { url: '/titles/{title_id}/hosting/sites/{site_id}/databases/{database_id}', method: HTTP_METHODS.GET },
|
|
20908
|
+
updateDatabase: { url: '/titles/{title_id}/hosting/sites/{site_id}/databases/{database_id}', method: HTTP_METHODS.PUT },
|
|
20909
|
+
retryDatabase: { url: '/titles/{title_id}/hosting/sites/{site_id}/databases/{database_id}/retry', method: HTTP_METHODS.POST },
|
|
20910
|
+
deleteDatabase: { url: '/titles/{title_id}/hosting/sites/{site_id}/databases/{database_id}', method: HTTP_METHODS.DELETE },
|
|
20911
|
+
};
|
|
20912
|
+
|
|
20913
|
+
/**
|
|
20914
|
+
* Typed SDK for game website hosting, Azure database add-ons, domains, usage,
|
|
20915
|
+
* deployment instructions, and hosted-play attribution.
|
|
20916
|
+
*/
|
|
20917
|
+
class Hosting {
|
|
20918
|
+
static catalog() {
|
|
20919
|
+
return Requests.processRoute(HostingRoute.routes.catalog);
|
|
20920
|
+
}
|
|
20921
|
+
static dashboard(title_id) {
|
|
20922
|
+
return Requests.processRoute(HostingRoute.routes.dashboard, undefined, { title_id });
|
|
20923
|
+
}
|
|
20924
|
+
static channelAnalytics(title_id, params) {
|
|
20925
|
+
return Requests.processRoute(HostingRoute.routes.channelAnalytics, undefined, { title_id }, params);
|
|
20926
|
+
}
|
|
20927
|
+
static createSite(title_id, data) {
|
|
20928
|
+
return Requests.processRoute(HostingRoute.routes.createSite, data, { title_id });
|
|
20929
|
+
}
|
|
20930
|
+
static updateSite(title_id, site_id, data) {
|
|
20931
|
+
return Requests.processRoute(HostingRoute.routes.updateSite, data, { title_id, site_id });
|
|
20932
|
+
}
|
|
20933
|
+
static createUploadUrl(title_id, site_id) {
|
|
20934
|
+
return Requests.processRoute(HostingRoute.routes.uploadUrl, {}, { title_id, site_id });
|
|
20935
|
+
}
|
|
20936
|
+
/** Upload directly to the short-lived Azure URL returned by createUploadUrl. */
|
|
20937
|
+
static uploadBuild(uploadUrl, file, requiredHeaders = {}, onUploadProgress) {
|
|
20938
|
+
return axios$1.put(uploadUrl, file, {
|
|
20939
|
+
headers: Object.assign({ 'x-ms-blob-type': 'BlockBlob', 'Content-Type': 'application/zip' }, requiredHeaders),
|
|
20940
|
+
onUploadProgress,
|
|
20941
|
+
});
|
|
20942
|
+
}
|
|
20943
|
+
static releases(title_id, site_id, params) {
|
|
20944
|
+
return Requests.processRoute(HostingRoute.routes.releases, undefined, { title_id, site_id }, params);
|
|
20945
|
+
}
|
|
20946
|
+
static createRelease(title_id, site_id, data) {
|
|
20947
|
+
return Requests.processRoute(HostingRoute.routes.createRelease, data, { title_id, site_id });
|
|
20948
|
+
}
|
|
20949
|
+
static promoteRelease(title_id, site_id, release_id) {
|
|
20950
|
+
return Requests.processRoute(HostingRoute.routes.promoteRelease, {}, { title_id, site_id, release_id });
|
|
20951
|
+
}
|
|
20952
|
+
static connectDomain(title_id, site_id, hostname) {
|
|
20953
|
+
return Requests.processRoute(HostingRoute.routes.connectDomain, { hostname }, { title_id, site_id });
|
|
20954
|
+
}
|
|
20955
|
+
static verifyDomain(title_id, site_id, domain_id) {
|
|
20956
|
+
return Requests.processRoute(HostingRoute.routes.verifyDomain, {}, { title_id, site_id, domain_id });
|
|
20957
|
+
}
|
|
20958
|
+
static checkDomain(hostname) {
|
|
20959
|
+
return Requests.processRoute(HostingRoute.routes.checkDomain, { hostname });
|
|
20960
|
+
}
|
|
20961
|
+
static purchaseDomain(title_id, site_id, data) {
|
|
20962
|
+
return Requests.processRoute(HostingRoute.routes.purchaseDomain, data, { title_id, site_id });
|
|
20963
|
+
}
|
|
20964
|
+
static aiInstructions(title_id, site_id, data = {}) {
|
|
20965
|
+
return Requests.processRoute(HostingRoute.routes.aiInstructions, data, { title_id, site_id });
|
|
20966
|
+
}
|
|
20967
|
+
static resolve(hostname) {
|
|
20968
|
+
return Requests.processRoute(HostingRoute.routes.resolve, undefined, undefined, { hostname });
|
|
20969
|
+
}
|
|
20970
|
+
static startPlaySession(data) {
|
|
20971
|
+
return Requests.processRoute(HostingRoute.routes.startPlaySession, data);
|
|
20972
|
+
}
|
|
20973
|
+
static heartbeatPlaySession(session_id, sessionToken) {
|
|
20974
|
+
const path = HostingRoute.routes.heartbeatPlaySession.url.replace('{session_id}', session_id);
|
|
20975
|
+
const base = (Config.getBaseUrl() || '').replace(/\/+$/, '');
|
|
20976
|
+
return axios$1.post(`${base}/${path.replace(/^\/+/, '')}`, {}, { headers: { Authorization: `Bearer ${sessionToken}` } });
|
|
20977
|
+
}
|
|
20978
|
+
static databases(title_id, site_id, params) {
|
|
20979
|
+
return Requests.processRoute(HostingRoute.routes.databases, undefined, { title_id, site_id }, params);
|
|
20980
|
+
}
|
|
20981
|
+
static createDatabase(title_id, site_id, data) {
|
|
20982
|
+
return Requests.processRoute(HostingRoute.routes.createDatabase, data, { title_id, site_id });
|
|
20983
|
+
}
|
|
20984
|
+
static database(title_id, site_id, database_id) {
|
|
20985
|
+
return Requests.processRoute(HostingRoute.routes.database, undefined, { title_id, site_id, database_id });
|
|
20986
|
+
}
|
|
20987
|
+
static updateDatabase(title_id, site_id, database_id, data) {
|
|
20988
|
+
return Requests.processRoute(HostingRoute.routes.updateDatabase, data, { title_id, site_id, database_id });
|
|
20989
|
+
}
|
|
20990
|
+
static retryDatabase(title_id, site_id, database_id) {
|
|
20991
|
+
return Requests.processRoute(HostingRoute.routes.retryDatabase, {}, { title_id, site_id, database_id });
|
|
20992
|
+
}
|
|
20993
|
+
static deleteDatabase(title_id, site_id, database_id, confirmation) {
|
|
20994
|
+
return Requests.processRoute(HostingRoute.routes.deleteDatabase, undefined, { title_id, site_id, database_id }, { confirmation });
|
|
20995
|
+
}
|
|
20996
|
+
}
|
|
20997
|
+
|
|
20884
20998
|
class Parser {
|
|
20885
20999
|
/**
|
|
20886
21000
|
* To be used inside a catch close, this function will parse out any JSON in a error response from the api.
|
|
@@ -21418,6 +21532,7 @@ Glitch.api = {
|
|
|
21418
21532
|
AdminUsers: AdminUsers,
|
|
21419
21533
|
MarketResearch: MarketResearch,
|
|
21420
21534
|
GameAdvertising: GameAdvertising,
|
|
21535
|
+
Hosting: Hosting,
|
|
21421
21536
|
};
|
|
21422
21537
|
Glitch.util = {
|
|
21423
21538
|
Requests: Requests,
|