glitch-javascript-sdk 3.10.8 → 4.0.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/README.md +7 -1
- package/dist/browser/hosting-runtime.js +13 -3
- package/dist/browser/hosting-runtime.js.map +1 -1
- package/dist/cjs/index.js +8348 -8
- package/dist/cjs/index.js.map +1 -1
- package/dist/esm/api/FestivalNetworking.d.ts +286 -0
- package/dist/esm/api/Messages.d.ts +4 -1
- package/dist/esm/api/Microtransactions.d.ts +776 -0
- package/dist/esm/api/index.d.ts +2 -0
- package/dist/esm/index.d.ts +8 -0
- package/dist/esm/index.js +8272 -6
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/routes/FestivalNetworkingRoute.d.ts +7 -0
- package/dist/esm/routes/MicrotransactionsRoute.d.ts +8 -0
- package/dist/esm/util/MicrotransactionBridge.d.ts +93 -0
- package/dist/esm/util/MicrotransactionOverlay.d.ts +59 -0
- package/dist/esm/util/Requests.d.ts +7 -3
- package/dist/index.d.ts +1227 -5
- package/guides/commerce-delivery-receiver.mjs +117 -0
- package/guides/microtransactions.md +466 -0
- package/package.json +7 -4
- package/src/api/FestivalNetworking.ts +216 -0
- package/src/api/Messages.ts +4 -1
- package/src/api/Microtransactions.ts +699 -0
- package/src/api/index.ts +2 -0
- package/src/index.ts +8 -0
- package/src/routes/FestivalNetworkingRoute.ts +33 -0
- package/src/routes/MicrotransactionsRoute.ts +57 -0
- package/src/util/MicrotransactionBridge.ts +193 -0
- package/src/util/MicrotransactionOverlay.ts +302 -0
- package/src/util/Requests.ts +15 -3
- package/src/util/Session.ts +3 -2
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
import { AxiosProgressEvent, AxiosPromise, AxiosRequestConfig } from 'axios';
|
|
2
|
+
import FestivalNetworkingRoute from '../routes/FestivalNetworkingRoute';
|
|
3
|
+
import Requests from '../util/Requests';
|
|
4
|
+
|
|
5
|
+
export type FestivalPostKind = 'discussion' | 'job' | 'talent';
|
|
6
|
+
export type FestivalPostState = 'active' | 'locked' | 'archived' | 'hidden' | 'deleted' | 'removed' | 'paused' | 'filled' | 'expired' | 'closed';
|
|
7
|
+
export type FestivalApplicationState = 'submitted' | 'viewed' | 'shortlisted' | 'interview' | 'accepted' | 'rejected' | 'withdrawn' | 'closed';
|
|
8
|
+
export type FestivalWorkType = 'full_time' | 'part_time' | 'contract' | 'gig';
|
|
9
|
+
export type FestivalRequestOptions = Pick<AxiosRequestConfig, 'signal' | 'timeout'>;
|
|
10
|
+
|
|
11
|
+
export interface FestivalNetworkingSettings {
|
|
12
|
+
discussions_enabled: boolean;
|
|
13
|
+
jobs_enabled: boolean;
|
|
14
|
+
employer_posts_enabled: boolean;
|
|
15
|
+
talent_posts_enabled: boolean;
|
|
16
|
+
matching_enabled: boolean;
|
|
17
|
+
voting_enabled: boolean;
|
|
18
|
+
comments_enabled: boolean;
|
|
19
|
+
media_enabled: boolean;
|
|
20
|
+
/** Registration or a valid ticket is mandatory; cannot be disabled. */
|
|
21
|
+
require_registration: true;
|
|
22
|
+
public_viewing: false;
|
|
23
|
+
anonymous_enabled: false;
|
|
24
|
+
categories: string[];
|
|
25
|
+
skills: string[];
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export interface FestivalPostInput {
|
|
29
|
+
kind: FestivalPostKind;
|
|
30
|
+
title: string;
|
|
31
|
+
/** Sanitized HTML from the shared WYSIWYG editor. */
|
|
32
|
+
content: string;
|
|
33
|
+
visibility?: 'public' | 'unlisted' | 'private';
|
|
34
|
+
category?: string | null;
|
|
35
|
+
tags?: string[];
|
|
36
|
+
skills?: string[];
|
|
37
|
+
preferred_skills?: string[];
|
|
38
|
+
job_types?: FestivalWorkType[];
|
|
39
|
+
company?: string | null;
|
|
40
|
+
organization_id?: string | null;
|
|
41
|
+
work_arrangement?: 'remote' | 'onsite' | 'hybrid' | null;
|
|
42
|
+
experience?: 'any' | 'entry' | 'junior' | 'mid' | 'senior' | 'lead' | null;
|
|
43
|
+
location?: string | null;
|
|
44
|
+
availability?: 'immediately' | 'within_30_days' | 'specific_date' | 'flexible' | 'unavailable';
|
|
45
|
+
availability_date?: string | null;
|
|
46
|
+
deadline?: string | null;
|
|
47
|
+
expires_at?: string | null;
|
|
48
|
+
compensation_type?: 'negotiable' | 'yearly' | 'monthly' | 'hourly' | 'flat_fee';
|
|
49
|
+
compensation_min?: number | null;
|
|
50
|
+
compensation_max?: number | null;
|
|
51
|
+
currency?: string | null;
|
|
52
|
+
portfolio_url?: string | null;
|
|
53
|
+
application_method?: 'internal' | 'external';
|
|
54
|
+
application_url?: string | null;
|
|
55
|
+
/** UserMedia IDs returned by uploadMedia, NOT Media IDs or clip-library selections. Max 8. */
|
|
56
|
+
media_ids?: string[];
|
|
57
|
+
public_compensation?: boolean;
|
|
58
|
+
public_location?: boolean;
|
|
59
|
+
public_availability?: boolean;
|
|
60
|
+
public_portfolio?: boolean;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export interface FestivalNetworkingFilters {
|
|
64
|
+
kind?: FestivalPostKind;
|
|
65
|
+
view?: 'all' | 'mine' | 'saved' | 'hidden' | 'comments';
|
|
66
|
+
sort?: 'new' | 'hot' | 'top' | 'discussed' | 'compensation' | 'deadline';
|
|
67
|
+
window?: 'today' | 'week' | 'month' | 'festival' | 'all';
|
|
68
|
+
q?: string;
|
|
69
|
+
category?: string;
|
|
70
|
+
skill?: string;
|
|
71
|
+
job_type?: FestivalWorkType;
|
|
72
|
+
arrangement?: 'remote' | 'onsite' | 'hybrid';
|
|
73
|
+
experience?: string;
|
|
74
|
+
location?: string;
|
|
75
|
+
company?: string;
|
|
76
|
+
availability?: string;
|
|
77
|
+
currency?: string;
|
|
78
|
+
compensation_type?: string;
|
|
79
|
+
min_compensation?: number;
|
|
80
|
+
tag?: string;
|
|
81
|
+
author?: string;
|
|
82
|
+
has_comments?: boolean;
|
|
83
|
+
has_portfolio?: boolean;
|
|
84
|
+
media_type?: 'image' | 'video';
|
|
85
|
+
page?: number;
|
|
86
|
+
per_page?: number;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
export interface FestivalMediaUpload {
|
|
90
|
+
id: string;
|
|
91
|
+
user_media_id: string;
|
|
92
|
+
media_id: string;
|
|
93
|
+
url: string;
|
|
94
|
+
mime_type: string;
|
|
95
|
+
size: number;
|
|
96
|
+
title: string;
|
|
97
|
+
processing_status: 'completed' | 'pending' | 'processing' | 'failed';
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
export interface FestivalNetworkingProfile { id: string | null; name: string; }
|
|
101
|
+
export interface FestivalNetworkingResponse<T> {
|
|
102
|
+
data: T;
|
|
103
|
+
message?: string;
|
|
104
|
+
meta?: { current_page: number; last_page: number; total?: number; };
|
|
105
|
+
has_access?: boolean;
|
|
106
|
+
can_manage?: boolean;
|
|
107
|
+
can_moderate?: boolean;
|
|
108
|
+
user?: FestivalNetworkingProfile | null;
|
|
109
|
+
show?: { id: string; name: string; };
|
|
110
|
+
audit?: Array<Record<string, unknown>>;
|
|
111
|
+
}
|
|
112
|
+
export interface FestivalPost {
|
|
113
|
+
id: string;
|
|
114
|
+
game_show_id: string;
|
|
115
|
+
parent_id: string | null;
|
|
116
|
+
kind: FestivalPostKind | 'comment';
|
|
117
|
+
title: string;
|
|
118
|
+
content: string;
|
|
119
|
+
state: FestivalPostState;
|
|
120
|
+
visibility: 'public' | 'unlisted' | 'private';
|
|
121
|
+
details: Partial<FestivalPostInput>;
|
|
122
|
+
author: FestivalNetworkingProfile | null;
|
|
123
|
+
created_at: string;
|
|
124
|
+
updated_at: string;
|
|
125
|
+
score: number;
|
|
126
|
+
my_vote: -1 | 0 | 1;
|
|
127
|
+
saved: boolean;
|
|
128
|
+
is_owner: boolean;
|
|
129
|
+
can_edit: boolean;
|
|
130
|
+
comment_count: number;
|
|
131
|
+
media: Array<{ id: string; user_media_id?: string | null; url: string; mime_type: string; title: string | null; }>;
|
|
132
|
+
my_application?: { id: string; status: FestivalApplicationState; } | null;
|
|
133
|
+
match?: { score: number; reasons: string[]; missing_required_skills: string[]; disclaimer: string; };
|
|
134
|
+
}
|
|
135
|
+
export interface FestivalApplicationInput { message?: string; portfolio?: string[]; }
|
|
136
|
+
export interface FestivalConversation {
|
|
137
|
+
id: string;
|
|
138
|
+
festival_application_id: string;
|
|
139
|
+
can_send: boolean;
|
|
140
|
+
read_only_reason: string | null;
|
|
141
|
+
festival_context: { game_show_id: string; post_id: string | null; title: string; kind: FestivalPostKind; application_status: FestivalApplicationState } | null;
|
|
142
|
+
users: Array<{ id: string | null; display_name: string; avatar: string | null }>;
|
|
143
|
+
messages: Array<{ id: string; thread_id: string; user_id: string | null; message: string; client_message_id: string | null; created_at: string; updated_at: string; user: { id: string | null; display_name: string; avatar: string | null } }>;
|
|
144
|
+
}
|
|
145
|
+
export interface FestivalPreferences { notifications?: boolean; blocked_users?: string[]; blocked_companies?: string[]; }
|
|
146
|
+
export interface FestivalReportInput {
|
|
147
|
+
reason: 'spam' | 'harassment' | 'hate' | 'sexual_content' | 'scam' | 'job_scam' | 'copyright' | 'malicious_link' | 'misleading' | 'other';
|
|
148
|
+
explanation?: string;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
/** Festival-scoped discussions, talent, jobs, moderation and new owned media uploads. */
|
|
152
|
+
export default class FestivalNetworking {
|
|
153
|
+
private static request<T>(name: string, show_id: string, data?: object, ids: Record<string, string> = {}, params?: object, options?: FestivalRequestOptions): AxiosPromise<FestivalNetworkingResponse<T>> {
|
|
154
|
+
const replacements = Object.fromEntries(Object.entries({ show_id, ...ids }).map(([key, id]) => [key, encodeURIComponent(id)]));
|
|
155
|
+
return Requests.processRoute<T>(FestivalNetworkingRoute.routes[name], data, replacements, params, options);
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
/** Read enabled tools and the current account's registration/ticket access. */
|
|
159
|
+
static settings<T = FestivalNetworkingSettings>(id: string, options?: FestivalRequestOptions) { return this.request<T>('settings', id, undefined, {}, undefined, options); }
|
|
160
|
+
/** Organizer-only settings update; admission remains mandatory. */
|
|
161
|
+
static updateSettings<T = FestivalNetworkingSettings>(id: string, data: Partial<FestivalNetworkingSettings>) { return this.request<T>('updateSettings', id, data); }
|
|
162
|
+
/** Search posts; compensation comparisons require currency and period. */
|
|
163
|
+
static listPosts<T = FestivalPost[]>(id: string, params?: FestivalNetworkingFilters, options?: FestivalRequestOptions) { return this.request<T>('listPosts', id, undefined, {}, params, options); }
|
|
164
|
+
/** Create a post with rich HTML and optional newly uploaded UserMedia IDs. */
|
|
165
|
+
static createPost<T = FestivalPost>(id: string, data: FestivalPostInput) { return this.request<T>('createPost', id, data); }
|
|
166
|
+
/** Direct links still require admission and content visibility permission. */
|
|
167
|
+
static getPost<T = FestivalPost>(id: string, post_id: string, options?: FestivalRequestOptions) { return this.request<T>('getPost', id, undefined, { post_id }, undefined, options); }
|
|
168
|
+
/** Edit or soft-delete via state; omit media_ids to preserve current attachments. */
|
|
169
|
+
static updatePost<T = FestivalPost>(id: string, post_id: string, data: Partial<FestivalPostInput> & { state?: FestivalPostState }) { return this.request<T>('updatePost', id, data, { post_id }); }
|
|
170
|
+
/** Paginated direct replies; fetch children to expand a thread. */
|
|
171
|
+
static listComments<T = FestivalPost[]>(id: string, post_id: string, params?: { page?: number }, options?: FestivalRequestOptions) { return this.request<T>('listComments', id, undefined, { post_id }, params, options); }
|
|
172
|
+
/** Add a rich-text reply, subject to locking and five-level nesting. */
|
|
173
|
+
static createComment<T = FestivalPost>(id: string, post_id: string, data: { content: string }) { return this.request<T>('createComment', id, data, { post_id }); }
|
|
174
|
+
/** Set, replace, or remove a vote/save/hide idempotently. */
|
|
175
|
+
static setInteraction<T = FestivalPost>(id: string, post_id: string, data: { action: 'vote' | 'saved' | 'hidden'; value: -1 | 0 | 1 }) { return this.request<T>('setInteraction', id, data, { post_id }); }
|
|
176
|
+
/** Apply or express interest once; the original listing is snapshotted. */
|
|
177
|
+
static apply<T = Record<string, unknown>>(id: string, post_id: string, data: FestivalApplicationInput) { return this.request<T>('apply', id, data, { post_id }); }
|
|
178
|
+
/** Discovery matches for the current user's own job/talent listing. */
|
|
179
|
+
static matches<T = FestivalPost[]>(id: string, post_id: string, params?: { page?: number }, options?: FestivalRequestOptions) { return this.request<T>('matches', id, undefined, { post_id }, params, options); }
|
|
180
|
+
/** Report suspicious content privately to festival moderators. */
|
|
181
|
+
static report<T = never>(id: string, post_id: string, data: FestivalReportInput) { return this.request<T>('report', id, data, { post_id }); }
|
|
182
|
+
/** Only the applicant and listing owner receive application records. */
|
|
183
|
+
static applications<T = Array<Record<string, unknown>>>(id: string, params?: { page?: number }, options?: FestivalRequestOptions) { return this.request<T>('applications', id, undefined, {}, params, options); }
|
|
184
|
+
/** Applicant withdrawal or owner-managed status changes. */
|
|
185
|
+
static updateApplication<T = Record<string, unknown>>(id: string, application_id: string, data: { status: Exclude<FestivalApplicationState, 'submitted'> }) { return this.request<T>('updateApplication', id, data, { application_id }); }
|
|
186
|
+
/** Open the application/talent inquiry's private shared-inbox conversation, creating it once for legacy applications. Only the applicant and original listing owner may call this. Use Messages.getThread/sendMessage for subsequent conversation activity. */
|
|
187
|
+
static conversation<T = FestivalConversation>(id: string, application_id: string) { return this.request<T>('conversation', id, {}, { application_id }); }
|
|
188
|
+
/** Moderator-only report queue and audit history. */
|
|
189
|
+
static moderation<T = Array<Record<string, unknown>>>(id: string, params?: { page?: number }, options?: FestivalRequestOptions) { return this.request<T>('moderation', id, undefined, {}, params, options); }
|
|
190
|
+
/** Moderation remains available even while the board is disabled. */
|
|
191
|
+
static moderatePost<T = FestivalPost>(id: string, post_id: string, data: { state?: 'active' | 'hidden' | 'locked' | 'deleted' | 'removed'; remove_media?: true }) { return this.request<T>('moderatePost', id, data, { post_id }); }
|
|
192
|
+
/** Resolve, dismiss or begin reviewing a report. */
|
|
193
|
+
static resolveReport<T = never>(id: string, report_id: string, data: { status: 'under_review' | 'resolved' | 'dismissed' }) { return this.request<T>('resolveReport', id, data, { report_id }); }
|
|
194
|
+
/** Moderator-only participant restrictions. */
|
|
195
|
+
static restrictMember<T = never>(id: string, user_id: string, data: { banned: boolean }) { return this.request<T>('restrictMember', id, data, { user_id }); }
|
|
196
|
+
/** Current user's privacy and notification preferences. */
|
|
197
|
+
static preferences<T = FestivalPreferences>(id: string, options?: FestivalRequestOptions) { return this.request<T>('preferences', id, undefined, {}, undefined, options); }
|
|
198
|
+
/** Set notification opt-out and blocked participants/companies. */
|
|
199
|
+
static updatePreferences<T = FestivalPreferences>(id: string, data: FestivalPreferences) { return this.request<T>('updatePreferences', id, data); }
|
|
200
|
+
/** Uploaded festival attachments only; not the gameplay clip library. */
|
|
201
|
+
static media<T = Array<Record<string, unknown>>>(id: string, params?: { page?: number }, options?: FestivalRequestOptions) { return this.request<T>('media', id, undefined, {}, params, options); }
|
|
202
|
+
/**
|
|
203
|
+
* Upload a new image (10 MB max) or video (100 MB max), using the existing media pipeline.
|
|
204
|
+
* The response ID is an owned UserMedia ID for createPost/updatePost media_ids.
|
|
205
|
+
* @param file New file selected by the attendee; supported images exclude SVG.
|
|
206
|
+
* @param data Which enabled board the upload is for.
|
|
207
|
+
* @param onUploadProgress Transfer progress; 100% may still require conversion before completion.
|
|
208
|
+
*/
|
|
209
|
+
static uploadMedia<T = FestivalMediaUpload>(id: string, file: File | Blob, data: { kind: FestivalPostKind }, onUploadProgress?: (event: AxiosProgressEvent) => void, options?: FestivalRequestOptions): AxiosPromise<FestivalNetworkingResponse<T>> {
|
|
210
|
+
return Requests.uploadFile<T>(FestivalNetworkingRoute.routes.uploadMedia.url.replace('{show_id}', encodeURIComponent(id)), 'media', file, data, undefined, onUploadProgress, options);
|
|
211
|
+
}
|
|
212
|
+
/** Organizations the authenticated user is authorized to represent. */
|
|
213
|
+
static organizations<T = Array<{ id: string; name: string }>>(id: string, options?: FestivalRequestOptions) { return this.request<T>('organizations', id, undefined, {}, undefined, options); }
|
|
214
|
+
/** Organizer-only aggregate participation metrics. */
|
|
215
|
+
static analytics<T = Record<string, unknown>>(id: string, options?: FestivalRequestOptions) { return this.request<T>('analytics', id, undefined, {}, undefined, options); }
|
|
216
|
+
}
|
package/src/api/Messages.ts
CHANGED
|
@@ -17,7 +17,10 @@ class Messages {
|
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
/**
|
|
20
|
-
* Send a new message that will be added to a thread
|
|
20
|
+
* Send a new message that will be added to a thread. Festival-scoped threads
|
|
21
|
+
* enforce current admission, blocking and read-only state server-side.
|
|
22
|
+
* Include an optional client_message_id UUID and reuse it when retrying a
|
|
23
|
+
* timed-out request to prevent duplicate messages and notifications.
|
|
21
24
|
*
|
|
22
25
|
* @see https://api.glitch.fun/api/documentation#/Messages/storeMessage
|
|
23
26
|
*
|