diff --git a/packages/backend/src/server/api/endpoints/charts/active-users.ts b/packages/backend/src/server/api/endpoints/charts/active-users.ts index 2ab58e430..6d20a40e2 100644 --- a/packages/backend/src/server/api/endpoints/charts/active-users.ts +++ b/packages/backend/src/server/api/endpoints/charts/active-users.ts @@ -1,35 +1,15 @@ import { Injectable } from '@nestjs/common'; -import { getJsonSchema } from '@/core/chart/core.js'; import { Endpoint } from '@/server/api/endpoint-base.js'; import ActiveUsersChart from '@/core/chart/charts/active-users.js'; -import { schema } from '@/core/chart/charts/entities/active-users.js'; - -export const meta = { - tags: ['charts', 'users'], - - res: getJsonSchema(schema), - - allowGet: true, - cacheSec: 60 * 60, -} as const; - -export const paramDef = { - type: 'object', - properties: { - span: { type: 'string', enum: ['day', 'hour'] }, - limit: { type: 'integer', minimum: 1, maximum: 500, default: 30 }, - offset: { type: 'integer', nullable: true, default: null }, - }, - required: ['span'], -} as const; // eslint-disable-next-line import/no-default-export @Injectable() -export default class extends Endpoint { +export default class extends Endpoint<'charts/active-users'> { + name = 'charts/active-users' as const; constructor( private activeUsersChart: ActiveUsersChart, ) { - super(meta, paramDef, async (ps, me) => { + super(async (ps, me) => { return await this.activeUsersChart.getChart(ps.span, ps.limit, ps.offset ? new Date(ps.offset) : null); }); } diff --git a/packages/backend/src/server/api/endpoints/charts/ap-request.ts b/packages/backend/src/server/api/endpoints/charts/ap-request.ts index e40a53d82..15472fbea 100644 --- a/packages/backend/src/server/api/endpoints/charts/ap-request.ts +++ b/packages/backend/src/server/api/endpoints/charts/ap-request.ts @@ -1,35 +1,15 @@ import { Injectable } from '@nestjs/common'; -import { getJsonSchema } from '@/core/chart/core.js'; import { Endpoint } from '@/server/api/endpoint-base.js'; import ApRequestChart from '@/core/chart/charts/ap-request.js'; -import { schema } from '@/core/chart/charts/entities/ap-request.js'; - -export const meta = { - tags: ['charts'], - - res: getJsonSchema(schema), - - allowGet: true, - cacheSec: 60 * 60, -} as const; - -export const paramDef = { - type: 'object', - properties: { - span: { type: 'string', enum: ['day', 'hour'] }, - limit: { type: 'integer', minimum: 1, maximum: 500, default: 30 }, - offset: { type: 'integer', nullable: true, default: null }, - }, - required: ['span'], -} as const; // eslint-disable-next-line import/no-default-export @Injectable() -export default class extends Endpoint { +export default class extends Endpoint<'charts/ap-request'> { + name = 'charts/ap-request' as const; constructor( private apRequestChart: ApRequestChart, ) { - super(meta, paramDef, async (ps, me) => { + super(async (ps, me) => { return await this.apRequestChart.getChart(ps.span, ps.limit, ps.offset ? new Date(ps.offset) : null); }); } diff --git a/packages/backend/src/server/api/endpoints/charts/drive.ts b/packages/backend/src/server/api/endpoints/charts/drive.ts index 9a5aff4af..9e1d475e7 100644 --- a/packages/backend/src/server/api/endpoints/charts/drive.ts +++ b/packages/backend/src/server/api/endpoints/charts/drive.ts @@ -1,35 +1,15 @@ import { Injectable } from '@nestjs/common'; -import { getJsonSchema } from '@/core/chart/core.js'; import { Endpoint } from '@/server/api/endpoint-base.js'; import DriveChart from '@/core/chart/charts/drive.js'; -import { schema } from '@/core/chart/charts/entities/drive.js'; - -export const meta = { - tags: ['charts', 'drive'], - - res: getJsonSchema(schema), - - allowGet: true, - cacheSec: 60 * 60, -} as const; - -export const paramDef = { - type: 'object', - properties: { - span: { type: 'string', enum: ['day', 'hour'] }, - limit: { type: 'integer', minimum: 1, maximum: 500, default: 30 }, - offset: { type: 'integer', nullable: true, default: null }, - }, - required: ['span'], -} as const; // eslint-disable-next-line import/no-default-export @Injectable() -export default class extends Endpoint { +export default class extends Endpoint<'charts/drive'> { + name = 'charts/drive' as const; constructor( private driveChart: DriveChart, ) { - super(meta, paramDef, async (ps, me) => { + super(async (ps, me) => { return await this.driveChart.getChart(ps.span, ps.limit, ps.offset ? new Date(ps.offset) : null); }); } diff --git a/packages/backend/src/server/api/endpoints/charts/federation.ts b/packages/backend/src/server/api/endpoints/charts/federation.ts index ed3a96868..b04fad923 100644 --- a/packages/backend/src/server/api/endpoints/charts/federation.ts +++ b/packages/backend/src/server/api/endpoints/charts/federation.ts @@ -1,35 +1,15 @@ import { Injectable } from '@nestjs/common'; -import { getJsonSchema } from '@/core/chart/core.js'; import { Endpoint } from '@/server/api/endpoint-base.js'; import FederationChart from '@/core/chart/charts/federation.js'; -import { schema } from '@/core/chart/charts/entities/federation.js'; - -export const meta = { - tags: ['charts'], - - res: getJsonSchema(schema), - - allowGet: true, - cacheSec: 60 * 60, -} as const; - -export const paramDef = { - type: 'object', - properties: { - span: { type: 'string', enum: ['day', 'hour'] }, - limit: { type: 'integer', minimum: 1, maximum: 500, default: 30 }, - offset: { type: 'integer', nullable: true, default: null }, - }, - required: ['span'], -} as const; // eslint-disable-next-line import/no-default-export @Injectable() -export default class extends Endpoint { +export default class extends Endpoint<'charts/federation'> { + name = 'charts/federation' as const; constructor( private federationChart: FederationChart, ) { - super(meta, paramDef, async (ps, me) => { + super(async (ps, me) => { return await this.federationChart.getChart(ps.span, ps.limit, ps.offset ? new Date(ps.offset) : null); }); } diff --git a/packages/backend/src/server/api/endpoints/charts/instance.ts b/packages/backend/src/server/api/endpoints/charts/instance.ts index c992d525c..ea280e288 100644 --- a/packages/backend/src/server/api/endpoints/charts/instance.ts +++ b/packages/backend/src/server/api/endpoints/charts/instance.ts @@ -1,36 +1,15 @@ import { Injectable } from '@nestjs/common'; -import { getJsonSchema } from '@/core/chart/core.js'; import { Endpoint } from '@/server/api/endpoint-base.js'; import InstanceChart from '@/core/chart/charts/instance.js'; -import { schema } from '@/core/chart/charts/entities/instance.js'; - -export const meta = { - tags: ['charts'], - - res: getJsonSchema(schema), - - allowGet: true, - cacheSec: 60 * 60, -} as const; - -export const paramDef = { - type: 'object', - properties: { - span: { type: 'string', enum: ['day', 'hour'] }, - limit: { type: 'integer', minimum: 1, maximum: 500, default: 30 }, - offset: { type: 'integer', nullable: true, default: null }, - host: { type: 'string' }, - }, - required: ['span', 'host'], -} as const; // eslint-disable-next-line import/no-default-export @Injectable() -export default class extends Endpoint { +export default class extends Endpoint<'charts/instance'> { + name = 'charts/instance' as const; constructor( private instanceChart: InstanceChart, ) { - super(meta, paramDef, async (ps, me) => { + super(async (ps, me) => { return await this.instanceChart.getChart(ps.span, ps.limit, ps.offset ? new Date(ps.offset) : null, ps.host); }); } diff --git a/packages/backend/src/server/api/endpoints/charts/notes.ts b/packages/backend/src/server/api/endpoints/charts/notes.ts index 5750cd5b7..d7b51cf3f 100644 --- a/packages/backend/src/server/api/endpoints/charts/notes.ts +++ b/packages/backend/src/server/api/endpoints/charts/notes.ts @@ -1,35 +1,15 @@ import { Injectable } from '@nestjs/common'; -import { getJsonSchema } from '@/core/chart/core.js'; import { Endpoint } from '@/server/api/endpoint-base.js'; import NotesChart from '@/core/chart/charts/notes.js'; -import { schema } from '@/core/chart/charts/entities/notes.js'; - -export const meta = { - tags: ['charts', 'notes'], - - res: getJsonSchema(schema), - - allowGet: true, - cacheSec: 60 * 60, -} as const; - -export const paramDef = { - type: 'object', - properties: { - span: { type: 'string', enum: ['day', 'hour'] }, - limit: { type: 'integer', minimum: 1, maximum: 500, default: 30 }, - offset: { type: 'integer', nullable: true, default: null }, - }, - required: ['span'], -} as const; // eslint-disable-next-line import/no-default-export @Injectable() -export default class extends Endpoint { +export default class extends Endpoint<'charts/notes'> { + name = 'charts/notes' as const; constructor( private notesChart: NotesChart, ) { - super(meta, paramDef, async (ps, me) => { + super(async (ps, me) => { return await this.notesChart.getChart(ps.span, ps.limit, ps.offset ? new Date(ps.offset) : null); }); } diff --git a/packages/backend/src/server/api/endpoints/charts/users.ts b/packages/backend/src/server/api/endpoints/charts/users.ts index 1374f0204..e4c375c81 100644 --- a/packages/backend/src/server/api/endpoints/charts/users.ts +++ b/packages/backend/src/server/api/endpoints/charts/users.ts @@ -1,35 +1,15 @@ import { Injectable } from '@nestjs/common'; -import { getJsonSchema } from '@/core/chart/core.js'; import { Endpoint } from '@/server/api/endpoint-base.js'; import UsersChart from '@/core/chart/charts/users.js'; -import { schema } from '@/core/chart/charts/entities/users.js'; - -export const meta = { - tags: ['charts', 'users'], - - res: getJsonSchema(schema), - - allowGet: true, - cacheSec: 60 * 60, -} as const; - -export const paramDef = { - type: 'object', - properties: { - span: { type: 'string', enum: ['day', 'hour'] }, - limit: { type: 'integer', minimum: 1, maximum: 500, default: 30 }, - offset: { type: 'integer', nullable: true, default: null }, - }, - required: ['span'], -} as const; // eslint-disable-next-line import/no-default-export @Injectable() -export default class extends Endpoint { +export default class extends Endpoint<'charts/users'> { + name = 'charts/users' as const; constructor( private usersChart: UsersChart, ) { - super(meta, paramDef, async (ps, me) => { + super(async (ps, me) => { return await this.usersChart.getChart(ps.span, ps.limit, ps.offset ? new Date(ps.offset) : null); }); } diff --git a/packages/misskey-js/src/endpoints.ts b/packages/misskey-js/src/endpoints.ts index d9ffd80b7..39863512c 100644 --- a/packages/misskey-js/src/endpoints.ts +++ b/packages/misskey-js/src/endpoints.ts @@ -3088,6 +3088,140 @@ export const endpoints = { res: chartSchemaToJSONSchema(chartsSchemas.perUserReactions) satisfies JSONSchema7, }], }, + 'charts/active-users': { + tags: ['charts', 'users'], + + allowGet: true, + cacheSec: 60 * 60, + + defines: [{ + req: { + type: 'object', + properties: { + span: { type: 'string', enum: ['day', 'hour'] }, + limit: { type: 'integer', minimum: 1, maximum: 500, default: 30 }, + offset: { type: 'integer', nullable: true, default: null }, + }, + required: ['span'], + }, + res: chartSchemaToJSONSchema(chartsSchemas.activeUsers) satisfies JSONSchema7, + }], + }, + 'charts/ap-request': { + tags: ['charts'], + + allowGet: true, + cacheSec: 60 * 60, + + defines: [{ + req: { + type: 'object', + properties: { + span: { type: 'string', enum: ['day', 'hour'] }, + limit: { type: 'integer', minimum: 1, maximum: 500, default: 30 }, + offset: { type: 'integer', nullable: true, default: null }, + }, + required: ['span'], + }, + res: chartSchemaToJSONSchema(chartsSchemas.apRequest) satisfies JSONSchema7, + }], + }, + 'charts/drive': { + tags: ['charts', 'drive'], + + allowGet: true, + cacheSec: 60 * 60, + + defines: [{ + req: { + type: 'object', + properties: { + span: { type: 'string', enum: ['day', 'hour'] }, + limit: { type: 'integer', minimum: 1, maximum: 500, default: 30 }, + offset: { type: 'integer', nullable: true, default: null }, + }, + required: ['span'], + }, + res: chartSchemaToJSONSchema(chartsSchemas.drive) satisfies JSONSchema7, + }], + }, + 'charts/federation': { + tags: ['charts'], + + allowGet: true, + cacheSec: 60 * 60, + + defines: [{ + req: { + type: 'object', + properties: { + span: { type: 'string', enum: ['day', 'hour'] }, + limit: { type: 'integer', minimum: 1, maximum: 500, default: 30 }, + offset: { type: 'integer', nullable: true, default: null }, + }, + required: ['span'], + }, + res: chartSchemaToJSONSchema(chartsSchemas.federation) satisfies JSONSchema7, + }], + }, + 'charts/instance': { + tags: ['charts'], + + allowGet: true, + cacheSec: 60 * 60, + + defines: [{ + req: { + type: 'object', + properties: { + span: { type: 'string', enum: ['day', 'hour'] }, + limit: { type: 'integer', minimum: 1, maximum: 500, default: 30 }, + offset: { type: 'integer', nullable: true, default: null }, + host: { type: 'string' }, + }, + required: ['span', 'host'], + }, + res: chartSchemaToJSONSchema(chartsSchemas.instance) satisfies JSONSchema7, + }], + }, + 'charts/notes': { + tags: ['charts', 'notes'], + + allowGet: true, + cacheSec: 60 * 60, + + defines: [{ + req: { + type: 'object', + properties: { + span: { type: 'string', enum: ['day', 'hour'] }, + limit: { type: 'integer', minimum: 1, maximum: 500, default: 30 }, + offset: { type: 'integer', nullable: true, default: null }, + }, + required: ['span'], + }, + res: chartSchemaToJSONSchema(chartsSchemas.notes) satisfies JSONSchema7, + }], + }, + 'charts/users': { + tags: ['charts', 'users'], + + allowGet: true, + cacheSec: 60 * 60, + + defines: [{ + req: { + type: 'object', + properties: { + span: { type: 'string', enum: ['day', 'hour'] }, + limit: { type: 'integer', minimum: 1, maximum: 500, default: 30 }, + offset: { type: 'integer', nullable: true, default: null }, + }, + required: ['span'], + }, + res: chartSchemaToJSONSchema(chartsSchemas.users) satisfies JSONSchema7, + }], + }, //#endregion } as const satisfies { [x: string]: IEndpointMeta; };