-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathtypes.go
461 lines (382 loc) · 16.6 KB
/
types.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
package itchio
import (
"time"
)
// User represents an itch.io account, with basic profile info
type User struct {
// Site-wide unique identifier generated by itch.io
ID int64 `json:"id"`
// The user's username (used for login)
Username string `json:"username"`
// The user's display name: human-friendly, may contain spaces, unicode etc.
DisplayName string `json:"displayName"`
// Has the user opted into creating games?
Developer bool `json:"developer" hades:"-"`
// Is the user part of itch.io's press program?
PressUser bool `json:"pressUser" hades:"-"`
// The address of the user's page on itch.io
URL string `json:"url"`
// User's avatar, may be a GIF
CoverURL string `json:"coverUrl"`
// Static version of user's avatar, only set if the main cover URL is a GIF
StillCoverURL string `json:"stillCoverUrl"`
}
// Game represents a page on itch.io, it could be a game,
// a tool, a comic, etc.
type Game struct {
// Site-wide unique identifier generated by itch.io
ID int64 `json:"id"`
// Canonical address of the game's page on itch.io
URL string `json:"url,omitempty"`
// Human-friendly title (may contain any character)
Title string `json:"title,omitempty"`
// Human-friendly short description
ShortText string `json:"shortText,omitempty"`
// Downloadable game, html game, etc.
Type GameType `json:"type,omitempty"`
// Classification: game, tool, comic, etc.
Classification GameClassification `json:"classification,omitempty"`
// Configuration for embedded (HTML5) games
// @optional
Embed *GameEmbedData `json:"embed,omitempty"`
// Cover url (might be a GIF)
CoverURL string `json:"coverUrl,omitempty"`
// Non-gif cover url, only set if main cover url is a GIF
StillCoverURL string `json:"stillCoverUrl,omitempty"`
// Date the game was created
CreatedAt *time.Time `json:"createdAt,omitempty"`
// Date the game was published, empty if not currently published
PublishedAt *time.Time `json:"publishedAt,omitempty"`
// Price in cents of a dollar
MinPrice int64 `json:"minPrice,omitempty"`
// Are payments accepted?
CanBeBought bool `json:"canBeBought,omitempty"`
// Does this game have a demo available?
HasDemo bool `json:"hasDemo,omitempty"`
// Is this game part of the itch.io press system?
InPressSystem bool `json:"inPressSystem,omitempty"`
// Platforms this game is available for
Platforms Platforms `json:"platforms" hades:"squash"`
// The user account this game is associated to
// @optional
User *User `json:"user,omitempty"`
// ID of the user account this game is associated to
UserID int64 `json:"userId,omitempty"`
// The best current sale for this game
// @optional
Sale *Sale `json:"sale,omitempty"`
// Owner-only fields
ViewsCount int64 `json:"viewsCount,omitempty" hades:"-"`
DownloadsCount int64 `json:"downloadsCount,omitempty" hades:"-"`
PurchasesCount int64 `json:"purchasesCount,omitempty" hades:"-"`
Published bool `json:"published,omitempty" hades:"-"`
}
// Platforms describes which OS/architectures a game or upload
// is compatible with.
type Platforms struct {
Windows Architectures `json:"windows,omitempty"`
Linux Architectures `json:"linux,omitempty"`
OSX Architectures `json:"osx,omitempty"`
}
// Architectures describes a set of processor architectures (mostly 32-bit vs 64-bit)
type Architectures string
const (
// ArchitecturesAll represents any processor architecture
ArchitecturesAll Architectures = "all"
// Architectures386 represents 32-bit processor architectures
Architectures386 Architectures = "386"
// ArchitecturesAmd64 represents 64-bit processor architectures
ArchitecturesAmd64 Architectures = "amd64"
)
// GameType is the type of an itch.io game page, mostly related to
// how it should be presented on web (downloadable or embed)
type GameType string
const (
// GameTypeDefault is downloadable games
GameTypeDefault GameType = "default"
// GameTypeFlash is for .swf (legacy)
GameTypeFlash GameType = "flash"
// GameTypeUnity is for .unity3d (legacy)
GameTypeUnity GameType = "unity"
// GameTypeJava is for .jar (legacy)
GameTypeJava GameType = "java"
// GameTypeHTML is for .html (thriving)
GameTypeHTML GameType = "html"
)
// GameClassification is the creator-picked classification for a page
type GameClassification string
const (
// GameClassificationGame is something you can play
GameClassificationGame GameClassification = "game"
// GameClassificationTool includes all software pretty much
GameClassificationTool GameClassification = "tool"
// GameClassificationAssets includes assets: graphics, sounds, etc.
GameClassificationAssets GameClassification = "assets"
// GameClassificationGameMod are game mods (no link to game, purely creator tagging)
GameClassificationGameMod GameClassification = "game_mod"
// GameClassificationPhysicalGame is for a printable / board / card game
GameClassificationPhysicalGame GameClassification = "physical_game"
// GameClassificationSoundtrack is a bunch of music files
GameClassificationSoundtrack GameClassification = "soundtrack"
// GameClassificationOther is anything that creators think don't fit in any other category
GameClassificationOther GameClassification = "other"
// GameClassificationComic is a comic book (pdf, jpg, specific comic formats, etc.)
GameClassificationComic GameClassification = "comic"
// GameClassificationBook is a book (pdf, jpg, specific e-book formats, etc.)
GameClassificationBook GameClassification = "book"
)
// GameEmbedData contains presentation information for embed games
type GameEmbedData struct {
// Game this embed info is for
GameID int64 `json:"gameId" hades:"primary_key"`
// width of the initial viewport, in pixels
Width int64 `json:"width"`
// height of the initial viewport, in pixels
Height int64 `json:"height"`
// for itch.io website, whether or not a fullscreen button should be shown
Fullscreen bool `json:"fullscreen"`
}
// Sale describes a discount for a game.
type Sale struct {
// Site-wide unique identifier generated by itch.io
ID int64 `json:"id"`
// Game this sale is for
GameID int64 `json:"gameId"`
// Discount rate in percent.
// Can be negative, see https://itch.io/updates/introducing-reverse-sales
Rate float64 `json:"rate"`
// Timestamp the sale started at
StartDate time.Time `json:"startDate"`
// Timestamp the sale ends at
EndDate time.Time `json:"endDate"`
}
// An Upload is a downloadable file. Some are wharf-enabled, which means
// they're actually a "channel" that may contain multiple builds, pushed
// with <https://github.com/itchio/butler>
type Upload struct {
// Site-wide unique identifier generated by itch.io
ID int64 `json:"id"`
// Storage (hosted, external, etc.)
Storage UploadStorage `json:"storage"`
// Host (if external storage)
Host string `json:"host,omitempty"`
// Original file name (example: `Overland_x64.zip`)
Filename string `json:"filename"`
// Human-friendly name set by developer (example: `Overland for Windows 64-bit`)
DisplayName string `json:"displayName"`
// Size of upload in bytes. For wharf-enabled uploads, it's the archive size.
Size int64 `json:"size"`
// Name of the wharf channel for this upload, if it's a wharf-enabled upload
ChannelName string `json:"channelName"`
// Latest build for this upload, if it's a wharf-enabled upload
Build *Build `json:"build"`
// ID of the latest build for this upload, if it's a wharf-enabled upload
BuildID int64 `json:"buildId,omitempty"`
// Upload type: default, soundtrack, etc.
Type UploadType `json:"type"`
// Is this upload a pre-order placeholder?
Preorder bool `json:"preorder"`
// Is this upload a free demo?
Demo bool `json:"demo"`
// Platforms this upload is compatible with
Platforms Platforms `json:"platforms" hades:"squash"`
// Date this upload was created at
CreatedAt *time.Time `json:"createdAt"`
// Date this upload was last updated at (order changed, display name set, etc.)
UpdatedAt *time.Time `json:"updatedAt"`
}
// UploadStorage describes where an upload file is stored.
type UploadStorage string
const (
// UploadStorageHosted is a classic upload (web) - no versioning
UploadStorageHosted UploadStorage = "hosted"
// UploadStorageBuild is a wharf upload (butler)
UploadStorageBuild UploadStorage = "build"
// UploadStorageExternal is an external upload - alllllllll bets are off.
UploadStorageExternal UploadStorage = "external"
)
// UploadType describes what's in an upload - an executable,
// a web game, some music, etc.
type UploadType string
const (
// UploadTypeDefault is for executables
UploadTypeDefault UploadType = "default"
//----------------
// embed types
//----------------
// UploadTypeFlash is for .swf files
UploadTypeFlash UploadType = "flash"
// UploadTypeUnity is for .unity3d files
UploadTypeUnity UploadType = "unity"
// UploadTypeJava is for .jar files
UploadTypeJava UploadType = "java"
// UploadTypeHTML is for .html files
UploadTypeHTML UploadType = "html"
//----------------
// asorted types
//----------------
// UploadTypeSoundtrack is for archives with .mp3/.ogg/.flac/etc files
UploadTypeSoundtrack UploadType = "soundtrack"
// UploadTypeBook is for books (epubs, pdfs, etc.)
UploadTypeBook UploadType = "book"
// UploadTypeVideo is for videos
UploadTypeVideo UploadType = "video"
// UploadTypeDocumentation is for documentation (pdf, maybe uhh doxygen?)
UploadTypeDocumentation UploadType = "documentation"
// UploadTypeMod is a bunch of loose files with no clear instructions how to apply them to a game
UploadTypeMod UploadType = "mod"
// UploadTypeAudioAssets is a bunch of .ogg/.wav files
UploadTypeAudioAssets UploadType = "audio_assets"
// UploadTypeGraphicalAssets is a bunch of .png/.svg/.gif files, maybe some .objs thrown in there
UploadTypeGraphicalAssets UploadType = "graphical_assets"
// UploadTypeSourcecode is for source code. No further comments.
UploadTypeSourcecode UploadType = "sourcecode"
// UploadTypeOther is for literally anything that isn't an existing category,
// or for stuff that isn't tagged properly.
UploadTypeOther UploadType = "other"
)
// A Collection is a set of games, curated by humans.
type Collection struct {
// Site-wide unique identifier generated by itch.io
ID int64 `json:"id"`
// Human-friendly title for collection, for example `Couch coop games`
Title string `json:"title"`
// Date this collection was created at
CreatedAt *time.Time `json:"createdAt"`
// Date this collection was last updated at (item added, title set, etc.)
UpdatedAt *time.Time `json:"updatedAt"`
// Number of games in the collection. This might not be accurate
// as some games might not be accessible to whoever is asking (project
// page deleted, visibility level changed, etc.)
GamesCount int64 `json:"gamesCount"`
// Games in this collection, with additional info
CollectionGames []*CollectionGame `json:"collectionGames,omitempty"`
UserID int64 `json:"userId"`
User *User `json:"user,omitempty"`
}
// CollectionGame represents a game's membership for a collection.
type CollectionGame struct {
CollectionID int64 `json:"collectionId" hades:"primary_key"`
Collection *Collection `json:"collection,omitempty"`
GameID int64 `json:"gameId" hades:"primary_key"`
Game *Game `json:"game,omitempty"`
Position int64 `json:"position"`
CreatedAt *time.Time `json:"createdAt"`
UpdatedAt *time.Time `json:"updatedAt"`
Blurb string `json:"blurb"`
UserID int64 `json:"userId"`
}
// A DownloadKey is often generated when a purchase is made, it
// allows downloading uploads for a game that are not available
// for free. It can also be generated by other means.
type DownloadKey struct {
// Site-wide unique identifier generated by itch.io
ID int64 `json:"id"`
// Identifier of the game to which this download key grants access
GameID int64 `json:"gameId"`
// Game to which this download key grants access
Game *Game `json:"game,omitempty"`
// Date this key was created at (often coincides with purchase time)
CreatedAt *time.Time `json:"createdAt"`
// Date this key was last updated at
UpdatedAt *time.Time `json:"updatedAt"`
// Identifier of the itch.io user to which this key belongs
OwnerID int64 `json:"ownerId"`
}
// Build contains information about a specific build
type Build struct {
// Site-wide unique identifier generated by itch.io
ID int64 `json:"id"`
// Identifier of the build before this one on the same channel,
// or 0 if this is the initial build.
ParentBuildID int64 `json:"parentBuildId"`
// State of the build: started, processing, etc.
State BuildState `json:"state"`
// Automatically-incremented version number, starting with 1
Version int64 `json:"version"`
// Value specified by developer with `--userversion` when pushing a build
// Might not be unique across builds of a given channel.
UserVersion string `json:"userVersion"`
// Files associated with this build - often at least an archive,
// a signature, and a patch. Some might be missing while the build
// is still processing or if processing has failed.
Files []*BuildFile `json:"files"`
// User who pushed the build
User *User `json:"user"`
// Timestamp the build was created at
CreatedAt *time.Time `json:"createdAt"`
// Timestamp the build was last updated at
UpdatedAt *time.Time `json:"updatedAt"`
}
// BuildState describes the state of a build, relative to its initial upload, and
// its processing.
type BuildState string
const (
// BuildStateStarted is the state of a build from its creation until the initial upload is complete
BuildStateStarted BuildState = "started"
// BuildStateProcessing is the state of a build from the initial upload's completion to its fully-processed state.
// This state does not mean the build is actually being processed right now, it's just queued for processing.
BuildStateProcessing BuildState = "processing"
// BuildStateCompleted means the build was successfully processed. Its patch hasn't necessarily been
// rediff'd yet, but we have the holy (patch,signature,archive) trinity.
BuildStateCompleted BuildState = "completed"
// BuildStateFailed means something went wrong with the build. A failing build will not update the channel
// head and can be requeued by the itch.io team, although if a new build is pushed before they do,
// that new build will "win".
BuildStateFailed BuildState = "failed"
)
// BuildFile contains information about a build's "file", which could be its
// archive, its signature, its patch, etc.
type BuildFile struct {
// Site-wide unique identifier generated by itch.io
ID int64 `json:"id"`
// Size of this build file
Size int64 `json:"size"`
// State of this file: created, uploading, uploaded, etc.
State BuildFileState `json:"state"`
// Type of this build file: archive, signature, patch, etc.
Type BuildFileType `json:"type"`
// Subtype of this build file, usually indicates compression
SubType BuildFileSubType `json:"subType"`
// Date this build file was created at
CreatedAt *time.Time `json:"createdAt"`
// Date this build file was last updated at
UpdatedAt *time.Time `json:"updatedAt"`
}
// BuildFileState describes the state of a specific file for a build
type BuildFileState string
const (
// BuildFileStateCreated means the file entry exists on itch.io
BuildFileStateCreated BuildFileState = "created"
// BuildFileStateUploading means the file is currently being uploaded to storage
BuildFileStateUploading BuildFileState = "uploading"
// BuildFileStateUploaded means the file is ready
BuildFileStateUploaded BuildFileState = "uploaded"
// BuildFileStateFailed means the file failed uploading
BuildFileStateFailed BuildFileState = "failed"
)
// BuildFileType describes the type of a build file: patch, archive, signature, etc.
type BuildFileType string
const (
// BuildFileTypePatch describes wharf patch files (.pwr)
BuildFileTypePatch BuildFileType = "patch"
// BuildFileTypeArchive describes canonical archive form (.zip)
BuildFileTypeArchive BuildFileType = "archive"
// BuildFileTypeSignature describes wharf signature files (.pws)
BuildFileTypeSignature BuildFileType = "signature"
// BuildFileTypeManifest is reserved
BuildFileTypeManifest BuildFileType = "manifest"
// BuildFileTypeUnpacked describes the single file that is in the build (if it was just a single file)
BuildFileTypeUnpacked BuildFileType = "unpacked"
)
// BuildFileSubType describes the subtype of a build file: mostly its compression
// level. For example, rediff'd patches are "optimized", whereas initial patches are "default"
type BuildFileSubType string
const (
// BuildFileSubTypeDefault describes default compression (rsync patches)
BuildFileSubTypeDefault BuildFileSubType = "default"
// BuildFileSubTypeGzip is reserved
BuildFileSubTypeGzip BuildFileSubType = "gzip"
// BuildFileSubTypeOptimized describes optimized compression (rediff'd / bsdiff patches)
BuildFileSubTypeOptimized BuildFileSubType = "optimized"
)