refactor: Expand schema (#7772)
* packedNotificationSchemaを更新 * read:gallery, write:gallery, read:gallery-likes, write:gallery-likesに翻訳を追加 * fix * add header, choice, invitation * test * fix * yatta * remove no longer needed "as PackedUser/PackedNote" * clean up * add simple-schema * fix lint * define items in full Schema * revert https://github.com/misskey-dev/misskey/pull/7772#discussion_r706627736 * user packとnote packの型不整合を修正
This commit is contained in:
parent
f59f424795
commit
53f3b779bf
24 changed files with 148 additions and 129 deletions
|
@ -56,7 +56,7 @@ export const packedBlockingSchema = {
|
|||
blockee: {
|
||||
type: 'object' as const,
|
||||
optional: false as const, nullable: false as const,
|
||||
ref: 'User',
|
||||
ref: 'User' as const,
|
||||
},
|
||||
}
|
||||
};
|
||||
|
|
|
@ -53,7 +53,7 @@ export const packedClipSchema = {
|
|||
},
|
||||
user: {
|
||||
type: 'object' as const,
|
||||
ref: 'User',
|
||||
ref: 'User' as const,
|
||||
optional: false as const, nullable: false as const,
|
||||
},
|
||||
name: {
|
||||
|
|
|
@ -234,7 +234,7 @@ export const packedDriveFileSchema = {
|
|||
folder: {
|
||||
type: 'object' as const,
|
||||
optional: true as const, nullable: true as const,
|
||||
ref: 'DriveFolder'
|
||||
ref: 'DriveFolder' as const,
|
||||
},
|
||||
userId: {
|
||||
type: 'string' as const,
|
||||
|
@ -245,7 +245,7 @@ export const packedDriveFileSchema = {
|
|||
user: {
|
||||
type: 'object' as const,
|
||||
optional: true as const, nullable: true as const,
|
||||
ref: 'User'
|
||||
ref: 'User' as const,
|
||||
}
|
||||
},
|
||||
};
|
||||
|
|
|
@ -87,7 +87,7 @@ export const packedDriveFolderSchema = {
|
|||
parent: {
|
||||
type: 'object' as const,
|
||||
optional: true as const, nullable: true as const,
|
||||
ref: 'DriveFolder'
|
||||
ref: 'DriveFolder' as const,
|
||||
},
|
||||
},
|
||||
};
|
||||
|
|
|
@ -110,7 +110,7 @@ export const packedFollowingSchema = {
|
|||
followee: {
|
||||
type: 'object' as const,
|
||||
optional: true as const, nullable: false as const,
|
||||
ref: 'User',
|
||||
ref: 'User' as const,
|
||||
},
|
||||
followerId: {
|
||||
type: 'string' as const,
|
||||
|
@ -120,7 +120,7 @@ export const packedFollowingSchema = {
|
|||
follower: {
|
||||
type: 'object' as const,
|
||||
optional: true as const, nullable: false as const,
|
||||
ref: 'User',
|
||||
ref: 'User' as const,
|
||||
},
|
||||
}
|
||||
};
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import { EntityRepository, Repository } from 'typeorm';
|
||||
import { GalleryPost } from '@/models/entities/gallery-post';
|
||||
import { SchemaType } from '../../misc/schema';
|
||||
import { SchemaType } from '@/misc/schema';
|
||||
import { Users, DriveFiles, GalleryLikes } from '../index';
|
||||
import { awaitAll } from '@/prelude/await-all';
|
||||
import { User } from '@/models/entities/user';
|
||||
|
@ -76,7 +76,7 @@ export const packedGalleryPostSchema = {
|
|||
},
|
||||
user: {
|
||||
type: 'object' as const,
|
||||
ref: 'User',
|
||||
ref: 'User' as const,
|
||||
optional: false as const, nullable: false as const,
|
||||
},
|
||||
fileIds: {
|
||||
|
@ -94,7 +94,7 @@ export const packedGalleryPostSchema = {
|
|||
items: {
|
||||
type: 'object' as const,
|
||||
optional: false as const, nullable: false as const,
|
||||
ref: 'DriveFile'
|
||||
ref: 'DriveFile' as const,
|
||||
}
|
||||
},
|
||||
tags: {
|
||||
|
|
|
@ -67,7 +67,7 @@ export const packedMessagingMessageSchema = {
|
|||
},
|
||||
user: {
|
||||
type: 'object' as const,
|
||||
ref: 'User',
|
||||
ref: 'User' as const,
|
||||
optional: true as const, nullable: false as const,
|
||||
},
|
||||
text: {
|
||||
|
@ -82,7 +82,7 @@ export const packedMessagingMessageSchema = {
|
|||
file: {
|
||||
type: 'object' as const,
|
||||
optional: true as const, nullable: true as const,
|
||||
ref: 'DriveFile',
|
||||
ref: 'DriveFile' as const,
|
||||
},
|
||||
recipientId: {
|
||||
type: 'string' as const,
|
||||
|
@ -92,7 +92,7 @@ export const packedMessagingMessageSchema = {
|
|||
recipient: {
|
||||
type: 'object' as const,
|
||||
optional: true as const, nullable: true as const,
|
||||
ref: 'User'
|
||||
ref: 'User' as const,
|
||||
},
|
||||
groupId: {
|
||||
type: 'string' as const,
|
||||
|
@ -102,7 +102,7 @@ export const packedMessagingMessageSchema = {
|
|||
group: {
|
||||
type: 'object' as const,
|
||||
optional: true as const, nullable: true as const,
|
||||
ref: 'UserGroup'
|
||||
ref: 'UserGroup' as const,
|
||||
},
|
||||
isRead: {
|
||||
type: 'boolean' as const,
|
||||
|
|
|
@ -56,7 +56,7 @@ export const packedMutingSchema = {
|
|||
mutee: {
|
||||
type: 'object' as const,
|
||||
optional: false as const, nullable: false as const,
|
||||
ref: 'User',
|
||||
ref: 'User' as const,
|
||||
},
|
||||
}
|
||||
};
|
||||
|
|
|
@ -45,7 +45,7 @@ export const packedNoteFavoriteSchema = {
|
|||
note: {
|
||||
type: 'object' as const,
|
||||
optional: false as const, nullable: false as const,
|
||||
ref: 'Note',
|
||||
ref: 'Note' as const,
|
||||
},
|
||||
noteId: {
|
||||
type: 'string' as const,
|
||||
|
|
|
@ -42,7 +42,7 @@ export const packedNoteReactionSchema = {
|
|||
user: {
|
||||
type: 'object' as const,
|
||||
optional: false as const, nullable: false as const,
|
||||
ref: 'User',
|
||||
ref: 'User' as const,
|
||||
},
|
||||
type: {
|
||||
type: 'string' as const,
|
||||
|
|
|
@ -95,7 +95,7 @@ export class NoteRepository extends Repository<Note> {
|
|||
hide = true;
|
||||
} else if (meId === packedNote.userId) {
|
||||
hide = false;
|
||||
} else if (packedNote.reply && (meId === (packedNote.reply as PackedNote).userId)) {
|
||||
} else if (packedNote.reply && (meId === packedNote.reply.userId)) {
|
||||
// 自分の投稿に対するリプライ
|
||||
hide = false;
|
||||
} else if (packedNote.mentions && packedNote.mentions.some(id => meId === id)) {
|
||||
|
@ -353,7 +353,7 @@ export const packedNoteSchema = {
|
|||
},
|
||||
user: {
|
||||
type: 'object' as const,
|
||||
ref: 'User',
|
||||
ref: 'User' as const,
|
||||
optional: false as const, nullable: false as const,
|
||||
},
|
||||
replyId: {
|
||||
|
@ -371,12 +371,12 @@ export const packedNoteSchema = {
|
|||
reply: {
|
||||
type: 'object' as const,
|
||||
optional: true as const, nullable: true as const,
|
||||
ref: 'Note'
|
||||
ref: 'Note' as const,
|
||||
},
|
||||
renote: {
|
||||
type: 'object' as const,
|
||||
optional: true as const, nullable: true as const,
|
||||
ref: 'Note'
|
||||
ref: 'Note' as const,
|
||||
},
|
||||
viaMobile: {
|
||||
type: 'boolean' as const,
|
||||
|
@ -423,7 +423,7 @@ export const packedNoteSchema = {
|
|||
items: {
|
||||
type: 'object' as const,
|
||||
optional: false as const, nullable: false as const,
|
||||
ref: 'DriveFile'
|
||||
ref: 'DriveFile' as const,
|
||||
}
|
||||
},
|
||||
tags: {
|
||||
|
@ -447,11 +447,24 @@ export const packedNoteSchema = {
|
|||
channel: {
|
||||
type: 'object' as const,
|
||||
optional: true as const, nullable: true as const,
|
||||
ref: 'Channel'
|
||||
items: {
|
||||
type: 'object' as const,
|
||||
optional: false as const, nullable: false as const,
|
||||
properties: {
|
||||
id: {
|
||||
type: 'string' as const,
|
||||
optional: false as const, nullable: false as const,
|
||||
},
|
||||
name: {
|
||||
type: 'string' as const,
|
||||
optional: false as const, nullable: true as const,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
localOnly: {
|
||||
type: 'boolean' as const,
|
||||
optional: false as const, nullable: true as const,
|
||||
optional: true as const, nullable: false as const,
|
||||
},
|
||||
emojis: {
|
||||
type: 'array' as const,
|
||||
|
@ -466,7 +479,7 @@ export const packedNoteSchema = {
|
|||
},
|
||||
url: {
|
||||
type: 'string' as const,
|
||||
optional: false as const, nullable: false as const,
|
||||
optional: false as const, nullable: true as const,
|
||||
},
|
||||
},
|
||||
},
|
||||
|
@ -485,11 +498,11 @@ export const packedNoteSchema = {
|
|||
},
|
||||
uri: {
|
||||
type: 'string' as const,
|
||||
optional: false as const, nullable: true as const,
|
||||
optional: true as const, nullable: false as const,
|
||||
},
|
||||
url: {
|
||||
type: 'string' as const,
|
||||
optional: false as const, nullable: true as const,
|
||||
optional: true as const, nullable: false as const,
|
||||
},
|
||||
|
||||
myReaction: {
|
||||
|
|
|
@ -136,7 +136,7 @@ export const packedNotificationSchema = {
|
|||
},
|
||||
user: {
|
||||
type: 'object' as const,
|
||||
ref: 'User',
|
||||
ref: 'User' as const,
|
||||
optional: true as const, nullable: true as const,
|
||||
},
|
||||
userId: {
|
||||
|
@ -146,7 +146,7 @@ export const packedNotificationSchema = {
|
|||
},
|
||||
note: {
|
||||
type: 'object' as const,
|
||||
ref: 'Note',
|
||||
ref: 'Note' as const,
|
||||
optional: true as const, nullable: true as const,
|
||||
},
|
||||
reaction: {
|
||||
|
|
|
@ -137,7 +137,7 @@ export const packedPageSchema = {
|
|||
},
|
||||
user: {
|
||||
type: 'object' as const,
|
||||
ref: 'User',
|
||||
ref: 'User' as const,
|
||||
optional: false as const, nullable: false as const,
|
||||
},
|
||||
}
|
||||
|
|
|
@ -375,12 +375,12 @@ export const packedUserSchema = {
|
|||
},
|
||||
isAdmin: {
|
||||
type: 'boolean' as const,
|
||||
nullable: false as const, optional: false as const,
|
||||
nullable: false as const, optional: true as const,
|
||||
default: false
|
||||
},
|
||||
isModerator: {
|
||||
type: 'boolean' as const,
|
||||
nullable: false as const, optional: false as const,
|
||||
nullable: false as const, optional: true as const,
|
||||
default: false
|
||||
},
|
||||
isBot: {
|
||||
|
@ -402,23 +402,11 @@ export const packedUserSchema = {
|
|||
type: 'string' as const,
|
||||
nullable: false as const, optional: false as const
|
||||
},
|
||||
host: {
|
||||
type: 'string' as const,
|
||||
nullable: true as const, optional: false as const
|
||||
},
|
||||
url: {
|
||||
type: 'string' as const,
|
||||
nullable: false as const, optional: false as const,
|
||||
format: 'url'
|
||||
},
|
||||
aliases: {
|
||||
type: 'array' as const,
|
||||
nullable: false as const, optional: false as const,
|
||||
items: {
|
||||
type: 'string' as const,
|
||||
nullable: false as const, optional: false as const
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
@ -457,7 +445,7 @@ export const packedUserSchema = {
|
|||
},
|
||||
isSuspended: {
|
||||
type: 'boolean' as const,
|
||||
nullable: false as const, optional: false as const,
|
||||
nullable: false as const, optional: true as const,
|
||||
example: false
|
||||
},
|
||||
description: {
|
||||
|
@ -476,7 +464,7 @@ export const packedUserSchema = {
|
|||
},
|
||||
fields: {
|
||||
type: 'array' as const,
|
||||
nullable: false as const, optional: false as const,
|
||||
nullable: false as const, optional: true as const,
|
||||
items: {
|
||||
type: 'object' as const,
|
||||
nullable: false as const, optional: false as const,
|
||||
|
@ -520,31 +508,31 @@ export const packedUserSchema = {
|
|||
items: {
|
||||
type: 'object' as const,
|
||||
nullable: false as const, optional: false as const,
|
||||
ref: 'Note'
|
||||
ref: 'Note' as const,
|
||||
}
|
||||
},
|
||||
pinnedPageId: {
|
||||
type: 'string' as const,
|
||||
nullable: true as const, optional: false as const
|
||||
nullable: true as const, optional: true as const
|
||||
},
|
||||
pinnedPage: {
|
||||
type: 'object' as const,
|
||||
nullable: true as const, optional: false as const,
|
||||
ref: 'Page'
|
||||
nullable: true as const, optional: true as const,
|
||||
ref: 'Page' as const,
|
||||
},
|
||||
twoFactorEnabled: {
|
||||
type: 'boolean' as const,
|
||||
nullable: false as const, optional: false as const,
|
||||
nullable: false as const, optional: true as const,
|
||||
default: false
|
||||
},
|
||||
usePasswordLessLogin: {
|
||||
type: 'boolean' as const,
|
||||
nullable: false as const, optional: false as const,
|
||||
nullable: false as const, optional: true as const,
|
||||
default: false
|
||||
},
|
||||
securityKeys: {
|
||||
type: 'boolean' as const,
|
||||
nullable: false as const, optional: false as const,
|
||||
nullable: false as const, optional: true as const,
|
||||
default: false
|
||||
},
|
||||
avatarId: {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue