fix(backend): add missing schemas and fix incorrect schemas (#13295)

* fix(backend): add missing schemas and fix incorrect schemas

* fix: ci

* fix: ci (本命)

* fix: run `pnpm build-misskey-js-with-types`

* fix: typos

* fix: role-condition-formula-value contains `id`

* fix: incorrect schema
This commit is contained in:
zyoshoka
2024-02-16 14:27:33 +09:00
committed by GitHub
parent 147e8f1e3e
commit 40bbae3d6c
31 changed files with 1038 additions and 160 deletions

View File

@@ -37,7 +37,17 @@ import { packedEmojiDetailedSchema, packedEmojiSimpleSchema } from '@/models/jso
import { packedFlashSchema } from '@/models/json-schema/flash.js';
import { packedAnnouncementSchema } from '@/models/json-schema/announcement.js';
import { packedSigninSchema } from '@/models/json-schema/signin.js';
import { packedRoleLiteSchema, packedRoleSchema, packedRolePoliciesSchema } from '@/models/json-schema/role.js';
import {
packedRoleLiteSchema,
packedRoleSchema,
packedRolePoliciesSchema,
packedRoleCondFormulaLogicsSchema,
packedRoleCondFormulaValueNot,
packedRoleCondFormulaValueIsLocalOrRemoteSchema,
packedRoleCondFormulaValueCreatedSchema,
packedRoleCondFormulaFollowersOrFollowingOrNotesSchema,
packedRoleCondFormulaValueSchema,
} from '@/models/json-schema/role.js';
import { packedAdSchema } from '@/models/json-schema/ad.js';
import { packedReversiGameLiteSchema, packedReversiGameDetailedSchema } from '@/models/json-schema/reversi-game.js';
@@ -78,6 +88,12 @@ export const refs = {
EmojiDetailed: packedEmojiDetailedSchema,
Flash: packedFlashSchema,
Signin: packedSigninSchema,
RoleCondFormulaLogics: packedRoleCondFormulaLogicsSchema,
RoleCondFormulaValueNot: packedRoleCondFormulaValueNot,
RoleCondFormulaValueIsLocalOrRemote: packedRoleCondFormulaValueIsLocalOrRemoteSchema,
RoleCondFormulaValueCreated: packedRoleCondFormulaValueCreatedSchema,
RoleCondFormulaFollowersOrFollowingOrNotes: packedRoleCondFormulaFollowersOrFollowingOrNotesSchema,
RoleCondFormulaValue: packedRoleCondFormulaValueSchema,
RoleLite: packedRoleLiteSchema,
Role: packedRoleSchema,
RolePolicies: packedRolePoliciesSchema,

View File

@@ -48,7 +48,7 @@ export class MiBubbleGameRecord {
@Column('jsonb', {
default: [],
})
public logs: any[];
public logs: number[][];
@Column('boolean', {
default: false,

View File

@@ -69,7 +69,7 @@ type CondFormulaValueNotesMoreThanOrEq = {
value: number;
};
export type RoleCondFormulaValue =
export type RoleCondFormulaValue = { id: string } & (
CondFormulaValueAnd |
CondFormulaValueOr |
CondFormulaValueNot |
@@ -82,7 +82,8 @@ export type RoleCondFormulaValue =
CondFormulaValueFollowingLessThanOrEq |
CondFormulaValueFollowingMoreThanOrEq |
CondFormulaValueNotesLessThanOrEq |
CondFormulaValueNotesMoreThanOrEq;
CondFormulaValueNotesMoreThanOrEq
);
@Entity('role')
export class MiRole {

View File

@@ -47,12 +47,12 @@ export const packedReversiGameLiteSchema = {
user1: {
type: 'object',
optional: false, nullable: false,
ref: 'User',
ref: 'UserLite',
},
user2: {
type: 'object',
optional: false, nullable: false,
ref: 'User',
ref: 'UserLite',
},
winnerId: {
type: 'string',
@@ -62,7 +62,7 @@ export const packedReversiGameLiteSchema = {
winner: {
type: 'object',
optional: false, nullable: true,
ref: 'User',
ref: 'UserLite',
},
surrenderedUserId: {
type: 'string',
@@ -165,12 +165,12 @@ export const packedReversiGameDetailedSchema = {
user1: {
type: 'object',
optional: false, nullable: false,
ref: 'User',
ref: 'UserLite',
},
user2: {
type: 'object',
optional: false, nullable: false,
ref: 'User',
ref: 'UserLite',
},
winnerId: {
type: 'string',
@@ -180,7 +180,7 @@ export const packedReversiGameDetailedSchema = {
winner: {
type: 'object',
optional: false, nullable: true,
ref: 'User',
ref: 'UserLite',
},
surrenderedUserId: {
type: 'string',
@@ -226,6 +226,9 @@ export const packedReversiGameDetailedSchema = {
items: {
type: 'array',
optional: false, nullable: false,
items: {
type: 'number',
},
},
},
map: {

View File

@@ -1,3 +1,129 @@
/*
* SPDX-FileCopyrightText: syuilo and misskey-project
* SPDX-License-Identifier: AGPL-3.0-only
*/
export const packedRoleCondFormulaLogicsSchema = {
type: 'object',
properties: {
id: {
type: 'string', optional: false,
},
type: {
type: 'string',
nullable: false, optional: false,
enum: ['and', 'or'],
},
values: {
type: 'array',
nullable: false, optional: false,
items: {
ref: 'RoleCondFormulaValue',
},
},
},
} as const;
export const packedRoleCondFormulaValueNot = {
type: 'object',
properties: {
id: {
type: 'string', optional: false,
},
type: {
type: 'string',
nullable: false, optional: false,
enum: ['not'],
},
value: {
type: 'object',
optional: false,
ref: 'RoleCondFormulaValue',
},
},
} as const;
export const packedRoleCondFormulaValueIsLocalOrRemoteSchema = {
type: 'object',
properties: {
id: {
type: 'string', optional: false,
},
type: {
type: 'string',
nullable: false, optional: false,
enum: ['isLocal', 'isRemote'],
},
},
} as const;
export const packedRoleCondFormulaValueCreatedSchema = {
type: 'object',
properties: {
id: {
type: 'string', optional: false,
},
type: {
type: 'string',
nullable: false, optional: false,
enum: [
'createdLessThan',
'createdMoreThan',
],
},
sec: {
type: 'number',
nullable: false, optional: false,
},
},
} as const;
export const packedRoleCondFormulaFollowersOrFollowingOrNotesSchema = {
type: 'object',
properties: {
id: {
type: 'string', optional: false,
},
type: {
type: 'string',
nullable: false, optional: false,
enum: [
'followersLessThanOrEq',
'followersMoreThanOrEq',
'followingLessThanOrEq',
'followingMoreThanOrEq',
'notesLessThanOrEq',
'notesMoreThanOrEq',
],
},
value: {
type: 'number',
nullable: false, optional: false,
},
},
} as const;
export const packedRoleCondFormulaValueSchema = {
type: 'object',
oneOf: [
{
ref: 'RoleCondFormulaLogics',
},
{
ref: 'RoleCondFormulaValueNot',
},
{
ref: 'RoleCondFormulaValueIsLocalOrRemote',
},
{
ref: 'RoleCondFormulaValueCreated',
},
{
ref: 'RoleCondFormulaFollowersOrFollowingOrNotes',
},
],
} as const;
export const packedRolePoliciesSchema = {
type: 'object',
optional: false, nullable: false,
@@ -174,6 +300,7 @@ export const packedRoleSchema = {
condFormula: {
type: 'object',
optional: false, nullable: false,
ref: 'RoleCondFormulaValue',
},
isPublic: {
type: 'boolean',

View File

@@ -3,16 +3,38 @@
* SPDX-License-Identifier: AGPL-3.0-only
*/
const notificationRecieveConfig = {
export const notificationRecieveConfig = {
type: 'object',
nullable: false, optional: true,
properties: {
type: {
type: 'string',
nullable: false, optional: false,
enum: ['all', 'following', 'follower', 'mutualFollow', 'list', 'never'],
oneOf: [
{
type: 'object',
nullable: false,
properties: {
type: {
type: 'string',
nullable: false,
enum: ['all', 'following', 'follower', 'mutualFollow', 'never'],
},
},
required: ['type'],
},
},
{
type: 'object',
nullable: false,
properties: {
type: {
type: 'string',
nullable: false,
enum: ['list'],
},
userListId: {
type: 'string',
format: 'misskey:id',
},
},
required: ['type', 'userListId'],
},
],
} as const;
export const packedUserLiteSchema = {
@@ -546,15 +568,20 @@ export const packedMeDetailedOnlySchema = {
type: 'object',
nullable: false, optional: false,
properties: {
app: notificationRecieveConfig,
quote: notificationRecieveConfig,
reply: notificationRecieveConfig,
follow: notificationRecieveConfig,
renote: notificationRecieveConfig,
mention: notificationRecieveConfig,
reaction: notificationRecieveConfig,
pollEnded: notificationRecieveConfig,
receiveFollowRequest: notificationRecieveConfig,
note: { optional: true, ...notificationRecieveConfig },
follow: { optional: true, ...notificationRecieveConfig },
mention: { optional: true, ...notificationRecieveConfig },
reply: { optional: true, ...notificationRecieveConfig },
renote: { optional: true, ...notificationRecieveConfig },
quote: { optional: true, ...notificationRecieveConfig },
reaction: { optional: true, ...notificationRecieveConfig },
pollEnded: { optional: true, ...notificationRecieveConfig },
receiveFollowRequest: { optional: true, ...notificationRecieveConfig },
followRequestAccepted: { optional: true, ...notificationRecieveConfig },
roleAssigned: { optional: true, ...notificationRecieveConfig },
achievementEarned: { optional: true, ...notificationRecieveConfig },
app: { optional: true, ...notificationRecieveConfig },
test: { optional: true, ...notificationRecieveConfig },
},
},
emailNotificationTypes: {

View File

@@ -15,9 +15,6 @@ export const meta = {
requireCredential: true,
requireAdmin: true,
kind: 'write:admin:delete-account',
res: {
},
} as const;
export const paramDef = {

View File

@@ -84,6 +84,24 @@ export const meta = {
properties: {
type: 'object',
optional: false, nullable: false,
properties: {
width: {
type: 'number',
optional: true, nullable: false,
},
height: {
type: 'number',
optional: true, nullable: false,
},
orientation: {
type: 'number',
optional: true, nullable: false,
},
avgColor: {
type: 'string',
optional: true, nullable: false,
},
},
},
storedInternal: {
type: 'boolean',

View File

@@ -18,6 +18,18 @@ export const meta = {
res: {
type: 'object',
optional: false, nullable: false,
additionalProperties: {
type: 'object',
properties: {
count: {
type: 'number',
},
size: {
type: 'number',
},
},
required: ['count', 'size'],
},
example: {
migrations: {
count: 66,

View File

@@ -10,6 +10,7 @@ import { DI } from '@/di-symbols.js';
import { RoleService } from '@/core/RoleService.js';
import { RoleEntityService } from '@/core/entities/RoleEntityService.js';
import { IdService } from '@/core/IdService.js';
import { notificationRecieveConfig } from '@/models/json-schema/user.js';
export const meta = {
tags: ['admin'],
@@ -21,6 +22,157 @@ export const meta = {
res: {
type: 'object',
nullable: false, optional: false,
properties: {
email: {
type: 'string',
optional: false, nullable: true,
},
emailVerified: {
type: 'boolean',
optional: false, nullable: false,
},
autoAcceptFollowed: {
type: 'boolean',
optional: false, nullable: false,
},
noCrawle: {
type: 'boolean',
optional: false, nullable: false,
},
preventAiLearning: {
type: 'boolean',
optional: false, nullable: false,
},
alwaysMarkNsfw: {
type: 'boolean',
optional: false, nullable: false,
},
autoSensitive: {
type: 'boolean',
optional: false, nullable: false,
},
carefulBot: {
type: 'boolean',
optional: false, nullable: false,
},
injectFeaturedNote: {
type: 'boolean',
optional: false, nullable: false,
},
receiveAnnouncementEmail: {
type: 'boolean',
optional: false, nullable: false,
},
mutedWords: {
type: 'array',
optional: false, nullable: false,
items: {
anyOf: [
{
type: 'string',
},
{
type: 'array',
items: {
type: 'string',
},
},
],
},
},
mutedInstances: {
type: 'array',
optional: false, nullable: false,
items: {
type: 'string',
},
},
notificationRecieveConfig: {
type: 'object',
optional: false, nullable: false,
properties: {
note: { optional: true, ...notificationRecieveConfig },
follow: { optional: true, ...notificationRecieveConfig },
mention: { optional: true, ...notificationRecieveConfig },
reply: { optional: true, ...notificationRecieveConfig },
renote: { optional: true, ...notificationRecieveConfig },
quote: { optional: true, ...notificationRecieveConfig },
reaction: { optional: true, ...notificationRecieveConfig },
pollEnded: { optional: true, ...notificationRecieveConfig },
receiveFollowRequest: { optional: true, ...notificationRecieveConfig },
followRequestAccepted: { optional: true, ...notificationRecieveConfig },
roleAssigned: { optional: true, ...notificationRecieveConfig },
achievementEarned: { optional: true, ...notificationRecieveConfig },
app: { optional: true, ...notificationRecieveConfig },
test: { optional: true, ...notificationRecieveConfig },
},
},
isModerator: {
type: 'boolean',
optional: false, nullable: false,
},
isSilenced: {
type: 'boolean',
optional: false, nullable: false,
},
isSuspended: {
type: 'boolean',
optional: false, nullable: false,
},
isHibernated: {
type: 'boolean',
optional: false, nullable: false,
},
lastActiveDate: {
type: 'string',
optional: false, nullable: true,
},
moderationNote: {
type: 'string',
optional: false, nullable: false,
},
signins: {
type: 'array',
optional: false, nullable: false,
items: {
ref: 'Signin',
},
},
policies: {
type: 'object',
optional: false, nullable: false,
ref: 'RolePolicies',
},
roles: {
type: 'array',
optional: false, nullable: false,
items: {
type: 'object',
ref: 'Role',
},
},
roleAssigns: {
type: 'array',
optional: false, nullable: false,
items: {
type: 'object',
properties: {
createdAt: {
type: 'string',
optional: false, nullable: false,
},
expiresAt: {
type: 'string',
optional: false, nullable: true,
},
roleId: {
type: 'string',
optional: false, nullable: false,
},
},
},
},
},
},
} as const;
@@ -89,7 +241,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
isSilenced: isSilenced,
isSuspended: user.isSuspended,
isHibernated: user.isHibernated,
lastActiveDate: user.lastActiveDate,
lastActiveDate: user.lastActiveDate ? user.lastActiveDate.toISOString() : null,
moderationNote: profile.moderationNote ?? '',
signins,
policies: await this.roleService.getUserPolicies(user.id),

View File

@@ -24,9 +24,19 @@ export const meta = {
type: 'object',
optional: false, nullable: false,
properties: {
id: { type: 'string', format: 'misskey:id' },
score: { type: 'integer' },
user: { ref: 'UserLite' },
id: {
type: 'string', format: 'misskey:id',
optional: false, nullable: false,
},
score: {
type: 'integer',
optional: false, nullable: false,
},
user: {
type: 'object',
optional: true, nullable: false,
ref: 'UserLite',
},
},
},
},

View File

@@ -29,9 +29,6 @@ export const meta = {
id: 'eb627bc7-574b-4a52-a860-3c3eae772b88',
},
},
res: {
},
} as const;
export const paramDef = {
@@ -39,7 +36,15 @@ export const paramDef = {
properties: {
score: { type: 'integer', minimum: 0 },
seed: { type: 'string', minLength: 1, maxLength: 1024 },
logs: { type: 'array' },
logs: {
type: 'array',
items: {
type: 'array',
items: {
type: 'number',
},
},
},
gameMode: { type: 'string' },
gameVersion: { type: 'integer' },
},

View File

@@ -15,6 +15,19 @@ export const meta = {
requireCredential: true,
secure: true,
res: {
type: 'object',
properties: {
backupCodes: {
type: 'array',
optional: false,
items: {
type: 'string',
},
},
},
},
} as const;
export const paramDef = {

View File

@@ -47,7 +47,7 @@ export const meta = {
properties: {
id: {
type: 'string',
nullable: true,
optional: true,
},
},
},

View File

@@ -21,26 +21,31 @@ export const meta = {
properties: {
id: {
type: 'string',
optional: false,
format: 'misskey:id',
},
name: {
type: 'string',
optional: true,
},
createdAt: {
type: 'string',
optional: false,
format: 'date-time',
},
lastUsedAt: {
type: 'string',
optional: true,
format: 'date-time',
},
permission: {
type: 'array',
optional: false,
uniqueItems: true,
items: {
type: 'string'
type: 'string',
},
}
},
},
},
},

View File

@@ -23,23 +23,27 @@ export const meta = {
id: {
type: 'string',
format: 'misskey:id',
optional: false,
},
name: {
type: 'string',
optional: false,
},
callbackUrl: {
type: 'string',
nullable: true,
optional: false, nullable: true,
},
permission: {
type: 'array',
optional: false,
uniqueItems: true,
items: {
type: 'string'
type: 'string',
},
},
isAuthorized: {
type: 'boolean',
optional: true,
},
},
},

View File

@@ -22,7 +22,16 @@ export const meta = {
res: {
type: 'object',
}
properties: {
updatedAt: {
type: 'string',
optional: false,
},
value: {
optional: false,
},
},
},
} as const;
export const paramDef = {
@@ -50,7 +59,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
}
return {
updatedAt: item.updatedAt,
updatedAt: item.updatedAt.toISOString(),
value: item.value,
};
});

View File

@@ -13,6 +13,9 @@ export const meta = {
res: {
type: 'object',
additionalProperties: {
type: 'string',
},
},
} as const;

View File

@@ -10,6 +10,13 @@ import { RegistryApiService } from '@/core/RegistryApiService.js';
export const meta = {
requireCredential: true,
kind: 'read:account',
res: {
type: 'array',
items: {
type: 'string',
},
},
} as const;
export const paramDef = {

View File

@@ -33,6 +33,7 @@ import { HttpRequestService } from '@/core/HttpRequestService.js';
import type { Config } from '@/config.js';
import { safeForSql } from '@/misc/safe-for-sql.js';
import { AvatarDecorationService } from '@/core/AvatarDecorationService.js';
import { notificationRecieveConfig } from '@/models/json-schema/user.js';
import { ApiLoggerService } from '../../ApiLoggerService.js';
import { ApiError } from '../../error.js';
@@ -184,7 +185,26 @@ export const paramDef = {
mutedInstances: { type: 'array', items: {
type: 'string',
} },
notificationRecieveConfig: { type: 'object' },
notificationRecieveConfig: {
type: 'object',
nullable: false,
properties: {
note: notificationRecieveConfig,
follow: notificationRecieveConfig,
mention: notificationRecieveConfig,
reply: notificationRecieveConfig,
renote: notificationRecieveConfig,
quote: notificationRecieveConfig,
reaction: notificationRecieveConfig,
pollEnded: notificationRecieveConfig,
receiveFollowRequest: notificationRecieveConfig,
followRequestAccepted: notificationRecieveConfig,
roleAssigned: notificationRecieveConfig,
achievementEarned: notificationRecieveConfig,
app: notificationRecieveConfig,
test: notificationRecieveConfig,
},
},
emailNotificationTypes: { type: 'array', items: {
type: 'string',
} },

View File

@@ -33,7 +33,7 @@ export const meta = {
properties: {
id: {
type: 'string',
format: 'misskey:id'
format: 'misskey:id',
},
userId: {
type: 'string',
@@ -45,7 +45,7 @@ export const meta = {
items: {
type: 'string',
enum: webhookEventTypes,
}
},
},
url: { type: 'string' },
secret: { type: 'string' },
@@ -108,7 +108,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
url: webhook.url,
secret: webhook.secret,
active: webhook.active,
latestSentAt: webhook.latestSentAt?.toISOString(),
latestSentAt: webhook.latestSentAt ? webhook.latestSentAt.toISOString() : null,
latestStatus: webhook.latestStatus,
};
});

View File

@@ -23,7 +23,7 @@ export const meta = {
properties: {
id: {
type: 'string',
format: 'misskey:id'
format: 'misskey:id',
},
userId: {
type: 'string',
@@ -35,7 +35,7 @@ export const meta = {
items: {
type: 'string',
enum: webhookEventTypes,
}
},
},
url: { type: 'string' },
secret: { type: 'string' },
@@ -43,8 +43,8 @@ export const meta = {
latestSentAt: { type: 'string', format: 'date-time', nullable: true },
latestStatus: { type: 'integer', nullable: true },
},
}
}
},
},
} as const;
export const paramDef = {
@@ -73,7 +73,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
url: webhook.url,
secret: webhook.secret,
active: webhook.active,
latestSentAt: webhook.latestSentAt?.toISOString(),
latestSentAt: webhook.latestSentAt ? webhook.latestSentAt.toISOString() : null,
latestStatus: webhook.latestStatus,
}
));

View File

@@ -30,7 +30,7 @@ export const meta = {
properties: {
id: {
type: 'string',
format: 'misskey:id'
format: 'misskey:id',
},
userId: {
type: 'string',
@@ -42,7 +42,7 @@ export const meta = {
items: {
type: 'string',
enum: webhookEventTypes,
}
},
},
url: { type: 'string' },
secret: { type: 'string' },
@@ -85,7 +85,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
url: webhook.url,
secret: webhook.secret,
active: webhook.active,
latestSentAt: webhook.latestSentAt?.toISOString(),
latestSentAt: webhook.latestSentAt ? webhook.latestSentAt.toISOString() : null,
latestStatus: webhook.latestStatus,
};
});

View File

@@ -14,9 +14,6 @@ export const meta = {
errors: {
},
res: {
},
} as const;
export const paramDef = {

View File

@@ -30,6 +30,9 @@ export const meta = {
},
res: {
type: 'object',
optional: true,
ref: 'ReversiGameDetailed',
},
} as const;

View File

@@ -18,24 +18,28 @@ export const meta = {
properties: {
id: {
type: 'string',
format: 'misskey:id'
format: 'misskey:id',
optional: true, nullable: false,
},
required: {
type: 'boolean',
optional: false, nullable: false,
},
string: {
type: 'string',
optional: true, nullable: false,
},
default: {
type: 'string',
optional: true, nullable: false,
},
nullableDefault: {
type: 'string',
default: 'hello',
nullable: true,
optional: true, nullable: true,
},
}
}
},
},
} as const;
export const paramDef = {