Skip to content

Commit

Permalink
More interfaces
Browse files Browse the repository at this point in the history
  • Loading branch information
TTTaevas committed Apr 24, 2023
1 parent f96c639 commit f2d4619
Show file tree
Hide file tree
Showing 6 changed files with 125 additions and 25 deletions.
42 changes: 21 additions & 21 deletions lib/changelog.ts
Original file line number Diff line number Diff line change
@@ -1,33 +1,33 @@
export interface ChangelogBuild {
created_at: Date,
display_version: string,
id: number,
update_stream: UpdateStream | null,
created_at: Date
display_version: string
id: number
update_stream: UpdateStream | null
users: number
version: string | null,
version: string | null
changelog_entries?: {
category: string,
created_at: Date | null,
github_pull_request_id: number | null,
github_url: string | null,
id: number | null,
major: Boolean,
repository: string | null,
title: string | null,
type: string,
category: string
created_at: Date | null
github_pull_request_id: number | null
github_url: string | null
id: number | null
major: Boolean
repository: string | null
title: string | null
type: string
url: string | null
},
}
versions?: {
next: ChangelogBuild | null,
next: ChangelogBuild | null
previous: ChangelogBuild | null
}
}

export interface UpdateStream {
display_name: string | null,
id: number,
is_featured: Boolean,
name: string,
latest_build: ChangelogBuild | null,
display_name: string | null
id: number
is_featured: Boolean
name: string
latest_build: ChangelogBuild | null
user_count: number
}
42 changes: 42 additions & 0 deletions lib/chat.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import { CurrentUserAttributes, UserCompact } from "./user";

export type ChannelType =
"PUBLIC" |
"PRIVATE" |
"MULTIPLAYER" |
"SPECTATOR" |
"TEMPORARY" |
"PRIVATE" |
"PM" |
"GROUP" |
"ANNOUNCE";

export interface UserSilence {
id: number
user_id: number
}

export interface ChatChannel {
channel_id: number
name: string
description: string | null
icon: string | null
type: ChannelType
moderated: Boolean
uuid: string | null
current_user_attributes?: CurrentUserAttributes | null
last_message_id?: number | null
users?: number[] | null
}

export interface ChatMessage {
channel_id: number
content: string
is_action: Boolean
message_id: number
sender_id: number
timestamp: Date
type: string
uuid: string | null
sender?: UserCompact
}
45 changes: 45 additions & 0 deletions lib/comment.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import { CurrentUserAttributes, UserCompact } from "./user"

export interface Comment {
commentable_id: number
commentable_type: string
created_at: Date
deleted_at: Date | null
edited_at: Date | null
edited_by_id: number | null
id: number
legacy_name: string | null
message: string | null
message_html: string | null
parent_id: number | null
pinned: Boolean
replies_count: number
updated_at: Date
user_id: number
votes_count: number
}

export interface CommentBundle {
commentable_meta: CommentableMeta[]
comments: Comment[]
has_more: Boolean
has_more_id: number | null
included_comments: Comment[]
pinned_comments: Comment[]
sort: string
top_level_count: number | null
total: number | null
user_follow: Boolean
user_votes: number[]
users: UserCompact[]
}

export interface CommentableMeta {
current_user_attributes: CurrentUserAttributes
id: number
owner_id: number | null
owner_title: string | null
title: string
type: string
url: string
}
8 changes: 5 additions & 3 deletions lib/interactive_test.ts → lib/tests/interactive_test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import "dotenv/config"
import util = require('util')
import * as osu from "."
import * as osu from ".."

const prompt = require("prompt-sync")({sigint: true})

Expand All @@ -15,8 +15,10 @@ async function test(id: string | undefined, secret: string | undefined, redirect

let api = await osu.API.createAsync({id: Number(id), secret}, {code, redirect_uri})
if (api) {
let friends = await api.getFriends()
if (!(friends instanceof osu.APIError)) {console.log(friends[0].statistics?.level.current); console.log(util.inspect(friends[0], false, null, true))}
let match = await api.getRoom({id: 231069})
if (match instanceof osu.APIError) {throw new Error("yeah no")}
let point = await api.getPlaylistItemScores(match.playlist[16])
console.log(util.inspect(point, false, null, true))
}
}

Expand Down
2 changes: 1 addition & 1 deletion lib/test.ts → lib/tests/test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as osu from "."
import * as osu from ".."
import "dotenv/config"
import util = require('util')
// console.log(util.inspect(users, false, null, true))
Expand Down
11 changes: 11 additions & 0 deletions lib/user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -179,3 +179,14 @@ export interface KudosuHistory {
title: string
}
}

export interface CurrentUserAttributes {
can_destroy: Boolean
can_reopen: Boolean
can_moderate_kudosu: Boolean
can_resolve: Boolean
vote_score: number
can_message: Boolean
can_message_error: string | null
last_read_id: number
}

0 comments on commit f2d4619

Please sign in to comment.