= p['type'] extends 'string' ? NullOrUndefined
: p['type'] extends 'boolean' ? NullOrUndefined
: p['type'] extends 'array' ? NullOrUndefined
>[]> : - p['type'] extends 'object' ? NullOrUndefined
>> : + p['type'] extends 'object' ? ( + p['ref'] extends keyof typeof refs + ? NullOrUndefined
> + : NullOrUndefined
>> + ) : p['type'] extends 'any' ? NullOrUndefined
:
any;
diff --git a/src/misc/simple-schema.ts b/src/misc/simple-schema.ts
new file mode 100644
index 0000000000..abbb348e24
--- /dev/null
+++ b/src/misc/simple-schema.ts
@@ -0,0 +1,15 @@
+export interface SimpleSchema {
+ type: 'boolean' | 'number' | 'string' | 'array' | 'object' | 'any';
+ nullable: boolean;
+ optional: boolean;
+ items?: SimpleSchema;
+ properties?: SimpleObj;
+ description?: string;
+ example?: any;
+ format?: string;
+ ref?: string;
+ enum?: string[];
+ default?: boolean | null;
+}
+
+export interface SimpleObj { [key: string]: SimpleSchema; }
diff --git a/src/models/repositories/blocking.ts b/src/models/repositories/blocking.ts
index dd3a10905c..515b3a6b16 100644
--- a/src/models/repositories/blocking.ts
+++ b/src/models/repositories/blocking.ts
@@ -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,
},
}
};
diff --git a/src/models/repositories/clip.ts b/src/models/repositories/clip.ts
index 49dc3a332e..e3d718bef4 100644
--- a/src/models/repositories/clip.ts
+++ b/src/models/repositories/clip.ts
@@ -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: {
diff --git a/src/models/repositories/drive-file.ts b/src/models/repositories/drive-file.ts
index 42a60ff03c..63bd020cbe 100644
--- a/src/models/repositories/drive-file.ts
+++ b/src/models/repositories/drive-file.ts
@@ -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,
}
},
};
diff --git a/src/models/repositories/drive-folder.ts b/src/models/repositories/drive-folder.ts
index 4228284f82..bc73018f29 100644
--- a/src/models/repositories/drive-folder.ts
+++ b/src/models/repositories/drive-folder.ts
@@ -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,
},
},
};
diff --git a/src/models/repositories/following.ts b/src/models/repositories/following.ts
index 3bb120bc4b..24ddd0d676 100644
--- a/src/models/repositories/following.ts
+++ b/src/models/repositories/following.ts
@@ -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,
},
}
};
diff --git a/src/models/repositories/gallery-post.ts b/src/models/repositories/gallery-post.ts
index 03edb35213..afa22e9edf 100644
--- a/src/models/repositories/gallery-post.ts
+++ b/src/models/repositories/gallery-post.ts
@@ -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: {
diff --git a/src/models/repositories/messaging-message.ts b/src/models/repositories/messaging-message.ts
index 1a4a8eecc4..f97905af2f 100644
--- a/src/models/repositories/messaging-message.ts
+++ b/src/models/repositories/messaging-message.ts
@@ -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,
diff --git a/src/models/repositories/muting.ts b/src/models/repositories/muting.ts
index e46f4ae448..d957b1792d 100644
--- a/src/models/repositories/muting.ts
+++ b/src/models/repositories/muting.ts
@@ -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,
},
}
};
diff --git a/src/models/repositories/note-favorite.ts b/src/models/repositories/note-favorite.ts
index 3248c32ded..47586a9116 100644
--- a/src/models/repositories/note-favorite.ts
+++ b/src/models/repositories/note-favorite.ts
@@ -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,
diff --git a/src/models/repositories/note-reaction.ts b/src/models/repositories/note-reaction.ts
index c349edf182..e73a832109 100644
--- a/src/models/repositories/note-reaction.ts
+++ b/src/models/repositories/note-reaction.ts
@@ -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,
diff --git a/src/models/repositories/note.ts b/src/models/repositories/note.ts
index 9e0f5e55f0..376a09d0c6 100644
--- a/src/models/repositories/note.ts
+++ b/src/models/repositories/note.ts
@@ -95,7 +95,7 @@ export class NoteRepository extends Repository