add Packed type
This commit is contained in:
parent
ee3457cb09
commit
a97fb08af0
|
@ -21,6 +21,9 @@ import { packedClipSchema } from '@/models/repositories/clip';
|
||||||
import { packedFederationInstanceSchema } from '@/models/repositories/federation-instance';
|
import { packedFederationInstanceSchema } from '@/models/repositories/federation-instance';
|
||||||
import { packedQueueCountSchema } from '@/models/repositories/queue';
|
import { packedQueueCountSchema } from '@/models/repositories/queue';
|
||||||
import { packedGalleryPostSchema } from '@/models/repositories/gallery-post';
|
import { packedGalleryPostSchema } from '@/models/repositories/gallery-post';
|
||||||
|
import { packedEmojiSchema } from '@/models/repositories/emoji';
|
||||||
|
import { packedReversiGameSchema } from '@/models/repositories/games/reversi/game';
|
||||||
|
import { packedReversiMatchingSchema } from '@/models/repositories/games/reversi/matching';
|
||||||
|
|
||||||
export const refs = {
|
export const refs = {
|
||||||
User: packedUserSchema,
|
User: packedUserSchema,
|
||||||
|
@ -45,8 +48,13 @@ export const refs = {
|
||||||
Clip: packedClipSchema,
|
Clip: packedClipSchema,
|
||||||
FederationInstance: packedFederationInstanceSchema,
|
FederationInstance: packedFederationInstanceSchema,
|
||||||
GalleryPost: packedGalleryPostSchema,
|
GalleryPost: packedGalleryPostSchema,
|
||||||
|
Emoji: packedEmojiSchema,
|
||||||
|
ReversiGame: packedReversiGameSchema,
|
||||||
|
ReversiMatching: packedReversiMatchingSchema,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export type Packed<x extends keyof typeof refs> = ObjType<(typeof refs[x])['properties']>;
|
||||||
|
|
||||||
export interface Schema extends SimpleSchema {
|
export interface Schema extends SimpleSchema {
|
||||||
items?: Schema;
|
items?: Schema;
|
||||||
properties?: Obj;
|
properties?: Obj;
|
||||||
|
@ -92,7 +100,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> :
|
||||||
|
|
Loading…
Reference in New Issue