Skip to content

Commit d59eed2

Browse files
committed
resolved conflicts
2 parents 2d6679b + 38b2baf commit d59eed2

File tree

6 files changed

+107
-39
lines changed

6 files changed

+107
-39
lines changed

.code-generation/config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ module.exports = {
4444
'assetType': 'set_asset_type',
4545
'signature': 'setSignature',
4646
},
47+
canGenerateSignature:false,
4748
classNameMap: {},
4849
childTransformations: {
4950
image: {

__TESTS__/unit/actions/Delivery.test.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -310,4 +310,11 @@ describe('Tests for Transformation Action -- Delivery', () => {
310310

311311
expect(url).toContain('f_jpg,fl_progressive:none');
312312
});
313+
314+
it('Can use shortened format notation', () => {
315+
// f_jpg,fl_progressive
316+
const url = createNewImage('sample').delivery(format('jpg')).toString();
317+
318+
expect(url).toContain('f_jpg');
319+
});
313320
});

__TESTS__/unit/actions/Transcode.test.ts

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import {AnimatedFormat} from "../../../src/qualifiers/animatedFormat";
22
import {createNewVideo} from "../../TestUtils/createCloudinaryVideo";
33
import {AudioFrequency} from "../../../src/qualifiers/audioFrequency";
4-
import {Transcode} from "../../../src/actions/transcode";
4+
import {audioCodec, Transcode} from "../../../src/actions/transcode";
55
import {AudioCodec} from "../../../src/qualifiers/audioCodec";
66
import {StreamingProfile} from "../../../src/qualifiers/streamingProfile";
77
import {VideoCodec} from "../../../src/qualifiers/videoCodec";
@@ -19,6 +19,15 @@ describe('Tests for Transformation Action -- Transcode', () => {
1919
expect(url).toBe('https://res.cloudinary.com/demo/video/upload/ac_aac/sample');
2020
});
2121

