mirror of
https://github.com/misskey-dev/misskey.git
synced 2024-12-28 14:30:39 +01:00
add Packed type
This commit is contained in:
parent
943f9881e7
commit
04aa4a5e2c
2 changed files with 5 additions and 3 deletions
|
@ -47,6 +47,8 @@ export const refs = {
|
||||||
GalleryPost: packedGalleryPostSchema,
|
GalleryPost: packedGalleryPostSchema,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export type Packed<x extends keyof typeof refs> = SchemaType<typeof refs[x]>
|
||||||
|
|
||||||
export interface Schema extends SimpleSchema {
|
export interface Schema extends SimpleSchema {
|
||||||
items?: Schema;
|
items?: Schema;
|
||||||
properties?: Obj;
|
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 'array' ? NullOrUndefined<p, MyType<NonNullable<p['items']>>[]> :
|
||||||
p['type'] extends 'object' ? (
|
p['type'] extends 'object' ? (
|
||||||
p['ref'] extends keyof typeof refs
|
p['ref'] extends keyof typeof refs
|
||||||
? NullOrUndefined<p, SchemaType<typeof refs[p['ref']]>>
|
? NullOrUndefined<p, Packed<p['ref']>>
|
||||||
: NullOrUndefined<p, ObjType<NonNullable<p['properties']>>>
|
: NullOrUndefined<p, ObjType<NonNullable<p['properties']>>>
|
||||||
) :
|
) :
|
||||||
p['type'] extends 'any' ? NullOrUndefined<p, any> :
|
p['type'] extends 'any' ? NullOrUndefined<p, any> :
|
||||||
|
|
|
@ -3,14 +3,14 @@ import * as mfm from 'mfm-js';
|
||||||
import { Note } from '@/models/entities/note';
|
import { Note } from '@/models/entities/note';
|
||||||
import { User } from '@/models/entities/user';
|
import { User } from '@/models/entities/user';
|
||||||
import { Users, PollVotes, DriveFiles, NoteReactions, Followings, Polls, Channels } from '../index';
|
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 { nyaize } from '@/misc/nyaize';
|
||||||
import { awaitAll } from '@/prelude/await-all';
|
import { awaitAll } from '@/prelude/await-all';
|
||||||
import { convertLegacyReaction, convertLegacyReactions, decodeReaction } from '@/misc/reaction-lib';
|
import { convertLegacyReaction, convertLegacyReactions, decodeReaction } from '@/misc/reaction-lib';
|
||||||
import { NoteReaction } from '@/models/entities/note-reaction';
|
import { NoteReaction } from '@/models/entities/note-reaction';
|
||||||
import { aggregateNoteEmojis, populateEmojis, prefetchEmojis } from '@/misc/populate-emojis';
|
import { aggregateNoteEmojis, populateEmojis, prefetchEmojis } from '@/misc/populate-emojis';
|
||||||
|
|
||||||
export type PackedNote = SchemaType<typeof packedNoteSchema>;
|
export type PackedNote = Packed<'Note'>;
|
||||||
|
|
||||||
@EntityRepository(Note)
|
@EntityRepository(Note)
|
||||||
export class NoteRepository extends Repository<Note> {
|
export class NoteRepository extends Repository<Note> {
|
||||||
|
|
Loading…
Reference in a new issue