@workbenchcrm/sdk 1.0.0 → 1.0.2
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 +143 -18
- package/dist/index.d.ts +143 -18
- 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
|
|
@@ -275,11 +297,11 @@ interface ListQuotesOptions extends ListOptions {
|
|
|
275
297
|
/**
|
|
276
298
|
* Job status values
|
|
277
299
|
*/
|
|
278
|
-
type JobStatus = '
|
|
300
|
+
type JobStatus = 'draft' | 'scheduled' | 'in_progress' | 'on_hold' | 'completed' | 'cancelled' | 'invoiced' | 'closed';
|
|
279
301
|
/**
|
|
280
302
|
* Job priority values
|
|
281
303
|
*/
|
|
282
|
-
type JobPriority = 'low' | 'medium' | 'high' | 'urgent';
|
|
304
|
+
type JobPriority = 'low' | 'medium' | 'normal' | 'high' | 'urgent';
|
|
283
305
|
/**
|
|
284
306
|
* Job record
|
|
285
307
|
*/
|
|
@@ -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
|
|
@@ -339,7 +363,7 @@ type ServiceRequestStatus = 'new' | 'reviewing' | 'scheduled' | 'completed' | 'c
|
|
|
339
363
|
/**
|
|
340
364
|
* Service request priority values
|
|
341
365
|
*/
|
|
342
|
-
type ServiceRequestPriority = 'low' | '
|
|
366
|
+
type ServiceRequestPriority = 'low' | 'normal' | 'high' | 'urgent';
|
|
343
367
|
/**
|
|
344
368
|
* Service request record
|
|
345
369
|
*/
|
|
@@ -347,6 +371,8 @@ interface ServiceRequest {
|
|
|
347
371
|
id: string;
|
|
348
372
|
business_id: string;
|
|
349
373
|
client_id: string | null;
|
|
374
|
+
/** Unique request number for display/reference (auto-generated) */
|
|
375
|
+
request_number: string;
|
|
350
376
|
title: string;
|
|
351
377
|
description: string | null;
|
|
352
378
|
status: ServiceRequestStatus;
|
|
@@ -361,7 +387,7 @@ interface ServiceRequest {
|
|
|
361
387
|
notes: string | null;
|
|
362
388
|
client?: Client;
|
|
363
389
|
created_at: string;
|
|
364
|
-
updated_at: string;
|
|
390
|
+
updated_at: string | null;
|
|
365
391
|
}
|
|
366
392
|
/**
|
|
367
393
|
* Options for creating a service request
|
|
@@ -396,7 +422,7 @@ interface ListServiceRequestsOptions extends ListOptions {
|
|
|
396
422
|
/**
|
|
397
423
|
* Available webhook event types
|
|
398
424
|
*/
|
|
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';
|
|
425
|
+
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
426
|
/**
|
|
401
427
|
* Webhook subscription
|
|
402
428
|
*/
|
|
@@ -408,8 +434,20 @@ interface Webhook {
|
|
|
408
434
|
events: WebhookEvent[];
|
|
409
435
|
secret: string;
|
|
410
436
|
is_active: boolean;
|
|
437
|
+
/** Custom metadata attached to the webhook */
|
|
438
|
+
metadata: Record<string, unknown> | null;
|
|
439
|
+
/** Number of consecutive delivery failures */
|
|
440
|
+
failure_count: number;
|
|
441
|
+
/** Timestamp of the last webhook trigger */
|
|
442
|
+
last_triggered_at: string | null;
|
|
443
|
+
/** Timestamp of the last successful delivery */
|
|
444
|
+
last_success_at: string | null;
|
|
445
|
+
/** Timestamp of the last failed delivery */
|
|
446
|
+
last_failure_at: string | null;
|
|
447
|
+
/** User ID who created the webhook */
|
|
448
|
+
created_by: string | null;
|
|
411
449
|
created_at: string;
|
|
412
|
-
updated_at: string;
|
|
450
|
+
updated_at: string | null;
|
|
413
451
|
}
|
|
414
452
|
/**
|
|
415
453
|
* Webhook delivery record
|
|
@@ -417,14 +455,26 @@ interface Webhook {
|
|
|
417
455
|
interface WebhookDelivery {
|
|
418
456
|
id: string;
|
|
419
457
|
webhook_id: string;
|
|
458
|
+
/** Unique event ID for idempotency */
|
|
459
|
+
event_id: string;
|
|
420
460
|
event_type: WebhookEvent;
|
|
421
461
|
payload: Record<string, unknown>;
|
|
462
|
+
/** Headers sent with the webhook request */
|
|
463
|
+
request_headers: Record<string, string> | null;
|
|
422
464
|
response_status: number | null;
|
|
465
|
+
/** Headers received in the response */
|
|
466
|
+
response_headers: Record<string, string> | null;
|
|
423
467
|
response_body: string | null;
|
|
468
|
+
/** Response time in milliseconds */
|
|
469
|
+
response_time_ms: number | null;
|
|
424
470
|
attempt_count: number;
|
|
471
|
+
/** Maximum number of delivery attempts */
|
|
472
|
+
max_attempts: number;
|
|
425
473
|
next_retry_at: string | null;
|
|
426
474
|
delivered_at: string | null;
|
|
427
475
|
failed_at: string | null;
|
|
476
|
+
/** Error message if delivery failed */
|
|
477
|
+
error_message: string | null;
|
|
428
478
|
created_at: string;
|
|
429
479
|
}
|
|
430
480
|
/**
|
|
@@ -434,6 +484,8 @@ interface CreateWebhookOptions {
|
|
|
434
484
|
name: string;
|
|
435
485
|
url: string;
|
|
436
486
|
events: WebhookEvent[];
|
|
487
|
+
/** Custom metadata to attach to the webhook */
|
|
488
|
+
metadata?: Record<string, unknown>;
|
|
437
489
|
}
|
|
438
490
|
/**
|
|
439
491
|
* Options for updating a webhook
|
|
@@ -443,12 +495,29 @@ interface UpdateWebhookOptions {
|
|
|
443
495
|
url?: string;
|
|
444
496
|
events?: WebhookEvent[];
|
|
445
497
|
is_active?: boolean;
|
|
498
|
+
metadata?: Record<string, unknown>;
|
|
446
499
|
}
|
|
447
500
|
/**
|
|
448
501
|
* Options for listing webhook deliveries
|
|
449
502
|
*/
|
|
450
503
|
interface ListWebhookDeliveriesOptions extends ListOptions {
|
|
451
504
|
event_type?: WebhookEvent;
|
|
505
|
+
/** Filter by delivery status */
|
|
506
|
+
status?: 'pending' | 'delivered' | 'failed';
|
|
507
|
+
}
|
|
508
|
+
/**
|
|
509
|
+
* Response from regenerating a webhook secret
|
|
510
|
+
*/
|
|
511
|
+
interface WebhookSecretResponse {
|
|
512
|
+
secret: string;
|
|
513
|
+
}
|
|
514
|
+
/**
|
|
515
|
+
* Webhook event type information
|
|
516
|
+
*/
|
|
517
|
+
interface WebhookEventTypeInfo {
|
|
518
|
+
event: WebhookEvent;
|
|
519
|
+
description: string;
|
|
520
|
+
category: 'client' | 'invoice' | 'quote' | 'job' | 'service_request';
|
|
452
521
|
}
|
|
453
522
|
|
|
454
523
|
/**
|
|
@@ -1259,6 +1328,62 @@ declare class WebhooksResource {
|
|
|
1259
1328
|
message: string;
|
|
1260
1329
|
delivery_id: string;
|
|
1261
1330
|
}>>;
|
|
1331
|
+
/**
|
|
1332
|
+
* Get a single webhook delivery
|
|
1333
|
+
*
|
|
1334
|
+
* Returns details about a specific delivery attempt, including
|
|
1335
|
+
* request/response headers and timing information.
|
|
1336
|
+
*
|
|
1337
|
+
* @param webhookId - Webhook UUID
|
|
1338
|
+
* @param deliveryId - Delivery UUID
|
|
1339
|
+
* @returns Delivery details
|
|
1340
|
+
*
|
|
1341
|
+
* @example
|
|
1342
|
+
* ```typescript
|
|
1343
|
+
* const { data: delivery } = await workbench.webhooks.getDelivery(
|
|
1344
|
+
* 'webhook-uuid',
|
|
1345
|
+
* 'delivery-uuid'
|
|
1346
|
+
* );
|
|
1347
|
+
* console.log(`Status: ${delivery.response_status}`);
|
|
1348
|
+
* console.log(`Response time: ${delivery.response_time_ms}ms`);
|
|
1349
|
+
* ```
|
|
1350
|
+
*/
|
|
1351
|
+
getDelivery(webhookId: string, deliveryId: string): Promise<ApiResponse<WebhookDelivery>>;
|
|
1352
|
+
/**
|
|
1353
|
+
* Regenerate webhook secret
|
|
1354
|
+
*
|
|
1355
|
+
* Generates a new secret for the webhook. The old secret will
|
|
1356
|
+
* immediately stop working. Make sure to update your webhook
|
|
1357
|
+
* handler with the new secret.
|
|
1358
|
+
*
|
|
1359
|
+
* @param id - Webhook UUID
|
|
1360
|
+
* @returns New webhook secret
|
|
1361
|
+
*
|
|
1362
|
+
* @example
|
|
1363
|
+
* ```typescript
|
|
1364
|
+
* const { data } = await workbench.webhooks.regenerateSecret('webhook-uuid');
|
|
1365
|
+
* console.log('New secret:', data.secret);
|
|
1366
|
+
* // Update your webhook handler with the new secret!
|
|
1367
|
+
* ```
|
|
1368
|
+
*/
|
|
1369
|
+
regenerateSecret(id: string): Promise<ApiResponse<WebhookSecretResponse>>;
|
|
1370
|
+
/**
|
|
1371
|
+
* List available webhook event types
|
|
1372
|
+
*
|
|
1373
|
+
* Returns all event types that can be subscribed to, with
|
|
1374
|
+
* descriptions and categories.
|
|
1375
|
+
*
|
|
1376
|
+
* @returns List of available event types
|
|
1377
|
+
*
|
|
1378
|
+
* @example
|
|
1379
|
+
* ```typescript
|
|
1380
|
+
* const { data: eventTypes } = await workbench.webhooks.listEventTypes();
|
|
1381
|
+
* eventTypes.forEach(et => {
|
|
1382
|
+
* console.log(`${et.event} (${et.category}): ${et.description}`);
|
|
1383
|
+
* });
|
|
1384
|
+
* ```
|
|
1385
|
+
*/
|
|
1386
|
+
listEventTypes(): Promise<ApiResponse<WebhookEventTypeInfo[]>>;
|
|
1262
1387
|
}
|
|
1263
1388
|
|
|
1264
1389
|
/**
|
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
|
|
@@ -275,11 +297,11 @@ interface ListQuotesOptions extends ListOptions {
|
|
|
275
297
|
/**
|
|
276
298
|
* Job status values
|
|
277
299
|
*/
|
|
278
|
-
type JobStatus = '
|
|
300
|
+
type JobStatus = 'draft' | 'scheduled' | 'in_progress' | 'on_hold' | 'completed' | 'cancelled' | 'invoiced' | 'closed';
|
|
279
301
|
/**
|
|
280
302
|
* Job priority values
|
|
281
303
|
*/
|
|
282
|
-
type JobPriority = 'low' | 'medium' | 'high' | 'urgent';
|
|
304
|
+
type JobPriority = 'low' | 'medium' | 'normal' | 'high' | 'urgent';
|
|
283
305
|
/**
|
|
284
306
|
* Job record
|
|
285
307
|
*/
|
|
@@ -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
|
|
@@ -339,7 +363,7 @@ type ServiceRequestStatus = 'new' | 'reviewing' | 'scheduled' | 'completed' | 'c
|
|
|
339
363
|
/**
|
|
340
364
|
* Service request priority values
|
|
341
365
|
*/
|
|
342
|
-
type ServiceRequestPriority = 'low' | '
|
|
366
|
+
type ServiceRequestPriority = 'low' | 'normal' | 'high' | 'urgent';
|
|
343
367
|
/**
|
|
344
368
|
* Service request record
|
|
345
369
|
*/
|
|
@@ -347,6 +371,8 @@ interface ServiceRequest {
|
|
|
347
371
|
id: string;
|
|
348
372
|
business_id: string;
|
|
349
373
|
client_id: string | null;
|
|
374
|
+
/** Unique request number for display/reference (auto-generated) */
|
|
375
|
+
request_number: string;
|
|
350
376
|
title: string;
|
|
351
377
|
description: string | null;
|
|
352
378
|
status: ServiceRequestStatus;
|
|
@@ -361,7 +387,7 @@ interface ServiceRequest {
|
|
|
361
387
|
notes: string | null;
|
|
362
388
|
client?: Client;
|
|
363
389
|
created_at: string;
|
|
364
|
-
updated_at: string;
|
|
390
|
+
updated_at: string | null;
|
|
365
391
|
}
|
|
366
392
|
/**
|
|
367
393
|
* Options for creating a service request
|
|
@@ -396,7 +422,7 @@ interface ListServiceRequestsOptions extends ListOptions {
|
|
|
396
422
|
/**
|
|
397
423
|
* Available webhook event types
|
|
398
424
|
*/
|
|
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';
|
|
425
|
+
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
426
|
/**
|
|
401
427
|
* Webhook subscription
|
|
402
428
|
*/
|
|
@@ -408,8 +434,20 @@ interface Webhook {
|
|
|
408
434
|
events: WebhookEvent[];
|
|
409
435
|
secret: string;
|
|
410
436
|
is_active: boolean;
|
|
437
|
+
/** Custom metadata attached to the webhook */
|
|
438
|
+
metadata: Record<string, unknown> | null;
|
|
439
|
+
/** Number of consecutive delivery failures */
|
|
440
|
+
failure_count: number;
|
|
441
|
+
/** Timestamp of the last webhook trigger */
|
|
442
|
+
last_triggered_at: string | null;
|
|
443
|
+
/** Timestamp of the last successful delivery */
|
|
444
|
+
last_success_at: string | null;
|
|
445
|
+
/** Timestamp of the last failed delivery */
|
|
446
|
+
last_failure_at: string | null;
|
|
447
|
+
/** User ID who created the webhook */
|
|
448
|
+
created_by: string | null;
|
|
411
449
|
created_at: string;
|
|
412
|
-
updated_at: string;
|
|
450
|
+
updated_at: string | null;
|
|
413
451
|
}
|
|
414
452
|
/**
|
|
415
453
|
* Webhook delivery record
|
|
@@ -417,14 +455,26 @@ interface Webhook {
|
|
|
417
455
|
interface WebhookDelivery {
|
|
418
456
|
id: string;
|
|
419
457
|
webhook_id: string;
|
|
458
|
+
/** Unique event ID for idempotency */
|
|
459
|
+
event_id: string;
|
|
420
460
|
event_type: WebhookEvent;
|
|
421
461
|
payload: Record<string, unknown>;
|
|
462
|
+
/** Headers sent with the webhook request */
|
|
463
|
+
request_headers: Record<string, string> | null;
|
|
422
464
|
response_status: number | null;
|
|
465
|
+
/** Headers received in the response */
|
|
466
|
+
response_headers: Record<string, string> | null;
|
|
423
467
|
response_body: string | null;
|
|
468
|
+
/** Response time in milliseconds */
|
|
469
|
+
response_time_ms: number | null;
|
|
424
470
|
attempt_count: number;
|
|
471
|
+
/** Maximum number of delivery attempts */
|
|
472
|
+
max_attempts: number;
|
|
425
473
|
next_retry_at: string | null;
|
|
426
474
|
delivered_at: string | null;
|
|
427
475
|
failed_at: string | null;
|
|
476
|
+
/** Error message if delivery failed */
|
|
477
|
+
error_message: string | null;
|
|
428
478
|
created_at: string;
|
|
429
479
|
}
|
|
430
480
|
/**
|
|
@@ -434,6 +484,8 @@ interface CreateWebhookOptions {
|
|
|
434
484
|
name: string;
|
|
435
485
|
url: string;
|
|
436
486
|
events: WebhookEvent[];
|
|
487
|
+
/** Custom metadata to attach to the webhook */
|
|
488
|
+
metadata?: Record<string, unknown>;
|
|
437
489
|
}
|
|
438
490
|
/**
|
|
439
491
|
* Options for updating a webhook
|
|
@@ -443,12 +495,29 @@ interface UpdateWebhookOptions {
|
|
|
443
495
|
url?: string;
|
|
444
496
|
events?: WebhookEvent[];
|
|
445
497
|
is_active?: boolean;
|
|
498
|
+
metadata?: Record<string, unknown>;
|
|
446
499
|
}
|
|
447
500
|
/**
|
|
448
501
|
* Options for listing webhook deliveries
|
|
449
502
|
*/
|
|
450
503
|
interface ListWebhookDeliveriesOptions extends ListOptions {
|
|
451
504
|
event_type?: WebhookEvent;
|
|
505
|
+
/** Filter by delivery status */
|
|
506
|
+
status?: 'pending' | 'delivered' | 'failed';
|
|
507
|
+
}
|
|
508
|
+
/**
|
|
509
|
+
* Response from regenerating a webhook secret
|
|
510
|
+
*/
|
|
511
|
+
interface WebhookSecretResponse {
|
|
512
|
+
secret: string;
|
|
513
|
+
}
|
|
514
|
+
/**
|
|
515
|
+
* Webhook event type information
|
|
516
|
+
*/
|
|
517
|
+
interface WebhookEventTypeInfo {
|
|
518
|
+
event: WebhookEvent;
|
|
519
|
+
description: string;
|
|
520
|
+
category: 'client' | 'invoice' | 'quote' | 'job' | 'service_request';
|
|
452
521
|
}
|
|
453
522
|
|
|
454
523
|
/**
|
|
@@ -1259,6 +1328,62 @@ declare class WebhooksResource {
|
|
|
1259
1328
|
message: string;
|
|
1260
1329
|
delivery_id: string;
|
|
1261
1330
|
}>>;
|
|
1331
|
+
/**
|
|
1332
|
+
* Get a single webhook delivery
|
|
1333
|
+
*
|
|
1334
|
+
* Returns details about a specific delivery attempt, including
|
|
1335
|
+
* request/response headers and timing information.
|
|
1336
|
+
*
|
|
1337
|
+
* @param webhookId - Webhook UUID
|
|
1338
|
+
* @param deliveryId - Delivery UUID
|
|
1339
|
+
* @returns Delivery details
|
|
1340
|
+
*
|
|
1341
|
+
* @example
|
|
1342
|
+
* ```typescript
|
|
1343
|
+
* const { data: delivery } = await workbench.webhooks.getDelivery(
|
|
1344
|
+
* 'webhook-uuid',
|
|
1345
|
+
* 'delivery-uuid'
|
|
1346
|
+
* );
|
|
1347
|
+
* console.log(`Status: ${delivery.response_status}`);
|
|
1348
|
+
* console.log(`Response time: ${delivery.response_time_ms}ms`);
|
|
1349
|
+
* ```
|
|
1350
|
+
*/
|
|
1351
|
+
getDelivery(webhookId: string, deliveryId: string): Promise<ApiResponse<WebhookDelivery>>;
|
|
1352
|
+
/**
|
|
1353
|
+
* Regenerate webhook secret
|
|
1354
|
+
*
|
|
1355
|
+
* Generates a new secret for the webhook. The old secret will
|
|
1356
|
+
* immediately stop working. Make sure to update your webhook
|
|
1357
|
+
* handler with the new secret.
|
|
1358
|
+
*
|
|
1359
|
+
* @param id - Webhook UUID
|
|
1360
|
+
* @returns New webhook secret
|
|
1361
|
+
*
|
|
1362
|
+
* @example
|
|
1363
|
+
* ```typescript
|
|
1364
|
+
* const { data } = await workbench.webhooks.regenerateSecret('webhook-uuid');
|
|
1365
|
+
* console.log('New secret:', data.secret);
|
|
1366
|
+
* // Update your webhook handler with the new secret!
|
|
1367
|
+
* ```
|
|
1368
|
+
*/
|
|
1369
|
+
regenerateSecret(id: string): Promise<ApiResponse<WebhookSecretResponse>>;
|
|
1370
|
+
/**
|
|
1371
|
+
* List available webhook event types
|
|
1372
|
+
*
|
|
1373
|
+
* Returns all event types that can be subscribed to, with
|
|
1374
|
+
* descriptions and categories.
|
|
1375
|
+
*
|
|
1376
|
+
* @returns List of available event types
|
|
1377
|
+
*
|
|
1378
|
+
* @example
|
|
1379
|
+
* ```typescript
|
|
1380
|
+
* const { data: eventTypes } = await workbench.webhooks.listEventTypes();
|
|
1381
|
+
* eventTypes.forEach(et => {
|
|
1382
|
+
* console.log(`${et.event} (${et.category}): ${et.description}`);
|
|
1383
|
+
* });
|
|
1384
|
+
* ```
|
|
1385
|
+
*/
|
|
1386
|
+
listEventTypes(): Promise<ApiResponse<WebhookEventTypeInfo[]>>;
|
|
1262
1387
|
}
|
|
1263
1388
|
|
|
1264
1389
|
/**
|
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
|