wip
This commit is contained in:
parent
307bc2a38e
commit
d7d3f00488
5 changed files with 10 additions and 96 deletions
|
@ -2,7 +2,7 @@ import type {
|
|||
Ad, Announcement, Antenna, App, AuthSession, Blocking, Channel, Clip, DateString, DetailedInstanceMetadata, DriveFile, DriveFolder, Following, FollowingFolloweePopulated, FollowingFollowerPopulated, FollowRequest, GalleryPost, Instance,
|
||||
LiteInstanceMetadata,
|
||||
MeDetailed,
|
||||
Note, NoteFavorite, OriginType, Page, ServerInfo, Stats, User, UserDetailed, UserGroup, UserList, UserSorting, Notification, NoteReaction, Signin, MessagingMessage,
|
||||
Note, NoteFavorite, OriginType, Page, ServerInfo, Stats, User, UserDetailed, UserList, UserSorting, Notification, NoteReaction, Signin, MessagingMessage,
|
||||
} from './entities.js';
|
||||
|
||||
type TODO = Record<string, any> | null;
|
||||
|
|
|
@ -1,77 +1,14 @@
|
|||
import { Packed } from "./schemas";
|
||||
|
||||
export type ID = string;
|
||||
export type DateString = string;
|
||||
|
||||
type TODO = Record<string, any>;
|
||||
|
||||
// NOTE: 極力この型を使うのは避け、UserLite か UserDetailed か明示するように
|
||||
export type User = UserLite | UserDetailed;
|
||||
|
||||
export type UserLite = {
|
||||
id: ID;
|
||||
username: string;
|
||||
host: string | null;
|
||||
name: string;
|
||||
onlineStatus: 'online' | 'active' | 'offline' | 'unknown';
|
||||
avatarUrl: string;
|
||||
avatarBlurhash: string;
|
||||
emojis: {
|
||||
name: string;
|
||||
url: string;
|
||||
}[];
|
||||
instance?: {
|
||||
name: Instance['name'];
|
||||
softwareName: Instance['softwareName'];
|
||||
softwareVersion: Instance['softwareVersion'];
|
||||
iconUrl: Instance['iconUrl'];
|
||||
faviconUrl: Instance['faviconUrl'];
|
||||
themeColor: Instance['themeColor'];
|
||||
};
|
||||
};
|
||||
|
||||
export type UserDetailed = UserLite & {
|
||||
alsoKnownAs: string[];
|
||||
bannerBlurhash: string | null;
|
||||
bannerColor: string | null;
|
||||
bannerUrl: string | null;
|
||||
birthday: string | null;
|
||||
createdAt: DateString;
|
||||
description: string | null;
|
||||
ffVisibility: 'public' | 'followers' | 'private';
|
||||
fields: {name: string; value: string}[];
|
||||
followersCount: number;
|
||||
followingCount: number;
|
||||
hasPendingFollowRequestFromYou: boolean;
|
||||
hasPendingFollowRequestToYou: boolean;
|
||||
isAdmin: boolean;
|
||||
isBlocked: boolean;
|
||||
isBlocking: boolean;
|
||||
isBot: boolean;
|
||||
isCat: boolean;
|
||||
isFollowed: boolean;
|
||||
isFollowing: boolean;
|
||||
isLocked: boolean;
|
||||
isModerator: boolean;
|
||||
isMuted: boolean;
|
||||
isSilenced: boolean;
|
||||
isSuspended: boolean;
|
||||
lang: string | null;
|
||||
lastFetchedAt?: DateString;
|
||||
location: string | null;
|
||||
movedTo: string;
|
||||
notesCount: number;
|
||||
pinnedNoteIds: ID[];
|
||||
pinnedNotes: Note[];
|
||||
pinnedPage: Page | null;
|
||||
pinnedPageId: string | null;
|
||||
publicReactions: boolean;
|
||||
securityKeys: boolean;
|
||||
twoFactorEnabled: boolean;
|
||||
updatedAt: DateString | null;
|
||||
uri: string | null;
|
||||
url: string | null;
|
||||
};
|
||||
|
||||
export type UserGroup = TODO;
|
||||
export type User = Packed<'User'>;
|
||||
export type UserLite = Packed<'UserLite'>;
|
||||
export type UserDetailed = Packed<'UserDetailed'>;
|
||||
|
||||
export type UserList = {
|
||||
id: ID;
|
||||
|
@ -231,11 +168,6 @@ export type Notification = {
|
|||
type: 'receiveFollowRequest';
|
||||
user: User;
|
||||
userId: User['id'];
|
||||
} | {
|
||||
type: 'groupInvited';
|
||||
invitation: UserGroup;
|
||||
user: User;
|
||||
userId: User['id'];
|
||||
} | {
|
||||
type: 'app';
|
||||
header?: string | null;
|
||||
|
|
|
@ -37,7 +37,7 @@ export const packedNotificationSchema = {
|
|||
} as const satisfies JSONSchema7Definition;
|
||||
|
||||
export const packedNotificationStrictSchema = {
|
||||
$id: 'https://misskey-hub.net/api/schemas/PackedNotificationStrict',
|
||||
$id: 'https://misskey-hub.net/api/schemas/NotificationStrict',
|
||||
|
||||
type: 'object',
|
||||
allOf: [
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import type { Antenna, CustomEmoji, DriveFile, MeDetailed, MessagingMessage, Note, Notification, PageEvent, User, UserGroup } from './entities.js';
|
||||
import type { Antenna, CustomEmoji, DriveFile, MeDetailed, MessagingMessage, Note, Notification, PageEvent, User } from './entities.js';
|
||||
|
||||
type FIXME = any;
|
||||
|
||||
|
@ -70,23 +70,6 @@ export type Channels = {
|
|||
};
|
||||
receives: null;
|
||||
};
|
||||
messaging: {
|
||||
params: {
|
||||
otherparty?: User['id'] | null;
|
||||
group?: UserGroup['id'] | null;
|
||||
};
|
||||
events: {
|
||||
message: (payload: MessagingMessage) => void;
|
||||
deleted: (payload: MessagingMessage['id']) => void;
|
||||
read: (payload: MessagingMessage['id'][]) => void;
|
||||
typers: (payload: User[]) => void;
|
||||
};
|
||||
receives: {
|
||||
read: {
|
||||
id: MessagingMessage['id'];
|
||||
};
|
||||
};
|
||||
};
|
||||
serverStats: {
|
||||
params: null;
|
||||
events: {
|
||||
|
|
|
@ -1,10 +1,9 @@
|
|||
import { Packed, Def } from '../src/schemas';
|
||||
// import { expectType } from 'tsd';
|
||||
import { expectType } from 'tsd';
|
||||
|
||||
describe('schemas', () => {
|
||||
test('user', () => {
|
||||
type UserLite = Packed<'UserLite'>;
|
||||
/* Error: is declared too wide for argument type
|
||||
expectType<UserLite>({
|
||||
id: 'string',
|
||||
name: null,
|
||||
|
@ -18,7 +17,6 @@ describe('schemas', () => {
|
|||
isCat: false,
|
||||
onlineStatus: null,
|
||||
});
|
||||
*/
|
||||
type UserDetailedNotMeOnly = Packed<'UserDetailedNotMeOnly'>;
|
||||
type UserDetailedNotMe = Packed<'UserDetailedNotMe'>;
|
||||
type MeDetailed = Packed<'MeDetailed'>;
|
||||
|
@ -42,6 +40,7 @@ describe('schemas', () => {
|
|||
});
|
||||
test('notification', () => {
|
||||
type Notification = Packed<'Notification'>;
|
||||
type NotificationStrict = Packed<'NotificationStrict'>;
|
||||
});
|
||||
test('drive file', () => {
|
||||
type DriveFile = Packed<'DriveFile'>;
|
||||
|
|
Loading…
Reference in a new issue