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 = { const loginReq = {
/** /**
* @param {{ code: string }} params One-time password * @param {{ code: string }} params One-time password
* @returns {Promise<{json: any, params}>} * @returns {Promise<{json: any, params: { code: string }}>}
*/ */
verifyOTP(params) { verifyOTP(params) {
return request('auth/twofactorauth/otp/verify', { return request('auth/twofactorauth/otp/verify', {
@@ -21,7 +21,7 @@ const loginReq = {
/** /**
* @param {{ code: string }} params One-time token * @param {{ code: string }} params One-time token
* @returns {Promise<{json: any, params}>} * @returns {Promise<{json: any, params: { code: string }}>}
*/ */
verifyTOTP(params) { verifyTOTP(params) {
return request('auth/twofactorauth/totp/verify', { return request('auth/twofactorauth/totp/verify', {
@@ -38,7 +38,7 @@ const loginReq = {
/** /**
* @param {{ code: string }} params One-time token * @param {{ code: string }} params One-time token
* @returns {Promise<{json: any, params}>} * @returns {Promise<{json: any, params: { code: string }}>}
*/ */
verifyEmailOTP(params) { verifyEmailOTP(params) {
return request('auth/twofactorauth/emailotp/verify', { return request('auth/twofactorauth/emailotp/verify', {

View File

@@ -4,7 +4,7 @@ import { useUserStore } from '../stores/user';
const friendReq = { const friendReq = {
/** /**
* Fetch friends of current user. * Fetch friends of current user.
* @type {import('../types/friend').getFriends} * @type {import('../types/api/friend').GetFriends}
*/ */
getFriends(params) { getFriends(params) {
const userStore = useUserStore(); const userStore = useUserStore();
@@ -29,7 +29,7 @@ const friendReq = {
/** /**
* @param {{ userId: string }} params * @param {{ userId: string }} params
* @returns {Promise<{json: T, params}>} * @returns {Promise<{json: any, params: { userId: string }}>}
*/ */
sendFriendRequest(params) { sendFriendRequest(params) {
return request(`user/${params.userId}/friendRequest`, { return request(`user/${params.userId}/friendRequest`, {
@@ -45,7 +45,7 @@ const friendReq = {
/** /**
* @param {{ userId: string }} params * @param {{ userId: string }} params
* @returns {Promise<{json: any, params}>} * @returns {Promise<{json: any, params: { userId: string }}>}
*/ */
cancelFriendRequest(params) { cancelFriendRequest(params) {
return request(`user/${params.userId}/friendRequest`, { return request(`user/${params.userId}/friendRequest`, {
@@ -61,7 +61,7 @@ const friendReq = {
/** /**
* @param {{ userId: string }} params * @param {{ userId: string }} params
* @returns {Promise<{json: any, params}>} * @returns {Promise<{json: any, params: { userId: string }}>}
*/ */
deleteFriend(params) { deleteFriend(params) {
return request(`auth/user/friends/${params.userId}`, { return request(`auth/user/friends/${params.userId}`, {
@@ -77,7 +77,7 @@ const friendReq = {
/** /**
* @param {{ userId: string }} params * @param {{ userId: string }} params
* @returns {Promise<{json: any, params}>} * @returns {Promise<{json: any, params: { userId: string }}>}
*/ */
getFriendStatus(params) { getFriendStatus(params) {
return request(`user/${params.userId}/friendStatus`, { 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<{ import { UnityPackage } from '../common';
json: getFavoritesResponseList;
// API functions
export type GetFavorites = (params: { n: number; offset: number }) => Promise<{
json: GetFavoritesResponseList;
params: { n: number; offset: number }; params: { n: number; offset: number };
}>; }>;
export type getFavoriteAvatars = (params: { export type GetFavoriteAvatars = (params: {
n: number; n: number;
offset: number; offset: number;
tag: string; tag: string;
}) => Promise<{ }) => Promise<{
json: getFavoriteAvatarsResponseList; json: GetFavoriteAvatarsResponseList;
params: { n: number; offset: number; tag: string }; params: { n: number; offset: number; tag: string };
}>; }>;
export type getFavoriteWorlds = (params: { export type GetFavoriteWorlds = (params: {
n: number; n: number;
offset: number; offset: number;
}) => Promise<{ }) => Promise<{
json: getFavoriteWorldsResponseList; json: GetFavoriteWorldsResponseList;
params: { n: number; offset: number }; params: { n: number; offset: number };
}>; }>;
export type addFavorite = (params: { export type AddFavorite = (params: {
type: string; type: string;
favoriteId: string; favoriteId: string;
tags: string; tags: string;
}) => Promise<{ }) => Promise<{
json: addFavoriteResponse; json: AddFavoriteResponse;
params: { params: {
type: string; type: string;
favoriteId: 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; favoriteId: string;
id: string; id: string;
tags: string[]; tags: string[];
type: string; type: string;
} }
type getFavoritesResponseList = getFavoritesResponseItem[] | undefined; interface GetFavoriteAvatarsResponseItem {
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 {
acknowledgements?: null | string; acknowledgements?: null | string;
authorId: string; authorId: string;
authorName: string; authorName: string;
@@ -79,10 +61,15 @@ interface getFavoriteAvatarsResponseItem {
id: string; id: string;
imageUrl: string; imageUrl: string;
name: string; name: string;
performance: Performance; performance: {
[platform: string]: string | number;
};
releaseStatus: string; releaseStatus: string;
searchable: boolean; searchable: boolean;
styles: Styles; styles: {
primary: null;
secondary: null;
};
tags: any[]; tags: any[];
thumbnailImageUrl: string; thumbnailImageUrl: string;
unityPackageUrl: string; unityPackageUrl: string;
@@ -92,9 +79,7 @@ interface getFavoriteAvatarsResponseItem {
version: number; version: number;
} }
type getFavoriteAvatarsResponseList = getFavoriteAvatarsResponseItem[]; interface GetFavoriteWorldsResponseItem {
interface getFavoriteWorldsResponseItem {
id: string; id: string;
name: string; name: string;
authorId: string; authorId: string;
@@ -121,11 +106,9 @@ interface getFavoriteWorldsResponseItem {
[key: string]: any; [key: string]: any;
} }
type getFavoriteWorldsResponseList = getFavoriteWorldsResponseItem[]; interface AddFavoriteResponse {
interface addFavoriteResponse {
favoriteId: string; favoriteId: string;
id: string; id: string;
type: 'world' | 'friend' | 'avatar'; type: 'world' | 'friend' | 'avatar';
tags: string[]; tags: string[];
} }

View File

@@ -1,9 +1,10 @@
export type getFriends = (params: { // API functions
export type GetFriends = (params: {
n: number; n: number;
offline: boolean; offline: boolean;
offset: number; offset: number;
}) => Promise<{ }) => Promise<{
json: getFriendsResponseList; json: GetFriendsResponseList;
params: { params: {
n: number; n: number;
offline: boolean; 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; bio: string;
bioLinks: string[]; bioLinks: string[];
currentAvatarImageUrl: string; currentAvatarImageUrl: string;
@@ -37,4 +40,4 @@ interface getFriendsResponseItem {
statusDescription: string; statusDescription: string;
tags: string[]; tags: string[];
userIcon: string; userIcon: string;
} }

View File

@@ -1,12 +1,14 @@
export type getGroup = (params: { // API functions
export type GetGroup = (params: {
groupId: string; groupId: string;
includeRoles?: boolean; includeRoles?: boolean;
}) => Promise<{ }) => Promise<{
json: getGroupResponse; json: GetGroupResponse;
params: { groupId: string; includeRoles?: boolean }; params: { groupId: string; includeRoles?: boolean };
}>; }>;
interface Group { // API response types
interface GetGroupResponse {
badges: any[]; badges: any[];
bannerId: string; bannerId: string;
bannerUrl: string; bannerUrl: string;
@@ -31,4 +33,4 @@ interface Group {
rules: string; rules: string;
shortCode: string; shortCode: string;
tags: 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; cache?: boolean;
json: getUserResponse; json: GetUserResponse;
ref: vrcxUser; ref: VrcxUser;
params: { userId: string }; 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: {};
$location_at: number; $location_at: number;
$online_for: number; $online_for: number;
@@ -32,7 +40,28 @@ export interface vrcxUser extends getUserResponse {
$lastFetch: number; $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; ageVerificationStatus: string;
ageVerified: boolean; ageVerified: boolean;
allowAvatarCopying: boolean; allowAvatarCopying: boolean;
@@ -77,33 +106,7 @@ interface getUserResponse {
worldId?: string; worldId?: string;
} }
export type getCurrentUser = (any) => Promise<{ interface GetCurrentUserResponse extends GetUserResponse {
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 {
acceptedPrivacyVersion: number; acceptedPrivacyVersion: number;
acceptedTOSVersion: number; acceptedTOSVersion: number;
accountDeletionDate: string | null; accountDeletionDate: string | null;
@@ -148,4 +151,4 @@ interface getCurrentUserResponse extends getUserResponse {
world: string; world: string;
}; };
queuedInstance: string | null; queuedInstance: string | null;
} }

View File

@@ -1,9 +1,13 @@
export type getWorld = (params: { worldId: string }) => Promise<{ import { UnityPackage } from '../common';
json: getWorldResponse;
// API functions
export type GetWorld = (params: { worldId: string }) => Promise<{
json: GetWorldResponse;
params: { worldId: string }; params: { worldId: string };
}>; }>;
interface getWorldResponse { // API response types
interface GetWorldResponse {
authorId: string; authorId: string;
authorName: string; authorName: string;
capacity: number; capacity: number;
@@ -35,17 +39,4 @@ interface getWorldResponse {
urlList: any[]; urlList: any[];
version: number; version: number;
visits: 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; Discord: Discord;
AssetBundleManager: AssetBundleManager; AssetBundleManager: AssetBundleManager;
webApiService: webApiService; webApiService: webApiService;
request: {}; request: any;
configRepository: any; configRepository: any;
datebase: any; datebase: any;
gameLogService: any; gameLogService: any;
@@ -62,21 +62,23 @@ declare global {
overlayHand: int overlayHand: int
) => Promise<void>; ) => Promise<void>;
}; };
__APP_GLOBALS__: { __APP_GLOBALS__: AppGlobals;
debug: boolean; }
debugWebSocket: boolean;
debugUserDiff: boolean; interface AppGlobals {
debugPhotonLogging: boolean; debug: boolean;
debugGameLog: boolean; debugWebSocket: boolean;
debugWebRequests: boolean; debugUserDiff: boolean;
debugFriendState: boolean; debugPhotonLogging: boolean;
errorNoty: any; debugGameLog: boolean;
dontLogMeOut: boolean; debugWebRequests: boolean;
endpointDomain: string; debugFriendState: boolean;
endpointDomainVrchat: string; errorNoty: any;
websocketDomain: string; dontLogMeOut: boolean;
websocketDomainVrchat: string; endpointDomain: string;
}; endpointDomainVrchat: string;
websocketDomain: string;
websocketDomainVrchat: string;
} }
const CefSharp: { 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;
}