Merge branch 'develop' into mahjong
This commit is contained in:
@@ -154,5 +154,5 @@ stream.on('_disconnected_', () => {
|
||||
---
|
||||
|
||||
<div align="center">
|
||||
<a href="https://github.com/misskey-dev/misskey/blob/develop/CONTRIBUTING.md"><img src="https://raw.githubusercontent.com/misskey-dev/assets/main/i-want-you.png" width="300"></a>
|
||||
<a href="https://github.com/misskey-dev/misskey/blob/develop/CONTRIBUTING.md"><img src="https://assets.misskey-hub.net/public/i-want-you.png" width="300"></a>
|
||||
</div>
|
||||
|
||||
@@ -95,7 +95,6 @@ async function watchSrc() {
|
||||
process.on('SIGHUP', resolve);
|
||||
process.on('SIGINT', resolve);
|
||||
process.on('SIGTERM', resolve);
|
||||
process.on('SIGKILL', resolve);
|
||||
process.on('uncaughtException', reject);
|
||||
process.on('exit', resolve);
|
||||
}).finally(async () => {
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import tsParser from '@typescript-eslint/parser';
|
||||
import sharedConfig from '../shared/eslint.config.js';
|
||||
|
||||
// eslint-disable-next-line import/no-default-export
|
||||
export default [
|
||||
...sharedConfig,
|
||||
{
|
||||
|
||||
@@ -551,7 +551,7 @@ type Channel = components['schemas']['Channel'];
|
||||
// Warning: (ae-forgotten-export) The symbol "AnyOf" needs to be exported by the entry point index.d.ts
|
||||
//
|
||||
// @public (undocumented)
|
||||
export abstract class ChannelConnection<Channel extends AnyOf<Channels> = any> extends EventEmitter<Channel['events']> {
|
||||
export abstract class ChannelConnection<Channel extends AnyOf<Channels> = AnyOf<Channels>> extends EventEmitter<Channel['events']> {
|
||||
constructor(stream: Stream, channel: string, name?: string);
|
||||
// (undocumented)
|
||||
channel: string;
|
||||
@@ -771,12 +771,12 @@ export type Channels = {
|
||||
user1: boolean;
|
||||
user2: boolean;
|
||||
}) => void;
|
||||
updateSettings: (payload: {
|
||||
updateSettings: <K extends ReversiUpdateKey>(payload: {
|
||||
userId: User['id'];
|
||||
key: string;
|
||||
value: any;
|
||||
key: K;
|
||||
value: ReversiGameDetailed[K];
|
||||
}) => void;
|
||||
log: (payload: Record<string, any>) => void;
|
||||
log: (payload: Record<string, unknown>) => void;
|
||||
};
|
||||
receives: {
|
||||
putStone: {
|
||||
@@ -785,10 +785,7 @@ export type Channels = {
|
||||
};
|
||||
ready: boolean;
|
||||
cancel: null | Record<string, never>;
|
||||
updateSettings: {
|
||||
key: string;
|
||||
value: any;
|
||||
};
|
||||
updateSettings: ReversiUpdateSettings<ReversiUpdateKey>;
|
||||
claimTimeIsUp: null | Record<string, never>;
|
||||
};
|
||||
};
|
||||
@@ -1160,6 +1157,12 @@ export type Endpoints = Overwrite<Endpoints_2, {
|
||||
req: SigninRequest;
|
||||
res: SigninResponse;
|
||||
};
|
||||
'admin/roles/create': {
|
||||
req: Overwrite<AdminRolesCreateRequest, {
|
||||
policies: PartialRolePolicyOverride;
|
||||
}>;
|
||||
res: AdminRolesCreateResponse;
|
||||
};
|
||||
}>;
|
||||
|
||||
// @public (undocumented)
|
||||
@@ -1185,6 +1188,7 @@ declare namespace entities {
|
||||
SignupPendingResponse,
|
||||
SigninRequest,
|
||||
SigninResponse,
|
||||
PartialRolePolicyOverride,
|
||||
EmptyRequest,
|
||||
EmptyResponse,
|
||||
AdminMetaResponse,
|
||||
@@ -2747,7 +2751,16 @@ type PagesUnlikeRequest = operations['pages___unlike']['requestBody']['content']
|
||||
type PagesUpdateRequest = operations['pages___update']['requestBody']['content']['application/json'];
|
||||
|
||||
// @public (undocumented)
|
||||
function parse(acct: string): Acct;
|
||||
function parse(_acct: string): Acct;
|
||||
|
||||
// Warning: (ae-forgotten-export) The symbol "Values" needs to be exported by the entry point index.d.ts
|
||||
//
|
||||
// @public (undocumented)
|
||||
type PartialRolePolicyOverride = Partial<{
|
||||
[k in keyof RolePolicies]: Omit<Values<Role['policies']>, 'value'> & {
|
||||
value: RolePolicies[k];
|
||||
};
|
||||
}>;
|
||||
|
||||
// @public (undocumented)
|
||||
export const permissions: readonly ["read:account", "write:account", "read:blocks", "write:blocks", "read:drive", "write:drive", "read:favorites", "write:favorites", "read:following", "write:following", "read:messaging", "write:messaging", "read:mutes", "write:mutes", "write:notes", "read:notifications", "write:notifications", "read:reactions", "write:reactions", "write:votes", "read:pages", "write:pages", "write:page-likes", "read:page-likes", "read:user-groups", "write:user-groups", "read:channels", "write:channels", "read:gallery", "write:gallery", "read:gallery-likes", "write:gallery-likes", "read:flash", "write:flash", "read:flash-likes", "write:flash-likes", "read:admin:abuse-user-reports", "write:admin:delete-account", "write:admin:delete-all-files-of-a-user", "read:admin:index-stats", "read:admin:table-stats", "read:admin:user-ips", "read:admin:meta", "write:admin:reset-password", "write:admin:resolve-abuse-user-report", "write:admin:send-email", "read:admin:server-info", "read:admin:show-moderation-log", "read:admin:show-user", "write:admin:suspend-user", "write:admin:unset-user-avatar", "write:admin:unset-user-banner", "write:admin:unsuspend-user", "write:admin:meta", "write:admin:user-note", "write:admin:roles", "read:admin:roles", "write:admin:relays", "read:admin:relays", "write:admin:invite-codes", "read:admin:invite-codes", "write:admin:announcements", "read:admin:announcements", "write:admin:avatar-decorations", "read:admin:avatar-decorations", "write:admin:federation", "write:admin:account", "read:admin:account", "write:admin:emoji", "read:admin:emoji", "write:admin:queue", "read:admin:queue", "write:admin:promo", "write:admin:drive", "read:admin:drive", "write:admin:ad", "read:admin:ad", "write:invite-codes", "read:invite-codes", "write:clip-favorite", "read:clip-favorite", "read:federation", "write:report-abuse"];
|
||||
@@ -2977,7 +2990,7 @@ export class Stream extends EventEmitter<StreamEvents> {
|
||||
constructor(origin: string, user: {
|
||||
token: string;
|
||||
} | null, options?: {
|
||||
WebSocket?: any;
|
||||
WebSocket?: WebSocket;
|
||||
});
|
||||
// (undocumented)
|
||||
close(): void;
|
||||
@@ -3000,9 +3013,9 @@ export class Stream extends EventEmitter<StreamEvents> {
|
||||
// (undocumented)
|
||||
send(typeOrPayload: string): void;
|
||||
// (undocumented)
|
||||
send(typeOrPayload: string, payload: any): void;
|
||||
send(typeOrPayload: string, payload: unknown): void;
|
||||
// (undocumented)
|
||||
send(typeOrPayload: Record<string, any> | any[]): void;
|
||||
send(typeOrPayload: Record<string, unknown> | unknown[]): void;
|
||||
// (undocumented)
|
||||
state: 'initializing' | 'reconnecting' | 'connected';
|
||||
// (undocumented)
|
||||
@@ -3237,7 +3250,9 @@ type UsersUpdateMemoRequest = operations['users___update-memo']['requestBody']['
|
||||
|
||||
// Warnings were encountered during analysis:
|
||||
//
|
||||
// src/entities.ts:25:2 - (ae-forgotten-export) The symbol "ModerationLogPayloads" needs to be exported by the entry point index.d.ts
|
||||
// src/entities.ts:35:2 - (ae-forgotten-export) The symbol "ModerationLogPayloads" needs to be exported by the entry point index.d.ts
|
||||
// src/streaming.types.ts:220:4 - (ae-forgotten-export) The symbol "ReversiUpdateKey" needs to be exported by the entry point index.d.ts
|
||||
// src/streaming.types.ts:230:4 - (ae-forgotten-export) The symbol "ReversiUpdateSettings" needs to be exported by the entry point index.d.ts
|
||||
|
||||
// (No @packageDocumentation comment for this package)
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"type": "module",
|
||||
"name": "misskey-js",
|
||||
"version": "2024.5.0",
|
||||
"version": "2024.7.0-beta.3",
|
||||
"description": "Misskey SDK for JavaScript",
|
||||
"license": "MIT",
|
||||
"main": "./built/index.js",
|
||||
@@ -35,23 +35,23 @@
|
||||
"directory": "packages/misskey-js"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@microsoft/api-extractor": "7.47.0",
|
||||
"@microsoft/api-extractor": "7.47.4",
|
||||
"@swc/jest": "0.2.36",
|
||||
"@types/jest": "29.5.12",
|
||||
"@types/node": "20.14.9",
|
||||
"@typescript-eslint/eslint-plugin": "7.15.0",
|
||||
"@typescript-eslint/parser": "7.15.0",
|
||||
"@types/node": "20.14.12",
|
||||
"@typescript-eslint/eslint-plugin": "7.17.0",
|
||||
"@typescript-eslint/parser": "7.17.0",
|
||||
"jest": "29.7.0",
|
||||
"jest-fetch-mock": "3.0.3",
|
||||
"jest-websocket-mock": "2.5.0",
|
||||
"mock-socket": "9.3.1",
|
||||
"ncp": "2.0.0",
|
||||
"nodemon": "3.1.4",
|
||||
"execa": "9.2.0",
|
||||
"execa": "9.3.0",
|
||||
"tsd": "0.31.1",
|
||||
"typescript": "5.5.3",
|
||||
"esbuild": "0.22.0",
|
||||
"glob": "10.4.2"
|
||||
"typescript": "5.5.4",
|
||||
"esbuild": "0.23.0",
|
||||
"glob": "11.0.0"
|
||||
},
|
||||
"files": [
|
||||
"built"
|
||||
|
||||
@@ -3,7 +3,8 @@ export type Acct = {
|
||||
host: string | null;
|
||||
};
|
||||
|
||||
export function parse(acct: string): Acct {
|
||||
export function parse(_acct: string): Acct {
|
||||
let acct = _acct;
|
||||
if (acct.startsWith('@')) acct = acct.substring(1);
|
||||
const split = acct.split('@', 2);
|
||||
return { username: split[0], host: split[1] || null };
|
||||
|
||||
@@ -14,6 +14,7 @@ export type APIError = {
|
||||
code: string;
|
||||
message: string;
|
||||
kind: 'client' | 'server';
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
info: Record<string, any>;
|
||||
};
|
||||
|
||||
@@ -29,6 +30,7 @@ export type FetchLike = (input: string, init?: {
|
||||
headers: { [key in string]: string }
|
||||
}) => Promise<{
|
||||
status: number;
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
json(): Promise<any>;
|
||||
}>;
|
||||
|
||||
@@ -49,6 +51,7 @@ export class APIClient {
|
||||
this.fetch = opts.fetch ?? ((...args) => fetch(...args));
|
||||
}
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
private assertIsRecord<T>(obj: T): obj is T & Record<string, any> {
|
||||
return obj !== null && typeof obj === 'object' && !Array.isArray(obj);
|
||||
}
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
import { Endpoints as Gen } from './autogen/endpoint.js';
|
||||
import { UserDetailed } from './autogen/models.js';
|
||||
import { UsersShowRequest } from './autogen/entities.js';
|
||||
import { AdminRolesCreateRequest, AdminRolesCreateResponse, UsersShowRequest } from './autogen/entities.js';
|
||||
import {
|
||||
PartialRolePolicyOverride,
|
||||
SigninRequest,
|
||||
SigninResponse,
|
||||
SignupPendingRequest,
|
||||
@@ -27,11 +28,13 @@ type StrictExtract<Union, Cond> = Cond extends Union ? Union : never;
|
||||
|
||||
type IsCaseMatched<E extends keyof Endpoints, P extends Endpoints[E]['req'], C extends number> =
|
||||
Endpoints[E]['res'] extends SwitchCase
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
? IsNeverType<StrictExtract<Endpoints[E]['res']['$switch']['$cases'][C], [P, any]>> extends false ? true : false
|
||||
: false
|
||||
|
||||
type GetCaseResult<E extends keyof Endpoints, P extends Endpoints[E]['req'], C extends number> =
|
||||
Endpoints[E]['res'] extends SwitchCase
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
? StrictExtract<Endpoints[E]['res']['$switch']['$cases'][C], [P, any]>[1]
|
||||
: never
|
||||
|
||||
@@ -79,5 +82,9 @@ export type Endpoints = Overwrite<
|
||||
req: SigninRequest;
|
||||
res: SigninResponse;
|
||||
},
|
||||
'admin/roles/create': {
|
||||
req: Overwrite<AdminRolesCreateRequest, { policies: PartialRolePolicyOverride }>;
|
||||
res: AdminRolesCreateResponse;
|
||||
}
|
||||
}
|
||||
>
|
||||
|
||||
@@ -4116,7 +4116,8 @@ export type components = {
|
||||
userId: string | null;
|
||||
}) | null;
|
||||
localOnly?: boolean;
|
||||
reactionAcceptance: string | null;
|
||||
/** @enum {string|null} */
|
||||
reactionAcceptance: 'likeOnly' | 'likeOnlyForRemote' | 'nonSensitiveOnly' | 'nonSensitiveOnlyForLocalLikeOnlyForRemote';
|
||||
reactionEmojis: {
|
||||
[key: string]: string;
|
||||
};
|
||||
@@ -4813,6 +4814,7 @@ export type components = {
|
||||
canHideAds: boolean;
|
||||
driveCapacityMb: number;
|
||||
alwaysMarkNsfw: boolean;
|
||||
canUpdateBioMedia: boolean;
|
||||
pinLimit: number;
|
||||
antennaLimit: number;
|
||||
wordMuteLimit: number;
|
||||
|
||||
@@ -1,3 +1,13 @@
|
||||
import type { operations } from './autogen/types.js';
|
||||
import type {
|
||||
AbuseReportNotificationRecipient, Ad,
|
||||
Announcement,
|
||||
EmojiDetailed, InviteCode,
|
||||
MetaDetailed,
|
||||
Note,
|
||||
Role, SystemWebhook, UserLite,
|
||||
} from './autogen/models.js';
|
||||
|
||||
export const notificationTypes = ['note', 'follow', 'mention', 'reply', 'renote', 'quote', 'reaction', 'pollVote', 'pollEnded', 'receiveFollowRequest', 'followRequestAccepted', 'groupInvited', 'app', 'roleAssigned', 'achievementEarned'] as const;
|
||||
|
||||
export const noteVisibilities = ['public', 'home', 'followers', 'specified'] as const;
|
||||
@@ -135,10 +145,30 @@ export const moderationLogTypes = [
|
||||
'unsetUserBanner',
|
||||
] as const;
|
||||
|
||||
// See: packages/backend/src/core/ReversiService.ts@L410
|
||||
export const reversiUpdateKeys = [
|
||||
'map',
|
||||
'bw',
|
||||
'isLlotheo',
|
||||
'canPutEverywhere',
|
||||
'loopedBoard',
|
||||
'timeLimitForEachTurn',
|
||||
] as const;
|
||||
|
||||
export type ReversiUpdateKey = typeof reversiUpdateKeys[number];
|
||||
|
||||
type AvatarDecoration = UserLite['avatarDecorations'][number];
|
||||
|
||||
type ReceivedAbuseReport = {
|
||||
reportId: AbuseReportNotificationRecipient['id'];
|
||||
report: operations['admin___abuse-user-reports']['responses'][200]['content']['application/json'];
|
||||
forwarded: boolean;
|
||||
};
|
||||
|
||||
export type ModerationLogPayloads = {
|
||||
updateServerSettings: {
|
||||
before: any | null;
|
||||
after: any | null;
|
||||
before: MetaDetailed | null;
|
||||
after: MetaDetailed | null;
|
||||
};
|
||||
suspend: {
|
||||
userId: string;
|
||||
@@ -159,16 +189,16 @@ export type ModerationLogPayloads = {
|
||||
};
|
||||
addCustomEmoji: {
|
||||
emojiId: string;
|
||||
emoji: any;
|
||||
emoji: EmojiDetailed;
|
||||
};
|
||||
updateCustomEmoji: {
|
||||
emojiId: string;
|
||||
before: any;
|
||||
after: any;
|
||||
before: EmojiDetailed;
|
||||
after: EmojiDetailed;
|
||||
};
|
||||
deleteCustomEmoji: {
|
||||
emojiId: string;
|
||||
emoji: any;
|
||||
emoji: EmojiDetailed;
|
||||
};
|
||||
assignRole: {
|
||||
userId: string;
|
||||
@@ -187,16 +217,16 @@ export type ModerationLogPayloads = {
|
||||
};
|
||||
createRole: {
|
||||
roleId: string;
|
||||
role: any;
|
||||
role: Role;
|
||||
};
|
||||
updateRole: {
|
||||
roleId: string;
|
||||
before: any;
|
||||
after: any;
|
||||
before: Role;
|
||||
after: Role;
|
||||
};
|
||||
deleteRole: {
|
||||
roleId: string;
|
||||
role: any;
|
||||
role: Role;
|
||||
};
|
||||
clearQueue: Record<string, never>;
|
||||
promoteQueue: Record<string, never>;
|
||||
@@ -211,39 +241,39 @@ export type ModerationLogPayloads = {
|
||||
noteUserId: string;
|
||||
noteUserUsername: string;
|
||||
noteUserHost: string | null;
|
||||
note: any;
|
||||
note: Note;
|
||||
};
|
||||
createGlobalAnnouncement: {
|
||||
announcementId: string;
|
||||
announcement: any;
|
||||
announcement: Announcement;
|
||||
};
|
||||
createUserAnnouncement: {
|
||||
announcementId: string;
|
||||
announcement: any;
|
||||
announcement: Announcement;
|
||||
userId: string;
|
||||
userUsername: string;
|
||||
userHost: string | null;
|
||||
};
|
||||
updateGlobalAnnouncement: {
|
||||
announcementId: string;
|
||||
before: any;
|
||||
after: any;
|
||||
before: Announcement;
|
||||
after: Announcement;
|
||||
};
|
||||
updateUserAnnouncement: {
|
||||
announcementId: string;
|
||||
before: any;
|
||||
after: any;
|
||||
before: Announcement;
|
||||
after: Announcement;
|
||||
userId: string;
|
||||
userUsername: string;
|
||||
userHost: string | null;
|
||||
};
|
||||
deleteGlobalAnnouncement: {
|
||||
announcementId: string;
|
||||
announcement: any;
|
||||
announcement: Announcement;
|
||||
};
|
||||
deleteUserAnnouncement: {
|
||||
announcementId: string;
|
||||
announcement: any;
|
||||
announcement: Announcement;
|
||||
userId: string;
|
||||
userUsername: string;
|
||||
userHost: string | null;
|
||||
@@ -281,37 +311,37 @@ export type ModerationLogPayloads = {
|
||||
};
|
||||
resolveAbuseReport: {
|
||||
reportId: string;
|
||||
report: any;
|
||||
report: ReceivedAbuseReport;
|
||||
forwarded: boolean;
|
||||
};
|
||||
createInvitation: {
|
||||
invitations: any[];
|
||||
invitations: InviteCode[];
|
||||
};
|
||||
createAd: {
|
||||
adId: string;
|
||||
ad: any;
|
||||
ad: Ad;
|
||||
};
|
||||
updateAd: {
|
||||
adId: string;
|
||||
before: any;
|
||||
after: any;
|
||||
before: Ad;
|
||||
after: Ad;
|
||||
};
|
||||
deleteAd: {
|
||||
adId: string;
|
||||
ad: any;
|
||||
ad: Ad;
|
||||
};
|
||||
createAvatarDecoration: {
|
||||
avatarDecorationId: string;
|
||||
avatarDecoration: any;
|
||||
avatarDecoration: AvatarDecoration;
|
||||
};
|
||||
updateAvatarDecoration: {
|
||||
avatarDecorationId: string;
|
||||
before: any;
|
||||
after: any;
|
||||
before: AvatarDecoration;
|
||||
after: AvatarDecoration;
|
||||
};
|
||||
deleteAvatarDecoration: {
|
||||
avatarDecorationId: string;
|
||||
avatarDecoration: any;
|
||||
avatarDecoration: AvatarDecoration;
|
||||
};
|
||||
unsetUserAvatar: {
|
||||
userId: string;
|
||||
@@ -327,28 +357,28 @@ export type ModerationLogPayloads = {
|
||||
};
|
||||
createSystemWebhook: {
|
||||
systemWebhookId: string;
|
||||
webhook: any;
|
||||
webhook: SystemWebhook;
|
||||
};
|
||||
updateSystemWebhook: {
|
||||
systemWebhookId: string;
|
||||
before: any;
|
||||
after: any;
|
||||
before: SystemWebhook;
|
||||
after: SystemWebhook;
|
||||
};
|
||||
deleteSystemWebhook: {
|
||||
systemWebhookId: string;
|
||||
webhook: any;
|
||||
webhook: SystemWebhook;
|
||||
};
|
||||
createAbuseReportNotificationRecipient: {
|
||||
recipientId: string;
|
||||
recipient: any;
|
||||
recipient: AbuseReportNotificationRecipient;
|
||||
};
|
||||
updateAbuseReportNotificationRecipient: {
|
||||
recipientId: string;
|
||||
before: any;
|
||||
after: any;
|
||||
before: AbuseReportNotificationRecipient;
|
||||
after: AbuseReportNotificationRecipient;
|
||||
};
|
||||
deleteAbuseReportNotificationRecipient: {
|
||||
recipientId: string;
|
||||
recipient: any;
|
||||
recipient: AbuseReportNotificationRecipient;
|
||||
};
|
||||
};
|
||||
|
||||
@@ -1,5 +1,14 @@
|
||||
import { ModerationLogPayloads } from './consts.js';
|
||||
import { Announcement, EmojiDetailed, MeDetailed, Page, User, UserDetailedNotMe } from './autogen/models.js';
|
||||
import {
|
||||
Announcement,
|
||||
EmojiDetailed,
|
||||
MeDetailed,
|
||||
Page,
|
||||
Role,
|
||||
RolePolicies,
|
||||
User,
|
||||
UserDetailedNotMe,
|
||||
} from './autogen/models.js';
|
||||
|
||||
export * from './autogen/entities.js';
|
||||
export * from './autogen/models.js';
|
||||
@@ -10,6 +19,7 @@ export type DateString = string;
|
||||
export type PageEvent = {
|
||||
pageId: Page['id'];
|
||||
event: string;
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
var: any;
|
||||
userId: User['id'];
|
||||
user: User;
|
||||
@@ -236,3 +246,7 @@ export type SigninResponse = {
|
||||
id: User['id'],
|
||||
i: string,
|
||||
};
|
||||
|
||||
type Values<T extends Record<PropertyKey, unknown>> = T[keyof T];
|
||||
|
||||
export type PartialRolePolicyOverride = Partial<{[k in keyof RolePolicies]: Omit<Values<Role['policies']>, 'value'> & { value: RolePolicies[k] }}>;
|
||||
|
||||
@@ -15,7 +15,7 @@ export function urlQuery(obj: Record<string, string | number | boolean | undefin
|
||||
.join('&');
|
||||
}
|
||||
|
||||
type AnyOf<T extends Record<any, any>> = T[keyof T];
|
||||
type AnyOf<T extends Record<PropertyKey, unknown>> = T[keyof T];
|
||||
|
||||
type StreamEvents = {
|
||||
_connected_: void;
|
||||
@@ -25,6 +25,7 @@ type StreamEvents = {
|
||||
/**
|
||||
* Misskey stream connection
|
||||
*/
|
||||
// eslint-disable-next-line import/no-default-export
|
||||
export default class Stream extends EventEmitter<StreamEvents> {
|
||||
private stream: _ReconnectingWebsocket.default;
|
||||
public state: 'initializing' | 'reconnecting' | 'connected' = 'initializing';
|
||||
@@ -34,7 +35,7 @@ export default class Stream extends EventEmitter<StreamEvents> {
|
||||
private idCounter = 0;
|
||||
|
||||
constructor(origin: string, user: { token: string; } | null, options?: {
|
||||
WebSocket?: any;
|
||||
WebSocket?: WebSocket;
|
||||
}) {
|
||||
super();
|
||||
|
||||
@@ -51,6 +52,7 @@ export default class Stream extends EventEmitter<StreamEvents> {
|
||||
this.send = this.send.bind(this);
|
||||
this.close = this.close.bind(this);
|
||||
|
||||
// eslint-disable-next-line no-param-reassign
|
||||
options = options ?? { };
|
||||
|
||||
const query = urlQuery({
|
||||
@@ -91,8 +93,8 @@ export default class Stream extends EventEmitter<StreamEvents> {
|
||||
this.sharedConnectionPools.push(pool);
|
||||
}
|
||||
|
||||
const connection = new SharedConnection(this, channel, pool, name);
|
||||
this.sharedConnections.push(connection);
|
||||
const connection = new SharedConnection<Channels[C]>(this, channel, pool, name);
|
||||
this.sharedConnections.push(connection as unknown as SharedConnection);
|
||||
return connection;
|
||||
}
|
||||
|
||||
@@ -106,7 +108,7 @@ export default class Stream extends EventEmitter<StreamEvents> {
|
||||
|
||||
private connectToChannel<C extends keyof Channels>(channel: C, params: Channels[C]['params']): NonSharedConnection<Channels[C]> {
|
||||
const connection = new NonSharedConnection(this, channel, this.genId(), params);
|
||||
this.nonSharedConnections.push(connection);
|
||||
this.nonSharedConnections.push(connection as unknown as NonSharedConnection);
|
||||
return connection;
|
||||
}
|
||||
|
||||
@@ -174,9 +176,9 @@ export default class Stream extends EventEmitter<StreamEvents> {
|
||||
* ! ストリーム上のやり取りはすべてJSONで行われます !
|
||||
*/
|
||||
public send(typeOrPayload: string): void
|
||||
public send(typeOrPayload: string, payload: any): void
|
||||
public send(typeOrPayload: Record<string, any> | any[]): void
|
||||
public send(typeOrPayload: string | Record<string, any> | any[], payload?: any): void {
|
||||
public send(typeOrPayload: string, payload: unknown): void
|
||||
public send(typeOrPayload: Record<string, unknown> | unknown[]): void
|
||||
public send(typeOrPayload: string | Record<string, unknown> | unknown[], payload?: unknown): void {
|
||||
if (typeof typeOrPayload === 'string') {
|
||||
this.stream.send(JSON.stringify({
|
||||
type: typeOrPayload,
|
||||
@@ -211,7 +213,7 @@ class Pool {
|
||||
public id: string;
|
||||
protected stream: Stream;
|
||||
public users = 0;
|
||||
private disposeTimerId: any;
|
||||
private disposeTimerId: ReturnType<typeof setTimeout> | null = null;
|
||||
private isConnected = false;
|
||||
|
||||
constructor(stream: Stream, channel: string, id: string) {
|
||||
@@ -275,7 +277,7 @@ class Pool {
|
||||
}
|
||||
}
|
||||
|
||||
export abstract class Connection<Channel extends AnyOf<Channels> = any> extends EventEmitter<Channel['events']> {
|
||||
export abstract class Connection<Channel extends AnyOf<Channels> = AnyOf<Channels>> extends EventEmitter<Channel['events']> {
|
||||
public channel: string;
|
||||
protected stream: Stream;
|
||||
public abstract id: string;
|
||||
@@ -291,7 +293,9 @@ export abstract class Connection<Channel extends AnyOf<Channels> = any> extends
|
||||
|
||||
this.stream = stream;
|
||||
this.channel = channel;
|
||||
this.name = name;
|
||||
if (name !== undefined) {
|
||||
this.name = name;
|
||||
}
|
||||
}
|
||||
|
||||
public send<T extends keyof Channel['receives']>(type: T, body: Channel['receives'][T]): void {
|
||||
@@ -307,7 +311,7 @@ export abstract class Connection<Channel extends AnyOf<Channels> = any> extends
|
||||
public abstract dispose(): void;
|
||||
}
|
||||
|
||||
class SharedConnection<Channel extends AnyOf<Channels> = any> extends Connection<Channel> {
|
||||
class SharedConnection<Channel extends AnyOf<Channels> = AnyOf<Channels>> extends Connection<Channel> {
|
||||
private pool: Pool;
|
||||
|
||||
public get id(): string {
|
||||
@@ -326,11 +330,11 @@ class SharedConnection<Channel extends AnyOf<Channels> = any> extends Connection
|
||||
public dispose(): void {
|
||||
this.pool.dec();
|
||||
this.removeAllListeners();
|
||||
this.stream.removeSharedConnection(this);
|
||||
this.stream.removeSharedConnection(this as unknown as SharedConnection);
|
||||
}
|
||||
}
|
||||
|
||||
class NonSharedConnection<Channel extends AnyOf<Channels> = any> extends Connection<Channel> {
|
||||
class NonSharedConnection<Channel extends AnyOf<Channels> = AnyOf<Channels>> extends Connection<Channel> {
|
||||
public id: string;
|
||||
protected params: Channel['params'];
|
||||
|
||||
@@ -357,6 +361,6 @@ class NonSharedConnection<Channel extends AnyOf<Channels> = any> extends Connect
|
||||
public dispose(): void {
|
||||
this.removeAllListeners();
|
||||
this.stream.send('disconnect', { id: this.id });
|
||||
this.stream.disconnectToChannel(this);
|
||||
this.stream.disconnectToChannel(this as unknown as NonSharedConnection);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,6 +21,14 @@ import {
|
||||
ServerStatsLog,
|
||||
ReversiGameDetailed,
|
||||
} from './entities.js';
|
||||
import {
|
||||
ReversiUpdateKey,
|
||||
} from './consts.js';
|
||||
|
||||
type ReversiUpdateSettings<K extends ReversiUpdateKey> = {
|
||||
key: K;
|
||||
value: ReversiGameDetailed[K];
|
||||
};
|
||||
|
||||
export type Channels = {
|
||||
main: {
|
||||
@@ -51,6 +59,7 @@ export type Channels = {
|
||||
registryUpdated: (payload: {
|
||||
scope?: string[];
|
||||
key: string;
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
value: any | null;
|
||||
}) => void;
|
||||
driveFileCreated: (payload: DriveFile) => void;
|
||||
@@ -208,8 +217,8 @@ export type Channels = {
|
||||
ended: (payload: { winnerId: User['id'] | null; game: ReversiGameDetailed; }) => void;
|
||||
canceled: (payload: { userId: User['id']; }) => void;
|
||||
changeReadyStates: (payload: { user1: boolean; user2: boolean; }) => void;
|
||||
updateSettings: (payload: { userId: User['id']; key: string; value: any; }) => void;
|
||||
log: (payload: Record<string, any>) => void;
|
||||
updateSettings: <K extends ReversiUpdateKey>(payload: { userId: User['id']; key: K; value: ReversiGameDetailed[K]; }) => void;
|
||||
log: (payload: Record<string, unknown>) => void;
|
||||
};
|
||||
receives: {
|
||||
putStone: {
|
||||
@@ -218,10 +227,7 @@ export type Channels = {
|
||||
};
|
||||
ready: boolean;
|
||||
cancel: null | Record<string, never>;
|
||||
updateSettings: {
|
||||
key: string;
|
||||
value: any;
|
||||
};
|
||||
updateSettings: ReversiUpdateSettings<ReversiUpdateKey>;
|
||||
claimTimeIsUp: null | Record<string, never>;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -259,4 +259,42 @@ describe('API', () => {
|
||||
expect(isAPIError(e)).toEqual(false);
|
||||
}
|
||||
});
|
||||
|
||||
test('admin/roles/create の型が合う', async() => {
|
||||
fetchMock.resetMocks();
|
||||
fetchMock.mockResponse(async () => {
|
||||
return {
|
||||
// 本来返すべき値は`Role`型だが、テストなのでお茶を濁す
|
||||
status: 200,
|
||||
body: '{}'
|
||||
};
|
||||
});
|
||||
|
||||
const cli = new APIClient({
|
||||
origin: 'https://misskey.test',
|
||||
credential: 'TOKEN',
|
||||
});
|
||||
await cli.request('admin/roles/create', {
|
||||
name: 'aaa',
|
||||
asBadge: false,
|
||||
canEditMembersByModerator: false,
|
||||
color: '#123456',
|
||||
condFormula: {},
|
||||
description: '',
|
||||
displayOrder: 0,
|
||||
iconUrl: '',
|
||||
isAdministrator: false,
|
||||
isExplorable: false,
|
||||
isModerator: false,
|
||||
isPublic: false,
|
||||
policies: {
|
||||
ltlAvailable: {
|
||||
value: true,
|
||||
priority: 0,
|
||||
useDefault: false,
|
||||
},
|
||||
},
|
||||
target: 'manual',
|
||||
});
|
||||
})
|
||||
});
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
"experimentalDecorators": true,
|
||||
"noImplicitReturns": true,
|
||||
"esModuleInterop": true,
|
||||
"exactOptionalPropertyTypes": true,
|
||||
"typeRoots": [
|
||||
"./node_modules/@types"
|
||||
],
|
||||
|
||||
Reference in New Issue
Block a user