From a7b0b2281d28e23e5492f74d748fb538e6af7a3c Mon Sep 17 00:00:00 2001 From: pcholuj Date: Tue, 20 Aug 2019 08:51:15 +0200 Subject: [PATCH 1/3] feat(auto_image): Add autoImage transformation --- src/lib/filelink.spec.ts | 6 ++++++ src/lib/filelink.ts | 11 +++++++++++ src/schema/transforms.schema.ts | 4 ++++ 3 files changed, 21 insertions(+) diff --git a/src/lib/filelink.spec.ts b/src/lib/filelink.spec.ts index 950d0918..caec73a9 100644 --- a/src/lib/filelink.spec.ts +++ b/src/lib/filelink.spec.ts @@ -198,6 +198,12 @@ describe('filelink', () => { expect(filelink.toString()).toBe('https://customDomain.com/DEFAULT_API_KEY/5aYkEQJSQCmYShsoCnZN'); }); + it('should be able to autoImage transformation', () => { + filelink.autoImage(); + expect(filelink.toString()).toBe('https://customDomain.com/DEFAULT_API_KEY/auto_image/5aYkEQJSQCmYShsoCnZN'); + }); + + it('should be able to add flip', () => { filelink.flip(); expect(filelink.toString()).toBe('https://customDomain.com/DEFAULT_API_KEY/flip/5aYkEQJSQCmYShsoCnZN'); diff --git a/src/lib/filelink.ts b/src/lib/filelink.ts index 7ba1e596..51f68b3a 100644 --- a/src/lib/filelink.ts +++ b/src/lib/filelink.ts @@ -721,6 +721,17 @@ export class Filelink { * Transformations part */ + /** + * Add autoimage transformation + * + * @see https://www.filestack.com/docs/api/processing/#auto-image-conversion + * @returns this + * @memberof Filelink + */ + autoImage() { + return this.addTask('auto_image', true); + } + /** * Adds flip transformation * diff --git a/src/schema/transforms.schema.ts b/src/schema/transforms.schema.ts index ed384ab4..2ae02d42 100644 --- a/src/schema/transforms.schema.ts +++ b/src/schema/transforms.schema.ts @@ -25,6 +25,10 @@ export const TransformSchema = { type: 'boolean', additionalProperties: false, }, + auto_image: { + type: 'boolean', + additionalProperties: false, + }, no_metadata: { type: 'boolean', additionalProperties: false, From 747ce36f34002e6efa5ee7283ac59744281d67d5 Mon Sep 17 00:00:00 2001 From: pcholuj Date: Wed, 21 Aug 2019 13:07:00 +0200 Subject: [PATCH 2/3] feat(transforms): add compress transformations --- src/lib/filelink.ts | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/lib/filelink.ts b/src/lib/filelink.ts index 51f68b3a..16b9d126 100644 --- a/src/lib/filelink.ts +++ b/src/lib/filelink.ts @@ -21,6 +21,7 @@ import { getValidator } from './../schema/validator'; import { resolveHost, b64 } from './utils'; import { FilestackError, FilestackErrorType } from './../filestack_error'; import Debug from 'debug'; +import { booleanLiteral } from '@babel/types'; const debug = Debug('fs:filelink'); /** @@ -277,6 +278,10 @@ export interface BorderParams { background?: string; } +export interface CompressParams { + metadata?: boolean; +} + export interface SharpenParams { amount: number; } @@ -787,6 +792,17 @@ export class Filelink { return this.addTask('monochrome', true); } + /** + * Add compress transformation + * + * @see https://www.filestack.com/docs/api/processing/#compress + * @returns this + * @memberof Filelink + */ + compress(params?: CompressParams) { + return this.addTask('compress', params || true); + } + /** * Adds negative transformation * From f0930d77992409f9a82171d8b2e123408ffaca7f Mon Sep 17 00:00:00 2001 From: pcholuj Date: Fri, 23 Aug 2019 10:26:54 +0200 Subject: [PATCH 3/3] style(linter): fix blank line linter error --- src/lib/filelink.spec.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/lib/filelink.spec.ts b/src/lib/filelink.spec.ts index caec73a9..20cbf0f1 100644 --- a/src/lib/filelink.spec.ts +++ b/src/lib/filelink.spec.ts @@ -203,7 +203,6 @@ describe('filelink', () => { expect(filelink.toString()).toBe('https://customDomain.com/DEFAULT_API_KEY/auto_image/5aYkEQJSQCmYShsoCnZN'); }); - it('should be able to add flip', () => { filelink.flip(); expect(filelink.toString()).toBe('https://customDomain.com/DEFAULT_API_KEY/flip/5aYkEQJSQCmYShsoCnZN');