refactor: src/types

This commit is contained in:
pa
2025-07-16 12:14:13 +09:00
committed by Natsumi
parent 39381de29e
commit 342850dc7e
14 changed files with 280 additions and 292 deletions

View File

@@ -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', {

View File

@@ -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`, {

40
src/types/api/avatar.d.ts vendored Normal file
View File

@@ -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;
}

View File

@@ -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[];
}
}

View File

@@ -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;
}
}

View File

@@ -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[];
}
}

97
src/types/api/instance.d.ts vendored Normal file
View File

@@ -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<string, any>;
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<string, any>;
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;
}

View File

@@ -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;
}
}

View File

@@ -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<string, unknown>;
assetVersion: number;
created_at: string;
id: string;
platform: string;
pluginUrl: string;
pluginUrlObject: Record<string, unknown>;
unitySortNumber: number;
unityVersion: string;
}
}

55
src/types/avatar.d.ts vendored
View File

@@ -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;
}

16
src/types/common.d.ts vendored Normal file
View File

@@ -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;
}

View File

@@ -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<void>;
};
__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: {

14
src/types/index.d.ts vendored Normal file
View File

@@ -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';

View File

@@ -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<string, any>;
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<string, any>;
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;
}