Skip to content

Commit 54035b3

Browse files
ANKUR DWIVEDIANKUR DWIVEDI
authored andcommitted
added webook events for pre and post transformation
1 parent d0c605b commit 54035b3

File tree

2 files changed

+80
-0
lines changed

2 files changed

+80
-0
lines changed

libs/interfaces/index.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@ import {
2222
WebhookEventVideoTransformationAccepted,
2323
WebhookEventVideoTransformationReady,
2424
WebhookEventVideoTransformationError,
25+
WebhookEventUploadPreTransformationSuccess,
26+
WebhookEventUploadPreTransformationError,
27+
WebhookEventUploadPostTransformationSuccess,
28+
WebhookEventUploadPostTransformationError
2529
} from "./webhookEvent";
2630

2731
type FinalUrlOptions = ImageKitOptions & UrlOptions; // actual options used to construct url
@@ -66,5 +70,9 @@ export type {
6670
WebhookEventVideoTransformationAccepted,
6771
WebhookEventVideoTransformationReady,
6872
WebhookEventVideoTransformationError,
73+
WebhookEventUploadPostTransformationSuccess,
74+
WebhookEventUploadPostTransformationError,
75+
WebhookEventUploadPreTransformationSuccess,
76+
WebhookEventUploadPreTransformationError
6977
};
7078
export type { IKCallback } from "./IKCallback";

libs/interfaces/webhookEvent.ts

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import { UploadResponse } from "./UploadResponse";
2+
13
type Asset = {
24
url: string;
35
};
@@ -74,8 +76,78 @@ export interface WebhookEventVideoTransformationError extends WebhookEventVideoT
7476
};
7577
}
7678

79+
type TransformationType = "transformation" | "abs" | "gif-to-video" | "thumbnail";
80+
81+
interface PreTransformationBase {
82+
id: string;
83+
created_at: string;
84+
request: {
85+
x_request_id: string;
86+
transformation: string;
87+
};
88+
}
89+
90+
interface PostTransformationBase {
91+
id: string;
92+
created_at: string;
93+
request: {
94+
x_request_id: string;
95+
transformation: {
96+
type: TransformationType;
97+
value?: string;
98+
protocol?: 'hls' | 'dash';
99+
};
100+
};
101+
}
102+
103+
export interface WebhookEventUploadPreTransformationSuccess extends PreTransformationBase {
104+
type: "upload.pre-transform.success";
105+
data: UploadResponse;
106+
}
107+
108+
export interface WebhookEventUploadPreTransformationError extends PostTransformationBase {
109+
type: "upload.pre-transform.error";
110+
data: {
111+
name: string;
112+
path: string;
113+
transformation: {
114+
error: {
115+
reason: string;
116+
};
117+
};
118+
};
119+
}
120+
121+
export interface WebhookEventUploadPostTransformationSuccess extends PostTransformationBase {
122+
type: "upload.post-transform.success";
123+
data: {
124+
fileId: string;
125+
url: string;
126+
name: string;
127+
};
128+
}
129+
130+
export interface WebhookEventUploadPostTransformationError extends PostTransformationBase {
131+
type: "upload.post-transform.error";
132+
data: {
133+
fileId: string;
134+
url: string;
135+
name: string;
136+
path: string;
137+
transformation: {
138+
error: {
139+
reason: string;
140+
};
141+
};
142+
};
143+
}
144+
77145
export type WebhookEvent =
78146
| WebhookEventVideoTransformationAccepted
79147
| WebhookEventVideoTransformationReady
80148
| WebhookEventVideoTransformationError
149+
| WebhookEventUploadPreTransformationSuccess
150+
| WebhookEventUploadPreTransformationError
151+
| WebhookEventUploadPostTransformationSuccess
152+
| WebhookEventUploadPostTransformationError
81153
| Object;

0 commit comments

Comments
 (0)