Merge remote-tracking branch 'misskey-dev/develop' into io

This commit is contained in:
まっちゃとーにゅ 2024-01-31 05:10:06 +09:00
commit 9ffa56aa1b
No known key found for this signature in database
GPG key ID: 143DE582A97FE052
200 changed files with 2833 additions and 4369 deletions

View file

@ -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;

View file

@ -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>>>;

View file

@ -164,7 +164,7 @@ export class NoteEntityService implements OnModuleInit {
return {
multiple: poll.multiple,
expiresAt: poll.expiresAt,
expiresAt: poll.expiresAt?.toISOString() ?? null,
choices,
};
}