wip
This commit is contained in:
parent
307bc2a38e
commit
d7d3f00488
|
@ -2,7 +2,7 @@ import type {
|
||||||
Ad, Announcement, Antenna, App, AuthSession, Blocking, Channel, Clip, DateString, DetailedInstanceMetadata, DriveFile, DriveFolder, Following, FollowingFolloweePopulated, FollowingFollowerPopulated, FollowRequest, GalleryPost, Instance,
|
Ad, Announcement, Antenna, App, AuthSession, Blocking, Channel, Clip, DateString, DetailedInstanceMetadata, DriveFile, DriveFolder, Following, FollowingFolloweePopulated, FollowingFollowerPopulated, FollowRequest, GalleryPost, Instance,
|
||||||
LiteInstanceMetadata,
|
LiteInstanceMetadata,
|
||||||
MeDetailed,
|
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';
|
} from './entities.js';
|
||||||
|
|
||||||
type TODO = Record<string, any> | null;
|
type TODO = Record<string, any> | null;
|
||||||
|
|
|
@ -1,77 +1,14 @@
|
||||||
|
import { Packed } from "./schemas";
|
||||||
|
|
||||||
export type ID = string;
|
export type ID = string;
|
||||||
export type DateString = string;
|
export type DateString = string;
|
||||||
|
|
||||||
type TODO = Record<string, any>;
|
type TODO = Record<string, any>;
|
||||||
|
|
||||||
// NOTE: 極力この型を使うのは避け、UserLite か UserDetailed か明示するように
|
// NOTE: 極力この型を使うのは避け、UserLite か UserDetailed か明示するように
|
||||||
export type User = UserLite | UserDetailed;
|
export type User = Packed<'User'>;
|
||||||
|
export type UserLite = Packed<'UserLite'>;
|
||||||
export type UserLite = {
|
export type UserDetailed = Packed<'UserDetailed'>;
|
||||||
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 UserList = {
|
export type UserList = {
|
||||||
id: ID;
|
id: ID;
|
||||||
|
@ -231,11 +168,6 @@ export type Notification = {
|
||||||
type: 'receiveFollowRequest';
|
type: 'receiveFollowRequest';
|
||||||
user: User;
|
user: User;
|
||||||
userId: User['id'];
|
userId: User['id'];
|
||||||
} | {
|
|
||||||
type: 'groupInvited';
|
|
||||||
invitation: UserGroup;
|
|
||||||
user: User;
|
|
||||||
userId: User['id'];
|
|
||||||
} | {
|
} | {
|
||||||
type: 'app';
|
type: 'app';
|
||||||
header?: string | null;
|
header?: string | null;
|
||||||
|
|
|
@ -37,7 +37,7 @@ export const packedNotificationSchema = {
|
||||||
} as const satisfies JSONSchema7Definition;
|
} as const satisfies JSONSchema7Definition;
|
||||||
|
|
||||||
export const packedNotificationStrictSchema = {
|
export const packedNotificationStrictSchema = {
|
||||||
$id: 'https://misskey-hub.net/api/schemas/PackedNotificationStrict',
|
$id: 'https://misskey-hub.net/api/schemas/NotificationStrict',
|
||||||
|
|
||||||
type: 'object',
|
type: 'object',
|
||||||
allOf: [
|
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;
|
type FIXME = any;
|
||||||
|
|
||||||
|
@ -70,23 +70,6 @@ export type Channels = {
|
||||||
};
|
};
|
||||||
receives: null;
|
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: {
|
serverStats: {
|
||||||
params: null;
|
params: null;
|
||||||
events: {
|
events: {
|
||||||
|
|
|
@ -1,10 +1,9 @@
|
||||||
import { Packed, Def } from '../src/schemas';
|
import { Packed, Def } from '../src/schemas';
|
||||||
// import { expectType } from 'tsd';
|
import { expectType } from 'tsd';
|
||||||
|
|
||||||
describe('schemas', () => {
|
describe('schemas', () => {
|
||||||
test('user', () => {
|
test('user', () => {
|
||||||
type UserLite = Packed<'UserLite'>;
|
type UserLite = Packed<'UserLite'>;
|
||||||
/* Error: is declared too wide for argument type
|
|
||||||
expectType<UserLite>({
|
expectType<UserLite>({
|
||||||
id: 'string',
|
id: 'string',
|
||||||
name: null,
|
name: null,
|
||||||
|
@ -18,7 +17,6 @@ describe('schemas', () => {
|
||||||
isCat: false,
|
isCat: false,
|
||||||
onlineStatus: null,
|
onlineStatus: null,
|
||||||
});
|
});
|
||||||
*/
|
|
||||||
type UserDetailedNotMeOnly = Packed<'UserDetailedNotMeOnly'>;
|
type UserDetailedNotMeOnly = Packed<'UserDetailedNotMeOnly'>;
|
||||||
type UserDetailedNotMe = Packed<'UserDetailedNotMe'>;
|
type UserDetailedNotMe = Packed<'UserDetailedNotMe'>;
|
||||||
type MeDetailed = Packed<'MeDetailed'>;
|
type MeDetailed = Packed<'MeDetailed'>;
|
||||||
|
@ -42,6 +40,7 @@ describe('schemas', () => {
|
||||||
});
|
});
|
||||||
test('notification', () => {
|
test('notification', () => {
|
||||||
type Notification = Packed<'Notification'>;
|
type Notification = Packed<'Notification'>;
|
||||||
|
type NotificationStrict = Packed<'NotificationStrict'>;
|
||||||
});
|
});
|
||||||
test('drive file', () => {
|
test('drive file', () => {
|
||||||
type DriveFile = Packed<'DriveFile'>;
|
type DriveFile = Packed<'DriveFile'>;
|
||||||
|
|
Loading…
Reference in a new issue