chartsSchemasオブジェクトに集約

This commit is contained in:
tamaina 2023-06-05 06:05:36 +00:00
parent 9530cb01b9
commit bb46030677
34 changed files with 191 additions and 228 deletions

View file

@ -1,7 +1,7 @@
import Chart from '../../core.js'; import Chart from '../../core.js';
import * as _ from 'misskey-js/built/schemas/charts/active-users.js'; import { chartsSchemas } from 'misskey-js/built/schemas/charts.js';
export const name = _.name; export const name = 'activeUsers' as const;
export const schema = _.schema; export const schema = chartsSchemas[name];
export const entity = Chart.schemaToEntity(name, schema); export const entity = Chart.schemaToEntity(name, schema);

View file

@ -1,7 +1,7 @@
import Chart from '../../core.js'; import Chart from '../../core.js';
import * as _ from 'misskey-js/built/schemas/charts/ap-request.js'; import { chartsSchemas } from 'misskey-js/built/schemas/charts.js';
export const name = _.name; export const name = 'apRequest' as const;
export const schema = _.schema; export const schema = chartsSchemas[name];
export const entity = Chart.schemaToEntity(name, schema); export const entity = Chart.schemaToEntity(name, schema);

View file

@ -1,7 +1,7 @@
import Chart from '../../core.js'; import Chart from '../../core.js';
import * as _ from 'misskey-js/built/schemas/charts/drive.js'; import { chartsSchemas } from 'misskey-js/built/schemas/charts.js';
export const name = _.name; export const name = 'drive' as const;
export const schema = _.schema; export const schema = chartsSchemas[name];
export const entity = Chart.schemaToEntity(name, schema); export const entity = Chart.schemaToEntity(name, schema);

View file

@ -1,7 +1,7 @@
import Chart from '../../core.js'; import Chart from '../../core.js';
import * as _ from 'misskey-js/built/schemas/charts/federation.js'; import { chartsSchemas } from 'misskey-js/built/schemas/charts.js';
export const name = _.name; export const name = 'federation' as const;
export const schema = _.schema; export const schema = chartsSchemas[name];
export const entity = Chart.schemaToEntity(name, schema); export const entity = Chart.schemaToEntity(name, schema);

View file

@ -1,7 +1,7 @@
import Chart from '../../core.js'; import Chart from '../../core.js';
import * as _ from 'misskey-js/built/schemas/charts/instance.js'; import { chartsSchemas } from 'misskey-js/built/schemas/charts.js';
export const name = _.name; export const name = 'instance' as const;
export const schema = _.schema; export const schema = chartsSchemas[name];
export const entity = Chart.schemaToEntity(name, schema, true); export const entity = Chart.schemaToEntity(name, schema, true);

View file

@ -1,7 +1,7 @@
import Chart from '../../core.js'; import Chart from '../../core.js';
import * as _ from 'misskey-js/built/schemas/charts/notes.js'; import { chartsSchemas } from 'misskey-js/built/schemas/charts.js';
export const name = _.name; export const name = 'notes' as const;
export const schema = _.schema; export const schema = chartsSchemas[name];
export const entity = Chart.schemaToEntity(name, schema); export const entity = Chart.schemaToEntity(name, schema);

View file

@ -1,7 +1,7 @@
import Chart from '../../core.js'; import Chart from '../../core.js';
import * as _ from 'misskey-js/built/schemas/charts/per-user-drive.js'; import { chartsSchemas } from 'misskey-js/built/schemas/charts.js';
export const name = _.name; export const name = 'perUserDrive' as const;
export const schema = _.schema; export const schema = chartsSchemas[name];
export const entity = Chart.schemaToEntity(name, schema, true); export const entity = Chart.schemaToEntity(name, schema, true);

View file

@ -1,7 +1,7 @@
import Chart from '../../core.js'; import Chart from '../../core.js';
import * as _ from 'misskey-js/built/schemas/charts/per-user-following.js'; import { chartsSchemas } from 'misskey-js/built/schemas/charts.js';
export const name = _.name; export const name = 'perUserFollowing' as const;
export const schema = _.schema; export const schema = chartsSchemas[name];
export const entity = Chart.schemaToEntity(name, schema, true); export const entity = Chart.schemaToEntity(name, schema, true);

