Skip to content

Commit d343935

Browse files
Merge pull request #575 from cloudinary/parameter-typing-impoved
feat: detailed typing for parameters
2 parents 5096924 + 3a27004 commit d343935

File tree

1 file changed

+41
-34
lines changed

1 file changed

+41
-34
lines changed

types/index.d.ts

Lines changed: 41 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { AnyARecord } from 'dns';
12
import { Transform } from 'stream';
23

34

@@ -260,9 +261,9 @@ declare module 'cloudinary' {
260261
background?: string;
261262
angle?: Angle;
262263
radius?: number | string;
263-
overlay?: string | object;
264+
overlay?: string | object; //might be Record<any, any>
264265
custom_function?: string | { function_type: string | "wasm" | "remote", source: string }
265-
variables?: Array<string | object>;
266+
variables?: Array<string | object>; //might be Record<any, any>
266267
if?: string;
267268
else?: string;
268269
end_if?: string;
@@ -274,7 +275,7 @@ declare module 'cloudinary' {
274275
}
275276

276277
export interface ImageTransformationOptions extends CommonTransformationOptions {
277-
underlay?: string | Object;
278+
underlay?: string | Object; //might be Record<any, any>
278279
color?: string;
279280
color_space?: ColorSpace;
280281
opacity?: number | string;
@@ -293,7 +294,7 @@ declare module 'cloudinary' {
293294
interface VideoTransformationOptions extends CommonTransformationOptions {
294295
audio_codec?: AudioCodec;
295296
audio_frequency?: AudioFrequency;
296-
video_codec?: string | Object;
297+
video_codec?: string | Object; //might be Record<any, any>
297298
bit_rate?: number | string;
298299
fps?: string | Array<number | string>;
299300
keyframe_interval?: string;
@@ -340,7 +341,7 @@ declare module 'cloudinary' {
340341
sign_url?: boolean;
341342
long_url_signature?: boolean;
342343
use_root_path?: boolean;
343-
auth_token?: object;
344+
auth_token?: AuthTokenApiOptions;
344345
account_id?: string;
345346
provisioning_api_key?: string;
346347
provisioning_api_secret?: string;
@@ -365,8 +366,8 @@ declare module 'cloudinary' {
365366
export interface ImageTagOptions {
366367
html_height?: string;
367368
html_width?: string;
368-
srcset?: object;
369-
attributes?: object;
369+
srcset?: object; //might be Record<any, any>
370+
attributes?: object; //might be Record<any, any>
370371
client_hints?: boolean;
371372
responsive?: boolean;
372373
hidpi?: boolean;
@@ -379,7 +380,7 @@ declare module 'cloudinary' {
379380
source_types?: string | string[];
380381
source_transformation?: TransformationOptions;
381382
fallback_content?: string;
382-
poster?: string | object;
383+
poster?: string | object; //might be Record<any, any>
383384
controls?: boolean;
384385
preload?: string;
385386

@@ -388,7 +389,7 @@ declare module 'cloudinary' {
388389

389390
/****************************** Admin API Options *************************************/
390391
export interface AdminApiOptions {
391-
agent?: object;
392+
agent?: object; //might be Record<any, any>
392393
content_type?: string;
393394
oauth_token?: string;
394395

@@ -436,7 +437,7 @@ declare module 'cloudinary' {
436437
similarity_search?: string;
437438
tags?: string | string[];
438439
moderation_status?: string;
439-
unsafe_update?: object;
440+
unsafe_update?: object; //might be Record<any, any>
440441
allowed_for_strict?: boolean;
441442
asset_folder?: string;
442443
unique_display_name?: boolean;
@@ -507,7 +508,7 @@ declare module 'cloudinary' {
507508
proxy?: string;
508509
public_id?: string;
509510
quality_analysis?: boolean;
510-
responsive_breakpoints?: object;
511+
responsive_breakpoints?: Record<any,any>;
511512
return_delete_token?: boolean
512513
timestamp?: number;
513514
transformation?: TransformationOptions;
@@ -527,7 +528,7 @@ declare module 'cloudinary' {
527528
account_id?: string;
528529
provisioning_api_key?: string;
529530
provisioning_api_secret?: string;
530-
agent?: object;
531+
agent?: object; //might be Record<any, any>?
531532
content_type?: string;
532533

533534
[futureKey: string]: any;
@@ -548,7 +549,7 @@ declare module 'cloudinary' {
548549
| string[]
549550
| VideoTransformationOptions
550551
| ImageTransformationOptions
551-
| Object
552+
| Object //might be Record<any, any>
552553
| Array<ImageTransformationOptions>
553554
| Array<VideoTransformationOptions>;
554555

@@ -593,8 +594,8 @@ declare module 'cloudinary' {
593594
original_filename: string;
594595
moderation: Array<string>;
595596
access_control: Array<string>;
596-
context: object;
597-
metadata: object;
597+
context: object; //won't change since it's response, we need to discuss documentation team about it before implementing.
598+
metadata: object; //won't change since it's response, we need to discuss documentation team about it before implementing.
598599
colors?: [string, number][];
599600

600601
[futureKey: string]: any;
@@ -622,8 +623,8 @@ declare module 'cloudinary' {
622623
label?: string;
623624
mandatory?: boolean;
624625
default_value?: number;
625-
validation?: object;
626-
datasource?: object;
626+
validation?: object; //there are 4 types, we need to discuss documentation team about it before implementing.
627+
datasource?: DatasourceEntry;
627628

628629
[futureKey: string]: any;
629630
}
@@ -634,8 +635,8 @@ declare module 'cloudinary' {
634635
label: string;
635636
mandatory: boolean;
636637
default_value: number;
637-
validation: object;
638-
datasource: object;
638+
validation: object; //there are 4 types, we need to discuss documentation team about it before implementing.
639+
datasource: DatasourceEntry;
639640

640641
[futureKey: string]: any;
641642
}
@@ -645,7 +646,7 @@ declare module 'cloudinary' {
645646
}
646647

647648
export interface DatasourceChange {
648-
values: Array<object>
649+
values: Array<DatasourceEntry>
649650
}
650651

651652
export interface ResourceApiResponse {
@@ -666,19 +667,19 @@ declare module 'cloudinary' {
666667
url: string;
667668
secure_url: string;
668669
tags: Array<string>;
669-
context: object;
670+
context: object; //won't change since it's response, we need to discuss documentation team about it before implementing.
670671
next_cursor: string;
671672
derived_next_cursor: string;
672-
exif: object;
673-
image_metadata: object;
673+
exif: object; //won't change since it's response, we need to discuss documentation team about it before implementing.
674+
image_metadata: object; //won't change since it's response, we need to discuss documentation team about it before implementing.
674675
faces: number[][];
675676
quality_analysis: number;
676677
colors: [string, number][];
677678
derived: Array<string>;
678-
moderation: object;
679+
moderation: object; //won't change since it's response, we need to discuss documentation team about it before implementing.
679680
phash: string;
680-
predominant: object;
681-
coordinates: object;
681+
predominant: object; //won't change since it's response, we need to discuss documentation team about it before implementing.
682+
coordinates: object; //won't change since it's response, we need to discuss documentation team about it before implementing.
682683
access_control: Array<string>;
683684
pages: number;
684685

@@ -687,6 +688,12 @@ declare module 'cloudinary' {
687688
]
688689
}
689690

691+
export type SignApiOptions = Record<string, any>;
692+
693+
export interface DatasourceEntry {
694+
external_id?: string;
695+
value: string;
696+
}
690697

691698
export namespace v2 {
692699

@@ -716,9 +723,9 @@ declare module 'cloudinary' {
716723

717724
namespace utils {
718725

719-
function sign_request(params_to_sign: object, options?: ConfigAndUrlOptions): { signature: string; api_key: string; [key:string]:any};
726+
function sign_request(params_to_sign: SignApiOptions, options?: ConfigAndUrlOptions): { signature: string; api_key: string; [key:string]:any};
720727

721-
function api_sign_request(params_to_sign: object, api_secret: string): string;
728+
function api_sign_request(params_to_sign: SignApiOptions, api_secret: string): string;
722729

723730
function verifyNotificationSignature(body: string, timestamp: number, signature: string, valid_for?: number): boolean;
724731

@@ -957,9 +964,9 @@ declare module 'cloudinary' {
957964

958965
function update_metadata_field(external_id: string, field: MetadataFieldApiOptions, callback?: ResponseCallback): Promise<MetadataFieldApiResponse>;
959966

960-
function update_metadata_field_datasource(field_external_id: string, entries_external_id: object, options?: AdminApiOptions, callback?: ResponseCallback): Promise<DatasourceChange>;
967+
function update_metadata_field_datasource(field_external_id: string, entries_external_id: DatasourceChange, options?: AdminApiOptions, callback?: ResponseCallback): Promise<DatasourceChange>;
961968

962-
function update_metadata_field_datasource(field_external_id: string, entries_external_id: object, callback?: ResponseCallback): Promise<DatasourceChange>;
969+
function update_metadata_field_datasource(field_external_id: string, entries_external_id: DatasourceChange, callback?: ResponseCallback): Promise<DatasourceChange>;
963970

964971
function delete_datasource_entries(field_external_id: string, entries_external_id: string[], options?: AdminApiOptions, callback?: ResponseCallback): Promise<DatasourceChange>;
965972

@@ -1067,9 +1074,9 @@ declare module 'cloudinary' {
10671074

10681075
/****************************** Structured Metadata API V2 Methods *************************************/
10691076

1070-
function update_metadata(metadata: string | object, public_ids: string[], options?:UploadApiOptions, callback?: ResponseCallback): Promise<MetadataFieldApiResponse>;
1077+
function update_metadata(metadata: string | Record<any, any>, public_ids: string[], options?:UploadApiOptions, callback?: ResponseCallback): Promise<MetadataFieldApiResponse>;
10711078

1072-
function update_metadata(metadata: string| object, public_ids: string[], callback?: ResponseCallback): Promise<MetadataFieldApiResponse>;
1079+
function update_metadata(metadata: string| Record<any, any>, public_ids: string[], callback?: ResponseCallback): Promise<MetadataFieldApiResponse>;
10731080
}
10741081

10751082
/****************************** Search API *************************************/
@@ -1115,11 +1122,11 @@ declare module 'cloudinary' {
11151122

11161123
function sub_account(subAccountId: string, options?: ProvisioningApiOptions, callback?: ResponseCallback): Promise<any>;
11171124

1118-
function create_sub_account(name: string, cloudName: string, customAttributes?: object, enabled?: boolean, baseAccount?: string, options?: ProvisioningApiOptions, callback?: ResponseCallback): Promise<any>;
1125+
function create_sub_account(name: string, cloudName: string, customAttributes?: Record<any,any>, enabled?: boolean, baseAccount?: string, options?: ProvisioningApiOptions, callback?: ResponseCallback): Promise<any>;
11191126

11201127
function delete_sub_account(subAccountId: string, options?: ProvisioningApiOptions, callback?: ResponseCallback): Promise<any>;
11211128

1122-
function update_sub_account(subAccountId: string, name?: string, cloudName?: string, customAttributes?: object, enabled?: boolean, options?: ProvisioningApiOptions, callback?: ResponseCallback): Promise<any>;
1129+
function update_sub_account(subAccountId: string, name?: string, cloudName?: string, customAttributes?: Record<any,any>, enabled?: boolean, options?: ProvisioningApiOptions, callback?: ResponseCallback): Promise<any>;
11231130

11241131
function user(userId: string, options?: ProvisioningApiOptions, callback?: ResponseCallback): Promise<any>;
11251132

0 commit comments

Comments
 (0)