@convertrilo/sdk 0.0.5 → 0.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +13 -0
- package/dist/src/index.d.ts +14 -0
- package/dist/src/index.js +9 -0
- package/dist/src/types.d.ts +73 -0
- package/docs/WEBHOOKS.md +33 -1
- package/openapi.yaml +50 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -167,6 +167,19 @@ for (const job of batch.jobs || []) {
|
|
|
167
167
|
|
|
168
168
|
Poll each returned `jobId` with `client.onDemandStatus(jobId)`.
|
|
169
169
|
|
|
170
|
+
## Webhook Delivery History
|
|
171
|
+
|
|
172
|
+
Managed webhooks are HMAC signed. You can test a webhook and inspect recent delivery attempts:
|
|
173
|
+
|
|
174
|
+
```ts
|
|
175
|
+
await client.testWebhook(webhookId);
|
|
176
|
+
|
|
177
|
+
const history = await client.getWebhookDeliveries(webhookId);
|
|
178
|
+
for (const delivery of history.deliveries || []) {
|
|
179
|
+
console.log(delivery.status, delivery.statusCode, delivery.event);
|
|
180
|
+
}
|
|
181
|
+
```
|
|
182
|
+
|
|
170
183
|
## Regenerate Types
|
|
171
184
|
|
|
172
185
|
The SDK types are generated from `openapi.yaml`.
|
package/dist/src/index.d.ts
CHANGED
|
@@ -115,8 +115,22 @@ export declare class ConvertriloClient {
|
|
|
115
115
|
lastFailedAt?: string | null;
|
|
116
116
|
createdAt?: string;
|
|
117
117
|
}>;
|
|
118
|
+
updateWebhook(id: string, body: paths["/webhooks/{id}"]["patch"]["requestBody"]["content"]["application/json"]): Promise<{
|
|
119
|
+
id?: string;
|
|
120
|
+
url?: string;
|
|
121
|
+
events?: string[];
|
|
122
|
+
secret?: string;
|
|
123
|
+
isActive?: boolean;
|
|
124
|
+
failureCount?: number;
|
|
125
|
+
lastTriggeredAt?: string | null;
|
|
126
|
+
lastFailedAt?: string | null;
|
|
127
|
+
createdAt?: string;
|
|
128
|
+
}>;
|
|
118
129
|
deleteWebhook(id: string): Promise<unknown>;
|
|
119
130
|
testWebhook(id: string): Promise<unknown>;
|
|
131
|
+
getWebhookDeliveries(id: string): Promise<{
|
|
132
|
+
deliveries?: import("./types").components["schemas"]["WebhookDeliveryResponse"][];
|
|
133
|
+
}>;
|
|
120
134
|
initStream(id: string): Promise<{
|
|
121
135
|
ok?: boolean;
|
|
122
136
|
uploadId?: string;
|
package/dist/src/index.js
CHANGED
|
@@ -134,12 +134,21 @@ export class ConvertriloClient {
|
|
|
134
134
|
body: JSON.stringify(body),
|
|
135
135
|
});
|
|
136
136
|
}
|
|
137
|
+
async updateWebhook(id, body) {
|
|
138
|
+
return this.request(`/webhooks/${id}`, {
|
|
139
|
+
method: "PATCH",
|
|
140
|
+
body: JSON.stringify(body),
|
|
141
|
+
});
|
|
142
|
+
}
|
|
137
143
|
async deleteWebhook(id) {
|
|
138
144
|
return this.request(`/webhooks/${id}`, { method: "DELETE" });
|
|
139
145
|
}
|
|
140
146
|
async testWebhook(id) {
|
|
141
147
|
return this.request(`/webhooks/${id}/test`, { method: "POST" });
|
|
142
148
|
}
|
|
149
|
+
async getWebhookDeliveries(id) {
|
|
150
|
+
return this.request(`/webhooks/${id}/deliveries`);
|
|
151
|
+
}
|
|
143
152
|
// Streaming
|
|
144
153
|
async initStream(id) {
|
|
145
154
|
return this.request(`/jobs/${id}/stream/init`, { method: "POST" });
|
package/dist/src/types.d.ts
CHANGED
|
@@ -707,6 +707,56 @@ export interface paths {
|
|
|
707
707
|
};
|
|
708
708
|
trace?: never;
|
|
709
709
|
};
|
|
710
|
+
"/webhooks/{id}/deliveries": {
|
|
711
|
+
parameters: {
|
|
712
|
+
query?: never;
|
|
713
|
+
header?: never;
|
|
714
|
+
path?: never;
|
|
715
|
+
cookie?: never;
|
|
716
|
+
};
|
|
717
|
+
/**
|
|
718
|
+
* List webhook delivery attempts
|
|
719
|
+
* @description Returns the 50 most recent managed or test delivery attempts for this webhook.
|
|
720
|
+
*/
|
|
721
|
+
get: {
|
|
722
|
+
parameters: {
|
|
723
|
+
query?: never;
|
|
724
|
+
header?: never;
|
|
725
|
+
path: {
|
|
726
|
+
id: string;
|
|
727
|
+
};
|
|
728
|
+
cookie?: never;
|
|
729
|
+
};
|
|
730
|
+
requestBody?: never;
|
|
731
|
+
responses: {
|
|
732
|
+
/** @description Recent delivery attempts */
|
|
733
|
+
200: {
|
|
734
|
+
headers: {
|
|
735
|
+
[name: string]: unknown;
|
|
736
|
+
};
|
|
737
|
+
content: {
|
|
738
|
+
"application/json": components["schemas"]["WebhookDeliveryListResponse"];
|
|
739
|
+
};
|
|
740
|
+
};
|
|
741
|
+
/** @description Webhook not found */
|
|
742
|
+
404: {
|
|
743
|
+
headers: {
|
|
744
|
+
[name: string]: unknown;
|
|
745
|
+
};
|
|
746
|
+
content: {
|
|
747
|
+
"application/json": components["schemas"]["ErrorResponse"];
|
|
748
|
+
};
|
|
749
|
+
};
|
|
750
|
+
};
|
|
751
|
+
};
|
|
752
|
+
put?: never;
|
|
753
|
+
post?: never;
|
|
754
|
+
delete?: never;
|
|
755
|
+
options?: never;
|
|
756
|
+
head?: never;
|
|
757
|
+
patch?: never;
|
|
758
|
+
trace?: never;
|
|
759
|
+
};
|
|
710
760
|
"/jobs/bulk": {
|
|
711
761
|
parameters: {
|
|
712
762
|
query?: never;
|
|
@@ -1655,6 +1705,29 @@ export interface components {
|
|
|
1655
1705
|
WebhookListResponse: {
|
|
1656
1706
|
webhooks?: components["schemas"]["WebhookResponse"][];
|
|
1657
1707
|
};
|
|
1708
|
+
WebhookDeliveryResponse: {
|
|
1709
|
+
/** Format: uuid */
|
|
1710
|
+
id?: string;
|
|
1711
|
+
/** Format: uuid */
|
|
1712
|
+
webhookId?: string;
|
|
1713
|
+
event?: string;
|
|
1714
|
+
/** Format: uuid */
|
|
1715
|
+
jobId?: string | null;
|
|
1716
|
+
/** @enum {string} */
|
|
1717
|
+
status?: "success" | "failed";
|
|
1718
|
+
statusCode?: number | null;
|
|
1719
|
+
durationMs?: number | null;
|
|
1720
|
+
/** @description Response body captured from the receiver, truncated to 2048 characters. */
|
|
1721
|
+
responseBody?: string | null;
|
|
1722
|
+
/** @description Network, timeout, or delivery error, truncated to 2048 characters. */
|
|
1723
|
+
error?: string | null;
|
|
1724
|
+
attempt?: number;
|
|
1725
|
+
/** Format: date-time */
|
|
1726
|
+
createdAt?: string;
|
|
1727
|
+
};
|
|
1728
|
+
WebhookDeliveryListResponse: {
|
|
1729
|
+
deliveries?: components["schemas"]["WebhookDeliveryResponse"][];
|
|
1730
|
+
};
|
|
1658
1731
|
S3Output: {
|
|
1659
1732
|
bucket: string;
|
|
1660
1733
|
key: string;
|
package/docs/WEBHOOKS.md
CHANGED
|
@@ -127,7 +127,39 @@ export async function POST(req: NextRequest) {
|
|
|
127
127
|
- A webhook is automatically disabled after 10 consecutive failures
|
|
128
128
|
- Re-enable it with `PATCH /webhooks/{id}` and `{ "isActive": true }`
|
|
129
129
|
|
|
130
|
-
Current deliveries are best-effort. There is not yet a durable retry queue
|
|
130
|
+
Current deliveries are best-effort. There is not yet a durable retry queue.
|
|
131
|
+
|
|
132
|
+
## Delivery History
|
|
133
|
+
|
|
134
|
+
Recent managed and test delivery attempts are available with:
|
|
135
|
+
|
|
136
|
+
```txt
|
|
137
|
+
GET /webhooks/{id}/deliveries
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
The response includes the 50 most recent attempts for that webhook:
|
|
141
|
+
|
|
142
|
+
```json
|
|
143
|
+
{
|
|
144
|
+
"deliveries": [
|
|
145
|
+
{
|
|
146
|
+
"id": "550e8400-e29b-41d4-a716-446655440000",
|
|
147
|
+
"webhookId": "4a5c26a0-7b04-4d37-8bb1-446655440000",
|
|
148
|
+
"event": "job.completed",
|
|
149
|
+
"jobId": "9db109f6-6a88-49d7-89e2-446655440000",
|
|
150
|
+
"status": "success",
|
|
151
|
+
"statusCode": 204,
|
|
152
|
+
"durationMs": 182,
|
|
153
|
+
"responseBody": null,
|
|
154
|
+
"error": null,
|
|
155
|
+
"attempt": 1,
|
|
156
|
+
"createdAt": "2026-06-09T07:30:00.000Z"
|
|
157
|
+
}
|
|
158
|
+
]
|
|
159
|
+
}
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
`responseBody` and `error` are capped at 2048 characters.
|
|
131
163
|
|
|
132
164
|
## One-Off On-Demand Webhook URL
|
|
133
165
|
|
package/openapi.yaml
CHANGED
|
@@ -345,6 +345,33 @@ components:
|
|
|
345
345
|
type: array
|
|
346
346
|
items:
|
|
347
347
|
$ref: "#/components/schemas/WebhookResponse"
|
|
348
|
+
WebhookDeliveryResponse:
|
|
349
|
+
type: object
|
|
350
|
+
properties:
|
|
351
|
+
id: { type: string, format: uuid }
|
|
352
|
+
webhookId: { type: string, format: uuid }
|
|
353
|
+
event: { type: string }
|
|
354
|
+
jobId: { type: string, format: uuid, nullable: true }
|
|
355
|
+
status: { type: string, enum: [success, failed] }
|
|
356
|
+
statusCode: { type: integer, nullable: true }
|
|
357
|
+
durationMs: { type: integer, nullable: true }
|
|
358
|
+
responseBody:
|
|
359
|
+
type: string
|
|
360
|
+
nullable: true
|
|
361
|
+
description: Response body captured from the receiver, truncated to 2048 characters.
|
|
362
|
+
error:
|
|
363
|
+
type: string
|
|
364
|
+
nullable: true
|
|
365
|
+
description: Network, timeout, or delivery error, truncated to 2048 characters.
|
|
366
|
+
attempt: { type: integer }
|
|
367
|
+
createdAt: { type: string, format: date-time }
|
|
368
|
+
WebhookDeliveryListResponse:
|
|
369
|
+
type: object
|
|
370
|
+
properties:
|
|
371
|
+
deliveries:
|
|
372
|
+
type: array
|
|
373
|
+
items:
|
|
374
|
+
$ref: "#/components/schemas/WebhookDeliveryResponse"
|
|
348
375
|
|
|
349
376
|
# On-Demand Encoding
|
|
350
377
|
S3Output:
|
|
@@ -897,6 +924,29 @@ paths:
|
|
|
897
924
|
schema: { type: string, format: uuid }
|
|
898
925
|
responses:
|
|
899
926
|
"200": { description: Test event sent }
|
|
927
|
+
/webhooks/{id}/deliveries:
|
|
928
|
+
get:
|
|
929
|
+
security: [{ BearerAuth: [] }]
|
|
930
|
+
summary: List webhook delivery attempts
|
|
931
|
+
description: Returns the 50 most recent managed or test delivery attempts for this webhook.
|
|
932
|
+
parameters:
|
|
933
|
+
- in: path
|
|
934
|
+
name: id
|
|
935
|
+
required: true
|
|
936
|
+
schema: { type: string, format: uuid }
|
|
937
|
+
responses:
|
|
938
|
+
"200":
|
|
939
|
+
description: Recent delivery attempts
|
|
940
|
+
content:
|
|
941
|
+
application/json:
|
|
942
|
+
schema:
|
|
943
|
+
$ref: "#/components/schemas/WebhookDeliveryListResponse"
|
|
944
|
+
"404":
|
|
945
|
+
description: Webhook not found
|
|
946
|
+
content:
|
|
947
|
+
application/json:
|
|
948
|
+
schema:
|
|
949
|
+
$ref: "#/components/schemas/ErrorResponse"
|
|
900
950
|
|
|
901
951
|
/jobs/bulk:
|
|
902
952
|
post:
|