View file

@ -1,7 +1,7 @@
import Chart from '../../core.js'; import Chart from '../../core.js';
import * as _ from 'misskey-js/built/schemas/charts/per-user-notes.js'; import { chartsSchemas } from 'misskey-js/built/schemas/charts.js';
export const name = _.name; export const name = 'perUserNotes' as const;
export const schema = _.schema; export const schema = chartsSchemas[name];
export const entity = Chart.schemaToEntity(name, schema, true); export const entity = Chart.schemaToEntity(name, schema, true);

View file

@ -1,7 +1,7 @@
import Chart from '../../core.js'; import Chart from '../../core.js';
import * as _ from 'misskey-js/built/schemas/charts/per-user-pv.js'; import { chartsSchemas } from 'misskey-js/built/schemas/charts.js';
export const name = _.name; export const name = 'perUserPv' as const;
export const schema = _.schema; export const schema = chartsSchemas[name];
export const entity = Chart.schemaToEntity(name, schema, true); export const entity = Chart.schemaToEntity(name, schema, true);

View file

@ -1,7 +1,7 @@
import Chart from '../../core.js'; import Chart from '../../core.js';
import * as _ from 'misskey-js/built/schemas/charts/per-user-reactions.js'; import { chartsSchemas } from 'misskey-js/built/schemas/charts.js';
export const name = _.name; export const name = 'perUserReactions' as const;
export const schema = _.schema; export const schema = chartsSchemas[name];
export const entity = Chart.schemaToEntity(name, schema, true); export const entity = Chart.schemaToEntity(name, schema, true);

View file

@ -1,7 +1,7 @@
import Chart from '../../core.js'; import Chart from '../../core.js';
import * as _ from 'misskey-js/built/schemas/charts/test-grouped.js'; import { chartsSchemas } from 'misskey-js/built/schemas/charts.js';
export const name = _.name; export const name = 'testGrouped';
export const schema = _.schema; export const schema = chartsSchemas[name];
export const entity = Chart.schemaToEntity(name, schema, true); export const entity = Chart.schemaToEntity(name, schema, true);

View file

@ -1,7 +1,7 @@
import Chart from '../../core.js'; import Chart from '../../core.js';
import * as _ from 'misskey-js/built/schemas/charts/test-intersection.js'; import { chartsSchemas } from 'misskey-js/built/schemas/charts.js';
export const name = _.name; export const name = 'testIntersection';
export const schema = _.schema; export const schema = chartsSchemas[name];
export const entity = Chart.schemaToEntity(name, schema); export const entity = Chart.schemaToEntity(name, schema);

View file

@ -1,7 +1,7 @@
import Chart from '../../core.js'; import Chart from '../../core.js';
import * as _ from 'misskey-js/built/schemas/charts/test-unique.js'; import { chartsSchemas } from 'misskey-js/built/schemas/charts.js';
export const name = _.name; export const name = 'testUnique';
export const schema = _.schema; export const schema = chartsSchemas[name];
export const entity = Chart.schemaToEntity(name, schema); export const entity = Chart.schemaToEntity(name, schema);

View file

@ -1,7 +1,7 @@
import Chart from '../../core.js'; import Chart from '../../core.js';
import * as _ from 'misskey-js/built/schemas/charts/test.js'; import { chartsSchemas } from 'misskey-js/built/schemas/charts.js';
export const name = _.name; export const name = 'test';
export const schema = _.schema; export const schema = chartsSchemas[name];
export const entity = Chart.schemaToEntity(name, schema); export const entity = Chart.schemaToEntity(name, schema);

View file

@ -1,7 +1,7 @@
import Chart from '../../core.js'; import Chart from '../../core.js';
import * as _ from 'misskey-js/built/schemas/charts/users.js'; import { chartsSchemas } from 'misskey-js/built/schemas/charts.js';
export const name = _.name; export const name = 'users';
export const schema = _.schema; export const schema = chartsSchemas[name];
export const entity = Chart.schemaToEntity(name, schema); export const entity = Chart.schemaToEntity(name, schema);

