Source

admin-bro-blog/src/types/blog-post-image.type.ts

/**
 * Type for an mixed property stored in the database responsible for `photoImage`
 * You can use it in your TypeScript schema like this:
 *
 * ```typescript
 * import { BlogPostImage } from '@softwarebrothers/admin-bro-blog'
 *
 * @Entity({ name: 'simple-blogs' })
 * export class SimpleBlog extends BaseEntity {
 *   @Column({type: 'jsonb', nullable: true  })
 *   public image?: BlogPostImage;
 * }
 * ```
 * @alias BlogPostImage
 * @memberof module:@softwarebrothers/admin-bro-blog
 */
export type BlogPostImage = {
  /** property holding object key (uploaded path) */
  key: string,
  /** mime type of uploaded file */
  mime: string,
  /** bucket (folder) where file has been stored */
  bucket: string,
  /** size of the uploaded file */
  size: number,
}

/**
 * Similar to {@link BlogPostImage} but for mixed property stored in the database responsible
 * for `inlineImages`.
 * @memberof module:@softwarebrothers/admin-bro-blog
 */
export type BlogPostImages = {
  /** Array holding object keys (uploaded path) */
  key: Array<string>,
  /** Array holding mime types */
  mimeType: Array<string>,
  /** Array holding buckets (folders) */
  bucket: Array<string>,
  /** Array holding sizes */
  size: Array<number>,
}

export const BLOG_POST_IMAGE_PROPERTIES = [
  'file',
  'filePath',
  'filesToDelete',
  'key',
  'mimeType',
  'bucket',
  'size',
] as const

export type BlogPostImageProperties = typeof BLOG_POST_IMAGE_PROPERTIES[number]
export type BlogPostImageDBProperties = keyof BlogPostImage

export type BlogPostImageVirtualProperties = keyof Omit<
  Record<BlogPostImageProperties, any>, BlogPostImageDBProperties>
SoftwareBrothers

Proudly built and maintained by SoftwareBrothers

Software House with a passion for both JavaScript and TypeScript.

See what we do See what we believe in

Proudly built and maintained by

SoftwareBrothers