Skip to content

Commit d82e60b

Browse files
committed
resolve conflicts
2 parents a6e9ba2 + 3914735 commit d82e60b

File tree

7 files changed

+155
-38
lines changed

7 files changed

+155
-38
lines changed

__TESTS__/unit/actions/Delivery.test.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,14 @@ describe('Tests for Transformation Action -- Delivery', () => {
215215
expect(url).toBe('https://res.cloudinary.com/demo/image/upload/q_auto/sample');
216216
});
217217

218+
it('Can use shortened quality notation', () => {
219+
const url = createNewImage('sample')
220+
.delivery(Delivery.quality('auto:best'))
221+
.toURL();
222+
223+
expect(url).toBe('https://res.cloudinary.com/demo/image/upload/q_auto:best/sample');
224+
});
225+
218226
it('Creates a cloudinaryURL with Delivery.density', () => {
219227
const url = createNewImage('sample')
220228
.delivery(Delivery.density(150))
@@ -319,4 +327,11 @@ describe('Tests for Transformation Action -- Delivery', () => {
319327

320328
expect(url).toContain('f_jpg,fl_progressive:none');
321329
});
330+
331+
it('Can use shortened format notation', () => {
332+
// f_jpg,fl_progressive
333+
const url = createNewImage('sample').delivery(format('jpg')).toString();
334+
335+
expect(url).toContain('f_jpg');
336+
});
322337
});

__TESTS__/unit/actions/Effect.test.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,14 @@ describe('Tests for Transformation Action -- Effect', () => {
152152
expect(url).toBe('https://res.cloudinary.com/demo/image/upload/e_art:peacock/sample');
153153
});
154154

155+
it('Can use shortened artisticFilter notation', () => {
156+
const url = createNewImage('sample')
157+
.effect(Effect.artisticFilter("al_dente"))
158+
.toURL();
159+
160+
expect(url).toBe('https://res.cloudinary.com/demo/image/upload/e_art:al_dente/sample');
161+
});
162+
155163
it('Creates a cloudinaryURL with effect cartoonify:50', () => {
156164
const url = createNewImage('sample')
157165
.effect(cartoonify().lineStrength(50).blackwhite())

__TESTS__/unit/actions/Resize/AspectRatio.test.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,13 @@ describe('Tests for AspectRatio values Action -- Resize.crop', () => {
3232

3333
expect(url).toContain('ar_1:1,c_crop/ar_16:9,c_crop/ar_4:3,c_crop/ar_3:2,c_crop/ar_3:1,c_crop/ar_5:4,c_crop/c_crop,fl_ignore_aspect_ratio');
3434
});
35+
it('Can use shortened aspectRatio notation', () => {
36+
const url = createNewImage('sample')
37+
.resize(
38+
crop().aspectRatio("3:2"))
39+
.setPublicID('sample')
40+
.toURL();
41+
42+
expect(url).toContain('ar_3:2,c_crop');
43+
});
3544
});

src/actions/delivery.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,11 @@ import {toFloatAsString} from "../internal/utils/toFloatAsString";
1313
import {DeliveryColorSpaceFromICC} from "./delivery/DeliveryColorSpaceFromICC";
1414
import {DeliveryAction} from "./delivery/DeliveryAction";
1515
import {ColorSpaceType} from "../types/types";
16+
import {QualityTypes} from "../types/types";
17+
import {ImageFormatType, VideoFormatType} from "../types/types";
1618

1719
export type IDeliveryAction = DeliveryAction | DeliveryColorSpaceFromICC;
1820

