Skip to content

Commit b979e59

Browse files
test: included more variants of calling asset relations api in type spec
1 parent 8262b44 commit b979e59

File tree

1 file changed

+74
-40
lines changed

1 file changed

+74
-40
lines changed

types/cloudinary_ts_spec.ts

Lines changed: 74 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@ cloudinary.v2.config();
99
cloudinary.v2.config(true);
1010

1111
// $ExpectType ConfigOptions
12-
cloudinary.v2.config({ cloud_name: "demo" });
12+
cloudinary.v2.config({cloud_name: "demo"});
1313

1414
// $ExpectError
15-
cloudinary.v2.config({ cloud_name: 0 });
15+
cloudinary.v2.config({cloud_name: 0});
1616

1717
// $ExpectType boolean | undefined
1818
cloudinary.v2.config("private_cdn");
@@ -237,19 +237,27 @@ cloudinary.v2.api.delete_derived_by_transformation(['image1', 'image2'], 'f_auto
237237
// $ExpectType Promise<any>
238238
cloudinary.v2.api.delete_derived_by_transformation(['image1', 'image2'], 'f_auto',
239239
{content_type: 'json'},
240-
function(err,res){console.log(err);});
240+
function (err, res) {
241+
console.log(err);
242+
});
241243

242244
// $ExpectType Promise<any>
243245
cloudinary.v2.api.delete_derived_by_transformation(['image1', 'image2'], 'f_auto',
244-
function(err,res){console.log(err);});
246+
function (err, res) {
247+
console.log(err);
248+
});
245249

246250
// $ExpectType Promise<any>
247251
cloudinary.v2.api.delete_derived_resources(['image1', 'image2'],
248-
function (err,res){console.log(err);});
252+
function (err, res) {
253+
console.log(err);
254+
});
249255

250256
// $ExpectType Promise<any>
251257
cloudinary.v2.api.delete_derived_resources(['image1', 'image2'], {keep_original: true},
252-
function (err,res){console.log(err);});
258+
function (err, res) {
259+
console.log(err);
260+
});
253261

254262
// $ExpectType Promise<any>
255263
cloudinary.v2.api.delete_resources_by_prefix('sunday',
@@ -331,7 +339,7 @@ cloudinary.v2.api.list_streaming_profiles(
331339
});
332340

333341
// $ExpectType Promise<any>
334-
cloudinary.v2.api.list_streaming_profiles( {content_type: 'json'},
342+
cloudinary.v2.api.list_streaming_profiles({content_type: 'json'},
335343
function (err, res) {
336344
console.log(err);
337345
});
@@ -452,17 +460,17 @@ cloudinary.v2.api.resources_by_context("mycontextkey",
452460

453461
// $ExpectType Promise<ResourceApiResponse>
454462
cloudinary.v2.api.resources_by_asset_ids(["asset_1", "asset_2"], {
455-
context: true,
456-
tags: true
457-
}, function (error, result) {
458-
console.log(result, error);
459-
});
463+
context: true,
464+
tags: true
465+
}, function (error, result) {
466+
console.log(result, error);
467+
});
460468

461469
// $ExpectType Promise<ResourceApiResponse>
462470
cloudinary.v2.api.resources_by_asset_ids(["asset_1", "asset_2"], {
463-
context: true,
464-
tags: true
465-
});
471+
context: true,
472+
tags: true
473+
});
466474

467475
// $ExpectType Promise<ResourceApiResponse>
468476
cloudinary.v2.api.resources_by_asset_ids(["asset_1", "asset_2"],
@@ -625,43 +633,57 @@ cloudinary.v2.api.add_metadata_field({
625633
label: 'LABEL_INT_1',
626634
type: "integer",
627635
default_value: 10,
628-
}).then((result)=> {
636+
}).then((result) => {
629637
console.log(result);
630638
});
631639

632-
cloudinary.v2.api.list_metadata_fields().then((result)=> {
640+
cloudinary.v2.api.list_metadata_fields().then((result) => {
633641
console.log(result.metadata_fields[0].datasource);
634642
});
635643

636644
cloudinary.v2.api.delete_metadata_field('EXTERNAL_ID_GET_LIST').then((res) => {
637-
console.log(res.message)
638-
}).catch((err)=> {console.log(err)})
645+
console.log(res.message)
646+
}).catch((err) => {
647+
console.log(err)
648+
})
639649

640-
cloudinary.v2.api.update_metadata_field('EXTERNAL_ID_GET_LIST',{mandatory: true},
650+
cloudinary.v2.api.update_metadata_field('EXTERNAL_ID_GET_LIST', {mandatory: true},
641651
function (res) {
642-
console.log(res);
643-
})
652+
console.log(res);
653+
})
644654

645655
const datasource_changes = {
646656
values: [
647-
{ external_id: "color_1", value: "brown" },
648-
{ external_id: "color_2", value: "black" },
657+
{external_id: "color_1", value: "brown"},
658+
{external_id: "color_2", value: "black"},
649659
],
650660
};
651661

652-
cloudinary.v2.uploader.update_metadata({ metadata_color: "red", metadata_shape: "" }, ["test_id_1", "test_id_2"])
653-
.then((res)=> {console.log(res)})
654-
.catch((err)=> {console.log(err)});
662+
cloudinary.v2.uploader.update_metadata({metadata_color: "red", metadata_shape: ""}, ["test_id_1", "test_id_2"])
663+
.then((res) => {
664+
console.log(res)
665+
})
666+
.catch((err) => {
667+
console.log(err)
668+
});
655669

