mirror of
https://github.com/misskey-dev/misskey.git
synced 2024-12-22 13:05:18 +01:00
Merge branch 'develop' of https://github.com/misskey-dev/misskey into develop
This commit is contained in:
commit
831131864f
14 changed files with 121 additions and 38 deletions
|
@ -37,7 +37,7 @@ export class ServerStatsService implements OnApplicationShutdown {
|
|||
const log = [] as any[];
|
||||
|
||||
ev.on('requestServerStatsLog', x => {
|
||||
ev.emit(`serverStatsLog:${x.id}`, log.slice(0, x.length ?? 50));
|
||||
ev.emit(`serverStatsLog:${x.id}`, log.slice(0, x.length));
|
||||
});
|
||||
|
||||
const tick = async () => {
|
||||
|
|
|
@ -10,12 +10,17 @@ import { $i } from '@/account.js';
|
|||
export const pendingApiRequestsCount = ref(0);
|
||||
|
||||
// Implements Misskey.api.ApiClient.request
|
||||
export function misskeyApi<E extends keyof Misskey.Endpoints, P extends Misskey.Endpoints[E]['req']>(
|
||||
export function misskeyApi<
|
||||
ResT = void,
|
||||
E extends keyof Misskey.Endpoints = keyof Misskey.Endpoints,
|
||||
P extends Misskey.Endpoints[E]['req'] = Misskey.Endpoints[E]['req'],
|
||||
_ResT = ResT extends void ? Misskey.api.SwitchCaseResponseType<E, P> : ResT,
|
||||
>(
|
||||
endpoint: E,
|
||||
data: P = {} as any,
|
||||
token?: string | null | undefined,
|
||||
signal?: AbortSignal,
|
||||
): Promise<Misskey.api.SwitchCaseResponseType<E, P>> {
|
||||
): Promise<_ResT> {
|
||||
if (endpoint.includes('://')) throw new Error('invalid endpoint');
|
||||
pendingApiRequestsCount.value++;
|
||||
|
||||
|
@ -23,7 +28,7 @@ export function misskeyApi<E extends keyof Misskey.Endpoints, P extends Misskey.
|
|||
pendingApiRequestsCount.value--;
|
||||
};
|
||||
|
||||
const promise = new Promise<Misskey.Endpoints[E]['res'] | void>((resolve, reject) => {
|
||||
const promise = new Promise<_ResT>((resolve, reject) => {
|
||||
// Append a credential
|
||||
if ($i) (data as any).i = $i.token;
|
||||
if (token !== undefined) (data as any).i = token;
|
||||
|
@ -44,7 +49,7 @@ export function misskeyApi<E extends keyof Misskey.Endpoints, P extends Misskey.
|
|||
if (res.status === 200) {
|
||||
resolve(body);
|
||||
} else if (res.status === 204) {
|
||||
resolve();
|
||||
resolve(undefined as _ResT); // void -> undefined
|
||||
} else {
|
||||
reject(body.error);
|
||||
}
|
||||
|
@ -57,10 +62,15 @@ export function misskeyApi<E extends keyof Misskey.Endpoints, P extends Misskey.
|
|||
}
|
||||
|
||||
// Implements Misskey.api.ApiClient.request
|
||||
export function misskeyApiGet<E extends keyof Misskey.Endpoints, P extends Misskey.Endpoints[E]['req']>(
|
||||
export function misskeyApiGet<
|
||||
ResT = void,
|
||||
E extends keyof Misskey.Endpoints = keyof Misskey.Endpoints,
|
||||
P extends Misskey.Endpoints[E]['req'] = Misskey.Endpoints[E]['req'],
|
||||
_ResT = ResT extends void ? Misskey.api.SwitchCaseResponseType<E, P> : ResT,
|
||||
>(
|
||||
endpoint: E,
|
||||
data: P = {} as any,
|
||||
): Promise<Misskey.api.SwitchCaseResponseType<E, P>> {
|
||||
): Promise<_ResT> {
|
||||
pendingApiRequestsCount.value++;
|
||||
|
||||
const onFinally = () => {
|
||||
|
@ -69,7 +79,7 @@ export function misskeyApiGet<E extends keyof Misskey.Endpoints, P extends Missk
|
|||
|
||||
const query = new URLSearchParams(data as any);
|
||||
|
||||
const promise = new Promise<Misskey.Endpoints[E]['res'] | void>((resolve, reject) => {
|
||||
const promise = new Promise<_ResT>((resolve, reject) => {
|
||||
// Send request
|
||||
window.fetch(`${apiUrl}/${endpoint}?${query}`, {
|
||||
method: 'GET',
|
||||
|
@ -81,7 +91,7 @@ export function misskeyApiGet<E extends keyof Misskey.Endpoints, P extends Missk
|
|||
if (res.status === 200) {
|
||||
resolve(body);
|
||||
} else if (res.status === 204) {
|
||||
resolve();
|
||||
resolve(undefined as _ResT); // void -> undefined
|
||||
} else {
|
||||
reject(body.error);
|
||||
}
|
||||
|
|
|
@ -80,13 +80,13 @@ import * as Misskey from 'misskey-js';
|
|||
import { v4 as uuid } from 'uuid';
|
||||
|
||||
const props = defineProps<{
|
||||
connection: any,
|
||||
connection: Misskey.ChannelConnection<Misskey.Channels['serverStats']>,
|
||||
meta: Misskey.entities.ServerInfoResponse
|
||||
}>();
|
||||
|
||||
const viewBoxX = ref<number>(50);
|
||||
const viewBoxY = ref<number>(30);
|
||||
const stats = ref<any[]>([]);
|
||||
const stats = ref<Misskey.entities.ServerStats[]>([]);
|
||||
const cpuGradientId = uuid();
|
||||
const cpuMaskId = uuid();
|
||||
const memGradientId = uuid();
|
||||
|
@ -107,6 +107,7 @@ onMounted(() => {
|
|||
props.connection.on('statsLog', onStatsLog);
|
||||
props.connection.send('requestLog', {
|
||||
id: Math.random().toString().substring(2, 10),
|
||||
length: 50,
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -115,7 +116,7 @@ onBeforeUnmount(() => {
|
|||
props.connection.off('statsLog', onStatsLog);
|
||||
});
|
||||
|
||||
function onStats(connStats) {
|
||||
function onStats(connStats: Misskey.entities.ServerStats) {
|
||||
stats.value.push(connStats);
|
||||
if (stats.value.length > 50) stats.value.shift();
|
||||
|
||||
|
@ -136,8 +137,8 @@ function onStats(connStats) {
|
|||
memP.value = (connStats.mem.active / props.meta.mem.total * 100).toFixed(0);
|
||||
}
|
||||
|
||||
function onStatsLog(statsLog) {
|
||||
for (const revStats of [...statsLog].reverse()) {
|
||||
function onStatsLog(statsLog: Misskey.entities.ServerStatsLog) {
|
||||
for (const revStats of statsLog.reverse()) {
|
||||
onStats(revStats);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,13 +20,13 @@ import * as Misskey from 'misskey-js';
|
|||
import XPie from './pie.vue';
|
||||
|
||||
const props = defineProps<{
|
||||
connection: any,
|
||||
connection: Misskey.ChannelConnection<Misskey.Channels['serverStats']>,
|
||||
meta: Misskey.entities.ServerInfoResponse
|
||||
}>();
|
||||
|
||||
const usage = ref<number>(0);
|
||||
|
||||
function onStats(stats) {
|
||||
function onStats(stats: Misskey.entities.ServerStats) {
|
||||
usage.value = stats.cpu;
|
||||
}
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@ SPDX-License-Identifier: AGPL-3.0-only
|
|||
<script lang="ts" setup>
|
||||
import { onUnmounted, ref } from 'vue';
|
||||
import * as Misskey from 'misskey-js';
|
||||
import { useWidgetPropsManager, Widget, WidgetComponentExpose } from '../widget.js';
|
||||
import { useWidgetPropsManager, WidgetComponentEmits, WidgetComponentExpose, WidgetComponentProps } from '../widget.js';
|
||||
import XCpuMemory from './cpu-mem.vue';
|
||||
import XNet from './net.vue';
|
||||
import XCpu from './cpu.vue';
|
||||
|
@ -54,11 +54,8 @@ const widgetPropsDef = {
|
|||
|
||||
type WidgetProps = GetFormResultType<typeof widgetPropsDef>;
|
||||
|
||||
// 現時点ではvueの制限によりimportしたtypeをジェネリックに渡せない
|
||||
//const props = defineProps<WidgetComponentProps<WidgetProps>>();
|
||||
//const emit = defineEmits<WidgetComponentEmits<WidgetProps>>();
|
||||
const props = defineProps<{ widget?: Widget<WidgetProps>; }>();
|
||||
const emit = defineEmits<{ (ev: 'updateProps', props: WidgetProps); }>();
|
||||
const props = defineProps<WidgetComponentProps<WidgetProps>>();
|
||||
const emit = defineEmits<WidgetComponentEmits<WidgetProps>>();
|
||||
|
||||
const { widgetProps, configure, save } = useWidgetPropsManager(name,
|
||||
widgetPropsDef,
|
||||
|
|
|
@ -22,7 +22,7 @@ import XPie from './pie.vue';
|
|||
import bytes from '@/filters/bytes.js';
|
||||
|
||||
const props = defineProps<{
|
||||
connection: any,
|
||||
connection: Misskey.ChannelConnection<Misskey.Channels['serverStats']>,
|
||||
meta: Misskey.entities.ServerInfoResponse
|
||||
}>();
|
||||
|
||||
|
@ -31,7 +31,7 @@ const total = ref<number>(0);
|
|||
const used = ref<number>(0);
|
||||
const free = ref<number>(0);
|
||||
|
||||
function onStats(stats) {
|
||||
function onStats(stats: Misskey.entities.ServerStats) {
|
||||
usage.value = stats.mem.active / props.meta.mem.total;
|
||||
total.value = props.meta.mem.total;
|
||||
used.value = stats.mem.active;
|
||||
|
|
|
@ -54,13 +54,13 @@ import * as Misskey from 'misskey-js';
|
|||
import bytes from '@/filters/bytes.js';
|
||||
|
||||
const props = defineProps<{
|
||||
connection: any,
|
||||
connection: Misskey.ChannelConnection<Misskey.Channels['serverStats']>,
|
||||
meta: Misskey.entities.ServerInfoResponse
|
||||
}>();
|
||||
|
||||
const viewBoxX = ref<number>(50);
|
||||
const viewBoxY = ref<number>(30);
|
||||
const stats = ref<any[]>([]);
|
||||
const stats = ref<Misskey.entities.ServerStats[]>([]);
|
||||
const inPolylinePoints = ref<string>('');
|
||||
const outPolylinePoints = ref<string>('');
|
||||
const inPolygonPoints = ref<string>('');
|
||||
|
@ -77,6 +77,7 @@ onMounted(() => {
|
|||
props.connection.on('statsLog', onStatsLog);
|
||||
props.connection.send('requestLog', {
|
||||
id: Math.random().toString().substring(2, 10),
|
||||
length: 50,
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -85,7 +86,7 @@ onBeforeUnmount(() => {
|
|||
props.connection.off('statsLog', onStatsLog);
|
||||
});
|
||||
|
||||
function onStats(connStats) {
|
||||
function onStats(connStats: Misskey.entities.ServerStats) {
|
||||
stats.value.push(connStats);
|
||||
if (stats.value.length > 50) stats.value.shift();
|
||||
|
||||
|
@ -109,8 +110,8 @@ function onStats(connStats) {
|
|||
outRecent.value = connStats.net.tx;
|
||||
}
|
||||
|
||||
function onStatsLog(statsLog) {
|
||||
for (const revStats of [...statsLog].reverse()) {
|
||||
function onStatsLog(statsLog: Misskey.entities.ServerStatsLog) {
|
||||
for (const revStats of statsLog.reverse()) {
|
||||
onStats(revStats);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2554,7 +2554,7 @@ type QueueStats = {
|
|||
};
|
||||
|
||||
// @public (undocumented)
|
||||
type QueueStatsLog = string[];
|
||||
type QueueStatsLog = QueueStats[];
|
||||
|
||||
// @public (undocumented)
|
||||
type RenoteMuteCreateRequest = operations['renote-mute/create']['requestBody']['content']['application/json'];
|
||||
|
@ -2628,7 +2628,7 @@ type ServerStats = {
|
|||
};
|
||||
|
||||
// @public (undocumented)
|
||||
type ServerStatsLog = string[];
|
||||
type ServerStatsLog = ServerStats[];
|
||||
|
||||
// @public (undocumented)
|
||||
type Signin = components['schemas']['Signin'];
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* version: 2023.12.2
|
||||
* generatedAt: 2024-01-04T18:10:15.096Z
|
||||
* generatedAt: 2024-01-07T09:49:34.543Z
|
||||
*/
|
||||
|
||||
import type { SwitchCaseResponseType } from '../api.js';
|
||||
|
@ -2249,6 +2249,18 @@ declare module '../api.js' {
|
|||
credential?: string | null,
|
||||
): Promise<SwitchCaseResponseType<E, P>>;
|
||||
|
||||
/**
|
||||
* No description provided.
|
||||
*
|
||||
* **Internal Endpoint**: This endpoint is an API for the misskey mainframe and is not intended for use by third parties.
|
||||
* **Credential required**: *Yes*
|
||||
*/
|
||||
request<E extends 'i/export-clips', P extends Endpoints[E]['req']>(
|
||||
endpoint: E,
|
||||
params: P,
|
||||
credential?: string | null,
|
||||
): Promise<SwitchCaseResponseType<E, P>>;
|
||||
|
||||
/**
|
||||
* No description provided.
|
||||
*
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* version: 2023.12.2
|
||||
* generatedAt: 2024-01-04T18:10:15.094Z
|
||||
* generatedAt: 2024-01-07T09:49:34.533Z
|
||||
*/
|
||||
|
||||
import type {
|
||||
|
@ -745,6 +745,7 @@ export type Endpoints = {
|
|||
'i/export-following': { req: IExportFollowingRequest; res: EmptyResponse };
|
||||
'i/export-mute': { req: EmptyRequest; res: EmptyResponse };
|
||||
'i/export-notes': { req: EmptyRequest; res: EmptyResponse };
|
||||
'i/export-clips': { req: EmptyRequest; res: EmptyResponse };
|
||||
'i/export-favorites': { req: EmptyRequest; res: EmptyResponse };
|
||||
'i/export-user-lists': { req: EmptyRequest; res: EmptyResponse };
|
||||
'i/export-antennas': { req: EmptyRequest; res: EmptyResponse };
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* version: 2023.12.2
|
||||
* generatedAt: 2024-01-04T18:10:15.093Z
|
||||
* generatedAt: 2024-01-07T09:49:34.526Z
|
||||
*/
|
||||
|
||||
import { operations } from './types.js';
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* version: 2023.12.2
|
||||
* generatedAt: 2024-01-04T18:10:15.091Z
|
||||
* generatedAt: 2024-01-07T09:49:34.518Z
|
||||
*/
|
||||
|
||||
import { components } from './types.js';
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
/*
|
||||
* version: 2023.12.2
|
||||
* generatedAt: 2024-01-04T18:10:15.023Z
|
||||
* generatedAt: 2024-01-07T09:49:34.268Z
|
||||
*/
|
||||
|
||||
/**
|
||||
|
@ -1966,6 +1966,16 @@ export type paths = {
|
|||
*/
|
||||
post: operations['i/export-notes'];
|
||||
};
|
||||
'/i/export-clips': {
|
||||
/**
|
||||
* i/export-clips
|
||||
* @description No description provided.
|
||||
*
|
||||
* **Internal Endpoint**: This endpoint is an API for the misskey mainframe and is not intended for use by third parties.
|
||||
* **Credential required**: *Yes*
|
||||
*/
|
||||
post: operations['i/export-clips'];
|
||||
};
|
||||
'/i/export-favorites': {
|
||||
/**
|
||||
* i/export-favorites
|
||||
|
@ -16243,6 +16253,57 @@ export type operations = {
|
|||
};
|
||||
};
|
||||
};
|
||||
/**
|
||||
* i/export-clips
|
||||
* @description No description provided.
|
||||
*
|
||||
* **Internal Endpoint**: This endpoint is an API for the misskey mainframe and is not intended for use by third parties.
|
||||
* **Credential required**: *Yes*
|
||||
*/
|
||||
'i/export-clips': {
|
||||
responses: {
|
||||
/** @description OK (without any results) */
|
||||
204: {
|
||||
content: never;
|
||||
};
|
||||
/** @description Client error */
|
||||
400: {
|
||||
content: {
|
||||
'application/json': components['schemas']['Error'];
|
||||
};
|
||||
};
|
||||
/** @description Authentication error */
|
||||
401: {
|
||||
content: {
|
||||
'application/json': components['schemas']['Error'];
|
||||
};
|
||||
};
|
||||
/** @description Forbidden error */
|
||||
403: {
|
||||
content: {
|
||||
'application/json': components['schemas']['Error'];
|
||||
};
|
||||
};
|
||||
/** @description I'm Ai */
|
||||
418: {
|
||||
content: {
|
||||
'application/json': components['schemas']['Error'];
|
||||
};
|
||||
};
|
||||
/** @description To many requests */
|
||||
429: {
|
||||
content: {
|
||||
'application/json': components['schemas']['Error'];
|
||||
};
|
||||
};
|
||||
/** @description Internal server error */
|
||||
500: {
|
||||
content: {
|
||||
'application/json': components['schemas']['Error'];
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
/**
|
||||
* i/export-favorites
|
||||
* @description No description provided.
|
||||
|
|
|
@ -149,7 +149,7 @@ export type ServerStats = {
|
|||
}
|
||||
};
|
||||
|
||||
export type ServerStatsLog = string[];
|
||||
export type ServerStatsLog = ServerStats[];
|
||||
|
||||
export type QueueStats = {
|
||||
deliver: {
|
||||
|
@ -166,7 +166,7 @@ export type QueueStats = {
|
|||
};
|
||||
};
|
||||
|
||||
export type QueueStatsLog = string[];
|
||||
export type QueueStatsLog = QueueStats[];
|
||||
|
||||
export type EmojiAdded = {
|
||||
emoji: EmojiDetailed
|
||||
|
|
Loading…
Reference in a new issue