Skip to content

Commit 9548f34

Browse files
author
Maya Shavin
committed
fix: add more types for server api
1 parent a6aaf53 commit 9548f34

File tree

7 files changed

+217
-28
lines changed

7 files changed

+217
-28
lines changed
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import { ResourceType } from '../cloud/ResourceType'
2+
import { StorageType } from '../cloud/StorageType'
3+
4+
export interface Asset {
5+
publicId: string,
6+
assetId: string,
7+
format: string,
8+
secureUrl: string,
9+
type: StorageType,
10+
version: number,
11+
height: number,
12+
width: number,
13+
eager?: Object[],
14+
placeholder?: boolean,
15+
tags?: string[],
16+
originalFilename: string,
17+
overwritten?: boolean,
18+
resourceType: ResourceType;
19+
signature: string;
20+
createdAt: string;
21+
pages?: number;
22+
bytes: number;
23+
etag?: string;
24+
url: string;
25+
accessMode: AccessMode;
26+
moderation?: Array<string>;
27+
accessControl: AccessControlType;
28+
context?: Object;
29+
metadata?: Object;
30+
}
31+

packages/types/lib/cloud/CloudConfig.d.ts

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,21 @@ import { ResourceType } from "./ResourceType";
22
import { StorageType } from "./StorageType";
33

44
export interface CloudConfig {
5-
apiKey?: string,
6-
apiSecret?: string,
7-
cloudName?: string,
8-
cname?: string,
9-
privateCdn?: boolean,
10-
resourceType?: ResourceType,
11-
secure?: boolean,
12-
secureDistribution?: string,
13-
storageType?: StorageType,
14-
shorten?: string,
15-
urlSuffix?: string,
16-
useRootPath?: boolean,
17-
cdnSubdomain?: boolean,
18-
version?: string | number,
19-
signature?: string,
20-
forceVersion?: boolean
5+
apiKey?: string;
6+
apiSecret?: string;
7+
cloudName?: string;
8+
cname?: string;
9+
privateCdn?: boolean;
10+
resourceType?: ResourceType;
11+
secure?: boolean;
12+
secureDistribution?: string;
13+
storageType?: StorageType;
14+
shorten?: string;
15+
urlSuffix?: string;
16+
useRootPath?: boolean;
17+
cdnSubdomain?: boolean;
18+
version?: string | number;
19+
signature?: string;
20+
forceVersion?: boolean;
21+
authToken?: Object;
2122
}

packages/types/lib/index.d.ts

