From 83b3344deed172e517e7b24a4530dd0f779e5e62 Mon Sep 17 00:00:00 2001 From: strausr Date: Mon, 11 Nov 2019 14:31:48 +0200 Subject: [PATCH] Add Type Script declaration file --- README.md | 4 + package.json | 16 +- tsconfig.json | 16 + types/cloudinary_ts_spec.ts | 765 +++++++++++++++++++++++++++++++ types/index.d.ts | 885 ++++++++++++++++++++++++++++++++++++ types/tsconfig.json | 17 + 6 files changed, 1701 insertions(+), 2 deletions(-) create mode 100644 tsconfig.json create mode 100644 types/cloudinary_ts_spec.ts create mode 100644 types/index.d.ts create mode 100644 types/tsconfig.json diff --git a/README.md b/README.md index a84190c8..1b434a4d 100644 --- a/README.md +++ b/README.md @@ -202,6 +202,10 @@ cloudinary.image("sample", {format: "png", width: 100, height: 100, crop: "fill" // ``` +### Typescript + +🎉New 🎉TypeScript support was just added. Check out the [declaration file](https://github.com/cloudinary/cloudinary_npm/types/index.d.ts). + ### Samples You can find our simple and ready-to-use samples projects, along with documentation in the [samples folder](https://github.com/cloudinary/cloudinary_npm/tree/master/samples). diff --git a/package.json b/package.json index ecd4166a..7c429f25 100644 --- a/package.json +++ b/package.json @@ -12,7 +12,8 @@ "main": "cloudinary.js", "dependencies": { "lodash": "^4.17.11", - "q": "^1.5.1" + "q": "^1.5.1", + "typescript": "^2.9.2" }, "devDependencies": { "babel-cli": "^6.26.0", @@ -24,6 +25,7 @@ "babel-register": "^6.26.0", "babel-runtime": "^6.26.0", "dotenv": "4.x", + "dtslint": "^0.9.1", "eslint": "^5.16.0", "eslint-config-airbnb-base": "^13.1.0", "eslint-plugin-import": "^2.17.2", @@ -36,8 +38,18 @@ "sinon": "^6.1.4", "webpack-cli": "^3.2.1" }, + "files": [ + "lib/**/*", + "lib-es5/**/*", + "cloudinary.js", + "babel.config.js", + "package.json", + "types/*" + ], + "types": "types", "scripts": { - "test": "node_v=$(node --version)z\nif [[ \"${node_v%%.*z}\" == 'v4' ]]\nthen\nnpm run test-es5\nelse\necho 10 && npm run test-es6\nfi", + "test": "node_v=$(node --version)z\nif [[ \"${node_v%%.*z}\" == 'v4' ]]\nthen\nnpm run test-es5\nelse\necho 10 && npm run test-es6\nfi\nnpm run dtslint", + "dtslint": "dtslint --expectOnly --localTs node_modules/typescript/lib types ", "lint": "eslint .", "compile": "node_modules/.bin/babel lib --out-dir lib-es5 --delete-dir-on-start --verbose", "test-es6": "which node && node node_modules/.bin/mocha --ui bdd -R spec --recursive test/", diff --git a/tsconfig.json b/tsconfig.json new file mode 100644 index 00000000..36e4c60b --- /dev/null +++ b/tsconfig.json @@ -0,0 +1,16 @@ +{ + "compilerOptions": { + "module": "commonjs", + "noImplicitAny": true, + "esModuleInterop": true, + "allowSyntheticDefaultImports": true, + "declaration": true + }, + "include": [ + "dist/**/*", + "types/**/*" + ], + "exclude": [ + "node_modules" + ] +} diff --git a/types/cloudinary_ts_spec.ts b/types/cloudinary_ts_spec.ts new file mode 100644 index 00000000..90d60cf5 --- /dev/null +++ b/types/cloudinary_ts_spec.ts @@ -0,0 +1,765 @@ +import * as cloudinary from 'cloudinary'; + +// $ExpectType void +cloudinary.v2.config({ + cloud_name: 'demo', +}); + +// $ExpectType void +cloudinary.v2.config(true); + +// $ExpectType void +cloudinary.v2.config("private_cdn", true); + +// $ExpectType string +const test = cloudinary.v2.image("front_face.png", { + secure: true, + transformation: [ + { + width: 150, height: 150, gravity: "face", radius: 20, effect: "sepia", + crop: "thumb" + }, + { + overlay: "cloudinary_icon", gravity: "south_east", x: 5, y: 5, + width: 50, opacity: 60, effect: "brightness:200" + }, + {angle: 10}, + ] +}); + +// $ExpectType string +cloudinary.v2.image("yellow_tulip.jpg", { + transformation: [ + {width: 220, height: 140, crop: "fill"}, + {overlay: "brown_sheep", width: 220, height: 140, x: 220, crop: "fill"}, + {overlay: "horses", width: 220, height: 140, y: 140, x: -110, crop: "fill"}, + { + overlay: "white_chicken", width: 220, height: 140, y: 70, x: 110, + crop: "fill" + }, + {overlay: "butterfly.png", height: 200, x: -10, angle: 10}, + {width: 400, height: 260, radius: 20, crop: "crop"}, + { + overlay: { + font_family: "Parisienne", font_size: 35, font_weight: "bold", + text: "Memories%20from%20our%20trip" + }, color: "#990C47", y: 155 + }, + {effect: "shadow"}, + ] +}); + +// $ExpectType string +cloudinary.v2.image("sample.jpg", { + audio_codec: '1', overlay: + {url: "http://cloudinary.com/images/old_logo.png7"} +}); + +// $ExpectType string +cloudinary.v2.picture("sample.jpg"); + +// $ExpectType string +cloudinary.v2.video("dog", { + width: 300, + height: 300, + crop: "pad", + background: "blue", + preload: "none", + controls: true, + fallback_content: "Your browser does not support HTML5 video tags" +}); + +// $ExpectType string +cloudinary.v2.video("cld_rubiks_guy", { + height: 320, width: 480, + background: "blurred:400:15", crop: "pad" +}); + +// $ExpectType Promise +cloudinary.v2.api.create_streaming_profile('custom_square', + { + display_name: "Custom square resolution", + representations: [ + { + transformation: { + crop: "limit", width: 1200, height: 1200, + bit_rate: "5m" + } + }, + { + transformation: { + crop: "limit", width: 900, height: 900, + bit_rate: "3500k" + } + }, + { + transformation: { + crop: "limit", width: 600, height: 600, + bit_rate: "1500k" + } + }] + }, + + (error, result) => { + console.log(result); + }); + +// $ExpectType Promise +cloudinary.v2.api.create_transformation('small_fill2', + {width: 150, height: 100, crop: 'fill'}, + (error, result) => { + console.log(result, error); + }); + +cloudinary.v2.api.create_transformation('small_fill2', + {width: 150, height: 100, crop: 'fill'}, {allowed_for_strict: true}, + (error, result) => { + console.log(result, error); + }); + +// $ExpectType Promise +cloudinary.v2.api.create_transformation('small_fill', + 'w_150,h_100,c_fill', + function (error, result) { + console.log(result, error); + }); + +// $ExpectType Promise +cloudinary.v2.api.update_transformation( + {width: 150, height: 100, crop: 'fill'}, + {allowed_for_strict: false}, + function (error, result) { + console.log(result, error); + } +); + +// $ExpectType Promise +cloudinary.v2.api.update_transformation('w_150,h_100,c_fill', + {allowed_for_strict: true}, + function (error, result) { + console.log(result, error); + }); + +// $ExpectType Promise +cloudinary.v2.api.update_transformation( + {width: 150, height: 100, crop: 'fill'}, + {allowed_for_strict: false}, + function (error, result) { + console.log(result, error); + } +); + +// $ExpectType Promise +cloudinary.v2.api.update_transformation('w_150,h_100,c_fill', + {allowed_for_strict: true}, + function (error, result) { + console.log(result, error); + }); + +// $ExpectType Promise +cloudinary.v2.api.update_transformation("my_named", + {crop: 'scale', width: 103}, + function (error, result) { + console.log(result, error); + }); + +// $ExpectType Promise +cloudinary.v2.api.create_upload_mapping('my_map', + {template: "http://www.example.com/images/"}, + function (error, result) { + console.log(result); + }); + +// $ExpectType Promise +cloudinary.v2.api.create_upload_preset( + { + name: "my_preset", + unsigned: true, + tags: "remote", + allowed_formats: "jpg,png" + }, + function (error, result) { + console.log(result); + } +); + +// $ExpectType Promise +cloudinary.v2.api.delete_all_resources( + {type: 'facebook'}, + function (error, result) { + console.log(result, error); + } +); + +// $ExpectType Promise +cloudinary.v2.api.delete_resources(['4'], + {width: '100'}, + function (error, result) { + console.log(result, error); + }); + +// $ExpectType Promise +cloudinary.v2.api.delete_resources(['image1', 'image2'], + function (error, result) { + console.log(result, error); + }); + +// $ExpectType Promise +cloudinary.v2.api.delete_derived_by_transformation(['image1', 'image2'], 'f_auto'); + +// $ExpectType Promise +cloudinary.v2.api.delete_derived_by_transformation(['image1', 'image2'], 'f_auto', + {content_type: 'json'}, + function(err,res){console.log(err);}); + +// $ExpectType Promise +cloudinary.v2.api.delete_derived_by_transformation(['image1', 'image2'], 'f_auto', + function(err,res){console.log(err);}); + +// $ExpectType Promise +cloudinary.v2.api.delete_derived_resources(['image1', 'image2'], + function (err,res){console.log(err);}); + +// $ExpectType Promise +cloudinary.v2.api.delete_derived_resources(['image1', 'image2'], {keep_original: true}, + function (err,res){console.log(err);}); + +// $ExpectType Promise +cloudinary.v2.api.delete_resources_by_prefix('sunday', + function (error, result) { + console.log(result, error); + }); + +// $ExpectType Promise +cloudinary.v2.api.delete_resources_by_tag('mytag', + function (error, result) { + console.log(result, error); + }); + +// $ExpectType Promise +cloudinary.v2.api.delete_streaming_profile('custom_square', + function (error, result) { + console.log(result); + }); + +// $ExpectType Promise +cloudinary.v2.api.delete_transformation( + {width: 150, height: 100, crop: 'fill'}, + function (error, result) { + console.log(result, error); + } +); + +// $ExpectType Promise +cloudinary.v2.api.delete_transformation( + {width: 150, height: 100, crop: 'fill'}, + {content_type: 'json'}, + function (error, result) { + console.log(result, error); + } +); + +// $ExpectType Promise +cloudinary.v2.api.delete_transformation('w_150,h_100,c_fill', + function (error, result) { + console.log(result, error); + }); + +// $ExpectType Promise +cloudinary.v2.api.delete_upload_mapping('wiki', + function (error, result) { + console.log(result); + }); + +// $ExpectType Promise +cloudinary.v2.api.delete_upload_mapping('wiki', + {content_type: 'json'}, + function (error, result) { + console.log(result); + }); + +// $ExpectType Promise +cloudinary.v2.api.delete_upload_preset('remote_media', + function (error, result) { + console.log(result); + }); + +// $ExpectType Promise +cloudinary.v2.api.delete_upload_preset('remote_media', + {content_type: 'json'}, + function (error, result) { + console.log(result); + }) + +// $ExpectType Promise +cloudinary.v2.api.get_streaming_profile('custom_square', + function (error, result) { + console.log(result); + }); + +// $ExpectType Promise +cloudinary.v2.api.list_streaming_profiles( + function (err, res) { + console.log(err); + }); + +// $ExpectType Promise +cloudinary.v2.api.list_streaming_profiles( {content_type: 'json'}, + function (err, res) { + console.log(err); + }); + +// $ExpectType Promise +cloudinary.v2.api.ping(function (err, res) { + console.log(err); +}); + +// $ExpectType Promise +cloudinary.v2.api.ping({public_id: '123'}); + +// $ExpectType Promise +cloudinary.v2.api.resource('rwkaliebnufp3bxyrvyo.txt', + {resource_type: 'raw'}, + function (error, result) { + console.log(result, error); + }); + +// $ExpectType Promise +cloudinary.v2.api.resource('4', + {type: 'facebook'}, + function (error, result) { + console.log(result, error); + }); + +// $ExpectType Promise +cloudinary.v2.api.resource('sample', + { + faces: true, + colors: true, + exif: true + }); + +// $ExpectType Promise +cloudinary.v2.api.resource('sample', + function (error, result) { + console.log(result, error); + }); + +// $ExpectType Promise +cloudinary.v2.api.resource('rwkaliebnufp3bxyrvyo.txt', + {resource_type: 'raw'}, + function (error, result) { + console.log(result, error); + }); + +// $ExpectType Promise +cloudinary.v2.api.resource('4', + {type: 'facebook'}, + function (error, result) { + console.log(result, error); + }); + +// $ExpectType Promise +cloudinary.v2.api.resource('sample', + { + faces: true, + colors: true, + exif: true + }, + function (error, result) { + console.log(result, error); + }); + +// $ExpectType Promise +cloudinary.v2.api.resource('sample', + function (error, result) { + console.log(result, error); + }); + +// $ExpectType Promise +cloudinary.v2.api.resources( + {resource_type: 'raw'}, + function (error, result) { + console.log(result, error); + } +); + +// $ExpectType Promise +cloudinary.v2.api.resources( + {type: 'facebook'}, + function (error, result) { + console.log(result, error); + } +); + +// $ExpectType Promise +cloudinary.v2.api.resources( + { + type: 'upload', + prefix: 'sample' + }, + function (error, result) { + console.log(result, error); + } +); + +// $ExpectType Promise +cloudinary.v2.api.resources( + {type: 'upload'}, + function (error, result) { + console.log(result, error); + } +); + +// $ExpectType Promise +cloudinary.v2.api.resources_by_context("mycontextkey", "mycontextvalue", + {resource_type: 'video'}, function (error, result) { + console.log(result, error); + }); + +// $ExpectType Promise +cloudinary.v2.api.resources_by_context("mycontextkey", + function (error, result) { + console.log(result, error); + }); + +// $ExpectType Promise +cloudinary.v2.api.resources_by_ids(["user_photo_1", "user_photo_2"], + function (error, result) { + console.log(result, error); + }); + +// $ExpectType Promise +cloudinary.v2.api.resources_by_ids(["user_photo_1", "user_photo_2"], + {resource_type: 'video'},); + +// $ExpectType Promise +cloudinary.v2.api.resources_by_moderation('webpurify', 'approved', + function (error, result) { + console.log(result, error); + }); + +// $ExpectType Promise +cloudinary.v2.api.resources_by_moderation('manual', 'pending', + function (error, result) { + console.log(result, error); + }); + +// $ExpectType Promise +cloudinary.v2.api.resources_by_tag("mytag", + {resource_type: 'raw'}, + function (error, result) { + console.log(result, error); + }); + +// $ExpectType Promise +cloudinary.v2.api.resources_by_tag("mytag", + function (error, result) { + console.log(result, error); + }); + +cloudinary.v2.api.restore(["image1", "image2"], + function (error, result) { + console.log(result, error); + }); + +// $ExpectType Promise +cloudinary.v2.api.root_folders(function (err, res) { + console.log(err); +}); + +// $ExpectType Promise +cloudinary.v2.api.sub_folders("cloud", function (error, result) { + console.log(result); +}); + +// $ExpectType Promise +cloudinary.v2.api.transformation({width: 150, height: 100, crop: 'fill'}, + function (error, result) { + console.log(result, error); + }); + +// $ExpectType Promise +cloudinary.v2.api.transformation('w_150,h_100,c_fill', + function (error, result) { + console.log(result, error); + }); + +// $ExpectType Promise +cloudinary.v2.api.transformations(function (error, result) { + console.log(result); +}); + +// $ExpectType Promise +cloudinary.v2.api.update_resources_access_mode_by_ids("public", ['image1', 'image2'], + function (error, result) { + console.log(result); + }); + +// $ExpectType Promise +cloudinary.v2.api.update_resources_access_mode_by_tag('public', "20170216", + function (error, result) { + console.log(result); + }); + +// $ExpectType Promise +cloudinary.v2.api.update_resources_access_mode_by_prefix("public", "to-publish", + {resource_type: 'video'}, + function (error, result) { + console.log(result); + }); + +// $ExpectType Promise +cloudinary.v2.api.update_streaming_profile('custom_square', + { + representations: [ + {transformation: {crop: "limit", width: 1200, height: 1200, bit_rate: "5m"}}, + {transformation: {crop: "limit", width: 900, height: 900, bit_rate: "3500k"}}, + {transformation: {crop: "limit", width: 600, height: 600, bit_rate: "1500k"}}, + {transformation: {crop: "limit", width: 320, height: 320, bit_rate: "192k"}}] + }, + function (error, result) { + console.log(result); + }); + +// $ExpectType Promise +cloudinary.v2.api.update_upload_mapping('wiki', + {template: "https://u.wiki.com/images/"}, + function (error, result) { + console.log(result); + }); + +// $ExpectType Promise +cloudinary.v2.api.update_upload_preset('wiki', + { + unsigned: true, + tags: "remote", + allowed_formats: "jpg,png" + }, + function (error, result) { + console.log(result); + }); + +// $ExpectType Promise +cloudinary.v2.api.upload_mapping('wiki', + function (error, result) { + console.log(result); + }); + +// $ExpectType Promise +cloudinary.v2.api.upload_mappings(function (error, result) { + console.log(result); +}); + +// $ExpectType Promise +cloudinary.v2.api.usage(function (error, result) { + console.log(result); +}); + +// Testing overload + +// $ExpectType Promise +cloudinary.v2.api.usage({public_id: 'demo'}); + +// $ExpectType Promise +cloudinary.v2.uploader.add_context('alt=Animal|class=Mammalia', ['dog', 'lion'], + function (error, result) { + console.log(result, error); + }); + +// $ExpectType Promise +cloudinary.v2.uploader.add_tag('animal', ['dog', 'lion'], + function (error, result) { + console.log(result, error); + }); + +// $ExpectType Promise +cloudinary.v2.uploader.create_zip( + { + tags: 'lion', + resource_type: 'image' + }, + function (error, result) { + console.log(result, error); + } +); + +// $ExpectType Promise +cloudinary.v2.uploader.destroy('sample', function (error, result) { + console.log(result, error); +}); + +// $ExpectType Promise +cloudinary.v2.uploader.explicit("sample", + { + type: "upload", + eager: [ + { + width: 400, + height: 400, + crop: "crop", + gravity: "face" + }, + { + width: 660, + height: 400, + crop: "pad", + background: "blue" + }] + }, + function (error, result) { + console.log(result, error); + }); + +// $ExpectType Promise +cloudinary.v2.uploader.explode('sample', {page: 'all'}, + function (error, result) { + console.log(result, error); + }); + +// Testing overload + +// $ExpectType Promise +cloudinary.v2.uploader.explode('sample', {page: 'all'}); + +// $ExpectType Promise +cloudinary.v2.uploader.explode('sample', + {page: 'all'}, + function (error, result) { + console.log(result, error); + }); + +// $ExpectType Promise +cloudinary.v2.uploader.generate_sprite('logo', + function (error, result) { + console.log(result, error); + }); + +// $ExpectType Promise +cloudinary.v2.uploader.multi('logo', + function (error, result) { + console.log(result, error); + }); + +// $ExpectType Promise +cloudinary.v2.uploader.remove_all_context(['dog', 'lion'], + function (error, result) { + console.log(result, error); + }); + +// $ExpectType Promise +cloudinary.v2.uploader.remove_all_tags(['dog', 'lion'], + function (error, result) { + console.log(result, error); + }); + +// $ExpectType Promise +cloudinary.v2.uploader.remove_tag('animal', ['dog', 'lion'], + function (error, result) { + console.log(result, error); + }); + +// $ExpectType Promise +cloudinary.v2.uploader.rename('canyon', 'grand_canyon', + function (error, result) { + console.log(result, error); + }); + +// $ExpectType Promise +cloudinary.v2.uploader.replace_tag('animal', ['dog', 'lion'], + function (error, result) { + console.log(result, error); + }); + +// $ExpectType Promise +cloudinary.v2.uploader.text("Sample text string", + { + public_id: "sample_text_image", + font_family: "Roboto", + font_size: 42, + font_color: "red", + font_weight: "bold" + }); + +// $ExpectType Promise +cloudinary.v2.uploader.upload("http://www.example.com/sample.jpg", + function (error, result) { + console.log(result, error); + }); + +// $ExpectType Promise +cloudinary.v2.uploader.upload("ftp://user1:mypass@ftp.example.com/sample.jpg", + { + eager: [ + {width: 400, height: 300, crop: "pad"}, + {width: 260, height: 200, crop: "crop", gravity: "north"}] + }, + function (error, result) { + console.log(result, error); + }); + +// $ExpectType Promise +cloudinary.v2.uploader.upload_large("my_large_video.mp4", + { + resource_type: "video", + chunk_size: 6000000 + }, + function (error, result) {console.log(result, error); + }); + +// $ExpectType Promise +cloudinary.v2.uploader.upload_large("my_large_video.mp4", + {resource_type: "video"}, + function (error, result) { + console.log(result, error); + }); + +// $ExpectType string +cloudinary.v2.utils.download_zip_url( + { + public_ids: 'dog,cat,lion', + resource_type: 'image' + } +); + +// $ExpectType Promise +cloudinary.v2.search + .expression('cat -tags:kitten') + .sort_by('public_id', 'desc') + .aggregate('format') + .execute().then(result => console.log(result)); + +// $ExpectType Promise +cloudinary.v2.search + .expression('cat') + .with_field('context') + .with_field('tags') + .max_results(10) + .execute().then(result => console.log(result)); + +// $ExpectType Promise +cloudinary.v2.search + .expression('resource_type:image AND tags=kitten AND uploaded_at>1d AND bytes>1m') + .sort_by('public_id', 'desc') + .max_results(30) + .execute().then(result => console.log(result)); + +// $ExpectType string +let test2 = cloudinary.v2.url("sample.jpg", { + sign_url: true, + custom_function: { + function_type: "remote", + source: + "https://my.example.custom/function" + } +}); + +// $ExpectType Promise +cloudinary.v2.uploader.remove_tag('12', ['11']).then((value) => { + console.log(value); +}); + +// $ExpectType Promise +cloudinary.v2.uploader.remove_tag('12', ['11'], function (err, res) { + console.log(err, res); +}); diff --git a/types/index.d.ts b/types/index.d.ts new file mode 100644 index 00000000..c0b84288 --- /dev/null +++ b/types/index.d.ts @@ -0,0 +1,885 @@ +declare module 'cloudinary' { + + /****************************** Constants *************************************/ + /****************************** Transformations *******************************/ + type CropMode = + string + | "scale" + | "fit" + | "limit" + | "mfit" + | "fill" + | "lfill" + | "pad" + | "lpad" + | "mpad" + | "crop" + | "thumb" + | "imagga_crop" + | "imagga_scale"; + type Gravity = + string + | "north_west" + | "north" + | "north_east" + | "west" + | "center" + | "east" + | "south_west" + | "south" + | "south_east" + | "xy_center" + | "face" + | "face:center" + | "face:auto" + | "faces" + | "faces:center" + | "faces:auto" + | "body" + | "body:face" + | "adv_face" + | "adv_faces" + | "adv_eyes" + | "custom" + | "custom:face" + | "custom:faces" + | "custom:adv_face" + | "custom:adv_faces" + | "auto" + | "auto:adv_face" + | "auto:adv_faces" + | "auto:adv_eyes" + | "auto:body" + | "auto:face" + | "auto:faces" + | "auto:custom_no_override" + | "auto:none" + | "liquid" + | "ocr_text"; + type Angle = number | string | Array | "auto_right" | "auto_left" | "ignore" | "vflip" | "hflip"; + type ImageEffect = + string + | "hue" + | "red" + | "green" + | "blue" + | "negate" + | "brightness" + | "auto_brightness" + | "brightness_hsb" + | "sepia" + | "grayscale" + | "blackwhite" + | "saturation" + | "colorize" + | "replace_color" + | "simulate_colorblind" + | "assist_colorblind" + | "recolor" + | "tint" + | "contrast" + | "auto_contrast" + | "auto_color" + | "vibrance" + | "noise" + | "ordered_dither" + | "pixelate_faces" + | "pixelate_region" + | "pixelate" + | "unsharp_mask" + | "sharpen" + | "blur_faces" + | "blur_region" + | "blur" + | "tilt_shift" + | "gradient_fade" + | "vignette" + | "anti_removal" + | "overlay" + | "mask" + | "multiply" + | "displace" + | "shear" + | "distort" + | "trim" + | "make_transparent" + | "shadow" + | "viesus_correct" + | "contrast" + | "vibrance" + | "fill_light" + | "auto_color" + | "auto_contrast" + | "auto_brightness" + | "gamma" + | "improve"; + + type VideoEffect = string | "accelerate" | "reverse" | "boomerang" | "loop" | "make_transparent" | "transition"; + type AudioCodec = string | "none" | "aac" | "vorbis" | "mp3"; + type AudioFrequency = + string + | number + | 8000 + | 11025 + | 16000 + | 22050 + | 32000 + | 37800 + | 44056 + | 44100 + | 47250 + | 48000 + | 88200 + | 96000 + | 176400 + | 192000; + /****************************** Flags *************************************/ + type ImageFlags = + string + | Array + | "any_format" + | "attachment" + | "apng" + | "awebp" + | "clip" + | "clip_evenodd" + | "cutter" + | "force_strip" + | "force_strip" + | "getinfo" + | "ignore_aspect_ratio" + | "immutable_cache" + | "keep_attribution" + | "keep_iptc" + | "layer_apply" + | "lossy" + | "preserve_transparency" + | "png8" + | "png8" + | "png32" + | "progressive" + | "rasterize" + | "region_relative" + | "relative" + | "replace_image" + | "sanitize" + | "strip_profile" + | "text_no_trim" + | "no_overflow" + | "text_disallow_overflow" + | "tiff8_lzw" + | "tiled"; + type VideoFlags = + string + | Array + | "animated" + | "awebp" + | "attachment" + | "streaming_attachment" + | "hlsv3" + | "keep_dar" + | "splice" + | "layer_apply" + | "no_stream" + | "mono" + | "relative" + | "truncate_ts" + | "waveform"; + type ColorSpace = string | "srgb" | "no_cmyk" | "keep_cmyk"; + type DeliveryType = + string + | "upload" + | "private" + | "authenticated" + | "fetch" + | "multi" + | "text" + | "asset" + | "list" + | "facebook" + | "twitter" + | "twitter_name" + | "instagram" + | "gravatar" + | "youtube" + | "hulu" + | "vimeo" + | "animoto" + | "worldstarhiphop" + | "dailymotion"; + /****************************** URL *************************************/ + type ResourceType = string | "image" | "raw" | "video"; + type ImageFormat = + string + | "gif" + | "png" + | "jpg" + | "bmp" + | "ico" + | "pdf" + | "tiff" + | "eps" + | "jpc" + | "jp2" + | "psd" + | "webp" + | "zip" + | "svg" + | "mp4" + | "webm" + | "wdp" + | "hpx" + | "djvu" + | "ai" + | "flif" + | "bpg" + | "miff" + | "tga" + | "heic" + type VideoFormat = + string + | "auto" + | "flv" + | "m3u8" + | "ts" + | "mov" + | "mkv" + | "mp4" + | "mpd" + | "ogv" + | "webm" + + export interface CommonTransformationOptions { + transformation?: TransformationOptions; + raw_transformation?: string; + crop?: CropMode; + width?: number | string; + height?: number | string; + size?: string; + aspect_ratio?: number | string; + gravity?: Gravity; + x?: number | string; + y?: number | string; + zoom?: number | string; + effect?: string | Array; + background?: string; + angle?: Angle; + radius?: number | string; + overlay?: string | object; + custom_function?: string | { function_type: string | "wasm" | "remote", source: string } + variables?: Array; + if?: string; + else?: string; + end_if?: string; + dpr?: number | string; + quality?: number | string; + delay?: number | string; + + [futureKey: string]: any; + } + + export interface ImageTransformationOptions extends CommonTransformationOptions{ + underlay?: string | Object; + color?: string; + color_space?: ColorSpace; + opacity?: number | string; + border?: string; + default_image?: string; + density?: number | string; + format?: ImageFormat; + fetch_format?: ImageFormat; + effect?: string | Array | ImageEffect; + page?: number | string; + flags?: ImageFlags | string; + + [futureKey: string]: any; + } + + interface VideoTransformationOptions extends CommonTransformationOptions{ + audio_codec?: AudioCodec; + audio_frequency?: AudioFrequency; + video_codec?: string | Object; + bit_rate?: number | string; + fps?: string | Array; + keyframe_interval?: string; + offset?: string, + start_offset?: number | string; + end_offset?: number | string; + duration?: number | string; + streaming_profile?: StreamingProfiles + video_sampling?: number | string; + format?: VideoFormat; + fetch_format?: VideoFormat; + effect?: string | Array | VideoEffect; + flags?: VideoFlags; + + [futureKey: string]: any; + } + + interface TextStyleOptions { + font_family?: string; + font_size?: number; + font_color?: string; + font_weight?: string; + font_style?: string; background?: string; + opacity?: number; + text_decoration?: string + } + + interface ConfigOptions { + cloud_name?: string; + api_key?: string; + api_secret?: string; + private_cdn?: boolean; + secure_distribution?: boolean; + force_version?: boolean; + ssl_detected?: boolean; + secure?: boolean; + cdn_subdomain?: boolean; + secure_cdn_subdomain?: boolean; + cname?: string; + shorten?: boolean; + sign_url?: boolean; + use_root_path?: boolean; + auth_token?: object; + + [futureKey: string]: any; + } + + export interface ResourceOptions { + type?: string; + resource_type?: string; + } + + export interface UrlOptions extends ResourceOptions{ + version?: string; + format?: string; + url_suffix?: string; + + [futureKey: string]: any; + } + + export interface ImageTagOptions { + html_height?: string; + html_width?: string; + srcset?: object; + attributes?: object; + client_hints?: boolean; + responsive?: boolean; + hidpi?: boolean; + responsive_placeholder?: boolean; + + [futureKey: string]: any; + } + + export interface VideoTagOptions { + source_types?: string | string[]; + source_transformation?: TransformationOptions; + fallback_content?: string; + poster?: string | object; + controls?: boolean; + preload?: string; + + [futureKey: string]: any; + } + /****************************** Admin API Options *************************************/ + export interface AdminApiOptions { + agent?: object; + content_type?: string; + + [futureKey: string]: any; + } + + export interface ArchiveApiOptions { + allow_missing?: boolean; + async?: boolean; + expires_at?: number; + flatten_folders?: boolean; + flatten_transformations?: boolean; + keep_derived?: boolean; + mode?: string; + notification_url?: string; + prefixes?: string; + public_ids?: string[] | string; + skip_transformation_name?: boolean; + tags?: string | string[]; + target_format?: TargetArchiveFormat; + target_public_id?: string; + target_tags?: string[]; + timestamp?: number; + transformations?: TransformationOptions; + type?: DeliveryType + use_original_filename?: boolean; + + [futureKey: string]: any; + } + + export interface UpdateApiOptions extends ResourceOptions{ + access_control?: string[]; + auto_tagging?: number; + background_removal?: string; + categorization?: string; + context?: boolean | string; + custom_coordinates?: string; + detection?: string; + face_coordinates?: string; + headers?: string; + notification_url?: string; + ocr?: string; + raw_convert?: string; + similarity_search?: string; + tags?: string | string[]; + moderation_status?: string; + unsafe_update?: object; + allowed_for_strict?: boolean; + + [futureKey: string]: any; + } + + export interface PublishApiOptions extends ResourceOptions{ + invalidate?: boolean; + overwrite?: boolean; + + [futureKey: string]: any; + } + + export interface ResourceApiOptions extends ResourceOptions{ + transformation?: TransformationOptions; + transformations?: TransformationOptions; + keep_original?: boolean; + next_cursor?: boolean | string; + public_ids?: string[]; + prefix?: string; + all?: boolean; + max_results?: number; + tags?: boolean; + tag?: string; + context?: boolean; + direction?: number | string; + moderations?: boolean; + start_at?: string; + exif?: boolean; + colors?: boolean; + derived_next_cursor?: string; + faces?: boolean; + image_metadata?: boolean; + pages?: boolean; + coordinates?: boolean; + phash?: boolean; + + [futureKey: string]: any; + } + + export interface UploadApiOptions { + access_mode?: AccessMode; + allowed_formats?: Array | Array; + async?: boolean; + backup?: boolean; + callback?: string; + colors?: boolean; + discard_original_filename?: boolean; + eager?: TransformationOptions; + eager_async?: boolean; + eager_notification_url?: string; + exif?: boolean; + faces?: boolean; + folder?: string; + format?: VideoFormat | ImageFormat; + image_metadata?: boolean; + invalidate?: boolean; + moderation?: ModerationKind; + notification_url?: string; + overwrite?: boolean; + phash?: boolean; + proxy?: string; + public_id?: string; + quality_analysis?: boolean; + responsive_breakpoints?: object; + return_delete_token?: boolean + timestamp?: number; + transformation?: TransformationOptions; + type?: DeliveryType; + unique_filename?: boolean; + upload_preset?: string; + use_filename?: boolean; + chunk_size?: number; + + [futureKey: string]: any; + } + + type TransformationOptions = + string + | string[] + | VideoTransformationOptions + | ImageTransformationOptions + | Object + | Array + | Array; + + type ImageTransformationAndTagsOptions = ImageTransformationOptions | ImageTagOptions; + type VideoTransformationAndTagsOptions = VideoTransformationOptions | VideoTagOptions; + type ImageAndVideoFormatOptions = ImageFormat | VideoFormat; + type ConfigAndUrlOptions = ConfigOptions | UrlOptions; + type AdminAndPublishOptions = AdminApiOptions | PublishApiOptions; + type AdminAndResourceOptions = AdminApiOptions | ResourceApiOptions; + type AdminAndUpdateApiOptions = AdminApiOptions | UpdateApiOptions; + + /****************************** API *************************************/ + type Status = string | "pending" | "approved" | "rejected"; + type StreamingProfiles = string | "4k" | "full_hd" | "hd" | "sd" | "full_hd_wifi" | "full_hd_lean" | "hd_lean"; + type ModerationKind = string | "manual" | "webpurify" | "aws_rek" | "metascan"; + type AccessMode = string | "public" | "authenticated"; + type TargetArchiveFormat = string | "zip" | "tgz"; + type ErrorCallBack = (error: any, result: any) => any; + + export namespace v2 { + + /****************************** Global Utils *************************************/ + + function cloudinary_js_config(): string; + + function config(new_config: ConfigOptions | string, new_value?: string | boolean): void; + + function config(new_config: boolean | object): void; + + function url(public_id: string, options?: TransformationOptions | ConfigAndUrlOptions): string; + + /****************************** Tags *************************************/ + + function image(source: string, options?: ImageTransformationAndTagsOptions | ConfigAndUrlOptions): string; + + function picture(public_id: string, options?: ImageTransformationAndTagsOptions | ConfigAndUrlOptions): string; + + function source(public_id: string, options?: TransformationOptions | ConfigAndUrlOptions): string; + + function video(public_id: string, options?: VideoTransformationAndTagsOptions | ConfigAndUrlOptions): string; + + /****************************** Utils *************************************/ + + namespace utils { + + function api_sign_request(params_to_sign: object, api_secret: string): string; + + function api_url(action?: string, options?: ConfigAndUrlOptions): Promise; + + function url(public_id?: string, options?:TransformationOptions | ConfigAndUrlOptions ): string; + + function video_thumbnail_url(public_id?: string, options?: VideoTransformationOptions | ConfigAndUrlOptions): string; + + function video_url(public_id?: string, options?: VideoTransformationOptions | ConfigAndUrlOptions): string; + + function archive_params(options?: ArchiveApiOptions): Promise; + + function download_archive_url(options?: ArchiveApiOptions | ConfigAndUrlOptions): string + + function download_zip_url(options?: ArchiveApiOptions | ConfigAndUrlOptions): string; + + function generate_auth_token(options?: ConfigOptions): string; + + function webhook_signature(data?: string, timestamp?: number, options?: ConfigOptions): string; + } + + /****************************** Admin API V2 Methods *************************************/ + + namespace api { + function create_streaming_profile(name: string, options: AdminApiOptions | { display_name?: string, representations: TransformationOptions }, callback?: ErrorCallBack): Promise; + + function create_transformation(name: string, transformation: TransformationOptions, callback?: ErrorCallBack): Promise; + + function create_transformation(name: string, transformation: TransformationOptions, options?: AdminApiOptions | { allowed_for_strict?: boolean }, callback?: ErrorCallBack): Promise; + + function create_upload_mapping(folder: string, options: AdminApiOptions | { template: string }, callback?: ErrorCallBack): Promise; + + function create_upload_preset(options?: AdminApiOptions | { name?: string, unsigned?: boolean, disallow_public_id?: boolean }, callback?: ErrorCallBack): Promise; + + function delete_all_resources(value?: AdminAndResourceOptions, callback?: ErrorCallBack): Promise; + + function delete_derived_by_transformation(public_ids: string[], transformations: TransformationOptions, callback?: ErrorCallBack): Promise; + + function delete_derived_by_transformation(public_ids: string[], transformations: TransformationOptions, options?: AdminApiOptions, callback?: ErrorCallBack): Promise; + + function delete_derived_resources(public_ids: string[], callback?: ErrorCallBack): Promise; + + function delete_derived_resources(public_ids: string[], options?: AdminAndResourceOptions, callback?: ErrorCallBack): Promise; + + function delete_resources(value: string[], callback?: ErrorCallBack): Promise; + + function delete_resources(value: string[], options?: AdminAndResourceOptions, callback?: ErrorCallBack): Promise; + + function delete_resources_by_prefix(prefix: string, options?: AdminAndResourceOptions, callback?: ErrorCallBack): Promise; + + function delete_resources_by_prefix(prefix: string, callback?: ErrorCallBack): Promise; + + function delete_resources_by_tag(tag: string, options?: AdminAndResourceOptions, callback?: ErrorCallBack): Promise; + + function delete_resources_by_tag(tag: string, callback?: ErrorCallBack): Promise; + + function delete_streaming_profile(name: string, options?: AdminApiOptions, callback?: ErrorCallBack): Promise; + + function delete_streaming_profile(name: string, callback?: ErrorCallBack): Promise; + + function delete_transformation(transformationName: TransformationOptions, callback?: ErrorCallBack): Promise; + + function delete_transformation(transformationName: TransformationOptions, options?: AdminApiOptions, callback?: ErrorCallBack): Promise; + + function delete_upload_mapping(folder: string, callback?: ErrorCallBack): Promise; + + function delete_upload_mapping(folder: string, options?: AdminApiOptions, callback?: ErrorCallBack): Promise; + + function delete_upload_preset(name: string, callback?: ErrorCallBack): Promise; + + function delete_upload_preset(name: string, options?: AdminApiOptions, callback?: ErrorCallBack): Promise; + + function get_streaming_profile(name: string | ErrorCallBack, options?: AdminApiOptions, callback?: ErrorCallBack): Promise; + + function get_streaming_profile(name: string | ErrorCallBack, callback?: ErrorCallBack): Promise; + + function list_streaming_profiles(callback?: ErrorCallBack): Promise; + + function list_streaming_profiles(options?: AdminApiOptions, callback?: ErrorCallBack): Promise; + + function ping(options?: AdminApiOptions, callback?: ErrorCallBack): Promise; + + function ping(callback?: ErrorCallBack): Promise; + + function publish_by_ids(public_ids: string[], options?: AdminAndPublishOptions, callback?: ErrorCallBack): Promise; + + function publish_by_ids(public_ids: string[], callback?: ErrorCallBack): Promise; + + function publish_by_prefix(prefix: string[] | string, options?: AdminAndPublishOptions, callback?: ErrorCallBack): Promise; + + function publish_by_prefix(prefix: string[] | string, callback?: ErrorCallBack): Promise; + + function publish_by_tag(tag: string, options?: AdminAndPublishOptions, callback?: ErrorCallBack): Promise; + + function publish_by_tag(tag: string, callback?: ErrorCallBack): Promise; + + function resource(public_id: string, options?: AdminAndResourceOptions, callback?: ErrorCallBack): Promise; + + function resource(public_id: string, callback?: ErrorCallBack): Promise; + + function resource_types(options?: AdminApiOptions, callback?: ErrorCallBack): Promise; + + function resources(options?: AdminAndResourceOptions, callback?: ErrorCallBack): Promise; + + function resources_by_context(key: string, value?: string, options?: AdminAndResourceOptions, callback?: ErrorCallBack): Promise; + + function resources_by_context(key: string, value?: string, options?: AdminAndResourceOptions): Promise; + + function resources_by_context(key: string, options?: AdminAndResourceOptions): Promise; + + function resources_by_context(key: string, callback?: ErrorCallBack): Promise; + + function resources_by_ids(public_ids: string[], options?: AdminAndResourceOptions, callback?: ErrorCallBack): Promise; + + function resources_by_ids(public_ids: string[], callback?: ErrorCallBack): Promise; + + function resources_by_moderation(moderation: ModerationKind, status: Status, options?: AdminAndResourceOptions, callback?: ErrorCallBack): Promise; + + function resources_by_moderation(moderation: ModerationKind, status: Status, callback?: ErrorCallBack): Promise; + + function resources_by_tag(tag: string, options?: AdminAndResourceOptions, callback?: ErrorCallBack): Promise; + + function resources_by_tag(tag: string, callback?: ErrorCallBack): Promise; + + function restore(public_ids: string[], options?: AdminApiOptions | { resource_type: ResourceType, type: DeliveryType }, callback?: ErrorCallBack): Promise; + + function restore(public_ids: string[], callback?: ErrorCallBack): Promise; + + function root_folders(callback?: ErrorCallBack, options?: AdminApiOptions): Promise; + + function search(params: string, options?: AdminApiOptions, callback?: ErrorCallBack): Promise; + + function search(params: string, callback?: ErrorCallBack): Promise; + + function sub_folders(root_folder: string, options?: AdminApiOptions, callback?: ErrorCallBack): Promise; + + function sub_folders(root_folder: string, callback?: ErrorCallBack): Promise; + + function tags(callback?: ErrorCallBack, options?: AdminApiOptions | { max_results?: number, next_cursor?: string, prefix?: string }): Promise; + + function transformation(transformation: TransformationOptions, options?: AdminApiOptions | { max_results?: number, next_cursor?: string, named?: boolean }, callback?: ErrorCallBack): Promise; + + function transformation(transformation: TransformationOptions, callback?: ErrorCallBack): Promise; + + function transformations(options?: AdminApiOptions | { max_results?: number, next_cursor?: string, named?: boolean }, callback?: ErrorCallBack): Promise; + + function transformations(callback?: ErrorCallBack): Promise; + + function update(public_id: string, options?: AdminAndUpdateApiOptions, callback?: ErrorCallBack): Promise; + + function update(public_id: string, callback?: ErrorCallBack): Promise; + + function update_resources_access_mode_by_ids(access_mode: AccessMode, ids: string[], options?: AdminAndUpdateApiOptions, callback?: ErrorCallBack): Promise; + + function update_resources_access_mode_by_ids(access_mode: AccessMode, ids: string[], callback?: ErrorCallBack): Promise; + + function update_resources_access_mode_by_prefix(access_mode: AccessMode, prefix: string, options?: AdminAndUpdateApiOptions, callback?: ErrorCallBack): Promise; + + function update_resources_access_mode_by_prefix(access_mode: AccessMode, prefix: string, callback?: ErrorCallBack): Promise; + + function update_resources_access_mode_by_tag(access_mode: AccessMode, tag: string, options?: AdminAndUpdateApiOptions, callback?: ErrorCallBack): Promise; + + function update_resources_access_mode_by_tag(access_mode: AccessMode, tag: string, callback?: ErrorCallBack): Promise; + + function update_streaming_profile(name: string, options: { display_name?: string, representations: Array<{ transformation?: VideoTransformationOptions }> }, callback?: ErrorCallBack): Promise; + + function update_transformation(transformation_name: TransformationOptions, updates?: TransformationOptions, callback?: ErrorCallBack): Promise; + + function update_transformation(transformation_name: TransformationOptions, callback?: ErrorCallBack): Promise; + + function update_upload_mapping(name: string, options: AdminApiOptions | { template: string }, callback?: ErrorCallBack): Promise; + + function update_upload_preset(name?: string, options?: AdminApiOptions | { unsigned?: boolean, disallow_public_id?: boolean }, callback?: ErrorCallBack): Promise; + + function update_upload_preset(name?: string, callback?: ErrorCallBack): Promise; + + function upload_mapping(name?: string, options?: AdminApiOptions, callback?: ErrorCallBack): Promise; + + function upload_mapping(name?: string, callback?: ErrorCallBack): Promise; + + function upload_mappings(options?: AdminApiOptions | { max_results?: number, next_cursor?: string }, callback?: ErrorCallBack): Promise; + + function upload_mappings(callback?: ErrorCallBack): Promise; + + function upload_preset(name?: string, options?: AdminApiOptions, callback?: ErrorCallBack): Promise; + + function upload_preset(name?: string, callback?: ErrorCallBack): Promise; + + function upload_presets(options?: AdminApiOptions | { max_results?: number, next_cursor?: string }, callback?: ErrorCallBack): Promise; + + function usage(callback?: ErrorCallBack, options?: AdminApiOptions): Promise; + + function usage(options?: AdminApiOptions): Promise; + } + + /****************************** Upload API V2 Methods *************************************/ + + namespace uploader { + function add_context(context: string, public_ids: string[], options?: { type?: DeliveryType, resource_type?: ResourceType }, callback?: ErrorCallBack): Promise; + + function add_context(context: string, public_ids: string[], callback?: ErrorCallBack): Promise; + + function add_tag(tag: string, public_ids: string[], options?: { type?: DeliveryType, resource_type?: ResourceType }, callback?: ErrorCallBack): Promise; + + function add_tag(tag: string, public_ids: string[], callback?: ErrorCallBack): Promise; + + function create_archive(options?: ArchiveApiOptions, target_format?: TargetArchiveFormat, callback?: ErrorCallBack,): Promise; + + function create_zip(options?: ArchiveApiOptions, callback?: ErrorCallBack): Promise; + + function destroy(public_id: string, options?: { resource_types?: ResourceType, type?: DeliveryType, invalidate?: boolean }, callback?: ErrorCallBack,): Promise; + + function destroy(public_id: string, callback?: ErrorCallBack,): Promise; + + function explicit(public_id: string, options?: UploadApiOptions, callback?: ErrorCallBack): Promise; + + function explicit(public_id: string, callback?: ErrorCallBack): Promise; + + function explode(public_id: string, options?: { page?: 'all', type?: DeliveryType, format?: ImageAndVideoFormatOptions, notification_url?: string, transformations?: TransformationOptions }, callback?: ErrorCallBack): Promise + + function explode(public_id: string, callback?: ErrorCallBack): Promise + + function generate_sprite(tag: string, options?: { transformation?: TransformationOptions, format?: ImageAndVideoFormatOptions, notification_url?: string, async?: boolean }, callback?: ErrorCallBack): Promise; + + function generate_sprite(tag: string, callback?: ErrorCallBack): Promise; + + function image_upload_tag(field?: string, options?: UploadApiOptions): Promise; + + function multi(tag: string, options?: { transformation?: TransformationOptions, async?: boolean, format?: ImageAndVideoFormatOptions, notification_url?: string }, callback?: ErrorCallBack): Promise; + + function multi(tag: string, callback?: ErrorCallBack): Promise; + + function remove_all_context(public_ids: string[], options?: { context?: string, resource_type?: ResourceType, type?: DeliveryType }, callback?: ErrorCallBack): Promise; + + function remove_all_context(public_ids: string[], callback?: ErrorCallBack): Promise; + + function remove_all_tags(public_ids: string[], options?: { tag?: string, resource_type?: ResourceType, type?: DeliveryType }, callback?: ErrorCallBack): Promise; + + function remove_all_tags(public_ids: string[], callback?: ErrorCallBack): Promise; + + function remove_tag(tag: string, public_ids: string[], options?: { tag?: string, resource_type?: ResourceType, type?: DeliveryType }, callback?: ErrorCallBack): Promise; + + function remove_tag(tag: string, public_ids: string[], callback?: ErrorCallBack): Promise; + + function rename(from_public_id: string, to_public_id: string, options?: { resource_type?: ResourceType, type?: DeliveryType, to_type?: DeliveryType, overwrite?: boolean, invalidate?: boolean }, callback?: ErrorCallBack): Promise; + + function rename(from_public_id: string, to_public_id: string, callback?: ErrorCallBack): Promise; + + function replace_tag(tag: string, public_ids: string[], options?: { resource_type?: ResourceType, type?: DeliveryType }, callback?: ErrorCallBack): Promise; + + function replace_tag(tag: string, public_ids: string[], callback?: ErrorCallBack): Promise; + + function text(text: string, options?: TextStyleOptions | { public_id?: string }, callback?: ErrorCallBack): Promise; + + function text(text: string, callback?: ErrorCallBack): Promise; + + function unsigned_image_upload_tag(field: string, upload_preset: string, options?: UploadApiOptions): Promise; + + function unsigned_upload(file: string, upload_preset: string, options?: UploadApiOptions, callback?: ErrorCallBack): Promise; + + function unsigned_upload(file: string, upload_preset: string, callback?: ErrorCallBack): Promise; + + function unsigned_upload_stream(upload_preset: string, options?: UploadApiOptions, callback?: ErrorCallBack): Promise; + + function unsigned_upload_stream(upload_preset: string, callback?: ErrorCallBack): Promise; + + function upload(file: string, options?: UploadApiOptions, callback?: ErrorCallBack): Promise; + + function upload(file: string, callback?: ErrorCallBack): Promise; + + function upload_chunked(path: string, options?: UploadApiOptions, callback?: ErrorCallBack): Promise; + + function upload_chunked(path: string, callback?: ErrorCallBack): Promise; + + function upload_chunked_stream(options?: UploadApiOptions, callback?: ErrorCallBack): Promise; + + function upload_large(path: string, options?: UploadApiOptions, callback?: ErrorCallBack): Promise; + + function upload_large(path: string, callback?: ErrorCallBack): Promise; + + function upload_stream(upload_preset: string, options?: UploadApiOptions, callback?: ErrorCallBack): Promise; + + function upload_stream(upload_preset: string, callback?: ErrorCallBack): Promise; + + function upload_tag_params(options?: UploadApiOptions, callback?: ErrorCallBack): Promise; + + function upload_url(options?: ConfigOptions): Promise; + } + + /****************************** Search API *************************************/ + + class search { + + aggregate(value?: string): search; + + execute(): Promise; + + expression(value?: string): search; + + max_results(value?: number): search; + + next_cursor(value?: string): search; + + sort_by(key: string, value: 'asc' | 'desc'): search; + + to_query(value?: string): search; + + with_field(value?: string): search; + + static aggregate(args?: string): search; + + static expression(args?: string): search; + + static instance(args?: string): search; + + static max_results(args?: number): search; + + static next_cursor(args?: string): search; + + static sort_by(key: string, value: 'asc' | 'desc'): search; + + static with_field(args?: string): search; + } + } +} diff --git a/types/tsconfig.json b/types/tsconfig.json new file mode 100644 index 00000000..dad95590 --- /dev/null +++ b/types/tsconfig.json @@ -0,0 +1,17 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": ["es6", "dom"], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "noEmit": true, + "baseUrl": ".", + "paths": { "cloudinary": ["."] } + + }, + "exclude": [ + "node_modules" + ] +}