22+
it('Can use shortened audioCodec notation', () => {
23+
const url = createNewVideo('sample')
24+
.transcode(audioCodec('aac'))
25+
.setPublicID('sample')
26+
.toURL();
27+
28+
expect(url).toBe('https://res.cloudinary.com/demo/video/upload/ac_aac/sample');
29+
});
30+
2231
it('Creates a cloudinaryURL with bitrate', () => {
2332
const url = createNewVideo('sample')
2433
.transcode(Transcode.bitRate('500k'))
@@ -120,6 +129,16 @@ describe('Tests for Transformation Action -- Transcode', () => {
120129
expect(url).toBe('https://res.cloudinary.com/demo/video/upload/f_webp,fl_animated,fl_awebp/sample');
121130
});
122131

132+
it('Can use shortened toAnimated webp', () => {
133+
const url = createNewVideo('sample')
134+
.transcode(Transcode
135+
.toAnimated('webp'))
136+
.setPublicID('sample')
137+
.toURL();
138+
139+
expect(url).toBe('https://res.cloudinary.com/demo/video/upload/f_webp,fl_animated,fl_awebp/sample');
140+
});
141+
123142
it('Creates a cloudinaryURL with toAnimated and delay', () => {
124143
const url = createNewVideo('sample')
125144
.transcode(Transcode

src/actions/delivery.ts

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

1718
export type IDeliveryAction = DeliveryAction | DeliveryColorSpaceFromICC;
1819

19-
2020
/**
2121
* @summary action
2222
* @description Defines the format of the delivered asset.
@@ -40,7 +40,7 @@ export type IDeliveryAction = DeliveryAction | DeliveryColorSpaceFromICC;
4040
* );
4141
*
4242
*/
43-
function format(format:FormatQualifier | string) :DeliveryFormat {
43+
function format(format:FormatQualifier | ImageFormatType | VideoFormatType | string) :DeliveryFormat {
4444
return new DeliveryFormat('f', format);
4545
}
4646

src/actions/transcode.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import ToAnimatedAction from "./transcode/ToAnimatedAction";
99
import {AnimatedFormatQualifierValue} from "../qualifiers/animatedFormat/AnimatedFormatQualifierValue";
1010
import {AdvVideoCodecType, VideoCodecType} from "../qualifiers/videoCodecType/VideoCodecType";
1111
import {VideoCodecAction} from "./transcode/VideoCodecAction";
12-
12+
import {AnimatedFormatType, AudioCodecType} from "../types/types";
1313

1414
export type ITranscodeAction = BitRateAction
1515
| AudioCodecAction
@@ -57,7 +57,7 @@ function audioFrequency(freq: string|number): AudioFrequencyAction{
5757
* @summary action
5858
* @memberOf Actions.Transcode
5959
* @description Sets the audio codec or removes the audio channel.
60-
* @param {string} codec The audio codec or "none".
60+
* @param {AudioCodecType | string} codec The audio codec or "none".
6161
* @example
6262
* import {Cloudinary} from "@cloudinary/base/instance/Cloudinary";
6363
* import {aac} from '@cloudinary/base/qualifiers/audioCodec'
@@ -69,7 +69,7 @@ function audioFrequency(freq: string|number): AudioFrequencyAction{
6969
* video.transcode( audioCodec( aac() ) );
7070
* @return {Actions.Transcode.AudioCodecAction}
7171
*/
72-
function audioCodec(codec: string): AudioCodecAction{
72+
function audioCodec(codec: AudioCodecType | string): AudioCodecAction{
7373
return new AudioCodecAction(codec);
7474
}
7575
/**
@@ -183,7 +183,7 @@ function streamingProfile(profile: string): StreamingProfileAction {
183183
* @summary action
184184
* @memberOf Actions.Transcode
185185
* @description Converts a video to animated image.
186-
* @param {string} animatedFormat The streaming profile.
186+
* @param {string | AnimatedFormatType} animatedFormat The streaming profile.
187187
* @example
188188
* import {Cloudinary} from "@cloudinary/base/instance/Cloudinary";
189189
* import {gif} from '@cloudinary/base/qualifiers/animatedFormat'
@@ -195,7 +195,7 @@ function streamingProfile(profile: string): StreamingProfileAction {
195195
* video.transcode( toAnimated( gif() ) );
196196
* @return {Actions.Transcode.ToAnimatedAction}
197197
*/
198-
function toAnimated(animatedFormat: AnimatedFormatQualifierValue | string = ''): ToAnimatedAction {
198+
function toAnimated(animatedFormat: AnimatedFormatQualifierValue | AnimatedFormatType | string = ''): ToAnimatedAction {
199199
return new ToAnimatedAction(animatedFormat);
200200
}
201201

src/types/types.ts

Lines changed: 72 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ export type ImageEffect =
110110
| "improve";
111111

112112
export type VideoEffect = string | "accelerate" | "reverse" | "boomerang" | "loop" | "make_transparent" | "transition";
113-
export type AudioCodec = string | "none" | "aac" | "vorbis" | "mp3";
113+
export type AudioCodecType = string | "none" | "aac" | "vorbis" | "mp3";
114114
export type AudioFrequency =
115115
string
116116
| number
@@ -202,34 +202,74 @@ export type DeliveryType =
202202
| "dailymotion";
203203
/****************************** URL *************************************/
204204
export type ResourceType = string | "image" | "raw" | "video";
205-
export type ImageFormat =
206-
string
207-
| "gif"
208-
| "png"
209-
| "jpg"
210-
| "bmp"
211-
| "ico"
212-
| "pdf"
213-
| "tiff"
214-
| "eps"
215-
| "jpc"
216-
| "jp2"
217-
| "psd"
218-
| "webp"
219-
| "zip"
220-
| "svg"
221-
| "webm"
222-
| "wdp"
223-
| "hpx"
224-
| "djvu"
225-
| "ai"
226-
| "flif"
227-
| "bpg"
228-
| "miff"
229-
| "tga"
230-
| "heic"
205+
export type ImageFormatType =
206+
string |
207+
'usdz'|
208+
'jp2'|
209+
'ai'|
210+
'auto'|
211+
'bmp'|
212+
'eps'|
213+
'flif'|
214+
'gif'|
215+
'heic'|
216+
'ico'|
217+
'jpc'|
218+
'jpg'|
219+
'pdf'|
220+
'png'|
221+
'psd'|
222+
'svg'|
223+
'tiff'|
224+
'wdp'|
225+
'webp'|
226+
'arw'|
227+
'aac'|
228+
'aiff'|
229+
'amr'|
230+
'flac'|
231+
'm4a'|
232+
'mp3'|
233+
'ogg'|
234+
'opus'|
235+
'wav'|
236+
'avif'|
237+
'cr2'|
238+
'djvu'|
239+
'eps3'|
240+
'ept'|
241+
'fxb'|
242+
'gltf'|
243+
'hdp'|
244+
'heif'|
245+
'indd'|
246+
'jpe'|
247+
'jpeg'|
248+
'jxr'|
249+
'ps'|
250+
'spd'|
251+
'tga'|
252+
'tif'|
253+
'3g2'|
254+
'3gp'|
255+
'avi'|
256+
'flv'|
257+
'm2ts'|
258+
'm3u8'|
259+
'mkv'|
260+
'mov'|
261+
'mp4'|
262+
'mpd'|
263+
'mpeg'|
264+
'mts'|
265+
'mxf'|
266+
'ogv'|
267+
'ts'|
268+
'webm'|
269+
'wmv'|
270+
'glb';
231271

232-
export type VideoFormat =
272+
export type VideoFormatType =
233273
string
234274
| "auto"
235275
| "flv"
@@ -242,6 +282,7 @@ export type VideoFormat =
242282
| "ogv"
243283
| "webm"
244284

285+
export type AnimatedFormatType = "auto" | "gif" | "webp" | "png";
245286

246287
export interface LegacyITransforamtionOptions {
247288
transformation?: LegacyITransforamtionOptions | string;
@@ -278,12 +319,12 @@ export interface LegacyITransforamtionOptions {
278319
} | string;
279320
default_image?: string;
280321
density?: stringOrNumber;
281-
format?: ImageFormat;
282-
fetch_format?: ImageFormat;
322+
format?: ImageFormatType;
323+
fetch_format?: ImageFormatType;
283324
effect?: string | Array<stringOrNumber> | ImageEffect;
284325
page?: stringOrNumber;
285326
flags?: ImageFlags | [] | string;
286-
audio_codec?: AudioCodec;
327+
audio_codec?: AudioCodecType;
287328
audio_frequency?: AudioFrequency;
288329
// eslint-disable-next-line @typescript-eslint/ban-types
289330
video_codec?: string | Object;

0 commit comments

Comments
 (0)