wip
This commit is contained in:
@@ -7,6 +7,7 @@ type TODO = Record<string, any>;
|
||||
|
||||
// NOTE: 極力この型を使うのは避け、UserLite か UserDetailed か明示するように
|
||||
export type User = Packed<'User'>;
|
||||
|
||||
export type UserLite = Packed<'UserLite'>;
|
||||
export type UserDetailed = Packed<'UserDetailed'>;
|
||||
export type UserList = Packed<'UserList'>;
|
||||
|
@@ -35,6 +35,7 @@ import { packedEmojiDetailedSchema, packedEmojiSimpleSchema } from './schemas/em
|
||||
import { packedFlashSchema } from './schemas/flash.js';
|
||||
import { packedAdSchema } from './schemas/ad.js';
|
||||
import { packedAnnouncementSchema } from './schemas/announcement.js';
|
||||
import { Error, ApiError } from './schemas/error.js';
|
||||
import type { JSONSchema7, JSONSchema7Definition, GetDef, GetRefs, GetKeys, UnionToArray } from 'schema-type';
|
||||
|
||||
export const refs = {
|
||||
@@ -74,6 +75,9 @@ export const refs = {
|
||||
Flash: packedFlashSchema,
|
||||
Ad: packedAdSchema,
|
||||
Announcement: packedAnnouncementSchema,
|
||||
|
||||
Error: Error,
|
||||
ApiError: ApiError,
|
||||
} as const satisfies { [x: string]: JSONSchema7Definition };
|
||||
|
||||
export type References = GetRefs<typeof refs>;
|
||||
|
@@ -17,6 +17,6 @@ export const packedBlockingSchema = {
|
||||
'id',
|
||||
'createdAt',
|
||||
'blockeeId',
|
||||
'blockee',
|
||||
//'blockee',
|
||||
],
|
||||
} as const satisfies JSONSchema7Definition;
|
||||
|
34
packages/misskey-js/src/schemas/error.ts
Normal file
34
packages/misskey-js/src/schemas/error.ts
Normal file
@@ -0,0 +1,34 @@
|
||||
import type { JSONSchema7Definition } from 'schema-type';
|
||||
|
||||
export const Error = {
|
||||
$id: 'https://misskey-hub.net/api/schemas/Error',
|
||||
|
||||
type: 'object',
|
||||
description: 'An error object.',
|
||||
properties: {
|
||||
code: {
|
||||
type: 'string',
|
||||
description: 'An error code. Unique within the endpoint.',
|
||||
},
|
||||
message: {
|
||||
type: 'string',
|
||||
description: 'An error message.',
|
||||
},
|
||||
id: {
|
||||
type: 'string',
|
||||
format: 'uuid',
|
||||
description: 'An error ID. This ID is static.',
|
||||
},
|
||||
},
|
||||
required: ['code', 'id', 'message'],
|
||||
} as const satisfies JSONSchema7Definition;
|
||||
|
||||
export const ApiError = {
|
||||
$id: 'https://misskey-hub.net/api/schemas/ApiError',
|
||||
|
||||
type: 'object',
|
||||
properties: {
|
||||
error: { $ref: 'https://misskey-hub.net/api/schemas/Error' },
|
||||
},
|
||||
required: ['error'],
|
||||
} as const satisfies JSONSchema7Definition;
|
@@ -97,4 +97,8 @@ describe('schemas', () => {
|
||||
test('ad', () => {
|
||||
type Ad = Packed<'Ad'>;
|
||||
});
|
||||
test('error', () => {
|
||||
type Error = Packed<'Error'>;
|
||||
type ApiError = Packed<'ApiError'>;
|
||||
});
|
||||
});
|
||||
|
@@ -20,7 +20,7 @@ describe('schemas', () => {
|
||||
}
|
||||
});
|
||||
|
||||
test('jointed schema (oneOf)', () => {
|
||||
test('jointed schema', () => {
|
||||
const req = getEndpointSchema('req', key as keyof Endpoints);
|
||||
if (req) ajv.compile(req);
|
||||
});
|
||||
|
Reference in New Issue
Block a user