vigor-roblox 1.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.
@@ -0,0 +1,239 @@
1
+ import { vigor } from 'vigor-fetch';
2
+
3
+ type RobloxUserId = number & {
4
+ __brand__: 'Roblox_UserId';
5
+ };
6
+ type RobloxUserName = string & {
7
+ __brand__: 'Roblox_UserName';
8
+ };
9
+ type RobloxDisplayName = string & {
10
+ __brand__: 'Roblox_UserDisplayName';
11
+ };
12
+ type RobloxCookie = string & {
13
+ __brand__: 'Roblox_Cookie';
14
+ };
15
+ type RobloxPlaceId = number & {
16
+ __brand__: 'Roblox_PlaceId';
17
+ };
18
+ type RobloxUniverseId = number & {
19
+ __brand__: 'Roblox_UniverseId';
20
+ };
21
+ type RobloxJobId = string & {
22
+ __brand__: 'Roblox_JobId';
23
+ };
24
+ type RobloxAssetId = number & {
25
+ __brand__: 'Roblox_AssetId';
26
+ };
27
+ declare const RobloxErrorMessageFuncs: {
28
+ readonly AUTH_FAILED: ({ status, cookie }: {
29
+ status: number | null;
30
+ cookie: string;
31
+ }) => string;
32
+ readonly RATE_LIMITED: ({ status, url, retryAfterMs }: {
33
+ status: number;
34
+ url: string | null;
35
+ retryAfterMs: number | null;
36
+ }) => string;
37
+ readonly REQUEST_FAILED: ({ status, url }: {
38
+ status: number | null;
39
+ url: string | null;
40
+ }) => string;
41
+ };
42
+ type RobloxErrorCodes = keyof typeof RobloxErrorMessageFuncs;
43
+ type RobloxErrorDatas<C extends RobloxErrorCodes> = Parameters<typeof RobloxErrorMessageFuncs[C]> extends [infer A] ? A : undefined;
44
+ type RobloxErrorOptions<C extends RobloxErrorCodes, T> = {
45
+ cause?: unknown;
46
+ data?: RobloxErrorDatas<C>;
47
+ timeline?: unknown[];
48
+ context?: T;
49
+ };
50
+ declare abstract class RobloxApiError<C extends RobloxErrorCodes, T = unknown> extends Error {
51
+ readonly timestamp: Date;
52
+ readonly cause?: unknown;
53
+ readonly code: C;
54
+ readonly data: RobloxErrorDatas<C> | undefined;
55
+ readonly timeline: unknown[];
56
+ readonly context: T | undefined;
57
+ constructor(code: C, options: RobloxErrorOptions<C, T>);
58
+ }
59
+ declare class RobloxAuthError extends RobloxApiError<'AUTH_FAILED'> {
60
+ constructor(options: RobloxErrorOptions<'AUTH_FAILED', never>);
61
+ }
62
+ declare class RobloxRateLimitError extends RobloxApiError<'RATE_LIMITED'> {
63
+ constructor(options: RobloxErrorOptions<'RATE_LIMITED', never>);
64
+ }
65
+ declare class RobloxRequestError extends RobloxApiError<'REQUEST_FAILED'> {
66
+ constructor(options: RobloxErrorOptions<'REQUEST_FAILED', never>);
67
+ }
68
+ interface RobloxUserDescription {
69
+ description: string;
70
+ }
71
+ interface RobloxUserBirthdate {
72
+ birthYear: number;
73
+ birthMonth: number;
74
+ birthDay: number;
75
+ }
76
+ interface RobloxUserGender {
77
+ gender: number;
78
+ }
79
+ interface RobloxUserAgeBracket {
80
+ ageBracket: number;
81
+ }
82
+ interface RobloxUserCountryCode {
83
+ countryCode: string;
84
+ }
85
+ interface RobloxUserRoles {
86
+ roles: string[];
87
+ }
88
+ type RobloxAuthenticatedUser = RobloxUserSimple & Partial<RobloxUserDescription> & Partial<RobloxUserBirthdate> & Partial<RobloxUserGender> & Partial<RobloxUserAgeBracket> & Partial<RobloxUserCountryCode> & Partial<RobloxUserRoles>;
89
+ interface RobloxApiCache {
90
+ select: <T>(type: string, separators: string[]) => Promise<Array<{
91
+ separator: string;
92
+ data: T;
93
+ }>>;
94
+ upsert: <T>(type: string, expire: number, items: Array<{
95
+ separator: string;
96
+ data: T;
97
+ }>) => Promise<void>;
98
+ }
99
+ interface RobloxUserSimple {
100
+ id: RobloxUserId;
101
+ name: RobloxUserName;
102
+ displayName: RobloxDisplayName;
103
+ hasVerifiedBadge: boolean;
104
+ requestedUsername?: string;
105
+ }
106
+ interface RobloxUser extends RobloxUserSimple {
107
+ description: string;
108
+ externalAppDisplayName: string | null;
109
+ isBanned: boolean;
110
+ created: string;
111
+ }
112
+ interface RobloxThumbnailTarget {
113
+ targetId?: RobloxAssetId | RobloxUserId;
114
+ token?: string;
115
+ type?: string;
116
+ size?: string;
117
+ format?: string;
118
+ isCircular?: boolean;
119
+ }
120
+ interface RobloxThumbnail extends RobloxThumbnailTarget {
121
+ url: string | null;
122
+ state: string;
123
+ version: string;
124
+ }
125
+ interface RobloxServerEntry {
126
+ jobId: RobloxJobId;
127
+ maxPlayers: number;
128
+ playing: number;
129
+ fps: number;
130
+ ping: number;
131
+ playerImgs: string[];
132
+ }
133
+ interface RobloxServerEntryWithLocation extends RobloxServerEntry {
134
+ location: RobloxServerLocation | null;
135
+ }
136
+ interface RobloxServersResult<E extends RobloxServerEntry = RobloxServerEntry> {
137
+ previousPageCursor: string | null;
138
+ nextPageCursor: string | null;
139
+ data: E[];
140
+ }
141
+ interface RobloxPresenceEntry {
142
+ userId: RobloxUserId;
143
+ userPresenceType: number;
144
+ lastLocation: string;
145
+ placeId: RobloxPlaceId | null;
146
+ rootPlaceId: RobloxPlaceId | null;
147
+ gameId: RobloxJobId | null;
148
+ universeId: RobloxUniverseId | null;
149
+ lastOnline: string;
150
+ }
151
+ interface RobloxPlaceInfo {
152
+ placeId: RobloxPlaceId;
153
+ universeId: RobloxUniverseId | null;
154
+ name: string;
155
+ description: string;
156
+ creator: {
157
+ id: number;
158
+ name: string;
159
+ type: string;
160
+ };
161
+ price: number | null;
162
+ playing: number;
163
+ visits: number;
164
+ maxPlayers: number;
165
+ created: string;
166
+ updated: string;
167
+ logos: string[];
168
+ }
169
+ interface RobloxServerLocation {
170
+ ip: string;
171
+ jobId: RobloxJobId;
172
+ countryCode: string;
173
+ countryName: string;
174
+ regionName: string;
175
+ city: string;
176
+ latitude: number;
177
+ longitude: number;
178
+ isp: string;
179
+ timezone: string;
180
+ }
181
+ interface CreateRobloxApiOptions {
182
+ cache: RobloxApiCache;
183
+ cookies: RobloxCookie[];
184
+ ipgeolocationKey: string;
185
+ }
186
+ interface ServersOpts {
187
+ placeId: RobloxPlaceId;
188
+ count?: number;
189
+ serverType?: 'Public' | 'Friend';
190
+ cursor?: string;
191
+ thumbnailFormat?: Partial<RobloxThumbnailTarget>;
192
+ }
193
+ type VigorFetchInstance = ReturnType<typeof vigor.fetch>;
194
+ interface RobloxApi {
195
+ authenticated: (cookies: RobloxCookie[]) => Promise<RobloxAuthenticatedUser[]>;
196
+ usersSimple: (userIds: RobloxUserId[]) => Promise<RobloxUserSimple[]>;
197
+ users: (userIds: RobloxUserId[]) => Promise<RobloxUser[]>;
198
+ usersByName: (usernames: string[]) => Promise<RobloxUserSimple[]>;
199
+ thumbnailAssets: (opts: {
200
+ assetIds: RobloxAssetId[];
201
+ size?: string;
202
+ format?: string;
203
+ }) => Promise<RobloxThumbnail[]>;
204
+ thumbnailsBatch: (targets: RobloxThumbnailTarget[], formatDefaults?: Partial<RobloxThumbnailTarget>) => Promise<RobloxThumbnail[]>;
205
+ serversSimple: (opts: ServersOpts) => Promise<RobloxServersResult<RobloxServerEntry>>;
206
+ servers: (opts: ServersOpts) => Promise<RobloxServersResult<RobloxServerEntryWithLocation>>;
207
+ presence: (userIds: RobloxUserId[]) => Promise<RobloxPresenceEntry[]>;
208
+ placeInfo: (placeIds: RobloxPlaceId[]) => Promise<RobloxPlaceInfo[]>;
209
+ usersSimpleWithImg: (userIds: RobloxUserId[]) => Promise<Array<RobloxUserSimple & {
210
+ img: string | null;
211
+ }>>;
212
+ usersWithImg: (userIds: RobloxUserId[]) => Promise<Array<RobloxUser & {
213
+ img: string | null;
214
+ }>>;
215
+ track: (opts: {
216
+ placeId: RobloxPlaceId;
217
+ targets: Array<string | number>;
218
+ }) => Promise<Array<{
219
+ user: RobloxUserSimple & {
220
+ img: string | null;
221
+ };
222
+ server: RobloxServerEntry & {
223
+ location: RobloxServerLocation | null;
224
+ } | null;
225
+ }>>;
226
+ serversRegion: (opts: {
227
+ placeId: RobloxPlaceId;
228
+ jobIds: RobloxJobId[];
229
+ }) => Promise<RobloxServerLocation[]>;
230
+ _internal: {
231
+ gamejoinApi: VigorFetchInstance;
232
+ gamesApi: VigorFetchInstance;
233
+ apisRoblox: VigorFetchInstance;
234
+ };
235
+ }
236
+ declare function createRobloxApi({ cache, cookies: cookiesList, ipgeolocationKey, }: CreateRobloxApiOptions): RobloxApi;
237
+
238
+ export { RobloxAuthError, RobloxRateLimitError, RobloxRequestError, createRobloxApi };
239
+ export type { CreateRobloxApiOptions, RobloxApi, RobloxApiCache, RobloxAssetId, RobloxAuthenticatedUser, RobloxCookie, RobloxDisplayName, RobloxJobId, RobloxPlaceId, RobloxPlaceInfo, RobloxPresenceEntry, RobloxServerEntry, RobloxServerEntryWithLocation, RobloxServerLocation, RobloxServersResult, RobloxThumbnail, RobloxThumbnailTarget, RobloxUniverseId, RobloxUser, RobloxUserAgeBracket, RobloxUserBirthdate, RobloxUserCountryCode, RobloxUserDescription, RobloxUserGender, RobloxUserId, RobloxUserName, RobloxUserRoles, RobloxUserSimple, VigorFetchInstance };