Storefronts can filter published content by metadata.tags the same way as products; website API docs are updated to match. Co-authored-by: Cursor <cursoragent@cursor.com>
179 lines
2.6 KiB
TypeScript
179 lines
2.6 KiB
TypeScript
import { BlogPostType, ContentStatus } from '@prisma/client';
|
|
import { Type } from 'class-transformer';
|
|
import {
|
|
IsArray,
|
|
IsEnum,
|
|
IsInt,
|
|
IsOptional,
|
|
IsString,
|
|
Matches,
|
|
Min,
|
|
MinLength,
|
|
} from 'class-validator';
|
|
|
|
export class ListBlogsDto {
|
|
@IsOptional()
|
|
@Type(() => Number)
|
|
@IsInt()
|
|
@Min(1)
|
|
page?: number;
|
|
|
|
@IsOptional()
|
|
@Type(() => Number)
|
|
@IsInt()
|
|
@Min(1)
|
|
pageSize?: number;
|
|
|
|
@IsOptional()
|
|
@IsEnum(ContentStatus)
|
|
status?: ContentStatus;
|
|
|
|
@IsOptional()
|
|
@IsEnum(BlogPostType)
|
|
type?: BlogPostType;
|
|
|
|
@IsOptional()
|
|
@IsString()
|
|
categoryId?: string;
|
|
|
|
@IsOptional()
|
|
@IsString()
|
|
title?: string;
|
|
|
|
@IsOptional()
|
|
@IsString()
|
|
tag?: string;
|
|
}
|
|
|
|
export class ListPublicBlogsDto {
|
|
@IsOptional()
|
|
@Type(() => Number)
|
|
@IsInt()
|
|
@Min(1)
|
|
page?: number;
|
|
|
|
@IsOptional()
|
|
@Type(() => Number)
|
|
@IsInt()
|
|
@Min(1)
|
|
pageSize?: number;
|
|
|
|
@IsOptional()
|
|
@IsEnum(BlogPostType)
|
|
type?: BlogPostType;
|
|
|
|
@IsOptional()
|
|
@IsString()
|
|
categoryId?: string;
|
|
|
|
@IsOptional()
|
|
@IsString()
|
|
title?: string;
|
|
|
|
@IsOptional()
|
|
@IsString()
|
|
tag?: string;
|
|
}
|
|
|
|
export class CreateBlogDto {
|
|
@IsString()
|
|
@MinLength(2)
|
|
title!: string;
|
|
|
|
@IsEnum(BlogPostType)
|
|
type!: BlogPostType;
|
|
|
|
@IsOptional()
|
|
@IsString()
|
|
abstract?: string;
|
|
|
|
@IsOptional()
|
|
@IsString()
|
|
mainTextHtml?: string;
|
|
|
|
@IsOptional()
|
|
@IsString()
|
|
categoryId?: string;
|
|
|
|
@IsOptional()
|
|
@IsEnum(ContentStatus)
|
|
status?: ContentStatus;
|
|
|
|
@IsOptional()
|
|
@IsString()
|
|
featuredMediaId?: string;
|
|
|
|
@IsOptional()
|
|
@IsArray()
|
|
@IsString({ each: true })
|
|
tags?: string[];
|
|
|
|
@IsOptional()
|
|
@IsString()
|
|
authorId?: string;
|
|
|
|
@IsOptional()
|
|
@IsString()
|
|
@Matches(/^[a-z0-9]+(?:-[a-z0-9]+)*$/)
|
|
slug?: string;
|
|
}
|
|
|
|
export class UpdateBlogDto {
|
|
@IsOptional()
|
|
@IsString()
|
|
@MinLength(2)
|
|
title?: string;
|
|
|
|
@IsOptional()
|
|
@IsEnum(BlogPostType)
|
|
type?: BlogPostType;
|
|
|
|
@IsOptional()
|
|
@IsString()
|
|
abstract?: string | null;
|
|
|
|
@IsOptional()
|
|
@IsString()
|
|
mainTextHtml?: string | null;
|
|
|
|
@IsOptional()
|
|
@IsString()
|
|
categoryId?: string | null;
|
|
|
|
@IsOptional()
|
|
@IsEnum(ContentStatus)
|
|
status?: ContentStatus;
|
|
|
|
@IsOptional()
|
|
@IsString()
|
|
featuredMediaId?: string | null;
|
|
|
|
@IsOptional()
|
|
@IsArray()
|
|
@IsString({ each: true })
|
|
tags?: string[];
|
|
|
|
@IsOptional()
|
|
@IsString()
|
|
authorId?: string | null;
|
|
|
|
@IsOptional()
|
|
@IsString()
|
|
@Matches(/^[a-z0-9]+(?:-[a-z0-9]+)*$/)
|
|
slug?: string;
|
|
}
|
|
|
|
export class CreateBlogCommentDto {
|
|
@IsString()
|
|
@MinLength(2)
|
|
authorName!: string;
|
|
|
|
@IsOptional()
|
|
@IsString()
|
|
authorEmail?: string;
|
|
|
|
@IsString()
|
|
@MinLength(1)
|
|
text!: string;
|
|
}
|