Merge remote-tracking branch 'misskey-dev/develop' into io
This commit is contained in:
commit
9ffa56aa1b
200 changed files with 2833 additions and 4369 deletions
|
@ -54,9 +54,9 @@ export interface MainEventTypes {
|
|||
reply: Packed<'Note'>;
|
||||
renote: Packed<'Note'>;
|
||||
follow: Packed<'UserDetailedNotMe'>;
|
||||
followed: Packed<'User'>;
|
||||
unfollow: Packed<'User'>;
|
||||
meUpdated: Packed<'User'>;
|
||||
followed: Packed<'UserDetailed' | 'UserLite'>;
|
||||
unfollow: Packed<'UserDetailed'>;
|
||||
meUpdated: Packed<'UserDetailed'>;
|
||||
pageEvent: {
|
||||
pageId: MiPage['id'];
|
||||
event: string;
|
||||
|
|
|
@ -94,6 +94,29 @@ type ToJsonSchema<S> = {
|
|||
};
|
||||
|
||||
export function getJsonSchema<S extends Schema>(schema: S): ToJsonSchema<Unflatten<ChartResult<S>>> {
|
||||
const unflatten = (str: string, parent: Record<string, any>) => {
|
||||
const keys = str.split('.');
|
||||
const key = keys.shift();
|
||||
const nextKey = keys[0];
|
||||
|
||||
if (key == null) return;
|
||||
|
||||
if (parent.properties[key] == null) {
|
||||
parent.properties[key] = nextKey ? {
|
||||
type: 'object',
|
||||
properties: {},
|
||||
required: [],
|
||||
} : {
|
||||
type: 'array',
|
||||
items: {
|
||||
type: 'number',
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
if (nextKey) unflatten(keys.join('.'), parent.properties[key] as Record<string, any>);
|
||||
};
|
||||
|
||||
const jsonSchema = {
|
||||
type: 'object',
|
||||
properties: {} as Record<string, unknown>,
|
||||
|
@ -101,10 +124,7 @@ export function getJsonSchema<S extends Schema>(schema: S): ToJsonSchema<Unflatt
|
|||
};
|
||||
|
||||
for (const k in schema) {
|
||||
jsonSchema.properties[k] = {
|
||||
type: 'array',
|
||||
items: { type: 'number' },
|
||||
};
|
||||
unflatten(k, jsonSchema);
|
||||
}
|
||||
|
||||
return jsonSchema as ToJsonSchema<Unflatten<ChartResult<S>>>;
|
||||
|
|
|
@ -164,7 +164,7 @@ export class NoteEntityService implements OnModuleInit {
|
|||
|
||||
return {
|
||||
multiple: poll.multiple,
|
||||
expiresAt: poll.expiresAt,
|
||||
expiresAt: poll.expiresAt?.toISOString() ?? null,
|
||||
choices,
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue