add Packed type

This commit is contained in:
tamaina 2021-09-12 15:35:59 +09:00
parent 943f9881e7
commit 04aa4a5e2c
2 changed files with 5 additions and 3 deletions

View File

@ -47,6 +47,8 @@ export const refs = {
GalleryPost: packedGalleryPostSchema,
};
export type Packed<x extends keyof typeof refs> = SchemaType<typeof refs[x]>
export interface Schema extends SimpleSchema {
items?: Schema;
properties?: Obj;
@ -92,7 +94,7 @@ export type SchemaType<p extends Schema> =
p['type'] extends 'array' ? NullOrUndefined<p, MyType<NonNullable<p['items']>>[]> :
p['type'] extends 'object' ? (
p['ref'] extends keyof typeof refs
? NullOrUndefined<p, SchemaType<typeof refs[p['ref']]>>
? NullOrUndefined<p, Packed<p['ref']>>
: NullOrUndefined<p, ObjType<NonNullable<p['properties']>>>
) :
p['type'] extends 'any' ? NullOrUndefined<p, any> :

View File

@ -3,14 +3,14 @@ import * as mfm from 'mfm-js';
import { Note } from '@/models/entities/note';
import { User } from '@/models/entities/user';
import { Users, PollVotes, DriveFiles, NoteReactions, Followings, Polls, Channels } from '../index';
import { SchemaType } from '@/misc/schema';
import { Packed } from '@/misc/schema';
import { nyaize } from '@/misc/nyaize';
import { awaitAll } from '@/prelude/await-all';
import { convertLegacyReaction, convertLegacyReactions, decodeReaction } from '@/misc/reaction-lib';
import { NoteReaction } from '@/models/entities/note-reaction';
import { aggregateNoteEmojis, populateEmojis, prefetchEmojis } from '@/misc/populate-emojis';
export type PackedNote = SchemaType<typeof packedNoteSchema>;
export type PackedNote = Packed<'Note'>;
@EntityRepository(Note)
export class NoteRepository extends Repository<Note> {