Lines changed: 25 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
export { CldOptions } from './options/CldOptions'
2-
export { TransformerOption, TransformerBaseOptions, TransformerVideoOption } from './options/TransformerOption'
3-
export { CloudConfig } from './cloud/CloudConfig'
4-
export { ResourceType } from './cloud/ResourceType'
5-
export { StorageType } from './cloud/StorageType'
6-
export {
1+
export type { CldOptions } from './options/CldOptions'
2+
export type { TransformerOption, TransformerBaseOptions, TransformerVideoOption } from './options/TransformerOption'
3+
export type { CloudConfig } from './cloud/CloudConfig'
4+
export type { ResourceType } from './cloud/ResourceType'
5+
export type { StorageType } from './cloud/StorageType'
6+
export type {
77
Effect,
88
VEffect,
99
Variable,
@@ -28,9 +28,26 @@ export {
2828
FPS,
2929
Transformation,
3030
FPSType,
31-
CompassGravity
31+
CompassGravity,
32+
TextStyle
3233
} from './transformation'
3334

34-
export {
35+
export type { Asset } from './asset/Asset'
36+
37+
export type {
38+
ResponseError,
39+
RenameOptions,
40+
ResourceOptions,
41+
ResponsiveBreakpointOption,
42+
UploadOptions,
43+
AccessControl,
44+
AccessControlType,
45+
AccessMode,
46+
AssetOptions,
47+
SingleDeleteOptions,
48+
ManupulationOptions
49+
} from './options/api'
50+
51+
export type {
3552
SocialCard, SocialImage, SocialText, TextArea
3653
} from './options/TextOptions'
Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
import { ResourceType } from "../cloud/ResourceType";
2+
import { StorageType } from "../cloud/StorageType";
3+
4+
export type ResponseError = {
5+
message: string;
6+
http_code: number
7+
}
8+
9+
export type ResourceOptions = {
10+
resourceType?: ResourceType;
11+
type?: StorageType;
12+
}
13+
14+
export type SingleDeleteOptions = ResourceOptions & {
15+
invalidate?: boolean;
16+
}
17+
18+
export type RenameOptions = ResourceOptions & {
19+
toType: StorageType;
20+
overwrite: boolean;
21+
}
22+
23+
export type AccessMode = 'public' | 'authenticated';
24+
25+
export type AccessControlType = 'token' | 'anonymous'
26+
27+
export type AccessControl = {
28+
type: AccessControlType;
29+
start?: string;
30+
end?: string;
31+
}
32+
33+
export type ResponsiveBreakpointOption = {
34+
createDerived: boolean;
35+
format?: string;
36+
transformation?: string;
37+
maxWidth?: number;
38+
minWidth?: number;
39+
bytesStep?: number;
40+
maxImages?: number
41+
}
42+
43+
export type AssetOptions = {
44+
tags?: string[]
45+
context?: string[]
46+
colors?: boolean
47+
faces?: boolean;
48+
qualityAnalysis?: boolean;
49+
accessibilityAnalysis?: boolean;
50+
cinemagraphAnalysis?: boolean;
51+
imageMetadata?: boolean;
52+
phash?: boolean
53+
responsiveBreakpoints?: ResponsiveBreakpointOption[]
54+
autoTagging?: number;
55+
categorization?: string;
56+
detection?: string;
57+
ocr?: string;
58+
exif?: boolean;
59+
}
60+
61+
export type ManupulationOptions = {
62+
eager?: string[];
63+
eageAsync?: boolean;
64+
eagerNotificationUrl?: string
65+
transformation?: string
66+
format?: string;
67+
customCoordinates?: string[]
68+
faceCoordinates?: string[]
69+
backgroundRemoval?: 'cloudinary_ai' | 'pixelz'
70+
rawConvert?: 'apose' | 'google_speech' | 'extract_text'
71+
}
72+
73+
export type UploadOptions = ResourceOptions & ManupulationOptions & AssetOptions & {
74+
publicId?: string;
75+
folder?: string;
76+
useFilename?: boolean;
77+
uniqueFilename?: boolean;
78+
accessControl?: AccessControl;
79+
accessMode?: AccessMode;
80+
discardOriginalFilename?: boolean;
81+
overwrite?: boolean;
82+
allowedFormats?: string[];
83+
async?: boolean;
84+
backup?: boolean;
85+
eval?: string;
86+
headers?: string;
87+
invalidate?: boolean;
88+
moderation?: string;
89+
notificationUrl?: string;
90+
proxy?: string;
91+
returnDeleteToken?: boolean;
92+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
export interface TextStyle {
2+
fontFamily?: string;
3+
fontSize?: number;
4+
fontColor?: string;
5+
fontWeight?: string;
6+
fontStyle?: string;
7+
background?: string;
8+
opacity?: number;
9+
textDecoration?: string
10+
}

packages/types/lib/transformation/index.d.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,5 @@ export { ColorSpace, VColorSpace } from './ColorSpace'
1313
export { AudioCodec } from './AudioCodec'
1414
export { FPS, FPSType } from './Fps'
1515
export type Transformation = Array<string | string[]>
16-
export { Offset } from './Offset'
16+
export { Offset } from './Offset'
17+
export { TextStyle } from './Overlay'

packages/utils/lib/constants/delivery.ts

Lines changed: 40 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,12 @@ export const STORAGE_TYPES = {
77
FACEBOOK: 'facebook',
88
TWITTER: 'twitter',
99
YOUTUBE: 'youtube',
10-
VIMEO: 'vimeo'
10+
VIMEO: 'vimeo',
11+
MULTI: 'multi',
12+
INSTAGRAM: 'instagram',
13+
HULU: 'hulu',
14+
ANIMOTO: 'animoto',
15+
DAILYMOTION: 'dailymotion'
1116
} as const
1217

1318
export const RESOURCE_TYPES = {
@@ -19,5 +24,37 @@ export const RESOURCE_TYPES = {
1924
export const VIDEO_SOURCE_TYPES = {
2025
WEBM: 'webm',
2126
MP4: 'mp4',
22-
OGV: 'ogv'
23-
} as const
27+
OGV: 'ogv',
28+
FLV: 'flv',
29+
M3U8: 'm3u8',
30+
TS: 'ts',
31+
MOV: 'mov',
32+
MKV: 'mkv',
33+
MPD: 'mpd'
34+
} as const
35+
36+
export const ImageFormats = {
37+
GIF: "gif",
38+
PNG: "png",
39+
JPG: "jpg",
40+
BMP: "bmp",
41+
ICO: "ico",
42+
PDF: "pdf",
43+
TIFF: "tiff",
44+
EPS: "eps",
45+
JPC: "jpc",
46+
JP2: "jp2",
47+
PSD: "psd",
48+
WEBP: "webp",
49+
ZIP: "zip",
50+
SVG: "svg",
51+
WDP: "wdp",
52+
HDX: "hpx",
53+
DJVU: "djvu",
54+
AI: "ai",
55+
FLIF: "flif",
56+
BPG: "bpg",
57+
MIFF: "miff",
58+
TGA: "tga",
59+
HEIC: "heic",
60+
}

0 commit comments

Comments
 (0)