View file

@ -3,8 +3,7 @@ import { IEndpointMeta } from './endpoints.types';
import { localUsernameSchema, passwordSchema } from './schemas/user'; import { localUsernameSchema, passwordSchema } from './schemas/user';
import ms from 'ms'; import ms from 'ms';
import { getJsonSchema } from './schemas'; import { getJsonSchema } from './schemas';
import * as perUserDriveChartSchema from './schemas/charts/per-user-drive'; import { chartsSchemas } from './schemas/charts.js';
import * as driveChartSchema from './schemas/charts/drive';
export const endpoints = { export const endpoints = {
//#region admin //#region admin
@ -3006,7 +3005,7 @@ export const endpoints = {
}, },
required: ['span', 'userId'], required: ['span', 'userId'],
}, },
res: getJsonSchema(perUserDriveChartSchema.schema) satisfies JSONSchema7, res: getJsonSchema(chartsSchemas.perUserDrive) satisfies JSONSchema7,
}], }],
}, },
//#endregion //#endregion

View file

@ -0,0 +1,141 @@
import { ChartSchema } from "../schemas";
export const chartsSchemas = {
'activeUsers': {
'readWrite': { intersection: ['read', 'write'] },
'read': { uniqueIncrement: true },
'write': { uniqueIncrement: true },
'registeredWithinWeek': { uniqueIncrement: true },
'registeredWithinMonth': { uniqueIncrement: true },
'registeredWithinYear': { uniqueIncrement: true },
'registeredOutsideWeek': { uniqueIncrement: true },
'registeredOutsideMonth': { uniqueIncrement: true },
'registeredOutsideYear': { uniqueIncrement: true },
},
'apRequest': {
'deliverFailed': { },
'deliverSucceeded': { },
'inboxReceived': { },
},
'drive': {
'local.incCount': {},
'local.incSize': {}, // in kilobyte
'local.decCount': {},
'local.decSize': {}, // in kilobyte
'remote.incCount': {},
'remote.incSize': {}, // in kilobyte
'remote.decCount': {},
'remote.decSize': {}, // in kilobyte
},
'federation': {
'deliveredInstances': { uniqueIncrement: true, range: 'small' },
'inboxInstances': { uniqueIncrement: true, range: 'small' },
'stalled': { uniqueIncrement: true, range: 'small' },
'sub': { accumulate: true, range: 'small' },
'pub': { accumulate: true, range: 'small' },
'pubsub': { accumulate: true, range: 'small' },
'subActive': { accumulate: true, range: 'small' },
'pubActive': { accumulate: true, range: 'small' },
},
'instance': {
'requests.failed': { range: 'small' },
'requests.succeeded': { range: 'small' },
'requests.received': { range: 'small' },
'notes.total': { accumulate: true },
'notes.inc': {},
'notes.dec': {},
'notes.diffs.normal': {},
'notes.diffs.reply': {},
'notes.diffs.renote': {},
'notes.diffs.withFile': {},
'users.total': { accumulate: true },
'users.inc': { range: 'small' },
'users.dec': { range: 'small' },
'following.total': { accumulate: true },
'following.inc': { range: 'small' },
'following.dec': { range: 'small' },
'followers.total': { accumulate: true },
'followers.inc': { range: 'small' },
'followers.dec': { range: 'small' },
'drive.totalFiles': { accumulate: true },
'drive.incFiles': {},
'drive.decFiles': {},
'drive.incUsage': {}, // in kilobyte
'drive.decUsage': {}, // in kilobyte
},
'notes': {
'totalCount': { accumulate: true },
'totalSize': { accumulate: true }, // in kilobyte
'incCount': { range: 'small' },
'incSize': {}, // in kilobyte
'decCount': { range: 'small' },
'decSize': {}, // in kilobyte
},
'perUserDrive': {
'totalCount': { accumulate: true },
'totalSize': { accumulate: true }, // in kilobyte
'incCount': { range: 'small' },
'incSize': {}, // in kilobyte
'decCount': { range: 'small' },
'decSize': {}, // in kilobyte
},
'perUserFollowing': {
'local.followings.total': { accumulate: true },
'local.followings.inc': { range: 'small' },
'local.followings.dec': { range: 'small' },
'local.followers.total': { accumulate: true },
'local.followers.inc': { range: 'small' },
'local.followers.dec': { range: 'small' },
'remote.followings.total': { accumulate: true },
'remote.followings.inc': { range: 'small' },
'remote.followings.dec': { range: 'small' },
'remote.followers.total': { accumulate: true },
'remote.followers.inc': { range: 'small' },
'remote.followers.dec': { range: 'small' },
},
'perUserNotes': {
'total': { accumulate: true },
'inc': { range: 'small' },
'dec': { range: 'small' },
'diffs.normal': { range: 'small' },
'diffs.reply': { range: 'small' },
'diffs.renote': { range: 'small' },
'diffs.withFile': { range: 'small' },
},
'perUserPv': {
'upv.user': { uniqueIncrement: true, range: 'small' },
'pv.user': { range: 'small' },
'upv.visitor': { uniqueIncrement: true, range: 'small' },
'pv.visitor': { range: 'small' },
},
'perUserReactions': {
'local.count': { range: 'small' },
'remote.count': { range: 'small' },
},
'testGrouped': {
'foo.total': { accumulate: true },
'foo.inc': {},
'foo.dec': {},
},
'testIntersection': {
'a': { uniqueIncrement: true },
'b': { uniqueIncrement: true },
'aAndB': { intersection: ['a', 'b'] },
},
'testUnique': {
'foo': { uniqueIncrement: true },
},
'test': {
'foo.total': { accumulate: true },
'foo.inc': {},
'foo.dec': {},
},
'users': {
'local.total': { accumulate: true },
'local.inc': { range: 'small' },
'local.dec': { range: 'small' },
'remote.total': { accumulate: true },
'remote.inc': { range: 'small' },
'remote.dec': { range: 'small' },
},
} as const satisfies Record<string, ChartSchema>;

