wip~~
This commit is contained in:
parent
ac99cdce8b
commit
4f5d77391f
50 changed files with 218 additions and 171 deletions
|
|
@ -8,10 +8,13 @@ import {
|
|||
packedUserDetailedSchema,
|
||||
packedUserSchema,
|
||||
} from './schemas/user.js';
|
||||
import {
|
||||
packedNotificationSchema,
|
||||
packedNotificationStrictSchema,
|
||||
} from './schemas/notification.js';
|
||||
import { packedNoteSchema } from './schemas/note.js';
|
||||
import { packedUserListSchema } from './schemas/user-list.js';
|
||||
import { packedAppSchema } from './schemas/app.js';
|
||||
import { packedNotificationSchema } from './schemas/notification.js';
|
||||
import { packedDriveFileSchema } from './schemas/drive-file.js';
|
||||
import { packedDriveFolderSchema } from './schemas/drive-folder.js';
|
||||
import { packedFollowingSchema } from './schemas/following.js';
|
||||
|
|
@ -49,6 +52,7 @@ export const refs = {
|
|||
NoteReaction: packedNoteReactionSchema,
|
||||
NoteFavorite: packedNoteFavoriteSchema,
|
||||
Notification: packedNotificationSchema,
|
||||
NotificationStrict: packedNotificationStrictSchema,
|
||||
DriveFile: packedDriveFileSchema,
|
||||
DriveFolder: packedDriveFolderSchema,
|
||||
Following: packedFollowingSchema,
|
||||
|
|
|
|||
|
|
@ -111,7 +111,7 @@ export const packedDriveFileSchema = {
|
|||
'md5',
|
||||
'size',
|
||||
'isSensitive',
|
||||
'burlhash',
|
||||
'blurhash',
|
||||
'properties',
|
||||
'url',
|
||||
'thumbnailUrl',
|
||||
|
|
|
|||
|
|
@ -17,10 +17,10 @@ export const packedNoteSchema = {
|
|||
}, { type: 'null' }],
|
||||
},
|
||||
text: {
|
||||
type: 'string',
|
||||
type: ['string', 'null'],
|
||||
},
|
||||
cw: {
|
||||
oneOf: [{ type: 'string' }, { type: 'null' }],
|
||||
type: ['string', 'null'],
|
||||
},
|
||||
userId: {
|
||||
$ref: 'https://misskey-hub.net/api/schemas/Id',
|
||||
|
|
|
|||
|
|
@ -1,117 +1,155 @@
|
|||
import type { JSONSchema7Definition } from 'schema-type';
|
||||
import { ACHIEVEMENT_TYPES } from '../consts';
|
||||
import { ACHIEVEMENT_TYPES, notificationTypes } from '../consts';
|
||||
|
||||
export const packedNotificationSchema = {
|
||||
$id: 'https://misskey-hub.net/api/schemas/Notification',
|
||||
type: 'object',
|
||||
properties: {
|
||||
id: { $ref: 'https://misskey-hub.net/api/schemas/Id' },
|
||||
createdAt: {
|
||||
type: 'string',
|
||||
format: 'date-time',
|
||||
},
|
||||
type: {
|
||||
type: 'string',
|
||||
enum: [...notificationTypes],
|
||||
},
|
||||
userId: {
|
||||
oneOf: [
|
||||
{ $ref: 'https://misskey-hub.net/api/schemas/Id' },
|
||||
{ type: 'null' },
|
||||
]
|
||||
},
|
||||
user: { $ref: 'https://misskey-hub.net/api/schemas/UserLite' },
|
||||
note: { $ref: 'https://misskey-hub.net/api/schemas/Note' },
|
||||
reaction: { type: ['string', 'null'] },
|
||||
achievement: {
|
||||
oneOf: [
|
||||
{ enum: [...ACHIEVEMENT_TYPES] },
|
||||
{ type: 'null' },
|
||||
],
|
||||
},
|
||||
header: { type: ['string', 'null'] },
|
||||
body: { type: ['string', 'null'] },
|
||||
icon: { type: ['string', 'null'] },
|
||||
},
|
||||
required: ['id', 'createdAt'],
|
||||
} as const satisfies JSONSchema7Definition;
|
||||
|
||||
export const packedNotificationStrictSchema = {
|
||||
$id: 'https://misskey-hub.net/api/schemas/PackedNotificationStrict',
|
||||
|
||||
type: 'object',
|
||||
allOf: [{
|
||||
type: 'object',
|
||||
properties: {
|
||||
id: { $ref: 'https://misskey-hub.net/api/schemas/Id' },
|
||||
createdAt: {
|
||||
type: 'string',
|
||||
format: 'date-time',
|
||||
},
|
||||
},
|
||||
required: ['id', 'createdAt'],
|
||||
}, {
|
||||
oneOf: [
|
||||
allOf: [
|
||||
{
|
||||
type: 'object',
|
||||
properties: {
|
||||
type: { const: 'follow' },
|
||||
userId: { $ref: 'https://misskey-hub.net/api/schemas/Id' },
|
||||
user: { $ref: 'https://misskey-hub.net/api/schemas/UserLite' },
|
||||
id: { $ref: 'https://misskey-hub.net/api/schemas/Id' },
|
||||
createdAt: {
|
||||
type: 'string',
|
||||
format: 'date-time',
|
||||
},
|
||||
},
|
||||
required: ['type', 'userId', 'user'],
|
||||
}, {
|
||||
required: ['id', 'createdAt'],
|
||||
},
|
||||
{
|
||||
type: 'object',
|
||||
properties: {
|
||||
type: { const: 'mention' },
|
||||
userId: { $ref: 'https://misskey-hub.net/api/schemas/Id' },
|
||||
user: { $ref: 'https://misskey-hub.net/api/schemas/UserLite' },
|
||||
note: { $ref: 'https://misskey-hub.net/api/schemas/Note' },
|
||||
},
|
||||
required: ['type', 'userId', 'user', 'note'],
|
||||
}, {
|
||||
type: 'object',
|
||||
properties: {
|
||||
type: { const: 'reply' },
|
||||
userId: { $ref: 'https://misskey-hub.net/api/schemas/Id' },
|
||||
user: { $ref: 'https://misskey-hub.net/api/schemas/UserLite' },
|
||||
note: { $ref: 'https://misskey-hub.net/api/schemas/Note' },
|
||||
},
|
||||
required: ['type', 'userId', 'user', 'note'],
|
||||
}, {
|
||||
type: 'object',
|
||||
properties: {
|
||||
type: { const: 'renote' },
|
||||
userId: { $ref: 'https://misskey-hub.net/api/schemas/Id' },
|
||||
user: { $ref: 'https://misskey-hub.net/api/schemas/UserLite' },
|
||||
note: { $ref: 'https://misskey-hub.net/api/schemas/Note' },
|
||||
},
|
||||
required: ['type', 'userId', 'user', 'note'],
|
||||
}, {
|
||||
type: 'object',
|
||||
properties: {
|
||||
type: { const: 'quote' },
|
||||
userId: { $ref: 'https://misskey-hub.net/api/schemas/Id' },
|
||||
user: { $ref: 'https://misskey-hub.net/api/schemas/UserLite' },
|
||||
note: { $ref: 'https://misskey-hub.net/api/schemas/Note' },
|
||||
},
|
||||
required: ['type', 'userId', 'user', 'note'],
|
||||
}, {
|
||||
type: 'object',
|
||||
properties: {
|
||||
type: { const: 'reaction' },
|
||||
reaction: { type: 'string' },
|
||||
userId: { $ref: 'https://misskey-hub.net/api/schemas/Id' },
|
||||
user: { $ref: 'https://misskey-hub.net/api/schemas/UserLite' },
|
||||
note: { $ref: 'https://misskey-hub.net/api/schemas/Note' },
|
||||
},
|
||||
required: ['type', 'reaction', 'userId', 'user', 'note'],
|
||||
}, {
|
||||
type: 'object',
|
||||
properties: {
|
||||
type: { const: 'pollEnded' },
|
||||
userId: { $ref: 'https://misskey-hub.net/api/schemas/Id' },
|
||||
user: { $ref: 'https://misskey-hub.net/api/schemas/UserLite' },
|
||||
note: { $ref: 'https://misskey-hub.net/api/schemas/Note' },
|
||||
},
|
||||
required: ['type', 'userId', 'user', 'note'],
|
||||
}, {
|
||||
type: 'object',
|
||||
properties: {
|
||||
type: { const: 'receiveFollowRequest' },
|
||||
userId: { $ref: 'https://misskey-hub.net/api/schemas/Id' },
|
||||
user: { $ref: 'https://misskey-hub.net/api/schemas/UserLite' },
|
||||
},
|
||||
required: ['type', 'userId', 'user'],
|
||||
}, {
|
||||
type: 'object',
|
||||
properties: {
|
||||
type: { const: 'followRequestAccepted' },
|
||||
userId: { $ref: 'https://misskey-hub.net/api/schemas/Id' },
|
||||
user: { $ref: 'https://misskey-hub.net/api/schemas/UserLite' },
|
||||
},
|
||||
required: ['type', 'userId', 'user'],
|
||||
}, {
|
||||
type: 'object',
|
||||
properties: {
|
||||
type: { const: 'achievementEarned' },
|
||||
achievement: { enum: [...ACHIEVEMENT_TYPES] },
|
||||
},
|
||||
required: ['type', 'achievement'],
|
||||
}, {
|
||||
type: 'object',
|
||||
properties: {
|
||||
type: { const: 'app' },
|
||||
header: { type: ['string', 'null'] },
|
||||
body: { type: 'string' },
|
||||
icon: { type: ['string', 'null'] },
|
||||
},
|
||||
required: ['type'],
|
||||
}],
|
||||
}],
|
||||
oneOf: [{
|
||||
type: 'object',
|
||||
properties: {
|
||||
type: { const: 'follow' },
|
||||
userId: { $ref: 'https://misskey-hub.net/api/schemas/Id' },
|
||||
user: { $ref: 'https://misskey-hub.net/api/schemas/UserLite' },
|
||||
},
|
||||
required: ['type', 'userId', 'user'],
|
||||
}, {
|
||||
type: 'object',
|
||||
properties: {
|
||||
type: { const: 'mention' },
|
||||
userId: { $ref: 'https://misskey-hub.net/api/schemas/Id' },
|
||||
user: { $ref: 'https://misskey-hub.net/api/schemas/UserLite' },
|
||||
note: { $ref: 'https://misskey-hub.net/api/schemas/Note' },
|
||||
},
|
||||
required: ['type', 'userId', 'user', 'note'],
|
||||
}, {
|
||||
type: 'object',
|
||||
properties: {
|
||||
type: { const: 'reply' },
|
||||
userId: { $ref: 'https://misskey-hub.net/api/schemas/Id' },
|
||||
user: { $ref: 'https://misskey-hub.net/api/schemas/UserLite' },
|
||||
note: { $ref: 'https://misskey-hub.net/api/schemas/Note' },
|
||||
},
|
||||
required: ['type', 'userId', 'user', 'note'],
|
||||
}, {
|
||||
type: 'object',
|
||||
properties: {
|
||||
type: { const: 'renote' },
|
||||
userId: { $ref: 'https://misskey-hub.net/api/schemas/Id' },
|
||||
user: { $ref: 'https://misskey-hub.net/api/schemas/UserLite' },
|
||||
note: { $ref: 'https://misskey-hub.net/api/schemas/Note' },
|
||||
},
|
||||
required: ['type', 'userId', 'user', 'note'],
|
||||
}, {
|
||||
type: 'object',
|
||||
properties: {
|
||||
type: { const: 'quote' },
|
||||
userId: { $ref: 'https://misskey-hub.net/api/schemas/Id' },
|
||||
user: { $ref: 'https://misskey-hub.net/api/schemas/UserLite' },
|
||||
note: { $ref: 'https://misskey-hub.net/api/schemas/Note' },
|
||||
},
|
||||
required: ['type', 'userId', 'user', 'note'],
|
||||
}, {
|
||||
type: 'object',
|
||||
properties: {
|
||||
type: { const: 'reaction' },
|
||||
reaction: { type: 'string' },
|
||||
userId: { $ref: 'https://misskey-hub.net/api/schemas/Id' },
|
||||
user: { $ref: 'https://misskey-hub.net/api/schemas/UserLite' },
|
||||
note: { $ref: 'https://misskey-hub.net/api/schemas/Note' },
|
||||
},
|
||||
required: ['type', 'reaction', 'userId', 'user', 'note'],
|
||||
}, {
|
||||
type: 'object',
|
||||
properties: {
|
||||
type: { const: 'pollEnded' },
|
||||
userId: { $ref: 'https://misskey-hub.net/api/schemas/Id' },
|
||||
user: { $ref: 'https://misskey-hub.net/api/schemas/UserLite' },
|
||||
note: { $ref: 'https://misskey-hub.net/api/schemas/Note' },
|
||||
},
|
||||
required: ['type', 'userId', 'user', 'note'],
|
||||
}, {
|
||||
type: 'object',
|
||||
properties: {
|
||||
type: { const: 'receiveFollowRequest' },
|
||||
userId: { $ref: 'https://misskey-hub.net/api/schemas/Id' },
|
||||
user: { $ref: 'https://misskey-hub.net/api/schemas/UserLite' },
|
||||
},
|
||||
required: ['type', 'userId', 'user'],
|
||||
}, {
|
||||
type: 'object',
|
||||
properties: {
|
||||
type: { const: 'followRequestAccepted' },
|
||||
userId: { $ref: 'https://misskey-hub.net/api/schemas/Id' },
|
||||
user: { $ref: 'https://misskey-hub.net/api/schemas/UserLite' },
|
||||
},
|
||||
required: ['type', 'userId', 'user'],
|
||||
}, {
|
||||
type: 'object',
|
||||
properties: {
|
||||
type: { const: 'achievementEarned' },
|
||||
achievement: { enum: [...ACHIEVEMENT_TYPES] },
|
||||
},
|
||||
required: ['type', 'achievement'],
|
||||
}, {
|
||||
type: 'object',
|
||||
properties: {
|
||||
type: { const: 'app' },
|
||||
header: { type: ['string', 'null'] },
|
||||
body: { type: 'string' },
|
||||
icon: { type: ['string', 'null'] },
|
||||
},
|
||||
required: ['type'],
|
||||
}],
|
||||
},
|
||||
],
|
||||
} as const satisfies JSONSchema7Definition;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue