Skip to content

Commit 174eee8

Browse files
feat(api): manual updates
1 parent dac30e1 commit 174eee8

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,
@@ -895,6 +896,7 @@ export declare namespace ImageKit {
895896

896897
export {
897898
Webhooks as Webhooks,
899+
type BaseWebhookEvent as BaseWebhookEvent,
898900
type UploadPostTransformErrorEvent as UploadPostTransformErrorEvent,
899901
type UploadPostTransformSuccessEvent as UploadPostTransformSuccessEvent,
900902
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
@@ -24,12 +24,23 @@ export class Webhooks extends APIResource {
2424
}
2525
}
2626

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

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

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

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

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

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

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

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

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

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

964986
export declare namespace Webhooks {
965987
export {
988+
type BaseWebhookEvent as BaseWebhookEvent,
966989
type UploadPostTransformErrorEvent as UploadPostTransformErrorEvent,
967990
type UploadPostTransformSuccessEvent as UploadPostTransformSuccessEvent,
968991
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)