backend/lib/seed/graphql/baseModels/BaseSeoModel.ts
2025-05-14 21:45:16 +02:00

104 lines
3.2 KiB
TypeScript

import { ObjectType, Field, ID, ArgsType, InputType, Int } from 'type-graphql';
import { BaseGraphModel } from '@seed/graphql/BaseGraphModel';
import ImageComponent, { SEOField } from '@seed/interfaces/components';
import { GetArgs, GetManyArgs } from '@seed/graphql/Request';
import { TranslatableComponent } from '@src/__components/components';
import { Permission } from '@seed/interfaces/permission';
import { AccountTypeEnum } from '@src/accounts/account.components';
const permissions: Permission = {
c: [AccountTypeEnum.admin],
r: [AccountTypeEnum.public],
w: [AccountTypeEnum.admin],
d: [AccountTypeEnum.admin],
};
@ObjectType()
export default class BaseSEOModel extends BaseGraphModel {
public constructor(collectionName?: string, perm?: Permission) {
const cName = collectionName ? collectionName : 'articles';
const permission = perm ? perm : permissions;
super({
// ...init,
collectionName: cName,
permissions: permission,
});
}
@Field(() => TranslatableComponent, { nullable: true })
title?: TranslatableComponent;
@Field(() => TranslatableComponent, { nullable: true })
teaser?: TranslatableComponent;
@Field(() => ImageComponent, { nullable: true })
cover?: ImageComponent;
@Field(() => ImageComponent, { nullable: true })
thumbnail?: ImageComponent;
@Field(() => [ImageComponent], { nullable: true })
extraImages?: ImageComponent[];
@Field(() => TranslatableComponent, { nullable: true })
content?: TranslatableComponent;
@Field(() => SEOField, { nullable: true })
seo?: SEOField;
@Field({ nullable: true })
urls?: TranslatableComponent;
searchOptions(): string[] {
return [];
}
filterOptions(): string[] {
return [];
}
}
@ArgsType()
export class BaseSEOArgs extends GetManyArgs {}
@InputType()
export class NewBaseSEOInput implements Partial<BaseSEOModel> {
@Field(() => TranslatableComponent, { nullable: true })
title?: TranslatableComponent;
@Field(() => TranslatableComponent, { nullable: true })
teaser?: TranslatableComponent;
@Field(() => ImageComponent, { nullable: true })
cover?: ImageComponent;
@Field(() => ImageComponent, { nullable: true })
thumbnail?: ImageComponent;
@Field(() => TranslatableComponent, { nullable: true })
content?: TranslatableComponent;
@Field(() => SEOField, { nullable: true })
seo?: SEOField;
@Field({ nullable: true })
urls?: TranslatableComponent;
}
@InputType()
export class EditBaseSEOInput implements Partial<BaseSEOModel> {
@Field(() => TranslatableComponent, { nullable: true })
title?: TranslatableComponent;
@Field(() => TranslatableComponent, { nullable: true })
teaser?: TranslatableComponent;
@Field(() => ImageComponent, { nullable: true })
cover?: ImageComponent;
@Field(() => ImageComponent, { nullable: true })
thumbnail?: ImageComponent;
@Field(() => TranslatableComponent, { nullable: true })
content?: TranslatableComponent;
@Field(() => SEOField, { nullable: true })
seo?: SEOField;
@Field({ nullable: true })
urls?: TranslatableComponent;
}