glitch-javascript-sdk 4.0.1 → 4.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/index.js +129 -10
- package/dist/cjs/index.js.map +1 -1
- package/dist/esm/api/Preorders.d.ts +162 -0
- package/dist/esm/api/index.d.ts +1 -0
- package/dist/esm/index.d.ts +3 -0
- package/dist/esm/index.js +107 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/routes/PreordersRoute.d.ts +7 -0
- package/dist/index.d.ts +162 -1
- package/guides/microtransactions.md +157 -9
- package/package.json +2 -2
- package/src/api/Preorders.ts +234 -0
- package/src/api/index.ts +1 -0
- package/src/index.ts +3 -0
- package/src/routes/PreordersRoute.ts +34 -0
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
import { AxiosPromise, AxiosRequestConfig } from 'axios';
|
|
2
|
+
import Response from '../util/Response';
|
|
3
|
+
export type PreorderFulfillmentType = 'glitch_license' | 'platform_key';
|
|
4
|
+
export type PreorderOfferStatus = 'draft' | 'active' | 'paused' | 'ended' | 'archived';
|
|
5
|
+
export type PreorderDerivedState = 'draft' | 'available' | 'scheduled' | 'sold_out' | 'paused' | 'ended' | 'released' | 'archived';
|
|
6
|
+
export type PreorderPaymentStatus = 'created' | 'requires_action' | 'processing' | 'paid' | 'failed' | 'canceled' | 'refunded' | 'disputed' | 'unknown';
|
|
7
|
+
export type PreorderFulfillmentStatus = 'waiting_for_release' | 'ready' | 'processing' | 'fulfilled' | 'blocked_missing_build' | 'blocked_missing_key' | 'canceled' | 'failed';
|
|
8
|
+
export interface PreorderRequestOptions extends Pick<AxiosRequestConfig, 'signal' | 'timeout'> {
|
|
9
|
+
}
|
|
10
|
+
export interface PreorderPrice {
|
|
11
|
+
country: string;
|
|
12
|
+
currency: string;
|
|
13
|
+
amount_minor: number;
|
|
14
|
+
}
|
|
15
|
+
export interface PreorderInventory {
|
|
16
|
+
available: number;
|
|
17
|
+
reserved: number;
|
|
18
|
+
delivered: number;
|
|
19
|
+
retired: number;
|
|
20
|
+
total: number;
|
|
21
|
+
}
|
|
22
|
+
export interface PreorderOfferInput {
|
|
23
|
+
sku: string;
|
|
24
|
+
platform_code: string;
|
|
25
|
+
platform_label: string;
|
|
26
|
+
fulfillment_type: PreorderFulfillmentType;
|
|
27
|
+
status?: PreorderOfferStatus;
|
|
28
|
+
sales_start_at?: string | null;
|
|
29
|
+
sales_end_at?: string | null;
|
|
30
|
+
release_at: string;
|
|
31
|
+
limit_total?: number | null;
|
|
32
|
+
max_per_user?: number;
|
|
33
|
+
custom_message?: string | null;
|
|
34
|
+
post_purchase_url?: string | null;
|
|
35
|
+
redeem_url?: string | null;
|
|
36
|
+
prices: PreorderPrice[];
|
|
37
|
+
}
|
|
38
|
+
export interface PreorderOffer extends Omit<PreorderOfferInput, 'status'> {
|
|
39
|
+
id: string;
|
|
40
|
+
title_id: string;
|
|
41
|
+
status: PreorderOfferStatus;
|
|
42
|
+
state: PreorderDerivedState;
|
|
43
|
+
sold: number;
|
|
44
|
+
reserved_or_paid: number;
|
|
45
|
+
remaining: number | null;
|
|
46
|
+
revision: number;
|
|
47
|
+
inventory?: PreorderInventory;
|
|
48
|
+
owned_count?: number;
|
|
49
|
+
}
|
|
50
|
+
export interface PreorderSettings {
|
|
51
|
+
enabled: boolean;
|
|
52
|
+
timezone: string;
|
|
53
|
+
readiness?: PreorderReadiness;
|
|
54
|
+
}
|
|
55
|
+
export interface PreorderCatalog {
|
|
56
|
+
enabled: boolean;
|
|
57
|
+
timezone?: string;
|
|
58
|
+
offers: PreorderOffer[];
|
|
59
|
+
}
|
|
60
|
+
export interface PreorderPurchaseInput {
|
|
61
|
+
country?: string;
|
|
62
|
+
currency?: string;
|
|
63
|
+
idempotency_key: string;
|
|
64
|
+
payment_method_id?: string;
|
|
65
|
+
payment_intent_id?: string;
|
|
66
|
+
}
|
|
67
|
+
export interface PreorderOrder {
|
|
68
|
+
id: string;
|
|
69
|
+
title_id: string;
|
|
70
|
+
offer_id: string;
|
|
71
|
+
user_id?: string;
|
|
72
|
+
platform_code: string;
|
|
73
|
+
platform_label: string;
|
|
74
|
+
fulfillment_type: PreorderFulfillmentType;
|
|
75
|
+
payment_status: PreorderPaymentStatus;
|
|
76
|
+
fulfillment_status: PreorderFulfillmentStatus;
|
|
77
|
+
currency: string;
|
|
78
|
+
subtotal_minor: number;
|
|
79
|
+
tax_minor: number;
|
|
80
|
+
total_minor: number;
|
|
81
|
+
promised_release_at: string;
|
|
82
|
+
current_release_at: string;
|
|
83
|
+
paid_at?: string;
|
|
84
|
+
fulfilled_at?: string;
|
|
85
|
+
custom_message?: string;
|
|
86
|
+
post_purchase_url?: string;
|
|
87
|
+
redeem_url?: string;
|
|
88
|
+
platform_key?: string;
|
|
89
|
+
key_masked_suffix?: string;
|
|
90
|
+
purchase_email?: string;
|
|
91
|
+
provider_reference?: string;
|
|
92
|
+
commission_minor?: number;
|
|
93
|
+
developer_share_minor?: number;
|
|
94
|
+
requires_action?: boolean;
|
|
95
|
+
client_secret?: string;
|
|
96
|
+
payment_intent_id?: string;
|
|
97
|
+
}
|
|
98
|
+
export interface PreorderReadinessIssue {
|
|
99
|
+
offer_id: string;
|
|
100
|
+
code: string;
|
|
101
|
+
[key: string]: unknown;
|
|
102
|
+
}
|
|
103
|
+
export interface PreorderReadiness {
|
|
104
|
+
enabled: boolean;
|
|
105
|
+
ready: boolean;
|
|
106
|
+
blockers: PreorderReadinessIssue[];
|
|
107
|
+
warnings: PreorderReadinessIssue[];
|
|
108
|
+
}
|
|
109
|
+
export interface PreorderAdminOrderFilters {
|
|
110
|
+
offer_id?: string;
|
|
111
|
+
payment_status?: string;
|
|
112
|
+
fulfillment_status?: string;
|
|
113
|
+
per_page?: number;
|
|
114
|
+
page?: number;
|
|
115
|
+
}
|
|
116
|
+
export type PreorderAdminOrderAction = 'refund' | 'reconcile' | 'fulfill' | 'resend_receipt' | 'resend_access';
|
|
117
|
+
declare class Preorders {
|
|
118
|
+
static catalog(title_id: string, options?: PreorderRequestOptions): AxiosPromise<Response<PreorderCatalog>>;
|
|
119
|
+
static purchase(title_id: string, offer_id: string, data: PreorderPurchaseInput, options?: PreorderRequestOptions): AxiosPromise<Response<PreorderOrder>>;
|
|
120
|
+
static myOrders(title_id: string, options?: PreorderRequestOptions): AxiosPromise<Response<{
|
|
121
|
+
orders: PreorderOrder[];
|
|
122
|
+
}>>;
|
|
123
|
+
static order(title_id: string, order_id: string, options?: PreorderRequestOptions): AxiosPromise<Response<PreorderOrder>>;
|
|
124
|
+
static refundMine(title_id: string, order_id: string, options?: PreorderRequestOptions): AxiosPromise<Response<PreorderOrder>>;
|
|
125
|
+
static resendMine(title_id: string, order_id: string, options?: PreorderRequestOptions): AxiosPromise<Response<{
|
|
126
|
+
resent: boolean;
|
|
127
|
+
}>>;
|
|
128
|
+
static settings(title_id: string, options?: PreorderRequestOptions): AxiosPromise<Response<PreorderSettings>>;
|
|
129
|
+
static updateSettings(title_id: string, data: Partial<Pick<PreorderSettings, 'enabled' | 'timezone'>>, options?: PreorderRequestOptions): AxiosPromise<Response<PreorderSettings>>;
|
|
130
|
+
static offers(title_id: string, options?: PreorderRequestOptions): AxiosPromise<Response<{
|
|
131
|
+
offers: PreorderOffer[];
|
|
132
|
+
}>>;
|
|
133
|
+
static offer(title_id: string, offer_id: string, options?: PreorderRequestOptions): AxiosPromise<Response<PreorderOffer>>;
|
|
134
|
+
static createOffer(title_id: string, data: PreorderOfferInput, options?: PreorderRequestOptions): AxiosPromise<Response<PreorderOffer>>;
|
|
135
|
+
static updateOffer(title_id: string, offer_id: string, data: PreorderOfferInput, options?: PreorderRequestOptions): AxiosPromise<Response<PreorderOffer>>;
|
|
136
|
+
static activateOffer(title_id: string, offer_id: string, options?: PreorderRequestOptions): AxiosPromise<Response<PreorderOffer>>;
|
|
137
|
+
static pauseOffer(title_id: string, offer_id: string, options?: PreorderRequestOptions): AxiosPromise<Response<PreorderOffer>>;
|
|
138
|
+
static archiveOffer(title_id: string, offer_id: string, options?: PreorderRequestOptions): AxiosPromise<Response<PreorderOffer>>;
|
|
139
|
+
static inventory(title_id: string, offer_id: string, options?: PreorderRequestOptions): AxiosPromise<Response<PreorderInventory>>;
|
|
140
|
+
static importKeys(title_id: string, offer_id: string, keys: string[], options?: PreorderRequestOptions): AxiosPromise<Response<{
|
|
141
|
+
inserted: number;
|
|
142
|
+
duplicate_in_upload: number;
|
|
143
|
+
duplicate_existing: number;
|
|
144
|
+
invalid: number;
|
|
145
|
+
inventory: PreorderInventory;
|
|
146
|
+
}>>;
|
|
147
|
+
static importKeyFile<T>(title_id: string, offer_id: string, file: File | Blob): AxiosPromise<Response<T>>;
|
|
148
|
+
static retireKey(title_id: string, offer_id: string, key_id: string, reason: string, options?: PreorderRequestOptions): AxiosPromise<Response<{
|
|
149
|
+
id: string;
|
|
150
|
+
status: string;
|
|
151
|
+
masked_suffix: string;
|
|
152
|
+
}>>;
|
|
153
|
+
static adminOrders(title_id: string, filters?: PreorderAdminOrderFilters, options?: PreorderRequestOptions): AxiosPromise<Response<{
|
|
154
|
+
orders: PreorderOrder[];
|
|
155
|
+
pagination: Record<string, number>;
|
|
156
|
+
}>>;
|
|
157
|
+
static readiness(title_id: string, options?: PreorderRequestOptions): AxiosPromise<Response<PreorderReadiness>>;
|
|
158
|
+
static adminOrderAction(title_id: string, order_id: string, action: PreorderAdminOrderAction, options?: PreorderRequestOptions): AxiosPromise<Response<PreorderOrder>>;
|
|
159
|
+
static mcpCapabilities<T = unknown>(title_id: string, options?: PreorderRequestOptions): AxiosPromise<Response<T>>;
|
|
160
|
+
static mcpOperation<T = unknown>(title_id: string, operation: string, argumentsData?: Record<string, unknown>, options?: PreorderRequestOptions): AxiosPromise<Response<T>>;
|
|
161
|
+
}
|
|
162
|
+
export default Preorders;
|
package/dist/esm/api/index.d.ts
CHANGED
package/dist/esm/index.d.ts
CHANGED
|
@@ -57,7 +57,9 @@ import { GameAdvertising } from './api';
|
|
|
57
57
|
import { Hosting } from './api';
|
|
58
58
|
import { GameDesign } from './api';
|
|
59
59
|
import { Microtransactions } from './api';
|
|
60
|
+
import { Preorders } from './api';
|
|
60
61
|
export * from './api/Microtransactions';
|
|
62
|
+
export * from './api/Preorders';
|
|
61
63
|
export * from './util/MicrotransactionBridge';
|
|
62
64
|
export * from './util/MicrotransactionOverlay';
|
|
63
65
|
import Requests from "./util/Requests";
|
|
@@ -137,6 +139,7 @@ declare class Glitch {
|
|
|
137
139
|
Hosting: typeof Hosting;
|
|
138
140
|
GameDesign: typeof GameDesign;
|
|
139
141
|
Microtransactions: typeof Microtransactions;
|
|
142
|
+
Preorders: typeof Preorders;
|
|
140
143
|
};
|
|
141
144
|
static util: {
|
|
142
145
|
Requests: typeof Requests;
|
package/dist/esm/index.js
CHANGED
|
@@ -21927,6 +21927,112 @@ class Microtransactions {
|
|
|
21927
21927
|
}
|
|
21928
21928
|
}
|
|
21929
21929
|
|
|
21930
|
+
class PreordersRoute {
|
|
21931
|
+
}
|
|
21932
|
+
PreordersRoute.routes = {
|
|
21933
|
+
catalog: { url: '/titles/{title_id}/preorders', method: HTTP_METHODS.GET },
|
|
21934
|
+
purchase: { url: '/titles/{title_id}/preorders/{offer_id}/purchase', method: HTTP_METHODS.POST },
|
|
21935
|
+
myOrders: { url: '/titles/{title_id}/preorders/me/orders', method: HTTP_METHODS.GET },
|
|
21936
|
+
order: { url: '/titles/{title_id}/preorders/orders/{order_id}', method: HTTP_METHODS.GET },
|
|
21937
|
+
refundMine: { url: '/titles/{title_id}/preorders/orders/{order_id}/refund', method: HTTP_METHODS.POST },
|
|
21938
|
+
resendMine: { url: '/titles/{title_id}/preorders/orders/{order_id}/resend-access', method: HTTP_METHODS.POST },
|
|
21939
|
+
settings: { url: '/titles/{title_id}/preorders/settings', method: HTTP_METHODS.GET },
|
|
21940
|
+
updateSettings: { url: '/titles/{title_id}/preorders/settings', method: HTTP_METHODS.PUT },
|
|
21941
|
+
offers: { url: '/titles/{title_id}/preorders/admin/offers', method: HTTP_METHODS.GET },
|
|
21942
|
+
createOffer: { url: '/titles/{title_id}/preorders/admin/offers', method: HTTP_METHODS.POST },
|
|
21943
|
+
offer: { url: '/titles/{title_id}/preorders/admin/offers/{offer_id}', method: HTTP_METHODS.GET },
|
|
21944
|
+
updateOffer: { url: '/titles/{title_id}/preorders/admin/offers/{offer_id}', method: HTTP_METHODS.PUT },
|
|
21945
|
+
activateOffer: { url: '/titles/{title_id}/preorders/admin/offers/{offer_id}/activate', method: HTTP_METHODS.POST },
|
|
21946
|
+
pauseOffer: { url: '/titles/{title_id}/preorders/admin/offers/{offer_id}/pause', method: HTTP_METHODS.POST },
|
|
21947
|
+
archiveOffer: { url: '/titles/{title_id}/preorders/admin/offers/{offer_id}/archive', method: HTTP_METHODS.POST },
|
|
21948
|
+
inventory: { url: '/titles/{title_id}/preorders/admin/offers/{offer_id}/keys', method: HTTP_METHODS.GET },
|
|
21949
|
+
importKeys: { url: '/titles/{title_id}/preorders/admin/offers/{offer_id}/keys/import', method: HTTP_METHODS.POST },
|
|
21950
|
+
retireKey: { url: '/titles/{title_id}/preorders/admin/offers/{offer_id}/keys/{key_id}/retire', method: HTTP_METHODS.POST },
|
|
21951
|
+
adminOrders: { url: '/titles/{title_id}/preorders/admin/orders', method: HTTP_METHODS.GET },
|
|
21952
|
+
readiness: { url: '/titles/{title_id}/preorders/admin/readiness', method: HTTP_METHODS.GET },
|
|
21953
|
+
adminOrderAction: { url: '/titles/{title_id}/preorders/admin/orders/{order_id}/{action}', method: HTTP_METHODS.POST },
|
|
21954
|
+
mcpCapabilities: { url: '/mcp/v1/titles/{title_id}/preorders/capabilities', method: HTTP_METHODS.GET },
|
|
21955
|
+
mcpOperation: { url: '/mcp/v1/titles/{title_id}/preorders/operations/{operation}', method: HTTP_METHODS.POST },
|
|
21956
|
+
};
|
|
21957
|
+
|
|
21958
|
+
class Preorders {
|
|
21959
|
+
static catalog(title_id, options) {
|
|
21960
|
+
return Requests.processRoute(PreordersRoute.routes.catalog, undefined, { title_id }, undefined, options);
|
|
21961
|
+
}
|
|
21962
|
+
static purchase(title_id, offer_id, data, options) {
|
|
21963
|
+
return Requests.processRoute(PreordersRoute.routes.purchase, data, { title_id, offer_id }, undefined, options);
|
|
21964
|
+
}
|
|
21965
|
+
static myOrders(title_id, options) {
|
|
21966
|
+
return Requests.processRoute(PreordersRoute.routes.myOrders, undefined, { title_id }, undefined, options);
|
|
21967
|
+
}
|
|
21968
|
+
static order(title_id, order_id, options) {
|
|
21969
|
+
return Requests.processRoute(PreordersRoute.routes.order, undefined, { title_id, order_id }, undefined, options);
|
|
21970
|
+
}
|
|
21971
|
+
static refundMine(title_id, order_id, options) {
|
|
21972
|
+
return Requests.processRoute(PreordersRoute.routes.refundMine, {}, { title_id, order_id }, undefined, options);
|
|
21973
|
+
}
|
|
21974
|
+
static resendMine(title_id, order_id, options) {
|
|
21975
|
+
return Requests.processRoute(PreordersRoute.routes.resendMine, {}, { title_id, order_id }, undefined, options);
|
|
21976
|
+
}
|
|
21977
|
+
static settings(title_id, options) {
|
|
21978
|
+
return Requests.processRoute(PreordersRoute.routes.settings, undefined, { title_id }, undefined, options);
|
|
21979
|
+
}
|
|
21980
|
+
static updateSettings(title_id, data, options) {
|
|
21981
|
+
return Requests.processRoute(PreordersRoute.routes.updateSettings, data, { title_id }, undefined, options);
|
|
21982
|
+
}
|
|
21983
|
+
static offers(title_id, options) {
|
|
21984
|
+
return Requests.processRoute(PreordersRoute.routes.offers, undefined, { title_id }, undefined, options);
|
|
21985
|
+
}
|
|
21986
|
+
static offer(title_id, offer_id, options) {
|
|
21987
|
+
return Requests.processRoute(PreordersRoute.routes.offer, undefined, { title_id, offer_id }, undefined, options);
|
|
21988
|
+
}
|
|
21989
|
+
static createOffer(title_id, data, options) {
|
|
21990
|
+
return Requests.processRoute(PreordersRoute.routes.createOffer, data, { title_id }, undefined, options);
|
|
21991
|
+
}
|
|
21992
|
+
static updateOffer(title_id, offer_id, data, options) {
|
|
21993
|
+
return Requests.processRoute(PreordersRoute.routes.updateOffer, data, { title_id, offer_id }, undefined, options);
|
|
21994
|
+
}
|
|
21995
|
+
static activateOffer(title_id, offer_id, options) {
|
|
21996
|
+
return Requests.processRoute(PreordersRoute.routes.activateOffer, {}, { title_id, offer_id }, undefined, options);
|
|
21997
|
+
}
|
|
21998
|
+
static pauseOffer(title_id, offer_id, options) {
|
|
21999
|
+
return Requests.processRoute(PreordersRoute.routes.pauseOffer, {}, { title_id, offer_id }, undefined, options);
|
|
22000
|
+
}
|
|
22001
|
+
static archiveOffer(title_id, offer_id, options) {
|
|
22002
|
+
return Requests.processRoute(PreordersRoute.routes.archiveOffer, {}, { title_id, offer_id }, undefined, options);
|
|
22003
|
+
}
|
|
22004
|
+
static inventory(title_id, offer_id, options) {
|
|
22005
|
+
return Requests.processRoute(PreordersRoute.routes.inventory, undefined, { title_id, offer_id }, undefined, options);
|
|
22006
|
+
}
|
|
22007
|
+
static importKeys(title_id, offer_id, keys, options) {
|
|
22008
|
+
return Requests.processRoute(PreordersRoute.routes.importKeys, { keys }, { title_id, offer_id }, undefined, options);
|
|
22009
|
+
}
|
|
22010
|
+
static importKeyFile(title_id, offer_id, file) {
|
|
22011
|
+
const url = PreordersRoute.routes.importKeys.url
|
|
22012
|
+
.replace('{title_id}', title_id)
|
|
22013
|
+
.replace('{offer_id}', offer_id);
|
|
22014
|
+
return Requests.uploadFile(url, 'key_file', file, {}, undefined, undefined, { excludeCommunityContext: true });
|
|
22015
|
+
}
|
|
22016
|
+
static retireKey(title_id, offer_id, key_id, reason, options) {
|
|
22017
|
+
return Requests.processRoute(PreordersRoute.routes.retireKey, { reason }, { title_id, offer_id, key_id }, undefined, options);
|
|
22018
|
+
}
|
|
22019
|
+
static adminOrders(title_id, filters, options) {
|
|
22020
|
+
return Requests.processRoute(PreordersRoute.routes.adminOrders, undefined, { title_id }, filters, options);
|
|
22021
|
+
}
|
|
22022
|
+
static readiness(title_id, options) {
|
|
22023
|
+
return Requests.processRoute(PreordersRoute.routes.readiness, undefined, { title_id }, undefined, options);
|
|
22024
|
+
}
|
|
22025
|
+
static adminOrderAction(title_id, order_id, action, options) {
|
|
22026
|
+
return Requests.processRoute(PreordersRoute.routes.adminOrderAction, {}, { title_id, order_id, action }, undefined, options);
|
|
22027
|
+
}
|
|
22028
|
+
static mcpCapabilities(title_id, options) {
|
|
22029
|
+
return Requests.processRoute(PreordersRoute.routes.mcpCapabilities, undefined, { title_id }, undefined, options);
|
|
22030
|
+
}
|
|
22031
|
+
static mcpOperation(title_id, operation, argumentsData = {}, options) {
|
|
22032
|
+
return Requests.processRoute(PreordersRoute.routes.mcpOperation, { arguments: argumentsData }, { title_id, operation }, undefined, options);
|
|
22033
|
+
}
|
|
22034
|
+
}
|
|
22035
|
+
|
|
21930
22036
|
/** Generate a 256-bit browser nonce. Fails closed without secure Web Crypto. */
|
|
21931
22037
|
function createMicrotransactionNonce() {
|
|
21932
22038
|
var _a;
|
|
@@ -30475,6 +30581,7 @@ Glitch.api = {
|
|
|
30475
30581
|
Hosting: Hosting,
|
|
30476
30582
|
GameDesign: GameDesign,
|
|
30477
30583
|
Microtransactions: Microtransactions,
|
|
30584
|
+
Preorders: Preorders,
|
|
30478
30585
|
};
|
|
30479
30586
|
Glitch.util = {
|
|
30480
30587
|
Requests: Requests,
|