diff --git a/packages/backend/src/misc/json-schema.ts b/packages/backend/src/misc/json-schema.ts index 7e7fc447c..49f35b9b7 100644 --- a/packages/backend/src/misc/json-schema.ts +++ b/packages/backend/src/misc/json-schema.ts @@ -37,6 +37,7 @@ 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 } from '@/models/json-schema/role.js'; export const refs = { UserLite: packedUserLiteSchema, @@ -73,6 +74,8 @@ export const refs = { EmojiDetailed: packedEmojiDetailedSchema, Flash: packedFlashSchema, Signin: packedSigninSchema, + RoleLite: packedRoleLiteSchema, + Role: packedRoleSchema, }; export type Packed = SchemaType; diff --git a/packages/backend/src/models/json-schema/role.ts b/packages/backend/src/models/json-schema/role.ts new file mode 100644 index 000000000..dd2f32b14 --- /dev/null +++ b/packages/backend/src/models/json-schema/role.ts @@ -0,0 +1,157 @@ +const rolePolicyValue = { + type: 'object', + properties: { + value: { + oneOf: [ + { + type: 'integer', + optional: false, nullable: false, + }, + { + type: 'boolean', + optional: false, nullable: false, + }, + ], + }, + priority: { + type: 'integer', + optional: false, nullable: false, + }, + useDefault: { + type: 'boolean', + optional: false, nullable: false, + }, + }, +} as const; + +export const packedRoleLiteSchema = { + type: 'object', + properties: { + id: { + type: 'string', + optional: false, nullable: false, + format: 'id', + example: 'xxxxxxxxxx', + }, + name: { + type: 'string', + optional: false, nullable: false, + example: 'New Role', + }, + color: { + type: 'string', + optional: false, nullable: true, + example: '#000000', + }, + iconUrl: { + type: 'string', + optional: false, nullable: true, + }, + description: { + type: 'string', + optional: false, nullable: false, + }, + isModerator: { + type: 'boolean', + optional: false, nullable: false, + example: false, + }, + isAdministrator: { + type: 'boolean', + optional: false, nullable: false, + example: false, + }, + displayOrder: { + type: 'integer', + optional: false, nullable: false, + example: 0, + }, + }, +} as const; + +export const packedRoleSchema = { + type: 'object', + allOf: [ + { + type: 'object', + ref: 'RoleLite', + }, + { + type: 'object', + properties: { + createdAt: { + type: 'string', + optional: false, nullable: false, + format: 'date-time', + }, + updatedAt: { + type: 'string', + optional: false, nullable: false, + format: 'date-time', + }, + target: { + type: 'string', + optional: false, nullable: false, + enum: ['manual', 'conditional'], + }, + condFormula: { + type: 'object', + optional: false, nullable: false, + }, + isPublic: { + type: 'boolean', + optional: false, nullable: false, + example: false, + }, + isExplorable: { + type: 'boolean', + optional: false, nullable: false, + example: false, + }, + asBadge: { + type: 'boolean', + optional: false, nullable: false, + example: false, + }, + canEditMembersByModerator: { + type: 'boolean', + optional: false, nullable: false, + example: false, + }, + policies: { + type: 'object', + optional: false, nullable: false, + properties: { + pinLimit: rolePolicyValue, + canInvite: rolePolicyValue, + clipLimit: rolePolicyValue, + canHideAds: rolePolicyValue, + inviteLimit: rolePolicyValue, + antennaLimit: rolePolicyValue, + gtlAvailable: rolePolicyValue, + ltlAvailable: rolePolicyValue, + webhookLimit: rolePolicyValue, + canPublicNote: rolePolicyValue, + userListLimit: rolePolicyValue, + wordMuteLimit: rolePolicyValue, + alwaysMarkNsfw: rolePolicyValue, + canSearchNotes: rolePolicyValue, + driveCapacityMb: rolePolicyValue, + rateLimitFactor: rolePolicyValue, + inviteLimitCycle: rolePolicyValue, + noteEachClipsLimit: rolePolicyValue, + inviteExpirationTime: rolePolicyValue, + canManageCustomEmojis: rolePolicyValue, + userEachUserListsLimit: rolePolicyValue, + canManageAvatarDecorations: rolePolicyValue, + canUseTranslator: rolePolicyValue, + }, + }, + usersCount: { + type: 'integer', + optional: false, nullable: false, + }, + }, + }, + ], +} as const; diff --git a/packages/backend/src/models/json-schema/user.ts b/packages/backend/src/models/json-schema/user.ts index 2621e7e6c..c6b2707b8 100644 --- a/packages/backend/src/models/json-schema/user.ts +++ b/packages/backend/src/models/json-schema/user.ts @@ -329,41 +329,7 @@ export const packedUserDetailedNotMeOnlySchema = { items: { type: 'object', nullable: false, optional: false, - properties: { - id: { - type: 'string', - nullable: false, optional: false, - format: 'id', - }, - name: { - type: 'string', - nullable: false, optional: false, - }, - color: { - type: 'string', - nullable: true, optional: false, - }, - iconUrl: { - type: 'string', - nullable: true, optional: false, - }, - description: { - type: 'string', - nullable: false, optional: false, - }, - isModerator: { - type: 'boolean', - nullable: false, optional: false, - }, - isAdministrator: { - type: 'boolean', - nullable: false, optional: false, - }, - displayOrder: { - type: 'number', - nullable: false, optional: false, - }, - }, + ref: 'RoleLite', }, }, memo: { diff --git a/packages/backend/src/server/api/endpoints/admin/roles/create.ts b/packages/backend/src/server/api/endpoints/admin/roles/create.ts index 8451b1955..fb5381533 100644 --- a/packages/backend/src/server/api/endpoints/admin/roles/create.ts +++ b/packages/backend/src/server/api/endpoints/admin/roles/create.ts @@ -13,6 +13,12 @@ export const meta = { requireCredential: true, requireAdmin: true, + + res: { + type: 'object', + optional: false, nullable: false, + ref: 'Role', + }, } as const; export const paramDef = { diff --git a/packages/backend/src/server/api/endpoints/admin/roles/list.ts b/packages/backend/src/server/api/endpoints/admin/roles/list.ts index 3ed4b324d..71b8e44e7 100644 --- a/packages/backend/src/server/api/endpoints/admin/roles/list.ts +++ b/packages/backend/src/server/api/endpoints/admin/roles/list.ts @@ -14,6 +14,16 @@ export const meta = { requireCredential: true, requireModerator: true, + + res: { + type: 'array', + optional: false, nullable: false, + items: { + type: 'object', + optional: false, nullable: false, + ref: 'Role', + }, + }, } as const; export const paramDef = { diff --git a/packages/backend/src/server/api/endpoints/admin/roles/show.ts b/packages/backend/src/server/api/endpoints/admin/roles/show.ts index 5f0accab6..1ca952a3f 100644 --- a/packages/backend/src/server/api/endpoints/admin/roles/show.ts +++ b/packages/backend/src/server/api/endpoints/admin/roles/show.ts @@ -23,6 +23,12 @@ export const meta = { id: '07dc7d34-c0d8-49b7-96c6-db3ce64ee0b3', }, }, + + res: { + type: 'object', + optional: false, nullable: false, + ref: 'Role', + }, } as const; export const paramDef = { diff --git a/packages/backend/src/server/api/endpoints/roles/list.ts b/packages/backend/src/server/api/endpoints/roles/list.ts index d1de73ad3..dc2be8e11 100644 --- a/packages/backend/src/server/api/endpoints/roles/list.ts +++ b/packages/backend/src/server/api/endpoints/roles/list.ts @@ -13,6 +13,16 @@ export const meta = { tags: ['role'], requireCredential: true, + + res: { + type: 'array', + optional: false, nullable: false, + items: { + type: 'object', + optional: false, nullable: false, + ref: 'Role', + }, + }, } as const; export const paramDef = { diff --git a/packages/backend/src/server/api/endpoints/roles/show.ts b/packages/backend/src/server/api/endpoints/roles/show.ts index 2afa0e7b7..6bfe52bb1 100644 --- a/packages/backend/src/server/api/endpoints/roles/show.ts +++ b/packages/backend/src/server/api/endpoints/roles/show.ts @@ -22,6 +22,12 @@ export const meta = { id: 'de5502bf-009a-4639-86c1-fec349e46dcb', }, }, + + res: { + type: 'object', + optional: false, nullable: false, + ref: 'Role', + }, } as const; export const paramDef = { diff --git a/packages/misskey-js/etc/misskey-js.api.md b/packages/misskey-js/etc/misskey-js.api.md index e2e3349c0..6225f9e23 100644 --- a/packages/misskey-js/etc/misskey-js.api.md +++ b/packages/misskey-js/etc/misskey-js.api.md @@ -227,12 +227,21 @@ type AdminRolesAssignRequest = operations['admin/roles/assign']['requestBody'][' // @public (undocumented) type AdminRolesCreateRequest = operations['admin/roles/create']['requestBody']['content']['application/json']; +// @public (undocumented) +type AdminRolesCreateResponse = operations['admin/roles/create']['responses']['200']['content']['application/json']; + // @public (undocumented) type AdminRolesDeleteRequest = operations['admin/roles/delete']['requestBody']['content']['application/json']; +// @public (undocumented) +type AdminRolesListResponse = operations['admin/roles/list']['responses']['200']['content']['application/json']; + // @public (undocumented) type AdminRolesShowRequest = operations['admin/roles/show']['requestBody']['content']['application/json']; +// @public (undocumented) +type AdminRolesShowResponse = operations['admin/roles/show']['responses']['200']['content']['application/json']; + // @public (undocumented) type AdminRolesUnassignRequest = operations['admin/roles/unassign']['requestBody']['content']['application/json']; @@ -1099,8 +1108,11 @@ declare namespace entities { AdminDeleteAccountResponse, AdminUpdateUserNoteRequest, AdminRolesCreateRequest, + AdminRolesCreateResponse, AdminRolesDeleteRequest, + AdminRolesListResponse, AdminRolesShowRequest, + AdminRolesShowResponse, AdminRolesUpdateRequest, AdminRolesAssignRequest, AdminRolesUnassignRequest, @@ -1414,7 +1426,9 @@ declare namespace entities { PingResponse, PinnedUsersResponse, PromoReadRequest, + RolesListResponse, RolesShowRequest, + RolesShowResponse, RolesUsersRequest, RolesNotesRequest, RolesNotesResponse, @@ -1519,7 +1533,9 @@ declare namespace entities { EmojiSimple, EmojiDetailed, Flash, - Signin + Signin, + RoleLite, + Role } } export { entities } @@ -2312,6 +2328,15 @@ type ResetPasswordRequest = operations['reset-password']['requestBody']['content // @public (undocumented) type RetentionResponse = operations['retention']['responses']['200']['content']['application/json']; +// @public (undocumented) +type Role = components['schemas']['Role']; + +// @public (undocumented) +type RoleLite = components['schemas']['RoleLite']; + +// @public (undocumented) +type RolesListResponse = operations['roles/list']['responses']['200']['content']['application/json']; + // @public (undocumented) type RolesNotesRequest = operations['roles/notes']['requestBody']['content']['application/json']; @@ -2321,6 +2346,9 @@ type RolesNotesResponse = operations['roles/notes']['responses']['200']['content // @public (undocumented) type RolesShowRequest = operations['roles/show']['requestBody']['content']['application/json']; +// @public (undocumented) +type RolesShowResponse = operations['roles/show']['responses']['200']['content']['application/json']; + // @public (undocumented) type RolesUsersRequest = operations['roles/users']['requestBody']['content']['application/json']; diff --git a/packages/misskey-js/src/autogen/endpoint.ts b/packages/misskey-js/src/autogen/endpoint.ts index cf571fc68..89faea6b4 100644 --- a/packages/misskey-js/src/autogen/endpoint.ts +++ b/packages/misskey-js/src/autogen/endpoint.ts @@ -1,6 +1,6 @@ /* * version: 2023.12.0-beta.1 - * generatedAt: 2023-12-04T07:13:58.541Z + * generatedAt: 2023-12-04T11:17:52.156Z */ import type { @@ -87,8 +87,11 @@ import type { AdminDeleteAccountResponse, AdminUpdateUserNoteRequest, AdminRolesCreateRequest, + AdminRolesCreateResponse, AdminRolesDeleteRequest, + AdminRolesListResponse, AdminRolesShowRequest, + AdminRolesShowResponse, AdminRolesUpdateRequest, AdminRolesAssignRequest, AdminRolesUnassignRequest, @@ -402,7 +405,9 @@ import type { PingResponse, PinnedUsersResponse, PromoReadRequest, + RolesListResponse, RolesShowRequest, + RolesShowResponse, RolesUsersRequest, RolesNotesRequest, RolesNotesResponse, @@ -543,10 +548,10 @@ export type Endpoints = { 'admin/update-meta': { req: AdminUpdateMetaRequest; res: EmptyResponse }; 'admin/delete-account': { req: AdminDeleteAccountRequest; res: AdminDeleteAccountResponse }; 'admin/update-user-note': { req: AdminUpdateUserNoteRequest; res: EmptyResponse }; - 'admin/roles/create': { req: AdminRolesCreateRequest; res: EmptyResponse }; + 'admin/roles/create': { req: AdminRolesCreateRequest; res: AdminRolesCreateResponse }; 'admin/roles/delete': { req: AdminRolesDeleteRequest; res: EmptyResponse }; - 'admin/roles/list': { req: EmptyRequest; res: EmptyResponse }; - 'admin/roles/show': { req: AdminRolesShowRequest; res: EmptyResponse }; + 'admin/roles/list': { req: EmptyRequest; res: AdminRolesListResponse }; + 'admin/roles/show': { req: AdminRolesShowRequest; res: AdminRolesShowResponse }; 'admin/roles/update': { req: AdminRolesUpdateRequest; res: EmptyResponse }; 'admin/roles/assign': { req: AdminRolesAssignRequest; res: EmptyResponse }; 'admin/roles/unassign': { req: AdminRolesUnassignRequest; res: EmptyResponse }; @@ -750,8 +755,8 @@ export type Endpoints = { 'ping': { req: EmptyRequest; res: PingResponse }; 'pinned-users': { req: EmptyRequest; res: PinnedUsersResponse }; 'promo/read': { req: PromoReadRequest; res: EmptyResponse }; - 'roles/list': { req: EmptyRequest; res: EmptyResponse }; - 'roles/show': { req: RolesShowRequest; res: EmptyResponse }; + 'roles/list': { req: EmptyRequest; res: RolesListResponse }; + 'roles/show': { req: RolesShowRequest; res: RolesShowResponse }; 'roles/users': { req: RolesUsersRequest; res: EmptyResponse }; 'roles/notes': { req: RolesNotesRequest; res: RolesNotesResponse }; 'request-reset-password': { req: RequestResetPasswordRequest; res: EmptyResponse }; diff --git a/packages/misskey-js/src/autogen/entities.ts b/packages/misskey-js/src/autogen/entities.ts index bbfa14913..611f1b950 100644 --- a/packages/misskey-js/src/autogen/entities.ts +++ b/packages/misskey-js/src/autogen/entities.ts @@ -1,6 +1,6 @@ /* * version: 2023.12.0-beta.1 - * generatedAt: 2023-12-04T07:13:58.538Z + * generatedAt: 2023-12-04T11:17:52.154Z */ import { operations } from './types.js'; @@ -89,8 +89,11 @@ export type AdminDeleteAccountRequest = operations['admin/delete-account']['requ export type AdminDeleteAccountResponse = operations['admin/delete-account']['responses']['200']['content']['application/json']; export type AdminUpdateUserNoteRequest = operations['admin/update-user-note']['requestBody']['content']['application/json']; export type AdminRolesCreateRequest = operations['admin/roles/create']['requestBody']['content']['application/json']; +export type AdminRolesCreateResponse = operations['admin/roles/create']['responses']['200']['content']['application/json']; export type AdminRolesDeleteRequest = operations['admin/roles/delete']['requestBody']['content']['application/json']; +export type AdminRolesListResponse = operations['admin/roles/list']['responses']['200']['content']['application/json']; export type AdminRolesShowRequest = operations['admin/roles/show']['requestBody']['content']['application/json']; +export type AdminRolesShowResponse = operations['admin/roles/show']['responses']['200']['content']['application/json']; export type AdminRolesUpdateRequest = operations['admin/roles/update']['requestBody']['content']['application/json']; export type AdminRolesAssignRequest = operations['admin/roles/assign']['requestBody']['content']['application/json']; export type AdminRolesUnassignRequest = operations['admin/roles/unassign']['requestBody']['content']['application/json']; @@ -404,7 +407,9 @@ export type FlashMyLikesResponse = operations['flash/my-likes']['responses']['20 export type PingResponse = operations['ping']['responses']['200']['content']['application/json']; export type PinnedUsersResponse = operations['pinned-users']['responses']['200']['content']['application/json']; export type PromoReadRequest = operations['promo/read']['requestBody']['content']['application/json']; +export type RolesListResponse = operations['roles/list']['responses']['200']['content']['application/json']; export type RolesShowRequest = operations['roles/show']['requestBody']['content']['application/json']; +export type RolesShowResponse = operations['roles/show']['responses']['200']['content']['application/json']; export type RolesUsersRequest = operations['roles/users']['requestBody']['content']['application/json']; export type RolesNotesRequest = operations['roles/notes']['requestBody']['content']['application/json']; export type RolesNotesResponse = operations['roles/notes']['responses']['200']['content']['application/json']; diff --git a/packages/misskey-js/src/autogen/models.ts b/packages/misskey-js/src/autogen/models.ts index 566b6dfb9..0607cd137 100644 --- a/packages/misskey-js/src/autogen/models.ts +++ b/packages/misskey-js/src/autogen/models.ts @@ -1,6 +1,6 @@ /* * version: 2023.12.0-beta.1 - * generatedAt: 2023-12-04T07:13:58.535Z + * generatedAt: 2023-12-04T11:17:52.151Z */ import { components } from './types.js'; @@ -38,3 +38,5 @@ export type EmojiSimple = components['schemas']['EmojiSimple']; export type EmojiDetailed = components['schemas']['EmojiDetailed']; export type Flash = components['schemas']['Flash']; export type Signin = components['schemas']['Signin']; +export type RoleLite = components['schemas']['RoleLite']; +export type Role = components['schemas']['Role']; diff --git a/packages/misskey-js/src/autogen/types.ts b/packages/misskey-js/src/autogen/types.ts index b734b36e4..e09f24d46 100644 --- a/packages/misskey-js/src/autogen/types.ts +++ b/packages/misskey-js/src/autogen/types.ts @@ -3,7 +3,7 @@ /* * version: 2023.12.0-beta.1 - * generatedAt: 2023-12-04T07:13:58.362Z + * generatedAt: 2023-12-04T11:17:51.997Z */ /** @@ -3197,17 +3197,7 @@ export type components = { usePasswordLessLogin: boolean; /** @default false */ securityKeys: boolean; - roles: ({ - /** Format: id */ - id: string; - name: string; - color: string | null; - iconUrl: string | null; - description: string; - isModerator: boolean; - isAdministrator: boolean; - displayOrder: number; - })[]; + roles: components['schemas']['RoleLite'][]; memo: string | null; moderationNote?: string; isFollowing?: boolean; @@ -3850,6 +3840,160 @@ export type components = { headers: Record; success: boolean; }; + RoleLite: { + /** + * Format: id + * @example xxxxxxxxxx + */ + id: string; + /** @example New Role */ + name: string; + /** @example #000000 */ + color: string | null; + iconUrl: string | null; + description: string; + /** @example false */ + isModerator: boolean; + /** @example false */ + isAdministrator: boolean; + /** @example 0 */ + displayOrder: number; + }; + Role: components['schemas']['RoleLite'] & ({ + /** Format: date-time */ + createdAt: string; + /** Format: date-time */ + updatedAt: string; + /** @enum {string} */ + target: 'manual' | 'conditional'; + condFormula: Record; + /** @example false */ + isPublic: boolean; + /** @example false */ + isExplorable: boolean; + /** @example false */ + asBadge: boolean; + /** @example false */ + canEditMembersByModerator: boolean; + policies: { + pinLimit: { + value: number | boolean; + priority: number; + useDefault: boolean; + }; + canInvite: { + value: number | boolean; + priority: number; + useDefault: boolean; + }; + clipLimit: { + value: number | boolean; + priority: number; + useDefault: boolean; + }; + canHideAds: { + value: number | boolean; + priority: number; + useDefault: boolean; + }; + inviteLimit: { + value: number | boolean; + priority: number; + useDefault: boolean; + }; + antennaLimit: { + value: number | boolean; + priority: number; + useDefault: boolean; + }; + gtlAvailable: { + value: number | boolean; + priority: number; + useDefault: boolean; + }; + ltlAvailable: { + value: number | boolean; + priority: number; + useDefault: boolean; + }; + webhookLimit: { + value: number | boolean; + priority: number; + useDefault: boolean; + }; + canPublicNote: { + value: number | boolean; + priority: number; + useDefault: boolean; + }; + userListLimit: { + value: number | boolean; + priority: number; + useDefault: boolean; + }; + wordMuteLimit: { + value: number | boolean; + priority: number; + useDefault: boolean; + }; + alwaysMarkNsfw: { + value: number | boolean; + priority: number; + useDefault: boolean; + }; + canSearchNotes: { + value: number | boolean; + priority: number; + useDefault: boolean; + }; + driveCapacityMb: { + value: number | boolean; + priority: number; + useDefault: boolean; + }; + rateLimitFactor: { + value: number | boolean; + priority: number; + useDefault: boolean; + }; + inviteLimitCycle: { + value: number | boolean; + priority: number; + useDefault: boolean; + }; + noteEachClipsLimit: { + value: number | boolean; + priority: number; + useDefault: boolean; + }; + inviteExpirationTime: { + value: number | boolean; + priority: number; + useDefault: boolean; + }; + canManageCustomEmojis: { + value: number | boolean; + priority: number; + useDefault: boolean; + }; + userEachUserListsLimit: { + value: number | boolean; + priority: number; + useDefault: boolean; + }; + canManageAvatarDecorations: { + value: number | boolean; + priority: number; + useDefault: boolean; + }; + canUseTranslator: { + value: number | boolean; + priority: number; + useDefault: boolean; + }; + }; + usersCount: number; + }); }; responses: never; parameters: never; @@ -7847,9 +7991,11 @@ export type operations = { }; }; responses: { - /** @description OK (without any results) */ - 204: { - content: never; + /** @description OK (with results) */ + 200: { + content: { + 'application/json': components['schemas']['Role']; + }; }; /** @description Client error */ 400: { @@ -7943,9 +8089,11 @@ export type operations = { */ 'admin/roles/list': { responses: { - /** @description OK (without any results) */ - 204: { - content: never; + /** @description OK (with results) */ + 200: { + content: { + 'application/json': components['schemas']['Role'][]; + }; }; /** @description Client error */ 400: { @@ -7995,9 +8143,11 @@ export type operations = { }; }; responses: { - /** @description OK (without any results) */ - 204: { - content: never; + /** @description OK (with results) */ + 200: { + content: { + 'application/json': components['schemas']['Role']; + }; }; /** @description Client error */ 400: { @@ -19841,9 +19991,11 @@ export type operations = { */ 'roles/list': { responses: { - /** @description OK (without any results) */ - 204: { - content: never; + /** @description OK (with results) */ + 200: { + content: { + 'application/json': components['schemas']['Role'][]; + }; }; /** @description Client error */ 400: { @@ -19893,9 +20045,11 @@ export type operations = { }; }; responses: { - /** @description OK (without any results) */ - 204: { - content: never; + /** @description OK (with results) */ + 200: { + content: { + 'application/json': components['schemas']['Role']; + }; }; /** @description Client error */ 400: {