wip
This commit is contained in:
		@@ -1,5 +1,5 @@
 | 
			
		||||
import { localUsernameSchema, passwordSchema } from "./schemas/user";
 | 
			
		||||
import type { JSONSchema7 } from 'json-schema-to-ts';
 | 
			
		||||
import type { JSONSchema7 } from 'schema-type';
 | 
			
		||||
 | 
			
		||||
export type RolePolicies = {
 | 
			
		||||
	gtlAvailable: boolean;
 | 
			
		||||
 
 | 
			
		||||
@@ -1,5 +1,3 @@
 | 
			
		||||
import type { FromSchema, JSONSchema7Reference } from 'json-schema-to-ts';
 | 
			
		||||
 | 
			
		||||
import { IdSchema } from './schemas/id.js';
 | 
			
		||||
import {
 | 
			
		||||
	packedUserLiteSchema,
 | 
			
		||||
@@ -32,6 +30,7 @@ import { packedQueueCountSchema } from './schemas/queue.js';
 | 
			
		||||
import { packedGalleryPostSchema } from './schemas/gallery-post.js';
 | 
			
		||||
import { packedEmojiDetailedSchema, packedEmojiSimpleSchema } from './schemas/emoji.js';
 | 
			
		||||
import { packedFlashSchema } from './schemas/flash.js';
 | 
			
		||||
import type { JSONSchema7, JSONSchema7Definition, GetDef, GetRefs, GetKeys, UnionToArray } from 'schema-type';
 | 
			
		||||
 | 
			
		||||
export const refs = {
 | 
			
		||||
	UserLite: packedUserLiteSchema,
 | 
			
		||||
@@ -65,16 +64,18 @@ export const refs = {
 | 
			
		||||
	EmojiSimple: packedEmojiSimpleSchema,
 | 
			
		||||
	EmojiDetailed: packedEmojiDetailedSchema,
 | 
			
		||||
	Flash: packedFlashSchema,
 | 
			
		||||
} as const satisfies { [x: string]: JSONSchema7Reference };
 | 
			
		||||
} as const satisfies { [x: string]: JSONSchema7Definition };
 | 
			
		||||
 | 
			
		||||
type Refs = typeof packedAntennaSchema | typeof packedNoteSchema; // TODO: typeof refs[keyof typeof refs];
 | 
			
		||||
type UnionToArray<T, A extends unknown[] = []> = T extends any ? [T, ...A] : never;
 | 
			
		||||
 | 
			
		||||
export type References = [
 | 
			
		||||
    typeof IdSchema,
 | 
			
		||||
    ...UnionToArray<Refs>
 | 
			
		||||
];
 | 
			
		||||
 | 
			
		||||
export type Packed<T extends keyof typeof refs> = FromSchema<typeof refs[T], { references: References }>
 | 
			
		||||
export type Packed<x extends GetKeys<References, 'https://misskey-dev.net/api/'>> = GetDef<References, x, 'https://misskey-dev.net/api/'>;
 | 
			
		||||
export type Def<x extends GetKeys<References>> = GetDef<References, x>;
 | 
			
		||||
 | 
			
		||||
export type PackedNote = Packed<'Note'>;
 | 
			
		||||
export type DefNote = Def<'/schemas/Note'>;
 | 
			
		||||
let renote: PackedNote['reply'];
 | 
			
		||||
 
 | 
			
		||||
@@ -1,14 +1,11 @@
 | 
			
		||||
import type { JSONSchema7Reference } from 'json-schema-to-ts';
 | 
			
		||||
import type { JSONSchema7Definition } from 'schema-type';
 | 
			
		||||
 | 
			
		||||
export const packedAntennaSchema = {
 | 
			
		||||
	$id: '/schemas/Antenna',
 | 
			
		||||
	$id: 'https://misskey-hub.net/api/schemas/Antenna',
 | 
			
		||||
 | 
			
		||||
	type: 'object',
 | 
			
		||||
	properties: {
 | 
			
		||||
		id: {
 | 
			
		||||
			type: 'string',
 | 
			
		||||
			format: 'id',
 | 
			
		||||
		},
 | 
			
		||||
		id: { $ref: '/schemas/Id' },
 | 
			
		||||
		createdAt: {
 | 
			
		||||
			type: 'string',
 | 
			
		||||
			format: 'date-time',
 | 
			
		||||
@@ -90,4 +87,4 @@ export const packedAntennaSchema = {
 | 
			
		||||
		'isActive',
 | 
			
		||||
		'hasUnreadNote',
 | 
			
		||||
	],
 | 
			
		||||
} as const satisfies JSONSchema7Reference;
 | 
			
		||||
} as const satisfies JSONSchema7Definition;
 | 
			
		||||
 
 | 
			
		||||
@@ -1,6 +1,7 @@
 | 
			
		||||
import type { JSONSchema7Definition } from 'schema-type';
 | 
			
		||||
export const IdSchema = {
 | 
			
		||||
    $id: '/schemas/Id',
 | 
			
		||||
    $id: 'https://misskey-hub.net/api/schemas/Id',
 | 
			
		||||
    type: 'string',
 | 
			
		||||
    format: 'id',
 | 
			
		||||
    example: 'xxxxxxxxxx',
 | 
			
		||||
};
 | 
			
		||||
    examples: 'xxxxxxxxxx',
 | 
			
		||||
} as const satisfies JSONSchema7Definition;
 | 
			
		||||
 
 | 
			
		||||
@@ -1,14 +1,11 @@
 | 
			
		||||
import type { JSONSchema7Reference } from 'json-schema-to-ts';
 | 
			
		||||
import type { JSONSchema7 } from 'schema-type';
 | 
			
		||||
 | 
			
		||||
export const packedNoteSchema = {
 | 
			
		||||
	$id: '/schemas/Note',
 | 
			
		||||
	$id: 'https://misskey-hub.net/api/schemas/schemas/Note',
 | 
			
		||||
 | 
			
		||||
	type: 'object',
 | 
			
		||||
	properties: {
 | 
			
		||||
		id: {
 | 
			
		||||
			type: 'string',
 | 
			
		||||
			$ref: '/schemas/Id',
 | 
			
		||||
		},
 | 
			
		||||
		id: { $ref: 'https://misskey-hub.net/api/schemas/schemas/Id' },
 | 
			
		||||
		createdAt: {
 | 
			
		||||
			type: 'string',
 | 
			
		||||
			format: 'date-time',
 | 
			
		||||
@@ -26,34 +23,22 @@ export const packedNoteSchema = {
 | 
			
		||||
			oneOf: [{ type: 'string' }, { type: 'null' }],
 | 
			
		||||
		},
 | 
			
		||||
		userId: {
 | 
			
		||||
			type: 'string',
 | 
			
		||||
			$ref: '/schemas/Id',
 | 
			
		||||
			$ref: 'https://misskey-hub.net/api/schemas/schemas/Id',
 | 
			
		||||
		},
 | 
			
		||||
		user: {
 | 
			
		||||
			type: 'object',
 | 
			
		||||
			$ref: '/schemas/UserLite',
 | 
			
		||||
			$ref: 'https://misskey-hub.net/api/schemas/schemas/UserLite',
 | 
			
		||||
		},
 | 
			
		||||
		replyId: {
 | 
			
		||||
			oneOf: [{
 | 
			
		||||
				type: 'string',
 | 
			
		||||
				$ref: '/schemas/Id',
 | 
			
		||||
			}, { type: 'null' }],
 | 
			
		||||
			oneOf: [{ $ref: 'https://misskey-hub.net/api/schemas/schemas/Id' }, { type: 'null' }],
 | 
			
		||||
		},
 | 
			
		||||
		renoteId: {
 | 
			
		||||
			oneOf: [{
 | 
			
		||||
				type: 'string',
 | 
			
		||||
				$ref: '/schemas/Id',
 | 
			
		||||
			}, { type: 'null' }],
 | 
			
		||||
			oneOf: [{ $ref: 'https://misskey-hub.net/api/schemas/schemas/Id' }, { type: 'null' }],
 | 
			
		||||
		},
 | 
			
		||||
		reply: {
 | 
			
		||||
			oneOf: [{
 | 
			
		||||
				$ref: '/schemas/Note',
 | 
			
		||||
			}, { type: 'null' }],
 | 
			
		||||
			oneOf: [{ $ref: 'https://misskey-hub.net/api/schemas/schemas/Note' }, { type: 'null' }],
 | 
			
		||||
		},
 | 
			
		||||
		renote: {
 | 
			
		||||
			oneOf: [{
 | 
			
		||||
				$ref: '/schemas/Note',
 | 
			
		||||
			}, { type: 'null' }],
 | 
			
		||||
			oneOf: [{ $ref: 'https://misskey-hub.net/api/schemas/schemas/Note' }, { type: 'null' }],
 | 
			
		||||
		},
 | 
			
		||||
		isHidden: {
 | 
			
		||||
			type: 'boolean',
 | 
			
		||||
@@ -63,48 +48,29 @@ export const packedNoteSchema = {
 | 
			
		||||
		},
 | 
			
		||||
		mentions: {
 | 
			
		||||
			type: 'array',
 | 
			
		||||
			items: {
 | 
			
		||||
				type: 'string',
 | 
			
		||||
				$ref: '/schemas/Id',
 | 
			
		||||
			},
 | 
			
		||||
			items: { $ref: 'https://misskey-hub.net/api/schemas/schemas/Id' },
 | 
			
		||||
		},
 | 
			
		||||
		visibleUserIds: {
 | 
			
		||||
			type: 'array',
 | 
			
		||||
			items: {
 | 
			
		||||
				type: 'string',
 | 
			
		||||
				$ref: '/schemas/Id',
 | 
			
		||||
			},
 | 
			
		||||
			items: { $ref: 'https://misskey-hub.net/api/schemas/schemas/Id' },
 | 
			
		||||
		},
 | 
			
		||||
		fileIds: {
 | 
			
		||||
			type: 'array',
 | 
			
		||||
			items: {
 | 
			
		||||
				type: 'string',
 | 
			
		||||
				$ref: '/schemas/Id',
 | 
			
		||||
			},
 | 
			
		||||
			items: { $ref: 'https://misskey-hub.net/api/schemas/schemas/Id' },
 | 
			
		||||
		},
 | 
			
		||||
		files: {
 | 
			
		||||
			type: 'array',
 | 
			
		||||
			items: {
 | 
			
		||||
				$ref: '/schemas/DriveFile',
 | 
			
		||||
			},
 | 
			
		||||
			items: { $ref: 'https://misskey-hub.net/api/schemas/schemas/DriveFile' },
 | 
			
		||||
		},
 | 
			
		||||
		tags: {
 | 
			
		||||
			type: 'array',
 | 
			
		||||
			items: {
 | 
			
		||||
				type: 'string',
 | 
			
		||||
			},
 | 
			
		||||
			items: { type: 'string' },
 | 
			
		||||
		},
 | 
			
		||||
		poll: {
 | 
			
		||||
			oneOf: [{
 | 
			
		||||
				type: 'object',
 | 
			
		||||
				$ref: '/schemas/Poll',
 | 
			
		||||
			}, { type: 'null' }],
 | 
			
		||||
			oneOf: [{ $ref: 'https://misskey-hub.net/api/schemas/schemas/Poll' }, { type: 'null' }],
 | 
			
		||||
		},
 | 
			
		||||
		channelId: {
 | 
			
		||||
			oneOf: [{
 | 
			
		||||
				type: 'string',
 | 
			
		||||
				$ref: '/schemas/Id',
 | 
			
		||||
			}, { type: 'null' }],
 | 
			
		||||
			oneOf: [{ $ref: 'https://misskey-hub.net/api/schemas/schemas/Id' }, { type: 'null' }],
 | 
			
		||||
		},
 | 
			
		||||
		channel: {
 | 
			
		||||
			oneOf: [{
 | 
			
		||||
@@ -156,4 +122,4 @@ export const packedNoteSchema = {
 | 
			
		||||
		'renoteCount',
 | 
			
		||||
		'repliesCount',
 | 
			
		||||
	],
 | 
			
		||||
} as const satisfies JSONSchema7Reference;
 | 
			
		||||
} as const satisfies JSONSchema7Definition;
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user