@workbenchcrm/sdk 1.0.0 → 1.0.1
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/dist/index.d.mts +138 -15
- package/dist/index.d.ts +138 -15
- package/dist/index.js +64 -0
- package/dist/index.mjs +64 -0
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -28,6 +28,10 @@ interface ListOptions {
|
|
|
28
28
|
page?: number;
|
|
29
29
|
/** Items per page (1-100, defaults to 20) */
|
|
30
30
|
per_page?: number;
|
|
31
|
+
/** Limit (alternative to per_page for offset-based pagination) */
|
|
32
|
+
limit?: number;
|
|
33
|
+
/** Offset for offset-based pagination */
|
|
34
|
+
offset?: number;
|
|
31
35
|
/** Search query string */
|
|
32
36
|
search?: string;
|
|
33
37
|
/** Field to sort by */
|
|
@@ -46,17 +50,22 @@ interface ResponseMeta {
|
|
|
46
50
|
}
|
|
47
51
|
/**
|
|
48
52
|
* Pagination information for list responses
|
|
53
|
+
* Supports both page-based and offset-based pagination
|
|
49
54
|
*/
|
|
50
55
|
interface Pagination {
|
|
51
|
-
/** Current page number */
|
|
52
|
-
page
|
|
53
|
-
/** Items per page */
|
|
54
|
-
per_page
|
|
56
|
+
/** Current page number (page-based) */
|
|
57
|
+
page?: number;
|
|
58
|
+
/** Items per page (page-based) */
|
|
59
|
+
per_page?: number;
|
|
55
60
|
/** Total number of items */
|
|
56
61
|
total: number;
|
|
57
|
-
/** Total number of pages */
|
|
58
|
-
total_pages
|
|
59
|
-
/**
|
|
62
|
+
/** Total number of pages (page-based) */
|
|
63
|
+
total_pages?: number;
|
|
64
|
+
/** Limit used for the query (offset-based) */
|
|
65
|
+
limit?: number;
|
|
66
|
+
/** Offset used for the query (offset-based) */
|
|
67
|
+
offset?: number;
|
|
68
|
+
/** Whether there are more items available */
|
|
60
69
|
has_more: boolean;
|
|
61
70
|
}
|
|
62
71
|
/**
|
|
@@ -106,11 +115,13 @@ interface Client {
|
|
|
106
115
|
status: ClientStatus;
|
|
107
116
|
source: string | null;
|
|
108
117
|
notes: string | null;
|
|
118
|
+
/** Internal notes visible only to business users */
|
|
119
|
+
internal_notes: string | null;
|
|
109
120
|
tags: string[] | null;
|
|
110
121
|
next_contact_date: string | null;
|
|
111
122
|
ask_for_review: boolean | null;
|
|
112
123
|
created_at: string;
|
|
113
|
-
updated_at: string;
|
|
124
|
+
updated_at: string | null;
|
|
114
125
|
}
|
|
115
126
|
/**
|
|
116
127
|
* Options for creating a client
|
|
@@ -124,6 +135,7 @@ interface CreateClientOptions {
|
|
|
124
135
|
status?: ClientStatus;
|
|
125
136
|
source?: string | null;
|
|
126
137
|
notes?: string | null;
|
|
138
|
+
internal_notes?: string | null;
|
|
127
139
|
tags?: string[] | null;
|
|
128
140
|
}
|
|
129
141
|
/**
|
|
@@ -142,7 +154,7 @@ interface ListClientsOptions extends ListOptions {
|
|
|
142
154
|
/**
|
|
143
155
|
* Invoice status values
|
|
144
156
|
*/
|
|
145
|
-
type InvoiceStatus = 'draft' | 'sent' | 'viewed' | 'partial' | 'paid' | 'overdue' | 'cancelled';
|
|
157
|
+
type InvoiceStatus = 'draft' | 'sent' | 'viewed' | 'partial' | 'paid' | 'overdue' | 'cancelled' | 'voided';
|
|
146
158
|
/**
|
|
147
159
|
* Invoice line item
|
|
148
160
|
*/
|
|
@@ -173,10 +185,14 @@ interface Invoice {
|
|
|
173
185
|
amount_paid: number;
|
|
174
186
|
notes: string | null;
|
|
175
187
|
terms: string | null;
|
|
188
|
+
/** Timestamp when the invoice was sent to the client */
|
|
189
|
+
sent_at: string | null;
|
|
190
|
+
/** Timestamp when the invoice was fully paid */
|
|
191
|
+
paid_at: string | null;
|
|
176
192
|
items: InvoiceItem[];
|
|
177
193
|
client?: Client;
|
|
178
194
|
created_at: string;
|
|
179
|
-
updated_at: string;
|
|
195
|
+
updated_at: string | null;
|
|
180
196
|
}
|
|
181
197
|
/**
|
|
182
198
|
* Options for creating an invoice
|
|
@@ -239,10 +255,16 @@ interface Quote {
|
|
|
239
255
|
total: number;
|
|
240
256
|
notes: string | null;
|
|
241
257
|
terms: string | null;
|
|
258
|
+
/** Timestamp when the quote was sent to the client */
|
|
259
|
+
sent_at: string | null;
|
|
260
|
+
/** Timestamp when the quote was approved/accepted */
|
|
261
|
+
approved_at: string | null;
|
|
262
|
+
/** User ID or name of who approved the quote */
|
|
263
|
+
approved_by: string | null;
|
|
242
264
|
items: QuoteItem[];
|
|
243
265
|
client?: Client;
|
|
244
266
|
created_at: string;
|
|
245
|
-
updated_at: string;
|
|
267
|
+
updated_at: string | null;
|
|
246
268
|
}
|
|
247
269
|
/**
|
|
248
270
|
* Options for creating a quote
|
|
@@ -287,6 +309,8 @@ interface Job {
|
|
|
287
309
|
id: string;
|
|
288
310
|
business_id: string;
|
|
289
311
|
client_id: string | null;
|
|
312
|
+
/** Unique job number for display/reference */
|
|
313
|
+
job_number: string | null;
|
|
290
314
|
title: string;
|
|
291
315
|
description: string | null;
|
|
292
316
|
status: JobStatus;
|
|
@@ -300,7 +324,7 @@ interface Job {
|
|
|
300
324
|
notes: string | null;
|
|
301
325
|
client?: Client;
|
|
302
326
|
created_at: string;
|
|
303
|
-
updated_at: string;
|
|
327
|
+
updated_at: string | null;
|
|
304
328
|
}
|
|
305
329
|
/**
|
|
306
330
|
* Options for creating a job
|
|
@@ -361,7 +385,7 @@ interface ServiceRequest {
|
|
|
361
385
|
notes: string | null;
|
|
362
386
|
client?: Client;
|
|
363
387
|
created_at: string;
|
|
364
|
-
updated_at: string;
|
|
388
|
+
updated_at: string | null;
|
|
365
389
|
}
|
|
366
390
|
/**
|
|
367
391
|
* Options for creating a service request
|
|
@@ -396,7 +420,7 @@ interface ListServiceRequestsOptions extends ListOptions {
|
|
|
396
420
|
/**
|
|
397
421
|
* Available webhook event types
|
|
398
422
|
*/
|
|
399
|
-
type WebhookEvent = 'client.created' | 'client.updated' | 'client.deleted' | 'invoice.created' | 'invoice.sent' | 'invoice.paid' | 'invoice.overdue' | 'quote.created' | 'quote.sent' | 'quote.accepted' | 'quote.rejected' | 'job.created' | 'job.status_changed' | 'job.completed' | 'service_request.created' | 'service_request.assigned';
|
|
423
|
+
type WebhookEvent = 'client.created' | 'client.updated' | 'client.deleted' | 'invoice.created' | 'invoice.updated' | 'invoice.sent' | 'invoice.viewed' | 'invoice.paid' | 'invoice.overdue' | 'invoice.voided' | 'quote.created' | 'quote.updated' | 'quote.sent' | 'quote.viewed' | 'quote.accepted' | 'quote.rejected' | 'quote.expired' | 'job.created' | 'job.updated' | 'job.status_changed' | 'job.completed' | 'job.cancelled' | 'service_request.created' | 'service_request.updated' | 'service_request.assigned' | 'service_request.completed';
|
|
400
424
|
/**
|
|
401
425
|
* Webhook subscription
|
|
402
426
|
*/
|
|
@@ -408,8 +432,20 @@ interface Webhook {
|
|
|
408
432
|
events: WebhookEvent[];
|
|
409
433
|
secret: string;
|
|
410
434
|
is_active: boolean;
|
|
435
|
+
/** Custom metadata attached to the webhook */
|
|
436
|
+
metadata: Record<string, unknown> | null;
|
|
437
|
+
/** Number of consecutive delivery failures */
|
|
438
|
+
failure_count: number;
|
|
439
|
+
/** Timestamp of the last webhook trigger */
|
|
440
|
+
last_triggered_at: string | null;
|
|
441
|
+
/** Timestamp of the last successful delivery */
|
|
442
|
+
last_success_at: string | null;
|
|
443
|
+
/** Timestamp of the last failed delivery */
|
|
444
|
+
last_failure_at: string | null;
|
|
445
|
+
/** User ID who created the webhook */
|
|
446
|
+
created_by: string | null;
|
|
411
447
|
created_at: string;
|
|
412
|
-
updated_at: string;
|
|
448
|
+
updated_at: string | null;
|
|
413
449
|
}
|
|
414
450
|
/**
|
|
415
451
|
* Webhook delivery record
|
|
@@ -417,14 +453,26 @@ interface Webhook {
|
|
|
417
453
|
interface WebhookDelivery {
|
|
418
454
|
id: string;
|
|
419
455
|
webhook_id: string;
|
|
456
|
+
/** Unique event ID for idempotency */
|
|
457
|
+
event_id: string;
|
|
420
458
|
event_type: WebhookEvent;
|
|
421
459
|
payload: Record<string, unknown>;
|
|
460
|
+
/** Headers sent with the webhook request */
|
|
461
|
+
request_headers: Record<string, string> | null;
|
|
422
462
|
response_status: number | null;
|
|
463
|
+
/** Headers received in the response */
|
|
464
|
+
response_headers: Record<string, string> | null;
|
|
423
465
|
response_body: string | null;
|
|
466
|
+
/** Response time in milliseconds */
|
|
467
|
+
response_time_ms: number | null;
|
|
424
468
|
attempt_count: number;
|
|
469
|
+
/** Maximum number of delivery attempts */
|
|
470
|
+
max_attempts: number;
|
|
425
471
|
next_retry_at: string | null;
|
|
426
472
|
delivered_at: string | null;
|
|
427
473
|
failed_at: string | null;
|
|
474
|
+
/** Error message if delivery failed */
|
|
475
|
+
error_message: string | null;
|
|
428
476
|
created_at: string;
|
|
429
477
|
}
|
|
430
478
|
/**
|
|
@@ -434,6 +482,8 @@ interface CreateWebhookOptions {
|
|
|
434
482
|
name: string;
|
|
435
483
|
url: string;
|
|
436
484
|
events: WebhookEvent[];
|
|
485
|
+
/** Custom metadata to attach to the webhook */
|
|
486
|
+
metadata?: Record<string, unknown>;
|
|
437
487
|
}
|
|
438
488
|
/**
|
|
439
489
|
* Options for updating a webhook
|
|
@@ -443,12 +493,29 @@ interface UpdateWebhookOptions {
|
|
|
443
493
|
url?: string;
|
|
444
494
|
events?: WebhookEvent[];
|
|
445
495
|
is_active?: boolean;
|
|
496
|
+
metadata?: Record<string, unknown>;
|
|
446
497
|
}
|
|
447
498
|
/**
|
|
448
499
|
* Options for listing webhook deliveries
|
|
449
500
|
*/
|
|
450
501
|
interface ListWebhookDeliveriesOptions extends ListOptions {
|
|
451
502
|
event_type?: WebhookEvent;
|
|
503
|
+
/** Filter by delivery status */
|
|
504
|
+
status?: 'pending' | 'delivered' | 'failed';
|
|
505
|
+
}
|
|
506
|
+
/**
|
|
507
|
+
* Response from regenerating a webhook secret
|
|
508
|
+
*/
|
|
509
|
+
interface WebhookSecretResponse {
|
|
510
|
+
secret: string;
|
|
511
|
+
}
|
|
512
|
+
/**
|
|
513
|
+
* Webhook event type information
|
|
514
|
+
*/
|
|
515
|
+
interface WebhookEventTypeInfo {
|
|
516
|
+
event: WebhookEvent;
|
|
517
|
+
description: string;
|
|
518
|
+
category: 'client' | 'invoice' | 'quote' | 'job' | 'service_request';
|
|
452
519
|
}
|
|
453
520
|
|
|
454
521
|
/**
|
|
@@ -1259,6 +1326,62 @@ declare class WebhooksResource {
|
|
|
1259
1326
|
message: string;
|
|
1260
1327
|
delivery_id: string;
|
|
1261
1328
|
}>>;
|
|
1329
|
+
/**
|
|
1330
|
+
* Get a single webhook delivery
|
|
1331
|
+
*
|
|
1332
|
+
* Returns details about a specific delivery attempt, including
|
|
1333
|
+
* request/response headers and timing information.
|
|
1334
|
+
*
|
|
1335
|
+
* @param webhookId - Webhook UUID
|
|
1336
|
+
* @param deliveryId - Delivery UUID
|
|
1337
|
+
* @returns Delivery details
|
|
1338
|
+
*
|
|
1339
|
+
* @example
|
|
1340
|
+
* ```typescript
|
|
1341
|
+
* const { data: delivery } = await workbench.webhooks.getDelivery(
|
|
1342
|
+
* 'webhook-uuid',
|
|
1343
|
+
* 'delivery-uuid'
|
|
1344
|
+
* );
|
|
1345
|
+
* console.log(`Status: ${delivery.response_status}`);
|
|
1346
|
+
* console.log(`Response time: ${delivery.response_time_ms}ms`);
|
|
1347
|
+
* ```
|
|
1348
|
+
*/
|
|
1349
|
+
getDelivery(webhookId: string, deliveryId: string): Promise<ApiResponse<WebhookDelivery>>;
|
|
1350
|
+
/**
|
|
1351
|
+
* Regenerate webhook secret
|
|
1352
|
+
*
|
|
1353
|
+
* Generates a new secret for the webhook. The old secret will
|
|
1354
|
+
* immediately stop working. Make sure to update your webhook
|
|
1355
|
+
* handler with the new secret.
|
|
1356
|
+
*
|
|
1357
|
+
* @param id - Webhook UUID
|
|
1358
|
+
* @returns New webhook secret
|
|
1359
|
+
*
|
|
1360
|
+
* @example
|
|
1361
|
+
* ```typescript
|
|
1362
|
+
* const { data } = await workbench.webhooks.regenerateSecret('webhook-uuid');
|
|
1363
|
+
* console.log('New secret:', data.secret);
|
|
1364
|
+
* // Update your webhook handler with the new secret!
|
|
1365
|
+
* ```
|
|
1366
|
+
*/
|
|
1367
|
+
regenerateSecret(id: string): Promise<ApiResponse<WebhookSecretResponse>>;
|
|
1368
|
+
/**
|
|
1369
|
+
* List available webhook event types
|
|
1370
|
+
*
|
|
1371
|
+
* Returns all event types that can be subscribed to, with
|
|
1372
|
+
* descriptions and categories.
|
|
1373
|
+
*
|
|
1374
|
+
* @returns List of available event types
|
|
1375
|
+
*
|
|
1376
|
+
* @example
|
|
1377
|
+
* ```typescript
|
|
1378
|
+
* const { data: eventTypes } = await workbench.webhooks.listEventTypes();
|
|
1379
|
+
* eventTypes.forEach(et => {
|
|
1380
|
+
* console.log(`${et.event} (${et.category}): ${et.description}`);
|
|
1381
|
+
* });
|
|
1382
|
+
* ```
|
|
1383
|
+
*/
|
|
1384
|
+
listEventTypes(): Promise<ApiResponse<WebhookEventTypeInfo[]>>;
|
|
1262
1385
|
}
|
|
1263
1386
|
|
|
1264
1387
|
/**
|
package/dist/index.d.ts
CHANGED
|
@@ -28,6 +28,10 @@ interface ListOptions {
|
|
|
28
28
|
page?: number;
|
|
29
29
|
/** Items per page (1-100, defaults to 20) */
|
|
30
30
|
per_page?: number;
|
|
31
|
+
/** Limit (alternative to per_page for offset-based pagination) */
|
|
32
|
+
limit?: number;
|
|
33
|
+
/** Offset for offset-based pagination */
|
|
34
|
+
offset?: number;
|
|
31
35
|
/** Search query string */
|
|
32
36
|
search?: string;
|
|
33
37
|
/** Field to sort by */
|
|
@@ -46,17 +50,22 @@ interface ResponseMeta {
|
|
|
46
50
|
}
|
|
47
51
|
/**
|
|
48
52
|
* Pagination information for list responses
|
|
53
|
+
* Supports both page-based and offset-based pagination
|
|
49
54
|
*/
|
|
50
55
|
interface Pagination {
|
|
51
|
-
/** Current page number */
|
|
52
|
-
page
|
|
53
|
-
/** Items per page */
|
|
54
|
-
per_page
|
|
56
|
+
/** Current page number (page-based) */
|
|
57
|
+
page?: number;
|
|
58
|
+
/** Items per page (page-based) */
|
|
59
|
+
per_page?: number;
|
|
55
60
|
/** Total number of items */
|
|
56
61
|
total: number;
|
|
57
|
-
/** Total number of pages */
|
|
58
|
-
total_pages
|
|
59
|
-
/**
|
|
62
|
+
/** Total number of pages (page-based) */
|
|
63
|
+
total_pages?: number;
|
|
64
|
+
/** Limit used for the query (offset-based) */
|
|
65
|
+
limit?: number;
|
|
66
|
+
/** Offset used for the query (offset-based) */
|
|
67
|
+
offset?: number;
|
|
68
|
+
/** Whether there are more items available */
|
|
60
69
|
has_more: boolean;
|
|
61
70
|
}
|
|
62
71
|
/**
|
|
@@ -106,11 +115,13 @@ interface Client {
|
|
|
106
115
|
status: ClientStatus;
|
|
107
116
|
source: string | null;
|
|
108
117
|
notes: string | null;
|
|
118
|
+
/** Internal notes visible only to business users */
|
|
119
|
+
internal_notes: string | null;
|
|
109
120
|
tags: string[] | null;
|
|
110
121
|
next_contact_date: string | null;
|
|
111
122
|
ask_for_review: boolean | null;
|
|
112
123
|
created_at: string;
|
|
113
|
-
updated_at: string;
|
|
124
|
+
updated_at: string | null;
|
|
114
125
|
}
|
|
115
126
|
/**
|
|
116
127
|
* Options for creating a client
|
|
@@ -124,6 +135,7 @@ interface CreateClientOptions {
|
|
|
124
135
|
status?: ClientStatus;
|
|
125
136
|
source?: string | null;
|
|
126
137
|
notes?: string | null;
|
|
138
|
+
internal_notes?: string | null;
|
|
127
139
|
tags?: string[] | null;
|
|
128
140
|
}
|
|
129
141
|
/**
|
|
@@ -142,7 +154,7 @@ interface ListClientsOptions extends ListOptions {
|
|
|
142
154
|
/**
|
|
143
155
|
* Invoice status values
|
|
144
156
|
*/
|
|
145
|
-
type InvoiceStatus = 'draft' | 'sent' | 'viewed' | 'partial' | 'paid' | 'overdue' | 'cancelled';
|
|
157
|
+
type InvoiceStatus = 'draft' | 'sent' | 'viewed' | 'partial' | 'paid' | 'overdue' | 'cancelled' | 'voided';
|
|
146
158
|
/**
|
|
147
159
|
* Invoice line item
|
|
148
160
|
*/
|
|
@@ -173,10 +185,14 @@ interface Invoice {
|
|
|
173
185
|
amount_paid: number;
|
|
174
186
|
notes: string | null;
|
|
175
187
|
terms: string | null;
|
|
188
|
+
/** Timestamp when the invoice was sent to the client */
|
|
189
|
+
sent_at: string | null;
|
|
190
|
+
/** Timestamp when the invoice was fully paid */
|
|
191
|
+
paid_at: string | null;
|
|
176
192
|
items: InvoiceItem[];
|
|
177
193
|
client?: Client;
|
|
178
194
|
created_at: string;
|
|
179
|
-
updated_at: string;
|
|
195
|
+
updated_at: string | null;
|
|
180
196
|
}
|
|
181
197
|
/**
|
|
182
198
|
* Options for creating an invoice
|
|
@@ -239,10 +255,16 @@ interface Quote {
|
|
|
239
255
|
total: number;
|
|
240
256
|
notes: string | null;
|
|
241
257
|
terms: string | null;
|
|
258
|
+
/** Timestamp when the quote was sent to the client */
|
|
259
|
+
sent_at: string | null;
|
|
260
|
+
/** Timestamp when the quote was approved/accepted */
|
|
261
|
+
approved_at: string | null;
|
|
262
|
+
/** User ID or name of who approved the quote */
|
|
263
|
+
approved_by: string | null;
|
|
242
264
|
items: QuoteItem[];
|
|
243
265
|
client?: Client;
|
|
244
266
|
created_at: string;
|
|
245
|
-
updated_at: string;
|
|
267
|
+
updated_at: string | null;
|
|
246
268
|
}
|
|
247
269
|
/**
|
|
248
270
|
* Options for creating a quote
|
|
@@ -287,6 +309,8 @@ interface Job {
|
|
|
287
309
|
id: string;
|
|
288
310
|
business_id: string;
|
|
289
311
|
client_id: string | null;
|
|
312
|
+
/** Unique job number for display/reference */
|
|
313
|
+
job_number: string | null;
|
|
290
314
|
title: string;
|
|
291
315
|
description: string | null;
|
|
292
316
|
status: JobStatus;
|
|
@@ -300,7 +324,7 @@ interface Job {
|
|
|
300
324
|
notes: string | null;
|
|
301
325
|
client?: Client;
|
|
302
326
|
created_at: string;
|
|
303
|
-
updated_at: string;
|
|
327
|
+
updated_at: string | null;
|
|
304
328
|
}
|
|
305
329
|
/**
|
|
306
330
|
* Options for creating a job
|
|
@@ -361,7 +385,7 @@ interface ServiceRequest {
|
|
|
361
385
|
notes: string | null;
|
|
362
386
|
client?: Client;
|
|
363
387
|
created_at: string;
|
|
364
|
-
updated_at: string;
|
|
388
|
+
updated_at: string | null;
|
|
365
389
|
}
|
|
366
390
|
/**
|
|
367
391
|
* Options for creating a service request
|
|
@@ -396,7 +420,7 @@ interface ListServiceRequestsOptions extends ListOptions {
|
|
|
396
420
|
/**
|
|
397
421
|
* Available webhook event types
|
|
398
422
|
*/
|
|
399
|
-
type WebhookEvent = 'client.created' | 'client.updated' | 'client.deleted' | 'invoice.created' | 'invoice.sent' | 'invoice.paid' | 'invoice.overdue' | 'quote.created' | 'quote.sent' | 'quote.accepted' | 'quote.rejected' | 'job.created' | 'job.status_changed' | 'job.completed' | 'service_request.created' | 'service_request.assigned';
|
|
423
|
+
type WebhookEvent = 'client.created' | 'client.updated' | 'client.deleted' | 'invoice.created' | 'invoice.updated' | 'invoice.sent' | 'invoice.viewed' | 'invoice.paid' | 'invoice.overdue' | 'invoice.voided' | 'quote.created' | 'quote.updated' | 'quote.sent' | 'quote.viewed' | 'quote.accepted' | 'quote.rejected' | 'quote.expired' | 'job.created' | 'job.updated' | 'job.status_changed' | 'job.completed' | 'job.cancelled' | 'service_request.created' | 'service_request.updated' | 'service_request.assigned' | 'service_request.completed';
|
|
400
424
|
/**
|
|
401
425
|
* Webhook subscription
|
|
402
426
|
*/
|
|
@@ -408,8 +432,20 @@ interface Webhook {
|
|
|
408
432
|
events: WebhookEvent[];
|
|
409
433
|
secret: string;
|
|
410
434
|
is_active: boolean;
|
|
435
|
+
/** Custom metadata attached to the webhook */
|
|
436
|
+
metadata: Record<string, unknown> | null;
|
|
437
|
+
/** Number of consecutive delivery failures */
|
|
438
|
+
failure_count: number;
|
|
439
|
+
/** Timestamp of the last webhook trigger */
|
|
440
|
+
last_triggered_at: string | null;
|
|
441
|
+
/** Timestamp of the last successful delivery */
|
|
442
|
+
last_success_at: string | null;
|
|
443
|
+
/** Timestamp of the last failed delivery */
|
|
444
|
+
last_failure_at: string | null;
|
|
445
|
+
/** User ID who created the webhook */
|
|
446
|
+
created_by: string | null;
|
|
411
447
|
created_at: string;
|
|
412
|
-
updated_at: string;
|
|
448
|
+
updated_at: string | null;
|
|
413
449
|
}
|
|
414
450
|
/**
|
|
415
451
|
* Webhook delivery record
|
|
@@ -417,14 +453,26 @@ interface Webhook {
|
|
|
417
453
|
interface WebhookDelivery {
|
|
418
454
|
id: string;
|
|
419
455
|
webhook_id: string;
|
|
456
|
+
/** Unique event ID for idempotency */
|
|
457
|
+
event_id: string;
|
|
420
458
|
event_type: WebhookEvent;
|
|
421
459
|
payload: Record<string, unknown>;
|
|
460
|
+
/** Headers sent with the webhook request */
|
|
461
|
+
request_headers: Record<string, string> | null;
|
|
422
462
|
response_status: number | null;
|
|
463
|
+
/** Headers received in the response */
|
|
464
|
+
response_headers: Record<string, string> | null;
|
|
423
465
|
response_body: string | null;
|
|
466
|
+
/** Response time in milliseconds */
|
|
467
|
+
response_time_ms: number | null;
|
|
424
468
|
attempt_count: number;
|
|
469
|
+
/** Maximum number of delivery attempts */
|
|
470
|
+
max_attempts: number;
|
|
425
471
|
next_retry_at: string | null;
|
|
426
472
|
delivered_at: string | null;
|
|
427
473
|
failed_at: string | null;
|
|
474
|
+
/** Error message if delivery failed */
|
|
475
|
+
error_message: string | null;
|
|
428
476
|
created_at: string;
|
|
429
477
|
}
|
|
430
478
|
/**
|
|
@@ -434,6 +482,8 @@ interface CreateWebhookOptions {
|
|
|
434
482
|
name: string;
|
|
435
483
|
url: string;
|
|
436
484
|
events: WebhookEvent[];
|
|
485
|
+
/** Custom metadata to attach to the webhook */
|
|
486
|
+
metadata?: Record<string, unknown>;
|
|
437
487
|
}
|
|
438
488
|
/**
|
|
439
489
|
* Options for updating a webhook
|
|
@@ -443,12 +493,29 @@ interface UpdateWebhookOptions {
|
|
|
443
493
|
url?: string;
|
|
444
494
|
events?: WebhookEvent[];
|
|
445
495
|
is_active?: boolean;
|
|
496
|
+
metadata?: Record<string, unknown>;
|
|
446
497
|
}
|
|
447
498
|
/**
|
|
448
499
|
* Options for listing webhook deliveries
|
|
449
500
|
*/
|
|
450
501
|
interface ListWebhookDeliveriesOptions extends ListOptions {
|
|
451
502
|
event_type?: WebhookEvent;
|
|
503
|
+
/** Filter by delivery status */
|
|
504
|
+
status?: 'pending' | 'delivered' | 'failed';
|
|
505
|
+
}
|
|
506
|
+
/**
|
|
507
|
+
* Response from regenerating a webhook secret
|
|
508
|
+
*/
|
|
509
|
+
interface WebhookSecretResponse {
|
|
510
|
+
secret: string;
|
|
511
|
+
}
|
|
512
|
+
/**
|
|
513
|
+
* Webhook event type information
|
|
514
|
+
*/
|
|
515
|
+
interface WebhookEventTypeInfo {
|
|
516
|
+
event: WebhookEvent;
|
|
517
|
+
description: string;
|
|
518
|
+
category: 'client' | 'invoice' | 'quote' | 'job' | 'service_request';
|
|
452
519
|
}
|
|
453
520
|
|
|
454
521
|
/**
|
|
@@ -1259,6 +1326,62 @@ declare class WebhooksResource {
|
|
|
1259
1326
|
message: string;
|
|
1260
1327
|
delivery_id: string;
|
|
1261
1328
|
}>>;
|
|
1329
|
+
/**
|
|
1330
|
+
* Get a single webhook delivery
|
|
1331
|
+
*
|
|
1332
|
+
* Returns details about a specific delivery attempt, including
|
|
1333
|
+
* request/response headers and timing information.
|
|
1334
|
+
*
|
|
1335
|
+
* @param webhookId - Webhook UUID
|
|
1336
|
+
* @param deliveryId - Delivery UUID
|
|
1337
|
+
* @returns Delivery details
|
|
1338
|
+
*
|
|
1339
|
+
* @example
|
|
1340
|
+
* ```typescript
|
|
1341
|
+
* const { data: delivery } = await workbench.webhooks.getDelivery(
|
|
1342
|
+
* 'webhook-uuid',
|
|
1343
|
+
* 'delivery-uuid'
|
|
1344
|
+
* );
|
|
1345
|
+
* console.log(`Status: ${delivery.response_status}`);
|
|
1346
|
+
* console.log(`Response time: ${delivery.response_time_ms}ms`);
|
|
1347
|
+
* ```
|
|
1348
|
+
*/
|
|
1349
|
+
getDelivery(webhookId: string, deliveryId: string): Promise<ApiResponse<WebhookDelivery>>;
|
|
1350
|
+
/**
|
|
1351
|
+
* Regenerate webhook secret
|
|
1352
|
+
*
|
|
1353
|
+
* Generates a new secret for the webhook. The old secret will
|
|
1354
|
+
* immediately stop working. Make sure to update your webhook
|
|
1355
|
+
* handler with the new secret.
|
|
1356
|
+
*
|
|
1357
|
+
* @param id - Webhook UUID
|
|
1358
|
+
* @returns New webhook secret
|
|
1359
|
+
*
|
|
1360
|
+
* @example
|
|
1361
|
+
* ```typescript
|
|
1362
|
+
* const { data } = await workbench.webhooks.regenerateSecret('webhook-uuid');
|
|
1363
|
+
* console.log('New secret:', data.secret);
|
|
1364
|
+
* // Update your webhook handler with the new secret!
|
|
1365
|
+
* ```
|
|
1366
|
+
*/
|
|
1367
|
+
regenerateSecret(id: string): Promise<ApiResponse<WebhookSecretResponse>>;
|
|
1368
|
+
/**
|
|
1369
|
+
* List available webhook event types
|
|
1370
|
+
*
|
|
1371
|
+
* Returns all event types that can be subscribed to, with
|
|
1372
|
+
* descriptions and categories.
|
|
1373
|
+
*
|
|
1374
|
+
* @returns List of available event types
|
|
1375
|
+
*
|
|
1376
|
+
* @example
|
|
1377
|
+
* ```typescript
|
|
1378
|
+
* const { data: eventTypes } = await workbench.webhooks.listEventTypes();
|
|
1379
|
+
* eventTypes.forEach(et => {
|
|
1380
|
+
* console.log(`${et.event} (${et.category}): ${et.description}`);
|
|
1381
|
+
* });
|
|
1382
|
+
* ```
|
|
1383
|
+
*/
|
|
1384
|
+
listEventTypes(): Promise<ApiResponse<WebhookEventTypeInfo[]>>;
|
|
1262
1385
|
}
|
|
1263
1386
|
|
|
1264
1387
|
/**
|
package/dist/index.js
CHANGED
|
@@ -793,6 +793,70 @@ var WebhooksResource = class {
|
|
|
793
793
|
async test(id) {
|
|
794
794
|
return this.client.post(`/v1/webhooks/${id}/test`);
|
|
795
795
|
}
|
|
796
|
+
/**
|
|
797
|
+
* Get a single webhook delivery
|
|
798
|
+
*
|
|
799
|
+
* Returns details about a specific delivery attempt, including
|
|
800
|
+
* request/response headers and timing information.
|
|
801
|
+
*
|
|
802
|
+
* @param webhookId - Webhook UUID
|
|
803
|
+
* @param deliveryId - Delivery UUID
|
|
804
|
+
* @returns Delivery details
|
|
805
|
+
*
|
|
806
|
+
* @example
|
|
807
|
+
* ```typescript
|
|
808
|
+
* const { data: delivery } = await workbench.webhooks.getDelivery(
|
|
809
|
+
* 'webhook-uuid',
|
|
810
|
+
* 'delivery-uuid'
|
|
811
|
+
* );
|
|
812
|
+
* console.log(`Status: ${delivery.response_status}`);
|
|
813
|
+
* console.log(`Response time: ${delivery.response_time_ms}ms`);
|
|
814
|
+
* ```
|
|
815
|
+
*/
|
|
816
|
+
async getDelivery(webhookId, deliveryId) {
|
|
817
|
+
return this.client.get(
|
|
818
|
+
`/v1/webhooks/${webhookId}/deliveries/${deliveryId}`
|
|
819
|
+
);
|
|
820
|
+
}
|
|
821
|
+
/**
|
|
822
|
+
* Regenerate webhook secret
|
|
823
|
+
*
|
|
824
|
+
* Generates a new secret for the webhook. The old secret will
|
|
825
|
+
* immediately stop working. Make sure to update your webhook
|
|
826
|
+
* handler with the new secret.
|
|
827
|
+
*
|
|
828
|
+
* @param id - Webhook UUID
|
|
829
|
+
* @returns New webhook secret
|
|
830
|
+
*
|
|
831
|
+
* @example
|
|
832
|
+
* ```typescript
|
|
833
|
+
* const { data } = await workbench.webhooks.regenerateSecret('webhook-uuid');
|
|
834
|
+
* console.log('New secret:', data.secret);
|
|
835
|
+
* // Update your webhook handler with the new secret!
|
|
836
|
+
* ```
|
|
837
|
+
*/
|
|
838
|
+
async regenerateSecret(id) {
|
|
839
|
+
return this.client.post(`/v1/webhooks/${id}/secret`);
|
|
840
|
+
}
|
|
841
|
+
/**
|
|
842
|
+
* List available webhook event types
|
|
843
|
+
*
|
|
844
|
+
* Returns all event types that can be subscribed to, with
|
|
845
|
+
* descriptions and categories.
|
|
846
|
+
*
|
|
847
|
+
* @returns List of available event types
|
|
848
|
+
*
|
|
849
|
+
* @example
|
|
850
|
+
* ```typescript
|
|
851
|
+
* const { data: eventTypes } = await workbench.webhooks.listEventTypes();
|
|
852
|
+
* eventTypes.forEach(et => {
|
|
853
|
+
* console.log(`${et.event} (${et.category}): ${et.description}`);
|
|
854
|
+
* });
|
|
855
|
+
* ```
|
|
856
|
+
*/
|
|
857
|
+
async listEventTypes() {
|
|
858
|
+
return this.client.get("/v1/webhooks/event-types");
|
|
859
|
+
}
|
|
796
860
|
};
|
|
797
861
|
|
|
798
862
|
// src/client.ts
|
package/dist/index.mjs
CHANGED
|
@@ -755,6 +755,70 @@ var WebhooksResource = class {
|
|
|
755
755
|
async test(id) {
|
|
756
756
|
return this.client.post(`/v1/webhooks/${id}/test`);
|
|
757
757
|
}
|
|
758
|
+
/**
|
|
759
|
+
* Get a single webhook delivery
|
|
760
|
+
*
|
|
761
|
+
* Returns details about a specific delivery attempt, including
|
|
762
|
+
* request/response headers and timing information.
|
|
763
|
+
*
|
|
764
|
+
* @param webhookId - Webhook UUID
|
|
765
|
+
* @param deliveryId - Delivery UUID
|
|
766
|
+
* @returns Delivery details
|
|
767
|
+
*
|
|
768
|
+
* @example
|
|
769
|
+
* ```typescript
|
|
770
|
+
* const { data: delivery } = await workbench.webhooks.getDelivery(
|
|
771
|
+
* 'webhook-uuid',
|
|
772
|
+
* 'delivery-uuid'
|
|
773
|
+
* );
|
|
774
|
+
* console.log(`Status: ${delivery.response_status}`);
|
|
775
|
+
* console.log(`Response time: ${delivery.response_time_ms}ms`);
|
|
776
|
+
* ```
|
|
777
|
+
*/
|
|
778
|
+
async getDelivery(webhookId, deliveryId) {
|
|
779
|
+
return this.client.get(
|
|
780
|
+
`/v1/webhooks/${webhookId}/deliveries/${deliveryId}`
|
|
781
|
+
);
|
|
782
|
+
}
|
|
783
|
+
/**
|
|
784
|
+
* Regenerate webhook secret
|
|
785
|
+
*
|
|
786
|
+
* Generates a new secret for the webhook. The old secret will
|
|
787
|
+
* immediately stop working. Make sure to update your webhook
|
|
788
|
+
* handler with the new secret.
|
|
789
|
+
*
|
|
790
|
+
* @param id - Webhook UUID
|
|
791
|
+
* @returns New webhook secret
|
|
792
|
+
*
|
|
793
|
+
* @example
|
|
794
|
+
* ```typescript
|
|
795
|
+
* const { data } = await workbench.webhooks.regenerateSecret('webhook-uuid');
|
|
796
|
+
* console.log('New secret:', data.secret);
|
|
797
|
+
* // Update your webhook handler with the new secret!
|
|
798
|
+
* ```
|
|
799
|
+
*/
|
|
800
|
+
async regenerateSecret(id) {
|
|
801
|
+
return this.client.post(`/v1/webhooks/${id}/secret`);
|
|
802
|
+
}
|
|
803
|
+
/**
|
|
804
|
+
* List available webhook event types
|
|
805
|
+
*
|
|
806
|
+
* Returns all event types that can be subscribed to, with
|
|
807
|
+
* descriptions and categories.
|
|
808
|
+
*
|
|
809
|
+
* @returns List of available event types
|
|
810
|
+
*
|
|
811
|
+
* @example
|
|
812
|
+
* ```typescript
|
|
813
|
+
* const { data: eventTypes } = await workbench.webhooks.listEventTypes();
|
|
814
|
+
* eventTypes.forEach(et => {
|
|
815
|
+
* console.log(`${et.event} (${et.category}): ${et.description}`);
|
|
816
|
+
* });
|
|
817
|
+
* ```
|
|
818
|
+
*/
|
|
819
|
+
async listEventTypes() {
|
|
820
|
+
return this.client.get("/v1/webhooks/event-types");
|
|
821
|
+
}
|
|
758
822
|
};
|
|
759
823
|
|
|
760
824
|
// src/client.ts
|