diff --git a/src/api/auth.js b/src/api/auth.js index 262ee1e3..55326c2d 100644 --- a/src/api/auth.js +++ b/src/api/auth.js @@ -4,7 +4,7 @@ import { useUserStore } from '../stores'; const loginReq = { /** * @param {{ code: string }} params One-time password - * @returns {Promise<{json: any, params}>} + * @returns {Promise<{json: any, params: { code: string }}>} */ verifyOTP(params) { return request('auth/twofactorauth/otp/verify', { @@ -21,7 +21,7 @@ const loginReq = { /** * @param {{ code: string }} params One-time token - * @returns {Promise<{json: any, params}>} + * @returns {Promise<{json: any, params: { code: string }}>} */ verifyTOTP(params) { return request('auth/twofactorauth/totp/verify', { @@ -38,7 +38,7 @@ const loginReq = { /** * @param {{ code: string }} params One-time token - * @returns {Promise<{json: any, params}>} + * @returns {Promise<{json: any, params: { code: string }}>} */ verifyEmailOTP(params) { return request('auth/twofactorauth/emailotp/verify', { diff --git a/src/api/friend.js b/src/api/friend.js index 5af61b16..acf51358 100644 --- a/src/api/friend.js +++ b/src/api/friend.js @@ -4,7 +4,7 @@ import { useUserStore } from '../stores/user'; const friendReq = { /** * Fetch friends of current user. - * @type {import('../types/friend').getFriends} + * @type {import('../types/api/friend').GetFriends} */ getFriends(params) { const userStore = useUserStore(); @@ -29,7 +29,7 @@ const friendReq = { /** * @param {{ userId: string }} params - * @returns {Promise<{json: T, params}>} + * @returns {Promise<{json: any, params: { userId: string }}>} */ sendFriendRequest(params) { return request(`user/${params.userId}/friendRequest`, { @@ -45,7 +45,7 @@ const friendReq = { /** * @param {{ userId: string }} params - * @returns {Promise<{json: any, params}>} + * @returns {Promise<{json: any, params: { userId: string }}>} */ cancelFriendRequest(params) { return request(`user/${params.userId}/friendRequest`, { @@ -61,7 +61,7 @@ const friendReq = { /** * @param {{ userId: string }} params - * @returns {Promise<{json: any, params}>} + * @returns {Promise<{json: any, params: { userId: string }}>} */ deleteFriend(params) { return request(`auth/user/friends/${params.userId}`, { @@ -77,7 +77,7 @@ const friendReq = { /** * @param {{ userId: string }} params - * @returns {Promise<{json: any, params}>} + * @returns {Promise<{json: any, params: { userId: string }}>} */ getFriendStatus(params) { return request(`user/${params.userId}/friendStatus`, { diff --git a/src/types/api/avatar.d.ts b/src/types/api/avatar.d.ts new file mode 100644 index 00000000..0c0da134 --- /dev/null +++ b/src/types/api/avatar.d.ts @@ -0,0 +1,40 @@ +import { UnityPackage } from '../common'; + +// API functions +export type GetAvatar = (params: { avatarId: string }) => Promise<{ + json: GetAvatarResponse; + params: { avatarId: string }; +}>; + +// API response types +interface GetAvatarResponse { + acknowledgements: string | null; + authorId: string; + authorName: string; + created_at: string; + description: string; + featured: boolean; + id: string; + imageUrl: string; + name: string; + pendingUpload: boolean; + performance: { + standalonewindows: string; + 'standalonewindows-sort': number; + }; + releaseStatus: string; + searchable: boolean; + styles: { + primary: string | null; + secondary: string | null; + }; + tags: string[]; + thumbnailImageUrl: string; + unityPackageUrl: string; + unityPackageUrlObject: { + unityPackageUrl: string; + }; + unityPackages: UnityPackage[]; + updated_at: string; + version: number; +} \ No newline at end of file diff --git a/src/types/favorite.d.ts b/src/types/api/favorite.d.ts similarity index 58% rename from src/types/favorite.d.ts rename to src/types/api/favorite.d.ts index 96d88294..f4884e32 100644 --- a/src/types/favorite.d.ts +++ b/src/types/api/favorite.d.ts @@ -1,31 +1,34 @@ -export type getFavorites = (params: { n: number; offset: number }) => Promise<{ - json: getFavoritesResponseList; +import { UnityPackage } from '../common'; + +// API functions +export type GetFavorites = (params: { n: number; offset: number }) => Promise<{ + json: GetFavoritesResponseList; params: { n: number; offset: number }; }>; -export type getFavoriteAvatars = (params: { +export type GetFavoriteAvatars = (params: { n: number; offset: number; tag: string; }) => Promise<{ - json: getFavoriteAvatarsResponseList; + json: GetFavoriteAvatarsResponseList; params: { n: number; offset: number; tag: string }; }>; -export type getFavoriteWorlds = (params: { +export type GetFavoriteWorlds = (params: { n: number; offset: number; }) => Promise<{ - json: getFavoriteWorldsResponseList; + json: GetFavoriteWorldsResponseList; params: { n: number; offset: number }; }>; -export type addFavorite = (params: { +export type AddFavorite = (params: { type: string; favoriteId: string; tags: string; }) => Promise<{ - json: addFavoriteResponse; + json: AddFavoriteResponse; params: { type: string; favoriteId: string; @@ -33,41 +36,20 @@ export type addFavorite = (params: { }; }>; -interface getFavoritesResponseItem { +// Type aliases +export type GetFavoritesResponseList = GetFavoritesResponseItem[] | undefined; +export type GetFavoriteAvatarsResponseList = GetFavoriteAvatarsResponseItem[]; +export type GetFavoriteWorldsResponseList = GetFavoriteWorldsResponseItem[]; + +// API response types +interface GetFavoritesResponseItem { favoriteId: string; id: string; tags: string[]; type: string; } -type getFavoritesResponseList = getFavoritesResponseItem[] | undefined; - -interface UnityPackage { - assetVersion: number; - created_at: string; - id: string; - performanceRating?: string; - platform: string; - scanStatus?: string; - unityVersion: string; - variant: string; - impostorizerVersion?: string; - assetUrl: string; - unitySortNumber?: number; - worldSignature?: string; - [key: string]: any; -} - -interface Performance { - [platform: string]: string | number; -} - -interface Styles { - primary: null; - secondary: null; -} - -interface getFavoriteAvatarsResponseItem { +interface GetFavoriteAvatarsResponseItem { acknowledgements?: null | string; authorId: string; authorName: string; @@ -79,10 +61,15 @@ interface getFavoriteAvatarsResponseItem { id: string; imageUrl: string; name: string; - performance: Performance; + performance: { + [platform: string]: string | number; + }; releaseStatus: string; searchable: boolean; - styles: Styles; + styles: { + primary: null; + secondary: null; + }; tags: any[]; thumbnailImageUrl: string; unityPackageUrl: string; @@ -92,9 +79,7 @@ interface getFavoriteAvatarsResponseItem { version: number; } -type getFavoriteAvatarsResponseList = getFavoriteAvatarsResponseItem[]; - -interface getFavoriteWorldsResponseItem { +interface GetFavoriteWorldsResponseItem { id: string; name: string; authorId: string; @@ -121,11 +106,9 @@ interface getFavoriteWorldsResponseItem { [key: string]: any; } -type getFavoriteWorldsResponseList = getFavoriteWorldsResponseItem[]; - -interface addFavoriteResponse { +interface AddFavoriteResponse { favoriteId: string; id: string; type: 'world' | 'friend' | 'avatar'; tags: string[]; -} +} \ No newline at end of file diff --git a/src/types/friend.d.ts b/src/types/api/friend.d.ts similarity index 76% rename from src/types/friend.d.ts rename to src/types/api/friend.d.ts index 2657e3a0..5248b2b6 100644 --- a/src/types/friend.d.ts +++ b/src/types/api/friend.d.ts @@ -1,9 +1,10 @@ -export type getFriends = (params: { +// API functions +export type GetFriends = (params: { n: number; offline: boolean; offset: number; }) => Promise<{ - json: getFriendsResponseList; + json: GetFriendsResponseList; params: { n: number; offline: boolean; @@ -11,9 +12,11 @@ export type getFriends = (params: { }; }>; -type getFriendsResponseList = getFriendsResponseItem[] | undefined; +// Type aliases +export type GetFriendsResponseList = GetFriendsResponseItem[] | undefined; -interface getFriendsResponseItem { +// API response types +interface GetFriendsResponseItem { bio: string; bioLinks: string[]; currentAvatarImageUrl: string; @@ -37,4 +40,4 @@ interface getFriendsResponseItem { statusDescription: string; tags: string[]; userIcon: string; -} +} \ No newline at end of file diff --git a/src/types/group.d.ts b/src/types/api/group.d.ts similarity index 83% rename from src/types/group.d.ts rename to src/types/api/group.d.ts index e41f9d82..610d7a42 100644 --- a/src/types/group.d.ts +++ b/src/types/api/group.d.ts @@ -1,12 +1,14 @@ -export type getGroup = (params: { +// API functions +export type GetGroup = (params: { groupId: string; includeRoles?: boolean; }) => Promise<{ - json: getGroupResponse; + json: GetGroupResponse; params: { groupId: string; includeRoles?: boolean }; }>; -interface Group { +// API response types +interface GetGroupResponse { badges: any[]; bannerId: string; bannerUrl: string; @@ -31,4 +33,4 @@ interface Group { rules: string; shortCode: string; tags: string[]; -} +} \ No newline at end of file diff --git a/src/types/api/instance.d.ts b/src/types/api/instance.d.ts new file mode 100644 index 00000000..6da3c496 --- /dev/null +++ b/src/types/api/instance.d.ts @@ -0,0 +1,97 @@ +import { UnityPackage } from '../common'; + +// API functions +export type GetInstance = (params: { + worldId: string; + instanceId: string; +}) => Promise<{ + json: GetInstanceResponse; + params: { worldId: string; instanceId: string }; +}>; + +export type GetInstanceShortName = (instance: { + worldId: string; + instanceId: string; + shortName?: string; +}) => Promise<{ + json: GetInstanceShortNameResponse; + instance: { worldId: string; instanceId: string }; + params?: { shortName: string }; +}>; + +// API response types +interface GetInstanceResponse { + active: boolean; + ageGate: boolean; + canRequestInvite: boolean; + capacity: number; + clientNumber: string; + closedAt: string | null; + contentSettings: Record; + displayName: string | null; + full: boolean; + gameServerVersion: number; + hardClose: string | null; + hasCapacityForYou: boolean; + hidden: string; + id: string; + instanceId: string; + instancePersistenceEnabled: boolean | null; + location: string; + n_users: number; + name: string; + ownerId: string; + permanent: boolean; + photonRegion: string; + platforms: { + android: number; + ios: number; + standalonewindows: number; + }; + playerPersistenceEnabled: boolean; + queueEnabled: boolean; + queueSize: number; + recommendedCapacity: number; + region: string; + secureName: string; + shortName: string | null; + strict: boolean; + tags: string[]; + type: string; + userCount: number; + world: { + authorId: string; + authorName: string; + capacity: number; + created_at: string; + defaultContentSettings: Record; + description: string; + favorites: number; + featured: boolean; + heat: number; + id: string; + imageUrl: string; + labsPublicationDate: string; + name: string; + organization: string; + popularity: number; + previewYoutubeId: string | null; + publicationDate: string; + recommendedCapacity: number; + releaseStatus: string; + tags: string[]; + thumbnailImageUrl: string; + udonProducts: any[]; + unityPackages: UnityPackage[]; + updated_at: string; + urlList: any[]; + version: number; + visits: number; + }; + worldId: string; +} + +interface GetInstanceShortNameResponse { + secureName: string; + shortName: string; +} \ No newline at end of file diff --git a/src/types/user.d.ts b/src/types/api/user.d.ts similarity index 87% rename from src/types/user.d.ts rename to src/types/api/user.d.ts index 8390bc1e..c751d99b 100644 --- a/src/types/user.d.ts +++ b/src/types/api/user.d.ts @@ -1,11 +1,19 @@ -export type getUser = (params: { userId: string }) => Promise<{ +// API functions +export type GetUser = (params: { userId: string }) => Promise<{ cache?: boolean; - json: getUserResponse; - ref: vrcxUser; + json: GetUserResponse; + ref: VrcxUser; params: { userId: string }; }>; -export interface vrcxUser extends getUserResponse { +export type GetCurrentUser = (params: any) => Promise<{ + json: GetCurrentUserResponse; + ref: VrcxCurrentUser; + params: GetCurrentUserResponse; +}>; + +// Extended user objects +export interface VrcxUser extends GetUserResponse { $location: {}; $location_at: number; $online_for: number; @@ -32,7 +40,28 @@ export interface vrcxUser extends getUserResponse { $lastFetch: number; } -interface getUserResponse { +export interface VrcxCurrentUser extends GetCurrentUserResponse { + $online_for?: number; + $offline_for?: number | null; + $location_at?: number; + $travelingToTime?: number; + $previousAvatarSwapTime?: number | null; + $homeLocation?: {}; + $isVRCPlus?: boolean; + $isModerator?: boolean; + $isTroll?: boolean; + $isProbableTroll?: boolean; + $trustLevel?: string; + $trustClass?: string; + $userColour?: string; + $trustSortNum?: number; + $languages?: string[]; + $locationTag?: string; + $travelingToLocation?: string; +} + +// API response types +interface GetUserResponse { ageVerificationStatus: string; ageVerified: boolean; allowAvatarCopying: boolean; @@ -77,33 +106,7 @@ interface getUserResponse { worldId?: string; } -export type getCurrentUser = (any) => Promise<{ - json: getCurrentUserResponse; - ref: vrcxCurrentUser; - params: getCurrentUserResponse; -}>; - -export interface vrcxCurrentUser extends getCurrentUserResponse { - $online_for?: number; - $offline_for?: number | null; - $location_at?: number; - $travelingToTime?: number; - $previousAvatarSwapTime?: number | null; - $homeLocation?: {}; - $isVRCPlus?: boolean; - $isModerator?: boolean; - $isTroll?: boolean; - $isProbableTroll?: boolean; - $trustLevel?: string; - $trustClass?: string; - $userColour?: string; - $trustSortNum?: number; - $languages?: string[]; - $locationTag?: string; - $travelingToLocation?: string; -} - -interface getCurrentUserResponse extends getUserResponse { +interface GetCurrentUserResponse extends GetUserResponse { acceptedPrivacyVersion: number; acceptedTOSVersion: number; accountDeletionDate: string | null; @@ -148,4 +151,4 @@ interface getCurrentUserResponse extends getUserResponse { world: string; }; queuedInstance: string | null; -} +} \ No newline at end of file diff --git a/src/types/world.d.ts b/src/types/api/world.d.ts similarity index 66% rename from src/types/world.d.ts rename to src/types/api/world.d.ts index abbe2f09..35e6d121 100644 --- a/src/types/world.d.ts +++ b/src/types/api/world.d.ts @@ -1,9 +1,13 @@ -export type getWorld = (params: { worldId: string }) => Promise<{ - json: getWorldResponse; +import { UnityPackage } from '../common'; + +// API functions +export type GetWorld = (params: { worldId: string }) => Promise<{ + json: GetWorldResponse; params: { worldId: string }; }>; -interface getWorldResponse { +// API response types +interface GetWorldResponse { authorId: string; authorName: string; capacity: number; @@ -35,17 +39,4 @@ interface getWorldResponse { urlList: any[]; version: number; visits: number; -} - -interface UnityPackage { - assetUrl: string; - assetUrlObject: Record; - assetVersion: number; - created_at: string; - id: string; - platform: string; - pluginUrl: string; - pluginUrlObject: Record; - unitySortNumber: number; - unityVersion: string; -} +} \ No newline at end of file diff --git a/src/types/avatar.d.ts b/src/types/avatar.d.ts deleted file mode 100644 index 438230d3..00000000 --- a/src/types/avatar.d.ts +++ /dev/null @@ -1,55 +0,0 @@ -export type getAvatar = (params: { avatarId: string }) => Promise<{ - json: getAvatarResponse; - params: { avatarId: string }; -}>; - -interface getAvatarResponse { - acknowledgements: string | null; - authorId: string; - authorName: string; - created_at: string; - description: string; - featured: boolean; - id: string; - imageUrl: string; - name: string; - pendingUpload: boolean; - performance: Performance; - releaseStatus: string; - searchable: boolean; - styles: Styles; - tags: string[]; - thumbnailImageUrl: string; - unityPackageUrl: string; - unityPackageUrlObject: UnityPackageUrlObject; - unityPackages: UnityPackage[]; - updated_at: string; - version: number; -} - -interface Performance { - standalonewindows: string; - 'standalonewindows-sort': number; -} - -interface Styles { - primary: string | null; - secondary: string | null; -} - -interface UnityPackageUrlObject { - unityPackageUrl: string; -} - -interface UnityPackage { - assetUrl: string; - assetVersion: number; - created_at: string; - id: string; - performanceRating: string; - platform: string; - scanStatus: string; - unitySortNumber: number; - unityVersion: string; - variant: string; -} diff --git a/src/types/common.d.ts b/src/types/common.d.ts new file mode 100644 index 00000000..eca94696 --- /dev/null +++ b/src/types/common.d.ts @@ -0,0 +1,16 @@ +// Common interfaces +export interface UnityPackage { + assetVersion: number; + created_at: string; + id: string; + performanceRating?: string; + platform: string; + scanStatus?: string; + unityVersion: string; + variant: string; + impostorizerVersion?: string; + assetUrl: string; + unitySortNumber?: number; + worldSignature?: string; + [key: string]: any; +} \ No newline at end of file diff --git a/src/types/globals.d.ts b/src/types/globals.d.ts index c5ad0bef..06e68dbb 100644 --- a/src/types/globals.d.ts +++ b/src/types/globals.d.ts @@ -15,7 +15,7 @@ declare global { Discord: Discord; AssetBundleManager: AssetBundleManager; webApiService: webApiService; - request: {}; + request: any; configRepository: any; datebase: any; gameLogService: any; @@ -62,21 +62,23 @@ declare global { overlayHand: int ) => Promise; }; - __APP_GLOBALS__: { - debug: boolean; - debugWebSocket: boolean; - debugUserDiff: boolean; - debugPhotonLogging: boolean; - debugGameLog: boolean; - debugWebRequests: boolean; - debugFriendState: boolean; - errorNoty: any; - dontLogMeOut: boolean; - endpointDomain: string; - endpointDomainVrchat: string; - websocketDomain: string; - websocketDomainVrchat: string; - }; + __APP_GLOBALS__: AppGlobals; + } + + interface AppGlobals { + debug: boolean; + debugWebSocket: boolean; + debugUserDiff: boolean; + debugPhotonLogging: boolean; + debugGameLog: boolean; + debugWebRequests: boolean; + debugFriendState: boolean; + errorNoty: any; + dontLogMeOut: boolean; + endpointDomain: string; + endpointDomainVrchat: string; + websocketDomain: string; + websocketDomainVrchat: string; } const CefSharp: { diff --git a/src/types/index.d.ts b/src/types/index.d.ts new file mode 100644 index 00000000..ae9818ca --- /dev/null +++ b/src/types/index.d.ts @@ -0,0 +1,14 @@ +// API Types +export * from './api/user'; +export * from './api/friend'; +export * from './api/avatar'; +export * from './api/world'; +export * from './api/instance'; +export * from './api/group'; +export * from './api/favorite'; + +// Common Types +export * from './common'; + +// Global Types +export * from './globals'; \ No newline at end of file diff --git a/src/types/instance.d.ts b/src/types/instance.d.ts deleted file mode 100644 index 6b7257c9..00000000 --- a/src/types/instance.d.ts +++ /dev/null @@ -1,108 +0,0 @@ -export type getInstance = (params: { - worldId: string; - instanceId: string; -}) => Promise<{ - json: getInstanceResponse; - params: { worldId: string; instanceId: string }; -}>; - -export type getInstanceShortName = (instance: { - worldId: string; - instanceId: string; - shortName?: string; -}) => Promise<{ - json: getInstanceShortNameResponse; - instance: { worldId: string; instanceId: string }; - params?: { shortName: string }; -}>; - -interface getInstanceResponse { - active: boolean; - ageGate: boolean; - canRequestInvite: boolean; - capacity: number; - clientNumber: string; - closedAt: string | null; - contentSettings: Record; - displayName: string | null; - full: boolean; - gameServerVersion: number; - hardClose: string | null; - hasCapacityForYou: boolean; - hidden: string; - id: string; - instanceId: string; - instancePersistenceEnabled: boolean | null; - location: string; - n_users: number; - name: string; - ownerId: string; - permanent: boolean; - photonRegion: string; - platforms: Platforms; - playerPersistenceEnabled: boolean; - queueEnabled: boolean; - queueSize: number; - recommendedCapacity: number; - region: string; - secureName: string; - shortName: string | null; - strict: boolean; - tags: string[]; - type: string; - userCount: number; - world: World; - worldId: string; -} - -interface Platforms { - android: number; - ios: number; - standalonewindows: number; -} - -interface World { - authorId: string; - authorName: string; - capacity: number; - created_at: string; - defaultContentSettings: Record; - description: string; - favorites: number; - featured: boolean; - heat: number; - id: string; - imageUrl: string; - labsPublicationDate: string; - name: string; - organization: string; - popularity: number; - previewYoutubeId: string | null; - publicationDate: string; - recommendedCapacity: number; - releaseStatus: string; - tags: string[]; - thumbnailImageUrl: string; - udonProducts: any[]; - unityPackages: WorldUnityPackage[]; - updated_at: string; - urlList: any[]; - version: number; - visits: number; -} - -interface WorldUnityPackage { - assetUrl: string; - assetVersion: number; - created_at: string; - id: string; - platform: string; - unitySortNumber: number; - unityVersion: string; - worldSignature: string; -} - -interface getInstanceShortNameResponse { - secureName: string; - shortName: string; -}