656-
cloudinary.v2.uploader.update_metadata('countryFieldId=[\"id_us\",\"id_uk\",\"id_france"]', [ 'dog', 'lion' ],
657-
function(error, result) { console.log(result, error) });
670+
cloudinary.v2.uploader.update_metadata('countryFieldId=[\"id_us\",\"id_uk\",\"id_france"]', ['dog', 'lion'],
671+
function (error, result) {
672+
console.log(result, error)
673+
});
658674

659675
cloudinary.v2.api.update_metadata_field_datasource('EXTERNAL_ID_GET_LIST1', datasource_changes)
660-
.then((res)=> {console.log(res)})
661-
.catch((err)=> {console.log(err)});
676+
.then((res) => {
677+
console.log(res)
678+
})
679+
.catch((err) => {
680+
console.log(err)
681+
});
662682

663683
cloudinary.v2.api.delete_datasource_entries('EXTERNAL_ID_DELETE_DATASOURCE_ENTRIES', ['size_2'])
664-
.then((res)=>{console.log(res)})
684+
.then((res) => {
685+
console.log(res)
686+
})
665687

666688
cloudinary.v2.api.add_metadata_rule({
667689
metadata_field_id: 'EXTERNAL_ID_GET_LIST',
@@ -852,7 +874,8 @@ cloudinary.v2.uploader.upload_large("my_large_video.mp4",
852874
resource_type: "video",
853875
chunk_size: 6000000
854876
},
855-
function (error, result) {console.log(result, error);
877+
function (error, result) {
878+
console.log(result, error);
856879
});
857880

858881
// $ExpectType Promise<UploadApiResponse>
@@ -872,8 +895,7 @@ cloudinary.v2.utils.download_zip_url(
872895

873896
// $ExpectType { [key: string]: any; signature: string; api_key: string; }
874897
cloudinary.v2.utils.sign_request(
875-
{
876-
}
898+
{}
877899
);
878900

879901
// $ExpectType Promise<void>
@@ -951,7 +973,7 @@ cloudinary.v2.provisioning.account.sub_accounts(
951973
cloudinary.v2.provisioning.account.sub_account(
952974
'str',
953975
[],
954-
(res) => {
976+
(res) => {
955977

956978
});
957979

@@ -960,7 +982,7 @@ cloudinary.v2.provisioning.account.sub_account(
960982
cloudinary.v2.provisioning.account.create_sub_account(
961983
'str',
962984
'str',
963-
{foo:'bar'},
985+
{foo: 'bar'},
964986
false,
965987
'sds',
966988
{},
@@ -1120,29 +1142,41 @@ cloudinary.v2.utils.private_download_url('foo', 'foo', {
11201142

11211143

11221144
// $ExpectType Promise<any>
1123-
cloudinary.v2.api.create_folder('foo',{
1145+
cloudinary.v2.api.create_folder('foo', {
11241146
attachment: true,
11251147
expires_at: 111
11261148
});
11271149

11281150

11291151
// $ExpectType Promise<any>
1130-
cloudinary.v2.api.delete_folder('foo',{
1152+
cloudinary.v2.api.delete_folder('foo', {
11311153
agent: new Http.Agent()
11321154
});
11331155

11341156
// $ExpectType Promise<NewAssetRelationResponse>
11351157
cloudinary.v2.api.add_related_assets('public-id', 'public-id-to-relate');
11361158

1159+
// $ExpectType Promise<NewAssetRelationResponse>
1160+
cloudinary.v2.api.add_related_assets('public-id', ['public-id-to-relate-1', 'public-id-to-relate-2']);
1161+
11371162
// $ExpectType Promise<NewAssetRelationResponse>
11381163
cloudinary.v2.api.add_related_assets_by_asset_id('asset-id', 'public-id-to-relate');
11391164

1165+
// $ExpectType Promise<NewAssetRelationResponse>
1166+
cloudinary.v2.api.add_related_assets_by_asset_id('asset-id', ['public-id-to-relate-1', 'public-id-to-relate-2']);
1167+
11401168
// $ExpectType Promise<DeleteAssetRelation>
11411169
cloudinary.v2.api.delete_related_assets('public-id', 'public-id-to-unrelate');
11421170

1171+
// $ExpectType Promise<DeleteAssetRelation>
1172+
cloudinary.v2.api.delete_related_assets('public-id', ['public-id-to-unrelate-1', 'public-id-to-unrelate-2']);
1173+
11431174
// $ExpectType Promise<DeleteAssetRelation>
11441175
cloudinary.v2.api.delete_related_assets_by_asset_id('asset-id', 'public-id-to-unrelate');
11451176

1177+
// $ExpectType Promise<DeleteAssetRelation>
1178+
cloudinary.v2.api.delete_related_assets_by_asset_id('asset-id', ['public-id-to-unrelate-1', 'public-id-to-unrelate-2']);
1179+
11461180
// $ExpectType Promise<any>
11471181
cloudinary.v2.uploader.create_slideshow({
11481182
manifest_json: {
@@ -1151,5 +1185,5 @@ cloudinary.v2.uploader.create_slideshow({
11511185
manifest_transformation: {
11521186
width: 100
11531187
},
1154-
height:100
1188+
height: 100
11551189
});

0 commit comments

Comments
 (0)