View file

@ -1,13 +0,0 @@
export const name = 'activeUsers';
export const schema = {
'readWrite': { intersection: ['read', 'write'] },
'read': { uniqueIncrement: true },
'write': { uniqueIncrement: true },
'registeredWithinWeek': { uniqueIncrement: true },
'registeredWithinMonth': { uniqueIncrement: true },
'registeredWithinYear': { uniqueIncrement: true },
'registeredOutsideWeek': { uniqueIncrement: true },
'registeredOutsideMonth': { uniqueIncrement: true },
'registeredOutsideYear': { uniqueIncrement: true },
} as const;

View file

@ -1,7 +0,0 @@
export const name = 'apRequest';
export const schema = {
'deliverFailed': { },
'deliverSucceeded': { },
'inboxReceived': { },
} as const;

View file

@ -1,12 +0,0 @@
export const name = 'drive';
export const schema = {
'local.incCount': {},
'local.incSize': {}, // in kilobyte
'local.decCount': {},
'local.decSize': {}, // in kilobyte
'remote.incCount': {},
'remote.incSize': {}, // in kilobyte
'remote.decCount': {},
'remote.decSize': {}, // in kilobyte
} as const;

View file

@ -1,12 +0,0 @@
export const name = 'federation';
export const schema = {
'deliveredInstances': { uniqueIncrement: true, range: 'small' },
'inboxInstances': { uniqueIncrement: true, range: 'small' },
'stalled': { uniqueIncrement: true, range: 'small' },
'sub': { accumulate: true, range: 'small' },
'pub': { accumulate: true, range: 'small' },
'pubsub': { accumulate: true, range: 'small' },
'subActive': { accumulate: true, range: 'small' },
'pubActive': { accumulate: true, range: 'small' },
} as const;

View file

