refactor: Expand schema (#7772)
* packedNotificationSchemaを更新 * read:gallery, write:gallery, read:gallery-likes, write:gallery-likesに翻訳を追加 * fix * add header, choice, invitation * test * fix * yatta * remove no longer needed "as PackedUser/PackedNote" * clean up * add simple-schema * fix lint * define items in full Schema * revert https://github.com/misskey-dev/misskey/pull/7772#discussion_r706627736 * user packとnote packの型不整合を修正
This commit is contained in:
parent
f59f424795
commit
53f3b779bf
24 changed files with 148 additions and 129 deletions
|
|
@ -7,7 +7,7 @@
|
|||
import * as nestedProperty from 'nested-property';
|
||||
import autobind from 'autobind-decorator';
|
||||
import Logger from '../logger';
|
||||
import { Schema } from '@/misc/schema';
|
||||
import { SimpleSchema } from '@/misc/simple-schema';
|
||||
import { EntitySchema, getRepository, Repository, LessThan, Between } from 'typeorm';
|
||||
import { dateUTC, isTimeSame, isTimeBefore, subtractTime, addTime } from '@/prelude/time';
|
||||
import { getChartInsertLock } from '@/misc/app-lock';
|
||||
|
|
@ -56,7 +56,7 @@ export default abstract class Chart<T extends Record<string, any>> {
|
|||
diff: DeepPartial<T>;
|
||||
group: string | null;
|
||||
}[] = [];
|
||||
public schema: Schema;
|
||||
public schema: SimpleSchema;
|
||||
protected repository: Repository<Log>;
|
||||
|
||||
protected abstract genNewLog(latest: T): DeepPartial<T>;
|
||||
|
|
@ -69,7 +69,7 @@ export default abstract class Chart<T extends Record<string, any>> {
|
|||
protected abstract fetchActual(group: string | null): Promise<DeepPartial<T>>;
|
||||
|
||||
@autobind
|
||||
private static convertSchemaToFlatColumnDefinitions(schema: Schema) {
|
||||
private static convertSchemaToFlatColumnDefinitions(schema: SimpleSchema) {
|
||||
const columns = {} as any;
|
||||
const flatColumns = (x: Obj, path?: string) => {
|
||||
for (const [k, v] of Object.entries(x)) {
|
||||
|
|
@ -181,7 +181,7 @@ export default abstract class Chart<T extends Record<string, any>> {
|
|||
}
|
||||
|
||||
@autobind
|
||||
public static schemaToEntity(name: string, schema: Schema): EntitySchema {
|
||||
public static schemaToEntity(name: string, schema: SimpleSchema): EntitySchema {
|
||||
return new EntitySchema({
|
||||
name: `__chart__${camelToSnake(name)}`,
|
||||
columns: {
|
||||
|
|
@ -211,7 +211,7 @@ export default abstract class Chart<T extends Record<string, any>> {
|
|||
});
|
||||
}
|
||||
|
||||
constructor(name: string, schema: Schema, grouped = false) {
|
||||
constructor(name: string, schema: SimpleSchema, grouped = false) {
|
||||
this.name = name;
|
||||
this.schema = schema;
|
||||
const entity = Chart.schemaToEntity(name, schema);
|
||||
|
|
@ -546,8 +546,8 @@ export default abstract class Chart<T extends Record<string, any>> {
|
|||
}
|
||||
}
|
||||
|
||||
export function convertLog(logSchema: Schema): Schema {
|
||||
const v: Schema = JSON.parse(JSON.stringify(logSchema)); // copy
|
||||
export function convertLog(logSchema: SimpleSchema): SimpleSchema {
|
||||
const v: SimpleSchema = JSON.parse(JSON.stringify(logSchema)); // copy
|
||||
if (v.type === 'number') {
|
||||
v.type = 'array';
|
||||
v.items = {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue