forked from FoundKeyGang/FoundKey
adjust types & api for pages
This commit is contained in:
parent
95d92a711a
commit
90d35b951f
5 changed files with 11 additions and 44 deletions
|
@ -75,21 +75,10 @@ export class Page {
|
|||
@JoinColumn()
|
||||
public eyeCatchingImage: DriveFile | null;
|
||||
|
||||
@Column('jsonb', {
|
||||
default: [],
|
||||
})
|
||||
public content: Record<string, any>[];
|
||||
|
||||
@Column('jsonb', {
|
||||
default: [],
|
||||
})
|
||||
public variables: Record<string, any>[];
|
||||
|
||||
@Column('varchar', {
|
||||
length: 16384,
|
||||
@Column('text', {
|
||||
default: '',
|
||||
})
|
||||
public script: string;
|
||||
public text: string;
|
||||
|
||||
/**
|
||||
* public ... 公開
|
||||
|
|
|
@ -62,15 +62,13 @@ export const PageRepository = db.getRepository(Page).extend({
|
|||
updatedAt: page.updatedAt.toISOString(),
|
||||
userId: page.userId,
|
||||
user: Users.pack(page.user || page.userId, me), // { detail: true } すると無限ループするので注意
|
||||
content: page.content,
|
||||
variables: page.variables,
|
||||
text: page.text,
|
||||
title: page.title,
|
||||
name: page.name,
|
||||
summary: page.summary,
|
||||
hideTitleWhenPinned: page.hideTitleWhenPinned,
|
||||
alignCenter: page.alignCenter,
|
||||
font: page.font,
|
||||
script: page.script,
|
||||
eyeCatchingImageId: page.eyeCatchingImageId,
|
||||
eyeCatchingImage: page.eyeCatchingImageId ? await DriveFiles.pack(page.eyeCatchingImageId) : null,
|
||||
attachedFiles: DriveFiles.packMany((await Promise.all(attachedFiles)).filter((x): x is DriveFile => x != null)),
|
||||
|
|
|
@ -29,12 +29,8 @@ export const packedPageSchema = {
|
|||
type: 'string',
|
||||
optional: false, nullable: true,
|
||||
},
|
||||
content: {
|
||||
type: 'array',
|
||||
optional: false, nullable: false,
|
||||
},
|
||||
variables: {
|
||||
type: 'array',
|
||||
text: {
|
||||
type: 'string',
|
||||
optional: false, nullable: false,
|
||||
},
|
||||
userId: {
|
||||
|
|
|
@ -43,19 +43,13 @@ export const paramDef = {
|
|||
title: { type: 'string' },
|
||||
name: { type: 'string', minLength: 1 },
|
||||
summary: { type: 'string', nullable: true },
|
||||
content: { type: 'array', items: {
|
||||
type: 'object', additionalProperties: true,
|
||||
} },
|
||||
variables: { type: 'array', items: {
|
||||
type: 'object', additionalProperties: true,
|
||||
} },
|
||||
script: { type: 'string' },
|
||||
text: { type: 'string', minLength: 1 },
|
||||
eyeCatchingImageId: { type: 'string', format: 'misskey:id', nullable: true },
|
||||
font: { type: 'string', enum: ['serif', 'sans-serif'], default: 'sans-serif' },
|
||||
alignCenter: { type: 'boolean', default: false },
|
||||
hideTitleWhenPinned: { type: 'boolean', default: false },
|
||||
},
|
||||
required: ['title', 'name', 'content', 'variables', 'script'],
|
||||
required: ['title', 'name', 'text'],
|
||||
} as const;
|
||||
|
||||
// eslint-disable-next-line import/no-default-export
|
||||
|
@ -88,9 +82,7 @@ export default define(meta, paramDef, async (ps, user) => {
|
|||
title: ps.title,
|
||||
name: ps.name,
|
||||
summary: ps.summary,
|
||||
content: ps.content,
|
||||
variables: ps.variables,
|
||||
script: ps.script,
|
||||
text: ps.text,
|
||||
eyeCatchingImageId: eyeCatchingImage ? eyeCatchingImage.id : null,
|
||||
userId: user.id,
|
||||
visibility: 'public',
|
||||
|
|
|
@ -49,19 +49,13 @@ export const paramDef = {
|
|||
title: { type: 'string' },
|
||||
name: { type: 'string', minLength: 1 },
|
||||
summary: { type: 'string', nullable: true },
|
||||
content: { type: 'array', items: {
|
||||
type: 'object', additionalProperties: true,
|
||||
} },
|
||||
variables: { type: 'array', items: {
|
||||
type: 'object', additionalProperties: true,
|
||||
} },
|
||||
script: { type: 'string' },
|
||||
text: { type: 'string', minLength: 1 },
|
||||
eyeCatchingImageId: { type: 'string', format: 'misskey:id', nullable: true },
|
||||
font: { type: 'string', enum: ['serif', 'sans-serif'] },
|
||||
alignCenter: { type: 'boolean' },
|
||||
hideTitleWhenPinned: { type: 'boolean' },
|
||||
},
|
||||
required: ['pageId', 'title', 'name', 'content', 'variables', 'script'],
|
||||
required: ['pageId', 'title', 'name', 'text'],
|
||||
} as const;
|
||||
|
||||
// eslint-disable-next-line import/no-default-export
|
||||
|
@ -101,9 +95,7 @@ export default define(meta, paramDef, async (ps, user) => {
|
|||
title: ps.title,
|
||||
name: ps.name === undefined ? page.name : ps.name,
|
||||
summary: ps.name === undefined ? page.summary : ps.summary,
|
||||
content: ps.content,
|
||||
variables: ps.variables,
|
||||
script: ps.script,
|
||||
text: ps.text,
|
||||
alignCenter: ps.alignCenter === undefined ? page.alignCenter : ps.alignCenter,
|
||||
hideTitleWhenPinned: ps.hideTitleWhenPinned === undefined ? page.hideTitleWhenPinned : ps.hideTitleWhenPinned,
|
||||
font: ps.font === undefined ? page.font : ps.font,
|
||||
|
|
Loading…
Reference in a new issue