19-
2021
/**
2122
* @summary action
2223
* @description Defines the format of the delivered asset.
@@ -40,7 +41,7 @@ export type IDeliveryAction = DeliveryAction | DeliveryColorSpaceFromICC;
4041
* );
4142
*
4243
*/
43-
function format(format:FormatQualifier | string) :DeliveryFormat {
44+
function format(format:FormatQualifier | ImageFormatType | VideoFormatType | string) :DeliveryFormat {
4445
return new DeliveryFormat('f', format);
4546
}
4647

@@ -75,7 +76,8 @@ function dpr(dpr: string|number):DeliveryAction {
7576
* <b>Learn more:</b> {@link https://cloudinary.com/documentation/image_optimization#how_to_optimize_image_quality | Image quality}
7677
* {@link https://cloudinary.com/documentation/video_manipulation_and_delivery#quality_control | Video quality}
7778
* @memberOf Actions.Delivery
78-
* @param {string | number | Qualifiers.Quality} qualityType For a list of supported quality types see {@link Qualifiers.Quality| quality types} for
79+
* @param {QualityTypes | string | number | Qualifiers.Quality} qualityType For a list of supported quality types see
80+
* {@link Qualifiers.Quality| quality types} for
7981
* possible values.
8082
* @return {Actions.Delivery.DeliveryQualityAction}
8183
* @example
@@ -89,7 +91,7 @@ function dpr(dpr: string|number):DeliveryAction {
8991
* quality('auto'),
9092
* );
9193
*/
92-
function quality(qualityType:string | number) :DeliveryQualityAction {
94+
function quality(qualityType:QualityTypes | string | number) :DeliveryQualityAction {
9395
return new DeliveryQualityAction(qualityType);
9496
}
9597

src/actions/effect.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import {FadeInEffectAction} from "./effect/leveled/fadeIn";
2424
import {RemoveBackgroundAction} from "./effect/removeBackgroundAction";
2525
import {ThemeEffect} from "./effect/theme";
2626
import {SystemColors} from "../qualifiers/color";
27+
import {ArtisticFilterType} from "../types/types";
2728

2829

2930
/**
@@ -101,10 +102,10 @@ function oilPaint(oilPaintLevel?: number):EffectActionWithStrength {
101102
* @summary action
102103
* @description Applies an artistic filter to the asset.
103104
* @memberOf Actions.Effect
104-
* @param artisticFilterType
105+
* @param {ArtisticFilterType | string} artisticFilterType
105106
* @return {Actions.Effect.SimpleEffectAction}
106107
*/
107-
function artisticFilter(artisticFilterType: string):SimpleEffectAction {
108+
function artisticFilter(artisticFilterType: ArtisticFilterType | string):SimpleEffectAction {
108109
return new SimpleEffectAction('art', artisticFilterType);
109110
}
110111

src/actions/resize/ResizeSimpleAction.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import {AspectRatioQualifierValue} from "../../qualifiers/aspectRatio/AspectRati
55
import {regionRelative, relative} from "../../qualifiers/flag";
66
import {FlagQualifier} from "../../qualifiers/flag/FlagQualifier";
77
import {ExpressionQualifier} from "../../qualifiers/expression/ExpressionQualifier";
8+
import {AspectRatioType} from "../../types/types";
89

910
/**
1011
* @description Defines a resize using width and height.
@@ -49,10 +50,10 @@ class ResizeSimpleAction extends Action {
4950
* @description Sets the aspect ratio of the asset.
5051
* For a list of supported types see {@link Qualifiers.AspectRatio |
5152
* AspectRatio values}
52-
* @param {number|string} ratio The new aspect ratio, specified as a percentage or ratio.
53+
* @param {AspectRatioType|number|string} ratio The new aspect ratio, specified as a percentage or ratio.
5354
* @return {this}
5455
*/
55-
aspectRatio(ratio: AspectRatioQualifierValue | FlagQualifier | number | string): this {
56+
aspectRatio(ratio: AspectRatioType | AspectRatioQualifierValue | FlagQualifier | number | string): this {
5657
// toFloatAsString is used to ensure 1 turns into 1.0
5758
if (ratio instanceof AspectRatioQualifierValue) {
5859
return this.addQualifier(new Qualifier('ar', ratio));

src/types/types.ts

Lines changed: 111 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -208,35 +208,74 @@ export type DeliveryType =
208208
| "dailymotion";
209209
/****************************** URL *************************************/
210210
export type ResourceType = string | "image" | "raw" | "video";
211-
export type ImageFormat =
212-
string
213-
| "gif"
214-
| "png"
215-
| "jpg"
216-
| "bmp"
217-
| "ico"
218-
| "pdf"
219-
| "tiff"
220-
| "eps"
221-
| "jpc"
222-
| "jp2"
223-
| "psd"
224-
| "webp"
225-
| "zip"
226-
| "svg"
227-
| "webm"
228-
| "wdp"
229-
| "hpx"
230-
| "djvu"
231-
| "ai"
232-
| "flif"
233-
| "bpg"
234-
| "miff"
235-
| "tga"
236-
| "heic"
237-
| "ignore_mask_channels";
211+
export type ImageFormatType =
212+
string |
213+
'usdz'|
214+
'jp2'|
215+
'ai'|
216+
'auto'|
217+
'bmp'|
218+
'eps'|
219+
'flif'|
220+
'gif'|
221+
'heic'|
222+
'ico'|
223+
'jpc'|
224+
'jpg'|
225+
'pdf'|
226+
'png'|
227+
'psd'|
228+
'svg'|
229+
'tiff'|
230+
'wdp'|
231+
'webp'|
232+
'arw'|
233+
'aac'|
234+
'aiff'|
235+
'amr'|
236+
'flac'|
237+
'm4a'|
238+
'mp3'|
239+
'ogg'|
240+
'opus'|
241+
'wav'|
242+
'avif'|
243+
'cr2'|
244+
'djvu'|
245+
'eps3'|
246+
'ept'|
247+
'fxb'|
248+
'gltf'|
249+
'hdp'|
250+
'heif'|
251+
'indd'|
252+
'jpe'|
253+
'jpeg'|
254+
'jxr'|
255+
'ps'|
256+
'spd'|
257+
'tga'|
258+
'tif'|
259+
'3g2'|
260+
'3gp'|
261+
'avi'|
262+
'flv'|
263+
'm2ts'|
264+
'm3u8'|
265+
'mkv'|
266+
'mov'|
267+
'mp4'|
268+
'mpd'|
269+
'mpeg'|
270+
'mts'|
271+
'mxf'|
272+
'ogv'|
273+
'ts'|
274+
'webm'|
275+
'wmv'|
276+
'glb';
238277

239-
export type VideoFormat =
278+
export type VideoFormatType =
240279
string
241280
| "auto"
242281
| "flv"
@@ -251,6 +290,37 @@ export type VideoFormat =
251290

252291
export type AnimatedFormatType = "auto" | "gif" | "webp" | "png";
253292

293+
export type ArtisticFilterType =
294+
"al_dente"|
295+
"athena"|
296+
"audrey"|
297+
"aurora"|
298+
"daguerre"|
299+
"eucalyptus"|
300+
"hairspray"|
301+
"hokusai"|
302+
"peacock"|
303+
"primavera"|
304+
"quartz"|
305+
"incognito"|
306+
"red_rock"|
307+
"sizzle"|
308+
"fes"|
309+
"linen"|
310+
"refresh"|
311+
"sonnet"|
312+
"ukulele"|
313+
"frost"|
314+
"zorro";
315+
316+
export type AspectRatioType =
317+
"1:1"|
318+
"5:4"|
319+
"3:1"|
320+
"3:2"|
321+
"4:3"|
322+
"16:9";
323+
254324
export type AudioFrequencyType =
255325
8000|
256326
11025|
@@ -364,8 +434,8 @@ export interface LegacyITransforamtionOptions {
364434
} | string;
365435
default_image?: string;
366436
density?: stringOrNumber;
367-
format?: ImageFormat;
368-
fetch_format?: ImageFormat;
437+
format?: ImageFormatType;
438+
fetch_format?: ImageFormatType;
369439
effect?: string | Array<stringOrNumber> | ImageEffect;
370440
page?: stringOrNumber;
371441
flags?: ImageFlags | [] | string;
@@ -406,3 +476,14 @@ export interface LegacyITransforamtionOptions {
406476
url_suffix?: string;
407477
[futureKey: string]: any;
408478
}
479+
480+
export type QualityTypes =
481+
'auto'|
482+
'auto:best'|
483+
'auto:eco'|
484+
'auto:good'|
485+
'auto:low'|
486+
'jpegmini'|
487+
'jpegmini:best' |
488+
'jpegmini:high' |
489+
'jpegmini:medium';

0 commit comments

Comments
 (0)