This is a mirror from the GitHub repo. github.com/STBoyden/game-site
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

at main 79 lines 2.6 kB view raw
1import type { CamelCasedPropertiesDeep } from "type-fest"; 2import { Option, Schema } from "effect"; 3 4export const getAppListSchema = Schema.Struct({ 5 key: Schema.String, 6 ifModifiedSince: Schema.optionalToOptional(Schema.DateFromSelf, Schema.Number, { 7 decode: maybeDate => Option.map(maybeDate, x => x.getTime()), 8 encode: maybeNumber => Option.map(maybeNumber, x => new Date(x)) 9 }), 10 includeGames: Schema.optionalToOptional(Schema.Boolean, Schema.Boolean, { 11 decode: maybeBool => Option.map(maybeBool, () => true), 12 encode: maybeBool => maybeBool 13 }), 14 includeDLC: Schema.optionalToOptional(Schema.Boolean, Schema.Boolean, { 15 decode: maybeBool => Option.map(maybeBool, () => false), 16 encode: maybeBool => maybeBool 17 }), 18 includeVideos: Schema.optionalToOptional(Schema.Boolean, Schema.Boolean, { 19 decode: maybeBool => Option.map(maybeBool, () => false), 20 encode: maybeBool => maybeBool 21 }), 22 includeHardware: Schema.optionalToOptional(Schema.Boolean, Schema.Boolean, { 23 decode: maybeBool => Option.map(maybeBool, () => false), 24 encode: maybeBool => maybeBool 25 }), 26 lastAppID: Schema.optional(Schema.Number), 27 maxResults: Schema.optional(Schema.Number.pipe(Schema.clamp(1, 50_000))) 28}); 29 30export const getAppListOutputSchema = Schema.Struct({ 31 response: Schema.Struct({ 32 apps: Schema.Array( 33 Schema.Struct({ 34 appid: Schema.Number, 35 name: Schema.String, 36 last_modified: Schema.Number.pipe( 37 Schema.transform(Schema.Date, { 38 strict: true, 39 decode: epochSeconds => new Date(epochSeconds * 1000).toISOString(), 40 encode: (_, date) => date.getTime() 41 }) 42 ), 43 price_change_number: Schema.Number 44 }) 45 ), 46 have_more_results: Schema.Boolean, 47 last_appid: Schema.Number 48 }) 49}); 50 51export type getAppListOutput = CamelCasedPropertiesDeep<typeof getAppListOutputSchema.Type>; 52 53export const getAppInfoSchema = Schema.Struct({ 54 appID: Schema.Number.pipe(Schema.greaterThan(10)) 55}); 56 57const controllerSupportSchema = Schema.Literal("full", "partial", "none"); 58 59export const getAppInfoOutputSchema = Schema.Union( 60 Schema.Struct({ success: Schema.Literal(false) }), 61 Schema.Struct({ 62 success: Schema.Literal(true), 63 data: Schema.Struct({ 64 type: Schema.String, 65 name: Schema.String, 66 steam_appid: Schema.Number, 67 required_age: Schema.Number, 68 is_free: Schema.Boolean, 69 controller_support: Schema.optionalToRequired( 70 controllerSupportSchema, 71 controllerSupportSchema, 72 { 73 decode: maybeOption => Option.getOrElse(maybeOption, () => "none"), 74 encode: option => Option.some(option) 75 } 76 ) 77 }) 78 }) 79);