From 7800cd75dffef4e14a8c180cb329379ab803d275 Mon Sep 17 00:00:00 2001 From: ikhsanalatsary Date: Thu, 2 May 2019 15:41:46 +0700 Subject: [PATCH] fix(index.d): type definition --- index.d.ts | 58 ++++++++++++++++++++++++++---------------------------- 1 file changed, 28 insertions(+), 30 deletions(-) diff --git a/index.d.ts b/index.d.ts index defefad..d167708 100644 --- a/index.d.ts +++ b/index.d.ts @@ -1,48 +1,33 @@ -import { ResizeOptions, RGBA, Region, ExtendOptions, ThresholdOptions, AvailableFormatInfo, OutputOptions, JpegOptions, PngOptions, Metadata } from 'sharp'; +import { ResizeOptions, RGBA, Region, ExtendOptions, ThresholdOptions, AvailableFormatInfo, OutputOptions, JpegOptions, PngOptions, Metadata, Kernel } from 'sharp'; import { UploadOptions } from '@google-cloud/storage'; -export interface Size { +export declare interface Size { width?: number; height?: number; option?: ResizeOptions; } -export interface Sharpen { +export declare interface Sharpen { sigma?: number; flat?: number; jagged?: number; } -export interface Threshold { +export declare interface Threshold { threshold?: number; options?: ThresholdOptions; } -export interface Format { +export declare interface Format { type: string | AvailableFormatInfo; - options?: OutputOptions | JpegOptions | PngOptions; + options?: OutputOptions | JpegOptions | PngOptions; } -type SharpOption = false | T; +declare type SharpOption = false | T; -interface CloudStorageSize { - suffix: string; - width: number; - height: number; -} - -export interface CloudStorageOptions extends UploadOptions { - bucket: string; - projectId: string; - keyFilename?: string; - filename?: string; - acl?: string; - sizes?: CloudStorageSize[] -} - -export interface SharpOptions { - size?: MulterOptions; - resize?: SharpOption; +export declare interface SharpOptions { + size?: Size; + resize?: boolean; crop?: SharpOption; background?: SharpOption; embed?: boolean; @@ -55,12 +40,12 @@ export interface SharpOptions { flatten?: boolean; extend?: SharpOption; negate?: boolean; - rotate?: boolean; + rotate?: SharpOption; flip?: boolean; flop?: boolean; - blur?: SharpOption; - sharpen?: SharpOption; - gamma?: SharpOption; + blur?: SharpOption; + sharpen?: SharpOption; + gamma?: SharpOption; grayscale?: boolean; greyscale?: boolean; normalize?: boolean; @@ -74,7 +59,20 @@ export interface SharpOptions { gzip?: boolean; } -export type MulterOptions = SharpOptions & CloudStorageOptions; +declare interface Sizes extends Size { + suffix: string; +} + +export declare interface CloudStorageOptions extends UploadOptions { + bucket: string; + projectId: string; + keyFilename?: string; + filename?: string; + acl?: string; + sizes?: Sizes[] +} + +export declare type MulterOptions = SharpOptions & CloudStorageOptions; declare class MulterSharp { constructor(options: MulterOptions)