diff --git a/types/cloudinary_ts_spec.ts b/types/cloudinary_ts_spec.ts index 418cf839..7f6c87a5 100644 --- a/types/cloudinary_ts_spec.ts +++ b/types/cloudinary_ts_spec.ts @@ -411,48 +411,55 @@ cloudinary.v2.api.resources( } ); -// $ExpectType Promise +// $ExpectType Promise cloudinary.v2.api.resources_by_context("mycontextkey", "mycontextvalue", {resource_type: 'video'}, function (error, result) { console.log(result, error); }); -// $ExpectType Promise +// $ExpectType Promise cloudinary.v2.api.resources_by_context("mycontextkey", function (error, result) { console.log(result, error); }); -// $ExpectType Promise +// $ExpectType Promise cloudinary.v2.api.resources_by_ids(["user_photo_1", "user_photo_2"], function (error, result) { console.log(result, error); }); -// $ExpectType Promise +// $ExpectType Promise cloudinary.v2.api.resources_by_ids(["user_photo_1", "user_photo_2"], {resource_type: 'video'},); -// $ExpectType Promise +cloudinary.v2.api.resources_by_ids(["user_photo_1", "user_photo_2"], { + context: true, + tags: true, +}).then((result) => { + console.log(result.resources[0].public_id); +}) + +// $ExpectType Promise cloudinary.v2.api.resources_by_moderation('webpurify', 'approved', function (error, result) { console.log(result, error); }); -// $ExpectType Promise +// $ExpectType Promise cloudinary.v2.api.resources_by_moderation('manual', 'pending', function (error, result) { console.log(result, error); }); -// $ExpectType Promise +// $ExpectType Promise cloudinary.v2.api.resources_by_tag("mytag", {resource_type: 'raw'}, function (error, result) { console.log(result, error); }); -// $ExpectType Promise +// $ExpectType Promise cloudinary.v2.api.resources_by_tag("mytag", function (error, result) { console.log(result, error); diff --git a/types/index.d.ts b/types/index.d.ts index ace1e6d5..2ac8051d 100644 --- a/types/index.d.ts +++ b/types/index.d.ts @@ -555,6 +555,46 @@ declare module 'cloudinary' { class UploadStream extends Transform { } + export interface ResourceApiResponse { + resources: [ + { + public_id: string; + format: string; + version: number; + resource_type: string; + type: string; + placeholder: boolean; + created_at: string; + bytes: number; + width: number; + height: number; + backup: boolean; + access_mode: string; + url: string; + secure_url: string; + tags: Array; + context: object; + next_cursor: string; + derived_next_cursor: string; + exif: object; + image_metadata: object; + faces: number[][]; + quality_analysis: number; + colors: string[][]; + derived: Array; + moderation: object; + phash: string; + predominant: object; + coordinates: object; + access_control: Array; + pages: number; + + [futureKey: string]: any; + } + ] + } + + export namespace v2 { /****************************** Global Utils *************************************/ @@ -685,25 +725,25 @@ declare module 'cloudinary' { function resources(options?: AdminAndResourceOptions, callback?: ResponseCallback): Promise; - function resources_by_context(key: string, value?: string, options?: AdminAndResourceOptions, callback?: ResponseCallback): Promise; + function resources_by_context(key: string, value?: string, options?: AdminAndResourceOptions, callback?: ResponseCallback): Promise; - function resources_by_context(key: string, value?: string, options?: AdminAndResourceOptions): 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, options?: AdminAndResourceOptions): Promise; - function resources_by_context(key: string, callback?: ResponseCallback): Promise; + function resources_by_context(key: string, callback?: ResponseCallback): Promise; - function resources_by_ids(public_ids: string[], options?: AdminAndResourceOptions, callback?: ResponseCallback): Promise; + function resources_by_ids(public_ids: string[] | string, options?: AdminAndResourceOptions, callback?: ResponseCallback): Promise; - function resources_by_ids(public_ids: string[], callback?: ResponseCallback): Promise; + function resources_by_ids(public_ids: string[] | string, callback?: ResponseCallback): Promise; - function resources_by_moderation(moderation: ModerationKind, status: Status, options?: AdminAndResourceOptions, callback?: ResponseCallback): Promise; + function resources_by_moderation(moderation: ModerationKind, status: Status, options?: AdminAndResourceOptions, callback?: ResponseCallback): Promise; - function resources_by_moderation(moderation: ModerationKind, status: Status, callback?: ResponseCallback): Promise; + function resources_by_moderation(moderation: ModerationKind, status: Status, callback?: ResponseCallback): Promise; - function resources_by_tag(tag: string, options?: AdminAndResourceOptions, callback?: ResponseCallback): Promise; + function resources_by_tag(tag: string, options?: AdminAndResourceOptions, callback?: ResponseCallback): Promise; - function resources_by_tag(tag: string, callback?: ResponseCallback): Promise; + function resources_by_tag(tag: string, callback?: ResponseCallback): Promise; function restore(public_ids: string[], options?: AdminApiOptions | { resource_type: ResourceType, type: DeliveryType }, callback?: ResponseCallback): Promise;