@ -1,28 +0,0 @@
export const name = 'instance';
export const schema = {
'requests.failed': { range: 'small' },
'requests.succeeded': { range: 'small' },
'requests.received': { range: 'small' },
'notes.total': { accumulate: true },
'notes.inc': {},
'notes.dec': {},
'notes.diffs.normal': {},
'notes.diffs.reply': {},
'notes.diffs.renote': {},
'notes.diffs.withFile': {},
'users.total': { accumulate: true },
'users.inc': { range: 'small' },
'users.dec': { range: 'small' },
'following.total': { accumulate: true },
'following.inc': { range: 'small' },
'following.dec': { range: 'small' },
'followers.total': { accumulate: true },
'followers.inc': { range: 'small' },
'followers.dec': { range: 'small' },
'drive.totalFiles': { accumulate: true },
'drive.incFiles': {},
'drive.decFiles': {},
'drive.incUsage': {}, // in kilobyte
'drive.decUsage': {}, // in kilobyte
} as const;

View file

@ -1,18 +0,0 @@
export const name = 'notes';
export const schema = {
'local.total': { accumulate: true },
'local.inc': {},
'local.dec': {},
'local.diffs.normal': {},
'local.diffs.reply': {},
'local.diffs.renote': {},
'local.diffs.withFile': {},
'remote.total': { accumulate: true },
'remote.inc': {},
'remote.dec': {},
'remote.diffs.normal': {},
'remote.diffs.reply': {},
'remote.diffs.renote': {},
'remote.diffs.withFile': {},
} as const;

View file

@ -1,10 +0,0 @@
export const name = 'perUserDrive';
export const schema = {
'totalCount': { accumulate: true },
'totalSize': { accumulate: true }, // in kilobyte
'incCount': { range: 'small' },
'incSize': {}, // in kilobyte
'decCount': { range: 'small' },
'decSize': {}, // in kilobyte
} as const;

View file

@ -1,16 +0,0 @@
export const name = 'perUserFollowing';
export const schema = {
'local.followings.total': { accumulate: true },
'local.followings.inc': { range: 'small' },
'local.followings.dec': { range: 'small' },
'local.followers.total': { accumulate: true },
'local.followers.inc': { range: 'small' },
'local.followers.dec': { range: 'small' },
'remote.followings.total': { accumulate: true },
'remote.followings.inc': { range: 'small' },
'remote.followings.dec': { range: 'small' },
'remote.followers.total': { accumulate: true },
'remote.followers.inc': { range: 'small' },
'remote.followers.dec': { range: 'small' },
} as const;

View file

@ -1,11 +0,0 @@
export const name = 'perUserNotes';
export const schema = {
'total': { accumulate: true },
'inc': { range: 'small' },
'dec': { range: 'small' },
'diffs.normal': { range: 'small' },
'diffs.reply': { range: 'small' },
'diffs.renote': { range: 'small' },
'diffs.withFile': { range: 'small' },
} as const;

View file

@ -1,8 +0,0 @@
export const name = 'perUserPv';
export const schema = {
'upv.user': { uniqueIncrement: true, range: 'small' },
'pv.user': { range: 'small' },
'upv.visitor': { uniqueIncrement: true, range: 'small' },
'pv.visitor': { range: 'small' },
} as const;

View file

@ -1,6 +0,0 @@
export const name = 'perUserReaction';
export const schema = {
'local.count': { range: 'small' },
'remote.count': { range: 'small' },
} as const;

View file

@ -1,7 +0,0 @@
export const name = 'testGrouped';
export const schema = {
'foo.total': { accumulate: true },
'foo.inc': {},
'foo.dec': {},
} as const;

View file

@ -1,7 +0,0 @@
export const name = 'testIntersection';
export const schema = {
'a': { uniqueIncrement: true },
'b': { uniqueIncrement: true },
'aAndB': { intersection: ['a', 'b'] },
} as const;

View file

@ -1,5 +0,0 @@
export const name = 'testUnique';
export const schema = {
'foo': { uniqueIncrement: true },
} as const;

View file

@ -1,7 +0,0 @@
export const name = 'test';
export const schema = {
'foo.total': { accumulate: true },
'foo.inc': {},
'foo.dec': {},
} as const;

View file

@ -1,10 +0,0 @@
export const name = 'users';
export const schema = {
'local.total': { accumulate: true },
'local.inc': { range: 'small' },
'local.dec': { range: 'small' },
'remote.total': { accumulate: true },
'remote.inc': { range: 'small' },
'remote.dec': { range: 'small' },
} as const;