Skip to content

Commit 4e25598

Browse files
feat(api): manual updates
1 parent 8bf53d4 commit 4e25598

File tree

6 files changed

+66
-39
lines changed

6 files changed

+66
-39
lines changed

.stats.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
configured_endpoints: 42
22
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-667f7f4988b44bc587d6eb9960ff5c8326e9f7e9b072f3f724f9f54166eff8b1.yml
33
openapi_spec_hash: f2081864a4abee0480e5ff991b4c936a
4-
config_hash: 4e73c7e12a531edcd1366dab7eccc360
4+
config_hash: 08e12746cdca1c59c897cf2e50893c3c

api.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,7 @@ Methods:
208208

209209
Types:
210210

211+
- <code><a href="./src/resources/webhooks.ts">BaseWebhookEvent</a></code>
211212
- <code><a href="./src/resources/webhooks.ts">UploadPostTransformErrorEvent</a></code>
212213
- <code><a href="./src/resources/webhooks.ts">UploadPostTransformSuccessEvent</a></code>
213214
- <code><a href="./src/resources/webhooks.ts">UploadPreTransformErrorEvent</a></code>

src/client.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import {
2727
CustomMetadataFields,
2828
} from './resources/custom-metadata-fields';
2929
import {
30+
BaseWebhookEvent,
3031
UnsafeUnwrapWebhookEvent,
3132
UnwrapWebhookEvent,
3233
UploadPostTransformErrorEvent,
@@ -894,6 +895,7 @@ export declare namespace ImageKit {
894895

895896
export {
896897
Webhooks as Webhooks,
898+
type BaseWebhookEvent as BaseWebhookEvent,
897899
type UploadPostTransformErrorEvent as UploadPostTransformErrorEvent,
898900
type UploadPostTransformSuccessEvent as UploadPostTransformSuccessEvent,
899901
type UploadPreTransformErrorEvent as UploadPreTransformErrorEvent,

src/resources/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ export {
4545
} from './folders/folders';
4646
export {
4747
Webhooks,
48+
type BaseWebhookEvent,
4849
type UploadPostTransformErrorEvent,
4950
type UploadPostTransformSuccessEvent,
5051
type UploadPreTransformErrorEvent,

src/resources/webhooks.ts

Lines changed: 60 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,23 @@ export class Webhooks extends APIResource {
2323
}
2424
}
2525

26-
export interface UploadPostTransformErrorEvent {
26+
export interface BaseWebhookEvent {
2727
/**
2828
* Unique identifier for the event.
2929
*/
3030
id: string;
3131

32+
/**
33+
* The type of webhook event.
34+
*/
35+
type: string;
36+
}
37+
38+
/**
39+
* Triggered when a post-transformation fails. The original file remains available,
40+
* but the requested transformation could not be generated.
41+
*/
42+
export interface UploadPostTransformErrorEvent extends BaseWebhookEvent {
3243
/**
3344
* Timestamp of when the event occurred in ISO8601 format.
3445
*/
@@ -110,12 +121,12 @@ export namespace UploadPostTransformErrorEvent {
110121
}
111122
}
112123

113-
export interface UploadPostTransformSuccessEvent {
114-
/**
115-
* Unique identifier for the event.
116-
*/
117-
id: string;
118-
124+
/**
125+
* Triggered when a post-transformation completes successfully. The transformed
126+
* version of the file is now ready and can be accessed via the provided URL. Note
127+
* that each post-transformation generates a separate webhook event.
128+
*/
129+
export interface UploadPostTransformSuccessEvent extends BaseWebhookEvent {
119130
/**
120131
* Timestamp of when the event occurred in ISO8601 format.
121132
*/
@@ -175,12 +186,11 @@ export namespace UploadPostTransformSuccessEvent {
175186
}
176187
}
177188

178-
export interface UploadPreTransformErrorEvent {
179-
/**
180-
* Unique identifier for the event.
181-
*/
182-
id: string;
183-
189+
/**
190+
* Triggered when a pre-transformation fails. The file upload may have been
191+
* accepted, but the requested transformation could not be applied.
192+
*/
193+
export interface UploadPreTransformErrorEvent extends BaseWebhookEvent {
184194
/**
185195
* Timestamp of when the event occurred in ISO8601 format.
186196
*/
@@ -236,12 +246,12 @@ export namespace UploadPreTransformErrorEvent {
236246
}
237247
}
238248

239-
export interface UploadPreTransformSuccessEvent {
240-
/**
241-
* Unique identifier for the event.
242-
*/
243-
id: string;
244-
249+
/**
250+
* Triggered when a pre-transformation completes successfully. The file has been
251+
* processed with the requested transformation and is now available in the Media
252+
* Library.
253+
*/
254+
export interface UploadPreTransformSuccessEvent extends BaseWebhookEvent {
245255
/**
246256
* Timestamp of when the event occurred in ISO8601 format.
247257
*/
@@ -480,12 +490,12 @@ export namespace UploadPreTransformSuccessEvent {
480490
}
481491
}
482492

483-
export interface VideoTransformationAcceptedEvent {
484-
/**
485-
* Unique identifier for the event.
486-
*/
487-
id: string;
488-
493+
/**
494+
* Triggered when a new video transformation request is accepted for processing.
495+
* This event confirms that ImageKit has received and queued your transformation
496+
* request. Use this for debugging and tracking transformation lifecycle.
497+
*/
498+
export interface VideoTransformationAcceptedEvent extends BaseWebhookEvent {
489499
/**
490500
* Timestamp when the event was created in ISO8601 format.
491501
*/
@@ -609,12 +619,13 @@ export namespace VideoTransformationAcceptedEvent {
609619
}
610620
}
611621

612-
export interface VideoTransformationErrorEvent {
613-
/**
614-
* Unique identifier for the event.
615-
*/
616-
id: string;
617-
622+
/**
623+
* Triggered when an error occurs during video encoding. Listen to this webhook to
624+
* log error reasons and debug issues. Check your origin and URL endpoint settings
625+
* if the reason is related to download failure. For other errors, contact ImageKit
626+
* support.
627+
*/
628+
export interface VideoTransformationErrorEvent extends BaseWebhookEvent {
618629
/**
619630
* Timestamp when the event was created in ISO8601 format.
620631
*/
@@ -751,12 +762,13 @@ export namespace VideoTransformationErrorEvent {
751762
}
752763
}
753764

754-
export interface VideoTransformationReadyEvent {
755-
/**
756-
* Unique identifier for the event.
757-
*/
758-
id: string;
759-
765+
/**
766+
* Triggered when video encoding is finished and the transformed resource is ready
767+
* to be served. This is the key event to listen for - update your database or CMS
768+
* flags when you receive this so your application can start showing the
769+
* transformed video to users.
770+
*/
771+
export interface VideoTransformationReadyEvent extends BaseWebhookEvent {
760772
/**
761773
* Timestamp when the event was created in ISO8601 format.
762774
*/
@@ -942,6 +954,11 @@ export namespace VideoTransformationReadyEvent {
942954
}
943955
}
944956

957+
/**
958+
* Triggered when a new video transformation request is accepted for processing.
959+
* This event confirms that ImageKit has received and queued your transformation
960+
* request. Use this for debugging and tracking transformation lifecycle.
961+
*/
945962
export type UnsafeUnwrapWebhookEvent =
946963
| VideoTransformationAcceptedEvent
947964
| VideoTransformationReadyEvent
@@ -951,6 +968,11 @@ export type UnsafeUnwrapWebhookEvent =
951968
| UploadPostTransformSuccessEvent
952969
| UploadPostTransformErrorEvent;
953970

971+
/**
972+
* Triggered when a new video transformation request is accepted for processing.
973+
* This event confirms that ImageKit has received and queued your transformation
974+
* request. Use this for debugging and tracking transformation lifecycle.
975+
*/
954976
export type UnwrapWebhookEvent =
955977
| VideoTransformationAcceptedEvent
956978
| VideoTransformationReadyEvent
@@ -962,6 +984,7 @@ export type UnwrapWebhookEvent =
962984

963985
export declare namespace Webhooks {
964986
export {
987+
type BaseWebhookEvent as BaseWebhookEvent,
965988
type UploadPostTransformErrorEvent as UploadPostTransformErrorEvent,
966989
type UploadPostTransformSuccessEvent as UploadPostTransformSuccessEvent,
967990
type UploadPreTransformErrorEvent as UploadPreTransformErrorEvent,

tests/api-resources/webhooks.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ describe('resource webhooks', () => {
1414
test.skip('unwrap', async () => {
1515
const key = 'whsec_c2VjcmV0Cg==';
1616
const payload =
17-
'{"id":"id","created_at":"2019-12-27T18:11:19.117Z","data":{"asset":{"url":"https://example.com"},"transformation":{"type":"video-transformation","options":{"audio_codec":"aac","auto_rotate":true,"format":"mp4","quality":0,"stream_protocol":"HLS","variants":["string"],"video_codec":"h264"}}},"request":{"url":"https://example.com","x_request_id":"x_request_id","user_agent":"user_agent"},"type":"video.transformation.accepted"}';
17+
'{"id":"id","type":"video.transformation.accepted","created_at":"2019-12-27T18:11:19.117Z","data":{"asset":{"url":"https://example.com"},"transformation":{"type":"video-transformation","options":{"audio_codec":"aac","auto_rotate":true,"format":"mp4","quality":0,"stream_protocol":"HLS","variants":["string"],"video_codec":"h264"}}},"request":{"url":"https://example.com","x_request_id":"x_request_id","user_agent":"user_agent"}}';
1818
const msgID = '1';
1919
const timestamp = new Date();
2020
const wh = new Webhook(key);

0 commit comments

Comments
 (0)