@agentuity/server 1.0.22 → 1.0.23
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/api/index.d.ts +1 -0
- package/dist/api/index.d.ts.map +1 -1
- package/dist/api/index.js +1 -0
- package/dist/api/index.js.map +1 -1
- package/dist/api/project/deploy.d.ts +8 -0
- package/dist/api/project/deploy.d.ts.map +1 -1
- package/dist/api/project/deploy.js +14 -13
- package/dist/api/project/deploy.js.map +1 -1
- package/dist/api/sandbox/execute.d.ts +2 -2
- package/dist/api/sandbox/execution.d.ts +4 -4
- package/dist/api/sandbox/snapshot-build.d.ts +2 -0
- package/dist/api/sandbox/snapshot-build.d.ts.map +1 -1
- package/dist/api/sandbox/snapshot-build.js +4 -0
- package/dist/api/sandbox/snapshot-build.js.map +1 -1
- package/dist/api/webhook/deliveries.d.ts +94 -0
- package/dist/api/webhook/deliveries.d.ts.map +1 -0
- package/dist/api/webhook/deliveries.js +79 -0
- package/dist/api/webhook/deliveries.js.map +1 -0
- package/dist/api/webhook/destinations.d.ts +136 -0
- package/dist/api/webhook/destinations.d.ts.map +1 -0
- package/dist/api/webhook/destinations.js +137 -0
- package/dist/api/webhook/destinations.js.map +1 -0
- package/dist/api/webhook/index.d.ts +41 -0
- package/dist/api/webhook/index.d.ts.map +1 -0
- package/dist/api/webhook/index.js +59 -0
- package/dist/api/webhook/index.js.map +1 -0
- package/dist/api/webhook/receipts.d.ts +77 -0
- package/dist/api/webhook/receipts.d.ts.map +1 -0
- package/dist/api/webhook/receipts.js +78 -0
- package/dist/api/webhook/receipts.js.map +1 -0
- package/dist/api/webhook/types.d.ts +249 -0
- package/dist/api/webhook/types.d.ts.map +1 -0
- package/dist/api/webhook/types.js +221 -0
- package/dist/api/webhook/types.js.map +1 -0
- package/dist/api/webhook/util.d.ts +202 -0
- package/dist/api/webhook/util.d.ts.map +1 -0
- package/dist/api/webhook/util.js +201 -0
- package/dist/api/webhook/util.js.map +1 -0
- package/dist/api/webhook/webhooks.d.ts +146 -0
- package/dist/api/webhook/webhooks.d.ts.map +1 -0
- package/dist/api/webhook/webhooks.js +165 -0
- package/dist/api/webhook/webhooks.js.map +1 -0
- package/dist/config.d.ts +1 -0
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +1 -0
- package/dist/config.js.map +1 -1
- package/dist/runtime-bootstrap.d.ts.map +1 -1
- package/dist/runtime-bootstrap.js +3 -0
- package/dist/runtime-bootstrap.js.map +1 -1
- package/package.json +4 -4
- package/src/api/index.ts +1 -0
- package/src/api/project/deploy.ts +16 -16
- package/src/api/sandbox/snapshot-build.ts +6 -0
- package/src/api/webhook/deliveries.ts +129 -0
- package/src/api/webhook/destinations.ts +224 -0
- package/src/api/webhook/index.ts +133 -0
- package/src/api/webhook/receipts.ts +124 -0
- package/src/api/webhook/types.ts +309 -0
- package/src/api/webhook/util.ts +237 -0
- package/src/api/webhook/webhooks.ts +260 -0
- package/src/config.ts +2 -0
- package/src/runtime-bootstrap.ts +3 -0
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { APIResponseSchema, APIResponseSchemaNoData } from "../api.js";
|
|
3
|
+
import { CreateWebhookDestinationRequestSchema, UpdateWebhookDestinationRequestSchema, WebhookDestinationSchema, } from "./types.js";
|
|
4
|
+
import { buildWebhookHeaders, WebhookError, webhookApiPath, withWebhookErrorHandling, } from "./util.js";
|
|
5
|
+
export const WebhookDestinationResponseSchema = APIResponseSchema(WebhookDestinationSchema);
|
|
6
|
+
export const WebhookDestinationsListResponseSchema = APIResponseSchema(z.array(WebhookDestinationSchema));
|
|
7
|
+
export const DeleteWebhookDestinationResponseSchema = APIResponseSchemaNoData();
|
|
8
|
+
/**
|
|
9
|
+
* Create a destination for a webhook.
|
|
10
|
+
*
|
|
11
|
+
* Destinations define where incoming webhook payloads are forwarded to.
|
|
12
|
+
* When a webhook receives a payload, it will be delivered to all configured destinations.
|
|
13
|
+
*
|
|
14
|
+
* @param client - The API client instance
|
|
15
|
+
* @param webhookId - The webhook ID (prefixed with wh_)
|
|
16
|
+
* @param params - Destination configuration including type and config
|
|
17
|
+
* @param options - Optional API options (e.g., orgId)
|
|
18
|
+
* @returns The created destination
|
|
19
|
+
* @throws {WebhookNotFoundError} If the webhook does not exist
|
|
20
|
+
* @throws {WebhookError} If the API request fails
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* ```typescript
|
|
24
|
+
* const destination = await createWebhookDestination(client, 'wh_abc123', {
|
|
25
|
+
* type: 'url',
|
|
26
|
+
* config: { url: 'https://api.example.com/webhook' },
|
|
27
|
+
* });
|
|
28
|
+
* console.log(`Created destination ${destination.id}`);
|
|
29
|
+
* ```
|
|
30
|
+
*/
|
|
31
|
+
export async function createWebhookDestination(client, webhookId, params, options) {
|
|
32
|
+
const url = webhookApiPath('destination-create', webhookId);
|
|
33
|
+
const resp = await withWebhookErrorHandling(() => client.post(url, params, WebhookDestinationResponseSchema, CreateWebhookDestinationRequestSchema, undefined, buildWebhookHeaders(options?.orgId)), { webhookId });
|
|
34
|
+
if (resp.success) {
|
|
35
|
+
return resp.data;
|
|
36
|
+
}
|
|
37
|
+
throw new WebhookError({
|
|
38
|
+
webhookId,
|
|
39
|
+
message: resp.message || 'Failed to create webhook destination',
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* List all destinations for a webhook.
|
|
44
|
+
*
|
|
45
|
+
* Retrieves all destinations configured for a webhook.
|
|
46
|
+
*
|
|
47
|
+
* @param client - The API client instance
|
|
48
|
+
* @param webhookId - The webhook ID (prefixed with wh_)
|
|
49
|
+
* @param options - Optional API options (e.g., orgId)
|
|
50
|
+
* @returns Array of destinations configured for the webhook
|
|
51
|
+
* @throws {WebhookNotFoundError} If the webhook does not exist
|
|
52
|
+
* @throws {WebhookError} If the API request fails
|
|
53
|
+
*
|
|
54
|
+
* @example
|
|
55
|
+
* ```typescript
|
|
56
|
+
* const destinations = await listWebhookDestinations(client, 'wh_abc123');
|
|
57
|
+
* for (const dest of destinations) {
|
|
58
|
+
* console.log(`Destination ${dest.id}: type=${dest.type}`);
|
|
59
|
+
* }
|
|
60
|
+
* ```
|
|
61
|
+
*/
|
|
62
|
+
export async function listWebhookDestinations(client, webhookId, options) {
|
|
63
|
+
const url = webhookApiPath('destination-list', webhookId);
|
|
64
|
+
const resp = await withWebhookErrorHandling(() => client.get(url, WebhookDestinationsListResponseSchema, undefined, buildWebhookHeaders(options?.orgId)), { webhookId });
|
|
65
|
+
if (resp.success) {
|
|
66
|
+
return resp.data;
|
|
67
|
+
}
|
|
68
|
+
throw new WebhookError({
|
|
69
|
+
webhookId,
|
|
70
|
+
message: resp.message || 'Failed to list webhook destinations',
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Update a webhook destination's configuration.
|
|
75
|
+
*
|
|
76
|
+
* Modifies an existing destination's config. Only the fields provided in params will be updated.
|
|
77
|
+
*
|
|
78
|
+
* @param client - The API client instance
|
|
79
|
+
* @param webhookId - The webhook ID (prefixed with wh_)
|
|
80
|
+
* @param destinationId - The destination ID to update (prefixed with whds_)
|
|
81
|
+
* @param params - Fields to update
|
|
82
|
+
* @param options - Optional API options (e.g., orgId)
|
|
83
|
+
* @returns The updated destination
|
|
84
|
+
* @throws {WebhookDestinationNotFoundError} If the destination does not exist
|
|
85
|
+
* @throws {WebhookNotFoundError} If the webhook does not exist
|
|
86
|
+
* @throws {WebhookError} If the API request fails
|
|
87
|
+
*
|
|
88
|
+
* @example
|
|
89
|
+
* ```typescript
|
|
90
|
+
* const updated = await updateWebhookDestination(client, 'wh_abc123', 'whds_def456', {
|
|
91
|
+
* config: { url: 'https://api.example.com/webhook/v2' },
|
|
92
|
+
* });
|
|
93
|
+
* ```
|
|
94
|
+
*/
|
|
95
|
+
export async function updateWebhookDestination(client, webhookId, destinationId, params, options) {
|
|
96
|
+
const url = webhookApiPath('destination-update', webhookId, destinationId);
|
|
97
|
+
const resp = await withWebhookErrorHandling(() => client.put(url, params, WebhookDestinationResponseSchema, UpdateWebhookDestinationRequestSchema, undefined, buildWebhookHeaders(options?.orgId)), { webhookId, destinationId });
|
|
98
|
+
if (resp.success) {
|
|
99
|
+
return resp.data;
|
|
100
|
+
}
|
|
101
|
+
throw new WebhookError({
|
|
102
|
+
webhookId,
|
|
103
|
+
message: resp.message || 'Failed to update webhook destination',
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Delete a webhook destination.
|
|
108
|
+
*
|
|
109
|
+
* Permanently removes a destination. Webhook payloads will no longer be
|
|
110
|
+
* forwarded to this endpoint. This action cannot be undone.
|
|
111
|
+
*
|
|
112
|
+
* @param client - The API client instance
|
|
113
|
+
* @param webhookId - The webhook ID (prefixed with wh_)
|
|
114
|
+
* @param destinationId - The destination ID to delete (prefixed with whds_)
|
|
115
|
+
* @param options - Optional API options (e.g., orgId)
|
|
116
|
+
* @throws {WebhookDestinationNotFoundError} If the destination does not exist
|
|
117
|
+
* @throws {WebhookNotFoundError} If the webhook does not exist
|
|
118
|
+
* @throws {WebhookError} If the API request fails
|
|
119
|
+
*
|
|
120
|
+
* @example
|
|
121
|
+
* ```typescript
|
|
122
|
+
* await deleteWebhookDestination(client, 'wh_abc123', 'whds_def456');
|
|
123
|
+
* console.log('Destination deleted');
|
|
124
|
+
* ```
|
|
125
|
+
*/
|
|
126
|
+
export async function deleteWebhookDestination(client, webhookId, destinationId, options) {
|
|
127
|
+
const url = webhookApiPath('destination-delete', webhookId, destinationId);
|
|
128
|
+
const resp = await withWebhookErrorHandling(() => client.delete(url, DeleteWebhookDestinationResponseSchema, undefined, buildWebhookHeaders(options?.orgId)), { webhookId, destinationId });
|
|
129
|
+
if (resp.success) {
|
|
130
|
+
return;
|
|
131
|
+
}
|
|
132
|
+
throw new WebhookError({
|
|
133
|
+
webhookId,
|
|
134
|
+
message: resp.message || 'Failed to delete webhook destination',
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
//# sourceMappingURL=destinations.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"destinations.js","sourceRoot":"","sources":["../../../src/api/webhook/destinations.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module webhook
|
|
3
|
+
*
|
|
4
|
+
* Webhook API client for managing webhooks, destinations, receipts, and deliveries.
|
|
5
|
+
*
|
|
6
|
+
* This module provides a complete client for the Agentuity Webhook API, supporting:
|
|
7
|
+
* - **Webhook Management**: Create, read, update, and delete webhooks
|
|
8
|
+
* - **Destinations**: Configure URL endpoints for webhook payload forwarding
|
|
9
|
+
* - **Receipts**: View incoming webhook payloads that were received
|
|
10
|
+
* - **Deliveries**: Track delivery attempts and retry failed deliveries
|
|
11
|
+
*
|
|
12
|
+
* @example Basic Webhook Operations
|
|
13
|
+
* ```typescript
|
|
14
|
+
* import { createWebhook, createWebhookDestination, listWebhookReceipts } from '@agentuity/server';
|
|
15
|
+
*
|
|
16
|
+
* // Create a webhook
|
|
17
|
+
* const webhook = await createWebhook(client, {
|
|
18
|
+
* name: 'github-events',
|
|
19
|
+
* description: 'Receives GitHub webhook events',
|
|
20
|
+
* });
|
|
21
|
+
*
|
|
22
|
+
* // Add a destination
|
|
23
|
+
* await createWebhookDestination(client, webhook.id, {
|
|
24
|
+
* type: 'url',
|
|
25
|
+
* config: { url: 'https://api.example.com/webhook' },
|
|
26
|
+
* });
|
|
27
|
+
*
|
|
28
|
+
* // List receipts
|
|
29
|
+
* const { receipts } = await listWebhookReceipts(client, webhook.id);
|
|
30
|
+
* for (const receipt of receipts) {
|
|
31
|
+
* console.log(`Received: ${receipt.id} at ${receipt.date}`);
|
|
32
|
+
* }
|
|
33
|
+
* ```
|
|
34
|
+
*/
|
|
35
|
+
export { type CreateWebhookDestinationRequest, CreateWebhookDestinationRequestSchema, type CreateWebhookRequest, CreateWebhookRequestSchema, type ListWebhookDeliveriesRequest, ListWebhookDeliveriesRequestSchema, type ListWebhookReceiptsRequest, ListWebhookReceiptsRequestSchema, type ListWebhooksRequest, ListWebhooksRequestSchema, type PaginationRequest, PaginationRequestSchema, type UpdateWebhookDestinationRequest, UpdateWebhookDestinationRequestSchema, type UpdateWebhookRequest, UpdateWebhookRequestSchema, type Webhook, type WebhookApiOptions, type WebhookDelivery, WebhookDeliverySchema, type WebhookDeliveryStatus, WebhookDeliveryStatusSchema, type WebhookDestination, WebhookDestinationSchema, type WebhookDestinationType, WebhookDestinationTypeSchema, type WebhookReceipt, WebhookReceiptSchema, WebhookSchema, } from './types.ts';
|
|
36
|
+
export { WebhookDeliveryNotFoundError, WebhookDestinationNotFoundError, WebhookError, WebhookNotFoundError, WebhookReceiptNotFoundError, } from './util.ts';
|
|
37
|
+
export { createWebhook, DeleteWebhookResponseSchema, deleteWebhook, getWebhook, listWebhooks, WebhookResponseSchema, WebhooksListResponseSchema, updateWebhook, } from './webhooks.ts';
|
|
38
|
+
export { createWebhookDestination, DeleteWebhookDestinationResponseSchema, deleteWebhookDestination, listWebhookDestinations, updateWebhookDestination, WebhookDestinationResponseSchema, WebhookDestinationsListResponseSchema, } from './destinations.ts';
|
|
39
|
+
export { getWebhookReceipt, listWebhookReceipts, WebhookReceiptResponseSchema, WebhookReceiptsListResponseSchema, } from './receipts.ts';
|
|
40
|
+
export { listWebhookDeliveries, retryWebhookDelivery, WebhookDeliveriesListResponseSchema, WebhookDeliveryResponseSchema, } from './deliveries.ts';
|
|
41
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/api/webhook/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AAMH,OAAO,EACN,KAAK,+BAA+B,EACpC,qCAAqC,EACrC,KAAK,oBAAoB,EACzB,0BAA0B,EAC1B,KAAK,4BAA4B,EACjC,kCAAkC,EAClC,KAAK,0BAA0B,EAC/B,gCAAgC,EAChC,KAAK,mBAAmB,EACxB,yBAAyB,EACzB,KAAK,iBAAiB,EACtB,uBAAuB,EACvB,KAAK,+BAA+B,EACpC,qCAAqC,EACrC,KAAK,oBAAoB,EACzB,0BAA0B,EAC1B,KAAK,OAAO,EACZ,KAAK,iBAAiB,EACtB,KAAK,eAAe,EACpB,qBAAqB,EACrB,KAAK,qBAAqB,EAC1B,2BAA2B,EAC3B,KAAK,kBAAkB,EACvB,wBAAwB,EACxB,KAAK,sBAAsB,EAC3B,4BAA4B,EAC5B,KAAK,cAAc,EACnB,oBAAoB,EACpB,aAAa,GACb,MAAM,YAAY,CAAC;AAMpB,OAAO,EACN,4BAA4B,EAC5B,+BAA+B,EAC/B,YAAY,EACZ,oBAAoB,EACpB,2BAA2B,GAC3B,MAAM,WAAW,CAAC;AAMnB,OAAO,EACN,aAAa,EACb,2BAA2B,EAC3B,aAAa,EACb,UAAU,EACV,YAAY,EACZ,qBAAqB,EACrB,0BAA0B,EAC1B,aAAa,GACb,MAAM,eAAe,CAAC;AAMvB,OAAO,EACN,wBAAwB,EACxB,sCAAsC,EACtC,wBAAwB,EACxB,uBAAuB,EACvB,wBAAwB,EACxB,gCAAgC,EAChC,qCAAqC,GACrC,MAAM,mBAAmB,CAAC;AAM3B,OAAO,EACN,iBAAiB,EACjB,mBAAmB,EACnB,4BAA4B,EAC5B,iCAAiC,GACjC,MAAM,eAAe,CAAC;AAMvB,OAAO,EACN,qBAAqB,EACrB,oBAAoB,EACpB,mCAAmC,EACnC,6BAA6B,GAC7B,MAAM,iBAAiB,CAAC"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module webhook
|
|
3
|
+
*
|
|
4
|
+
* Webhook API client for managing webhooks, destinations, receipts, and deliveries.
|
|
5
|
+
*
|
|
6
|
+
* This module provides a complete client for the Agentuity Webhook API, supporting:
|
|
7
|
+
* - **Webhook Management**: Create, read, update, and delete webhooks
|
|
8
|
+
* - **Destinations**: Configure URL endpoints for webhook payload forwarding
|
|
9
|
+
* - **Receipts**: View incoming webhook payloads that were received
|
|
10
|
+
* - **Deliveries**: Track delivery attempts and retry failed deliveries
|
|
11
|
+
*
|
|
12
|
+
* @example Basic Webhook Operations
|
|
13
|
+
* ```typescript
|
|
14
|
+
* import { createWebhook, createWebhookDestination, listWebhookReceipts } from '@agentuity/server';
|
|
15
|
+
*
|
|
16
|
+
* // Create a webhook
|
|
17
|
+
* const webhook = await createWebhook(client, {
|
|
18
|
+
* name: 'github-events',
|
|
19
|
+
* description: 'Receives GitHub webhook events',
|
|
20
|
+
* });
|
|
21
|
+
*
|
|
22
|
+
* // Add a destination
|
|
23
|
+
* await createWebhookDestination(client, webhook.id, {
|
|
24
|
+
* type: 'url',
|
|
25
|
+
* config: { url: 'https://api.example.com/webhook' },
|
|
26
|
+
* });
|
|
27
|
+
*
|
|
28
|
+
* // List receipts
|
|
29
|
+
* const { receipts } = await listWebhookReceipts(client, webhook.id);
|
|
30
|
+
* for (const receipt of receipts) {
|
|
31
|
+
* console.log(`Received: ${receipt.id} at ${receipt.date}`);
|
|
32
|
+
* }
|
|
33
|
+
* ```
|
|
34
|
+
*/
|
|
35
|
+
// ============================================================================
|
|
36
|
+
// Types & Schemas
|
|
37
|
+
// ============================================================================
|
|
38
|
+
export { CreateWebhookDestinationRequestSchema, CreateWebhookRequestSchema, ListWebhookDeliveriesRequestSchema, ListWebhookReceiptsRequestSchema, ListWebhooksRequestSchema, PaginationRequestSchema, UpdateWebhookDestinationRequestSchema, UpdateWebhookRequestSchema, WebhookDeliverySchema, WebhookDeliveryStatusSchema, WebhookDestinationSchema, WebhookDestinationTypeSchema, WebhookReceiptSchema, WebhookSchema, } from "./types.js";
|
|
39
|
+
// ============================================================================
|
|
40
|
+
// Errors
|
|
41
|
+
// ============================================================================
|
|
42
|
+
export { WebhookDeliveryNotFoundError, WebhookDestinationNotFoundError, WebhookError, WebhookNotFoundError, WebhookReceiptNotFoundError, } from "./util.js";
|
|
43
|
+
// ============================================================================
|
|
44
|
+
// Webhook Operations
|
|
45
|
+
// ============================================================================
|
|
46
|
+
export { createWebhook, DeleteWebhookResponseSchema, deleteWebhook, getWebhook, listWebhooks, WebhookResponseSchema, WebhooksListResponseSchema, updateWebhook, } from "./webhooks.js";
|
|
47
|
+
// ============================================================================
|
|
48
|
+
// Destination Operations
|
|
49
|
+
// ============================================================================
|
|
50
|
+
export { createWebhookDestination, DeleteWebhookDestinationResponseSchema, deleteWebhookDestination, listWebhookDestinations, updateWebhookDestination, WebhookDestinationResponseSchema, WebhookDestinationsListResponseSchema, } from "./destinations.js";
|
|
51
|
+
// ============================================================================
|
|
52
|
+
// Receipt Operations
|
|
53
|
+
// ============================================================================
|
|
54
|
+
export { getWebhookReceipt, listWebhookReceipts, WebhookReceiptResponseSchema, WebhookReceiptsListResponseSchema, } from "./receipts.js";
|
|
55
|
+
// ============================================================================
|
|
56
|
+
// Delivery Operations
|
|
57
|
+
// ============================================================================
|
|
58
|
+
export { listWebhookDeliveries, retryWebhookDelivery, WebhookDeliveriesListResponseSchema, WebhookDeliveryResponseSchema, } from "./deliveries.js";
|
|
59
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/api/webhook/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AAEH,+EAA+E;AAC/E,kBAAkB;AAClB,+EAA+E;AAE/E,OAAO,EAEN,qCAAqC,EAErC,0BAA0B,EAE1B,kCAAkC,EAElC,gCAAgC,EAEhC,yBAAyB,EAEzB,uBAAuB,EAEvB,qCAAqC,EAErC,0BAA0B,EAI1B,qBAAqB,EAErB,2BAA2B,EAE3B,wBAAwB,EAExB,4BAA4B,EAE5B,oBAAoB,EACpB,aAAa,GACb,MAAM,YAAY,CAAC;AAEpB,+EAA+E;AAC/E,SAAS;AACT,+EAA+E;AAE/E,OAAO,EACN,4BAA4B,EAC5B,+BAA+B,EAC/B,YAAY,EACZ,oBAAoB,EACpB,2BAA2B,GAC3B,MAAM,WAAW,CAAC;AAEnB,+EAA+E;AAC/E,qBAAqB;AACrB,+EAA+E;AAE/E,OAAO,EACN,aAAa,EACb,2BAA2B,EAC3B,aAAa,EACb,UAAU,EACV,YAAY,EACZ,qBAAqB,EACrB,0BAA0B,EAC1B,aAAa,GACb,MAAM,eAAe,CAAC;AAEvB,+EAA+E;AAC/E,yBAAyB;AACzB,+EAA+E;AAE/E,OAAO,EACN,wBAAwB,EACxB,sCAAsC,EACtC,wBAAwB,EACxB,uBAAuB,EACvB,wBAAwB,EACxB,gCAAgC,EAChC,qCAAqC,GACrC,MAAM,mBAAmB,CAAC;AAE3B,+EAA+E;AAC/E,qBAAqB;AACrB,+EAA+E;AAE/E,OAAO,EACN,iBAAiB,EACjB,mBAAmB,EACnB,4BAA4B,EAC5B,iCAAiC,GACjC,MAAM,eAAe,CAAC;AAEvB,+EAA+E;AAC/E,sBAAsB;AACtB,+EAA+E;AAE/E,OAAO,EACN,qBAAqB,EACrB,oBAAoB,EACpB,mCAAmC,EACnC,6BAA6B,GAC7B,MAAM,iBAAiB,CAAC"}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { type APIClient } from '../api.ts';
|
|
3
|
+
import { type ListWebhookReceiptsRequest, type WebhookApiOptions, type WebhookReceipt } from './types.ts';
|
|
4
|
+
export declare const WebhookReceiptResponseSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
5
|
+
success: z.ZodLiteral<false>;
|
|
6
|
+
message: z.ZodString;
|
|
7
|
+
code: z.ZodOptional<z.ZodString>;
|
|
8
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
9
|
+
success: z.ZodLiteral<true>;
|
|
10
|
+
data: z.ZodObject<{
|
|
11
|
+
id: z.ZodString;
|
|
12
|
+
date: z.ZodString;
|
|
13
|
+
webhook_id: z.ZodString;
|
|
14
|
+
headers: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
15
|
+
payload: z.ZodUnknown;
|
|
16
|
+
}, z.core.$strip>;
|
|
17
|
+
}, z.core.$strip>], "success">;
|
|
18
|
+
export declare const WebhookReceiptsListResponseSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
19
|
+
success: z.ZodLiteral<false>;
|
|
20
|
+
message: z.ZodString;
|
|
21
|
+
code: z.ZodOptional<z.ZodString>;
|
|
22
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
23
|
+
success: z.ZodLiteral<true>;
|
|
24
|
+
data: z.ZodArray<z.ZodObject<{
|
|
25
|
+
id: z.ZodString;
|
|
26
|
+
date: z.ZodString;
|
|
27
|
+
webhook_id: z.ZodString;
|
|
28
|
+
headers: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
29
|
+
payload: z.ZodUnknown;
|
|
30
|
+
}, z.core.$strip>>;
|
|
31
|
+
}, z.core.$strip>], "success">;
|
|
32
|
+
/**
|
|
33
|
+
* List receipts for a webhook with optional pagination.
|
|
34
|
+
*
|
|
35
|
+
* Receipts represent incoming webhook payloads that were received.
|
|
36
|
+
*
|
|
37
|
+
* @param client - The API client instance
|
|
38
|
+
* @param webhookId - The webhook ID (prefixed with wh_)
|
|
39
|
+
* @param params - Optional pagination parameters
|
|
40
|
+
* @param options - Optional API options (e.g., orgId)
|
|
41
|
+
* @returns Object containing the list of receipts
|
|
42
|
+
* @throws {WebhookNotFoundError} If the webhook does not exist
|
|
43
|
+
* @throws {WebhookError} If the API request fails
|
|
44
|
+
*
|
|
45
|
+
* @example
|
|
46
|
+
* ```typescript
|
|
47
|
+
* const { receipts } = await listWebhookReceipts(client, 'wh_abc123', { limit: 10 });
|
|
48
|
+
* for (const receipt of receipts) {
|
|
49
|
+
* console.log(`Receipt ${receipt.id}: received at ${receipt.date}`);
|
|
50
|
+
* }
|
|
51
|
+
* ```
|
|
52
|
+
*/
|
|
53
|
+
export declare function listWebhookReceipts(client: APIClient, webhookId: string, params?: ListWebhookReceiptsRequest, options?: WebhookApiOptions): Promise<{
|
|
54
|
+
receipts: WebhookReceipt[];
|
|
55
|
+
}>;
|
|
56
|
+
/**
|
|
57
|
+
* Get a specific receipt for a webhook.
|
|
58
|
+
*
|
|
59
|
+
* Retrieves the full receipt details including headers and payload.
|
|
60
|
+
*
|
|
61
|
+
* @param client - The API client instance
|
|
62
|
+
* @param webhookId - The webhook ID (prefixed with wh_)
|
|
63
|
+
* @param receiptId - The receipt ID (prefixed with whrc_)
|
|
64
|
+
* @param options - Optional API options (e.g., orgId)
|
|
65
|
+
* @returns The receipt details
|
|
66
|
+
* @throws {WebhookReceiptNotFoundError} If the receipt does not exist
|
|
67
|
+
* @throws {WebhookNotFoundError} If the webhook does not exist
|
|
68
|
+
* @throws {WebhookError} If the API request fails
|
|
69
|
+
*
|
|
70
|
+
* @example
|
|
71
|
+
* ```typescript
|
|
72
|
+
* const receipt = await getWebhookReceipt(client, 'wh_abc123', 'whrc_def456');
|
|
73
|
+
* console.log(`Receipt payload:`, receipt.payload);
|
|
74
|
+
* ```
|
|
75
|
+
*/
|
|
76
|
+
export declare function getWebhookReceipt(client: APIClient, webhookId: string, receiptId: string, options?: WebhookApiOptions): Promise<WebhookReceipt>;
|
|
77
|
+
//# sourceMappingURL=receipts.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"receipts.d.ts","sourceRoot":"","sources":["../../../src/api/webhook/receipts.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,KAAK,SAAS,EAAqB,MAAM,WAAW,CAAC;AAC9D,OAAO,EACN,KAAK,0BAA0B,EAC/B,KAAK,iBAAiB,EACtB,KAAK,cAAc,EAEnB,MAAM,YAAY,CAAC;AASpB,eAAO,MAAM,4BAA4B;;;;;;;;;;;;;8BAA0C,CAAC;AACpF,eAAO,MAAM,iCAAiC;;;;;;;;;;;;;8BAAmD,CAAC;AAElG;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAsB,mBAAmB,CACxC,MAAM,EAAE,SAAS,EACjB,SAAS,EAAE,MAAM,EACjB,MAAM,CAAC,EAAE,0BAA0B,EACnC,OAAO,CAAC,EAAE,iBAAiB,GACzB,OAAO,CAAC;IAAE,QAAQ,EAAE,cAAc,EAAE,CAAA;CAAE,CAAC,CA8BzC;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAsB,iBAAiB,CACtC,MAAM,EAAE,SAAS,EACjB,SAAS,EAAE,MAAM,EACjB,SAAS,EAAE,MAAM,EACjB,OAAO,CAAC,EAAE,iBAAiB,GACzB,OAAO,CAAC,cAAc,CAAC,CAqBzB"}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { APIResponseSchema } from "../api.js";
|
|
3
|
+
import { WebhookReceiptSchema, } from "./types.js";
|
|
4
|
+
import { buildWebhookHeaders, WebhookError, webhookApiPath, webhookApiPathWithQuery, withWebhookErrorHandling, } from "./util.js";
|
|
5
|
+
export const WebhookReceiptResponseSchema = APIResponseSchema(WebhookReceiptSchema);
|
|
6
|
+
export const WebhookReceiptsListResponseSchema = APIResponseSchema(z.array(WebhookReceiptSchema));
|
|
7
|
+
/**
|
|
8
|
+
* List receipts for a webhook with optional pagination.
|
|
9
|
+
*
|
|
10
|
+
* Receipts represent incoming webhook payloads that were received.
|
|
11
|
+
*
|
|
12
|
+
* @param client - The API client instance
|
|
13
|
+
* @param webhookId - The webhook ID (prefixed with wh_)
|
|
14
|
+
* @param params - Optional pagination parameters
|
|
15
|
+
* @param options - Optional API options (e.g., orgId)
|
|
16
|
+
* @returns Object containing the list of receipts
|
|
17
|
+
* @throws {WebhookNotFoundError} If the webhook does not exist
|
|
18
|
+
* @throws {WebhookError} If the API request fails
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* ```typescript
|
|
22
|
+
* const { receipts } = await listWebhookReceipts(client, 'wh_abc123', { limit: 10 });
|
|
23
|
+
* for (const receipt of receipts) {
|
|
24
|
+
* console.log(`Receipt ${receipt.id}: received at ${receipt.date}`);
|
|
25
|
+
* }
|
|
26
|
+
* ```
|
|
27
|
+
*/
|
|
28
|
+
export async function listWebhookReceipts(client, webhookId, params, options) {
|
|
29
|
+
const searchParams = new URLSearchParams();
|
|
30
|
+
if (params?.limit !== undefined) {
|
|
31
|
+
searchParams.set('limit', String(params.limit));
|
|
32
|
+
}
|
|
33
|
+
if (params?.offset !== undefined) {
|
|
34
|
+
searchParams.set('offset', String(params.offset));
|
|
35
|
+
}
|
|
36
|
+
const queryString = searchParams.toString();
|
|
37
|
+
const url = webhookApiPathWithQuery('receipt-list', queryString || undefined, webhookId);
|
|
38
|
+
const resp = await withWebhookErrorHandling(() => client.get(url, WebhookReceiptsListResponseSchema, undefined, buildWebhookHeaders(options?.orgId)), { webhookId });
|
|
39
|
+
if (resp.success) {
|
|
40
|
+
return { receipts: resp.data };
|
|
41
|
+
}
|
|
42
|
+
throw new WebhookError({
|
|
43
|
+
webhookId,
|
|
44
|
+
message: resp.message || 'Failed to list webhook receipts',
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Get a specific receipt for a webhook.
|
|
49
|
+
*
|
|
50
|
+
* Retrieves the full receipt details including headers and payload.
|
|
51
|
+
*
|
|
52
|
+
* @param client - The API client instance
|
|
53
|
+
* @param webhookId - The webhook ID (prefixed with wh_)
|
|
54
|
+
* @param receiptId - The receipt ID (prefixed with whrc_)
|
|
55
|
+
* @param options - Optional API options (e.g., orgId)
|
|
56
|
+
* @returns The receipt details
|
|
57
|
+
* @throws {WebhookReceiptNotFoundError} If the receipt does not exist
|
|
58
|
+
* @throws {WebhookNotFoundError} If the webhook does not exist
|
|
59
|
+
* @throws {WebhookError} If the API request fails
|
|
60
|
+
*
|
|
61
|
+
* @example
|
|
62
|
+
* ```typescript
|
|
63
|
+
* const receipt = await getWebhookReceipt(client, 'wh_abc123', 'whrc_def456');
|
|
64
|
+
* console.log(`Receipt payload:`, receipt.payload);
|
|
65
|
+
* ```
|
|
66
|
+
*/
|
|
67
|
+
export async function getWebhookReceipt(client, webhookId, receiptId, options) {
|
|
68
|
+
const url = webhookApiPath('receipt-get', webhookId, receiptId);
|
|
69
|
+
const resp = await withWebhookErrorHandling(() => client.get(url, WebhookReceiptResponseSchema, undefined, buildWebhookHeaders(options?.orgId)), { webhookId, receiptId });
|
|
70
|
+
if (resp.success) {
|
|
71
|
+
return resp.data;
|
|
72
|
+
}
|
|
73
|
+
throw new WebhookError({
|
|
74
|
+
webhookId,
|
|
75
|
+
message: resp.message || 'Failed to get webhook receipt',
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
//# sourceMappingURL=receipts.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"receipts.js","sourceRoot":"","sources":["../../../src/api/webhook/receipts.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAkB,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAC9D,OAAO,EAIN,oBAAoB,GACpB,MAAM,YAAY,CAAC;AACpB,OAAO,EACN,mBAAmB,EACnB,YAAY,EACZ,cAAc,EACd,uBAAuB,EACvB,wBAAwB,GACxB,MAAM,WAAW,CAAC;AAEnB,MAAM,CAAC,MAAM,4BAA4B,GAAG,iBAAiB,CAAC,oBAAoB,CAAC,CAAC;AACpF,MAAM,CAAC,MAAM,iCAAiC,GAAG,iBAAiB,CAAC,CAAC,CAAC,KAAK,CAAC,oBAAoB,CAAC,CAAC,CAAC;AAElG;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,CAAC,KAAK,UAAU,mBAAmB,CACxC,MAAiB,EACjB,SAAiB,EACjB,MAAmC,EACnC,OAA2B;IAE3B,MAAM,YAAY,GAAG,IAAI,eAAe,EAAE,CAAC;IAC3C,IAAI,MAAM,EAAE,KAAK,KAAK,SAAS,EAAE,CAAC;QACjC,YAAY,CAAC,GAAG,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;IACjD,CAAC;IACD,IAAI,MAAM,EAAE,MAAM,KAAK,SAAS,EAAE,CAAC;QAClC,YAAY,CAAC,GAAG,CAAC,QAAQ,EAAE,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC;IACnD,CAAC;IAED,MAAM,WAAW,GAAG,YAAY,CAAC,QAAQ,EAAE,CAAC;IAC5C,MAAM,GAAG,GAAG,uBAAuB,CAAC,cAAc,EAAE,WAAW,IAAI,SAAS,EAAE,SAAS,CAAC,CAAC;IACzF,MAAM,IAAI,GAAG,MAAM,wBAAwB,CAC1C,GAAG,EAAE,CACJ,MAAM,CAAC,GAAG,CACT,GAAG,EACH,iCAAiC,EACjC,SAAS,EACT,mBAAmB,CAAC,OAAO,EAAE,KAAK,CAAC,CACnC,EACF,EAAE,SAAS,EAAE,CACb,CAAC;IAEF,IAAI,IAAI,CAAC,OAAO,EAAE,CAAC;QAClB,OAAO,EAAE,QAAQ,EAAE,IAAI,CAAC,IAAI,EAAE,CAAC;IAChC,CAAC;IAED,MAAM,IAAI,YAAY,CAAC;QACtB,SAAS;QACT,OAAO,EAAE,IAAI,CAAC,OAAO,IAAI,iCAAiC;KAC1D,CAAC,CAAC;AACJ,CAAC;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,CAAC,KAAK,UAAU,iBAAiB,CACtC,MAAiB,EACjB,SAAiB,EACjB,SAAiB,EACjB,OAA2B;IAE3B,MAAM,GAAG,GAAG,cAAc,CAAC,aAAa,EAAE,SAAS,EAAE,SAAS,CAAC,CAAC;IAChE,MAAM,IAAI,GAAG,MAAM,wBAAwB,CAC1C,GAAG,EAAE,CACJ,MAAM,CAAC,GAAG,CACT,GAAG,EACH,4BAA4B,EAC5B,SAAS,EACT,mBAAmB,CAAC,OAAO,EAAE,KAAK,CAAC,CACnC,EACF,EAAE,SAAS,EAAE,SAAS,EAAE,CACxB,CAAC;IAEF,IAAI,IAAI,CAAC,OAAO,EAAE,CAAC;QAClB,OAAO,IAAI,CAAC,IAAI,CAAC;IAClB,CAAC;IAED,MAAM,IAAI,YAAY,CAAC;QACtB,SAAS;QACT,OAAO,EAAE,IAAI,CAAC,OAAO,IAAI,+BAA+B;KACxD,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,249 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
/**
|
|
3
|
+
* Webhook destination type schema.
|
|
4
|
+
*
|
|
5
|
+
* Currently only 'url' destinations are supported.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```typescript
|
|
9
|
+
* const destType = WebhookDestinationTypeSchema.parse('url');
|
|
10
|
+
* ```
|
|
11
|
+
*/
|
|
12
|
+
export declare const WebhookDestinationTypeSchema: z.ZodEnum<{
|
|
13
|
+
url: "url";
|
|
14
|
+
}>;
|
|
15
|
+
/**
|
|
16
|
+
* Webhook destination type.
|
|
17
|
+
*/
|
|
18
|
+
export type WebhookDestinationType = z.infer<typeof WebhookDestinationTypeSchema>;
|
|
19
|
+
/**
|
|
20
|
+
* Webhook delivery status schema.
|
|
21
|
+
*
|
|
22
|
+
* - `pending`: Delivery is queued and waiting to be sent.
|
|
23
|
+
* - `success`: Delivery was completed successfully.
|
|
24
|
+
* - `failed`: Delivery failed after all retry attempts.
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* ```typescript
|
|
28
|
+
* const status = WebhookDeliveryStatusSchema.parse('success');
|
|
29
|
+
* ```
|
|
30
|
+
*/
|
|
31
|
+
export declare const WebhookDeliveryStatusSchema: z.ZodEnum<{
|
|
32
|
+
success: "success";
|
|
33
|
+
pending: "pending";
|
|
34
|
+
failed: "failed";
|
|
35
|
+
}>;
|
|
36
|
+
/**
|
|
37
|
+
* Webhook delivery status type.
|
|
38
|
+
*/
|
|
39
|
+
export type WebhookDeliveryStatus = z.infer<typeof WebhookDeliveryStatusSchema>;
|
|
40
|
+
/**
|
|
41
|
+
* Webhook schema representing a webhook endpoint.
|
|
42
|
+
*
|
|
43
|
+
* @example
|
|
44
|
+
* ```typescript
|
|
45
|
+
* const webhook = await getWebhook(client, 'wh_abc123');
|
|
46
|
+
* console.log(`Webhook: ${webhook.name} (${webhook.id})`);
|
|
47
|
+
* ```
|
|
48
|
+
*/
|
|
49
|
+
export declare const WebhookSchema: z.ZodObject<{
|
|
50
|
+
id: z.ZodString;
|
|
51
|
+
created_at: z.ZodString;
|
|
52
|
+
updated_at: z.ZodString;
|
|
53
|
+
created_by: z.ZodString;
|
|
54
|
+
name: z.ZodString;
|
|
55
|
+
description: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
56
|
+
url: z.ZodOptional<z.ZodString>;
|
|
57
|
+
}, z.core.$strip>;
|
|
58
|
+
/**
|
|
59
|
+
* Webhook type.
|
|
60
|
+
*/
|
|
61
|
+
export type Webhook = z.infer<typeof WebhookSchema>;
|
|
62
|
+
/**
|
|
63
|
+
* Webhook destination schema representing a delivery target for webhook events.
|
|
64
|
+
*
|
|
65
|
+
* Destinations define where incoming webhook payloads are forwarded to.
|
|
66
|
+
*
|
|
67
|
+
* @example
|
|
68
|
+
* ```typescript
|
|
69
|
+
* const destinations = await listWebhookDestinations(client, 'wh_abc123');
|
|
70
|
+
* for (const dest of destinations) {
|
|
71
|
+
* console.log(`Destination ${dest.id}: type=${dest.type}`);
|
|
72
|
+
* }
|
|
73
|
+
* ```
|
|
74
|
+
*/
|
|
75
|
+
export declare const WebhookDestinationSchema: z.ZodObject<{
|
|
76
|
+
id: z.ZodString;
|
|
77
|
+
created_at: z.ZodString;
|
|
78
|
+
updated_at: z.ZodString;
|
|
79
|
+
created_by: z.ZodString;
|
|
80
|
+
webhook_id: z.ZodString;
|
|
81
|
+
type: z.ZodEnum<{
|
|
82
|
+
url: "url";
|
|
83
|
+
}>;
|
|
84
|
+
config: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
85
|
+
}, z.core.$strip>;
|
|
86
|
+
/**
|
|
87
|
+
* Webhook destination type.
|
|
88
|
+
*/
|
|
89
|
+
export type WebhookDestination = z.infer<typeof WebhookDestinationSchema>;
|
|
90
|
+
/**
|
|
91
|
+
* Webhook receipt schema representing an incoming webhook payload that was received.
|
|
92
|
+
*
|
|
93
|
+
* Receipts capture the raw payload and headers of each incoming webhook request.
|
|
94
|
+
*
|
|
95
|
+
* @example
|
|
96
|
+
* ```typescript
|
|
97
|
+
* const receipt = await getWebhookReceipt(client, 'wh_abc123', 'whrc_def456');
|
|
98
|
+
* console.log(`Receipt ${receipt.id}: received at ${receipt.date}`);
|
|
99
|
+
* ```
|
|
100
|
+
*/
|
|
101
|
+
export declare const WebhookReceiptSchema: z.ZodObject<{
|
|
102
|
+
id: z.ZodString;
|
|
103
|
+
date: z.ZodString;
|
|
104
|
+
webhook_id: z.ZodString;
|
|
105
|
+
headers: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
106
|
+
payload: z.ZodUnknown;
|
|
107
|
+
}, z.core.$strip>;
|
|
108
|
+
/**
|
|
109
|
+
* Webhook receipt type.
|
|
110
|
+
*/
|
|
111
|
+
export type WebhookReceipt = z.infer<typeof WebhookReceiptSchema>;
|
|
112
|
+
/**
|
|
113
|
+
* Webhook delivery schema representing a delivery attempt to a destination.
|
|
114
|
+
*
|
|
115
|
+
* Deliveries track the status and result of forwarding a received webhook
|
|
116
|
+
* payload to a configured destination.
|
|
117
|
+
*
|
|
118
|
+
* @example
|
|
119
|
+
* ```typescript
|
|
120
|
+
* const deliveries = await listWebhookDeliveries(client, 'wh_abc123');
|
|
121
|
+
* for (const delivery of deliveries) {
|
|
122
|
+
* console.log(`Delivery ${delivery.id}: ${delivery.status}`);
|
|
123
|
+
* }
|
|
124
|
+
* ```
|
|
125
|
+
*/
|
|
126
|
+
export declare const WebhookDeliverySchema: z.ZodObject<{
|
|
127
|
+
id: z.ZodString;
|
|
128
|
+
date: z.ZodString;
|
|
129
|
+
webhook_id: z.ZodString;
|
|
130
|
+
webhook_destination_id: z.ZodString;
|
|
131
|
+
webhook_receipt_id: z.ZodString;
|
|
132
|
+
status: z.ZodEnum<{
|
|
133
|
+
success: "success";
|
|
134
|
+
pending: "pending";
|
|
135
|
+
failed: "failed";
|
|
136
|
+
}>;
|
|
137
|
+
retries: z.ZodNumber;
|
|
138
|
+
error: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
139
|
+
response: z.ZodOptional<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
|
|
140
|
+
}, z.core.$strip>;
|
|
141
|
+
/**
|
|
142
|
+
* Webhook delivery type.
|
|
143
|
+
*/
|
|
144
|
+
export type WebhookDelivery = z.infer<typeof WebhookDeliverySchema>;
|
|
145
|
+
/**
|
|
146
|
+
* Common options for webhook API calls.
|
|
147
|
+
*
|
|
148
|
+
* Used to pass organization context when calling from CLI or other
|
|
149
|
+
* contexts where the org is not implicit in the authentication token.
|
|
150
|
+
*/
|
|
151
|
+
export interface WebhookApiOptions {
|
|
152
|
+
/**
|
|
153
|
+
* Organization ID for the request.
|
|
154
|
+
* Required when using user authentication (CLI) instead of SDK key.
|
|
155
|
+
*/
|
|
156
|
+
orgId?: string;
|
|
157
|
+
}
|
|
158
|
+
/**
|
|
159
|
+
* Request schema for creating a new webhook.
|
|
160
|
+
*
|
|
161
|
+
* @example
|
|
162
|
+
* ```typescript
|
|
163
|
+
* const request: CreateWebhookRequest = {
|
|
164
|
+
* name: 'github-events',
|
|
165
|
+
* description: 'Receives GitHub webhook events',
|
|
166
|
+
* };
|
|
167
|
+
* ```
|
|
168
|
+
*/
|
|
169
|
+
export declare const CreateWebhookRequestSchema: z.ZodObject<{
|
|
170
|
+
name: z.ZodString;
|
|
171
|
+
description: z.ZodOptional<z.ZodString>;
|
|
172
|
+
}, z.core.$strip>;
|
|
173
|
+
/** Request type for creating a webhook. */
|
|
174
|
+
export type CreateWebhookRequest = z.infer<typeof CreateWebhookRequestSchema>;
|
|
175
|
+
/**
|
|
176
|
+
* Request schema for updating an existing webhook.
|
|
177
|
+
*
|
|
178
|
+
* @example
|
|
179
|
+
* ```typescript
|
|
180
|
+
* const request: UpdateWebhookRequest = {
|
|
181
|
+
* name: 'github-events-v2',
|
|
182
|
+
* description: 'Updated description',
|
|
183
|
+
* };
|
|
184
|
+
* ```
|
|
185
|
+
*/
|
|
186
|
+
export declare const UpdateWebhookRequestSchema: z.ZodObject<{
|
|
187
|
+
name: z.ZodString;
|
|
188
|
+
description: z.ZodOptional<z.ZodString>;
|
|
189
|
+
}, z.core.$strip>;
|
|
190
|
+
/** Request type for updating a webhook. */
|
|
191
|
+
export type UpdateWebhookRequest = z.infer<typeof UpdateWebhookRequestSchema>;
|
|
192
|
+
/**
|
|
193
|
+
* Request schema for creating a webhook destination.
|
|
194
|
+
*
|
|
195
|
+
* @example
|
|
196
|
+
* ```typescript
|
|
197
|
+
* const request: CreateWebhookDestinationRequest = {
|
|
198
|
+
* type: 'url',
|
|
199
|
+
* config: { url: 'https://api.example.com/webhook' },
|
|
200
|
+
* };
|
|
201
|
+
* ```
|
|
202
|
+
*/
|
|
203
|
+
export declare const CreateWebhookDestinationRequestSchema: z.ZodObject<{
|
|
204
|
+
type: z.ZodEnum<{
|
|
205
|
+
url: "url";
|
|
206
|
+
}>;
|
|
207
|
+
config: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
208
|
+
}, z.core.$strip>;
|
|
209
|
+
/** Request type for creating a webhook destination. */
|
|
210
|
+
export type CreateWebhookDestinationRequest = z.infer<typeof CreateWebhookDestinationRequestSchema>;
|
|
211
|
+
/**
|
|
212
|
+
* Request schema for updating a webhook destination.
|
|
213
|
+
*
|
|
214
|
+
* @example
|
|
215
|
+
* ```typescript
|
|
216
|
+
* const request: UpdateWebhookDestinationRequest = {
|
|
217
|
+
* config: { url: 'https://api.example.com/webhook/v2' },
|
|
218
|
+
* };
|
|
219
|
+
* ```
|
|
220
|
+
*/
|
|
221
|
+
export declare const UpdateWebhookDestinationRequestSchema: z.ZodObject<{
|
|
222
|
+
config: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
223
|
+
}, z.core.$strip>;
|
|
224
|
+
/** Request type for updating a webhook destination. */
|
|
225
|
+
export type UpdateWebhookDestinationRequest = z.infer<typeof UpdateWebhookDestinationRequestSchema>;
|
|
226
|
+
export declare const PaginationRequestSchema: z.ZodObject<{
|
|
227
|
+
limit: z.ZodOptional<z.ZodNumber>;
|
|
228
|
+
offset: z.ZodOptional<z.ZodNumber>;
|
|
229
|
+
}, z.core.$strip>;
|
|
230
|
+
export type PaginationRequest = z.infer<typeof PaginationRequestSchema>;
|
|
231
|
+
export declare const ListWebhooksRequestSchema: z.ZodObject<{
|
|
232
|
+
limit: z.ZodOptional<z.ZodNumber>;
|
|
233
|
+
offset: z.ZodOptional<z.ZodNumber>;
|
|
234
|
+
}, z.core.$strip>;
|
|
235
|
+
/** Request type for listing webhooks. */
|
|
236
|
+
export type ListWebhooksRequest = z.infer<typeof ListWebhooksRequestSchema>;
|
|
237
|
+
export declare const ListWebhookReceiptsRequestSchema: z.ZodObject<{
|
|
238
|
+
limit: z.ZodOptional<z.ZodNumber>;
|
|
239
|
+
offset: z.ZodOptional<z.ZodNumber>;
|
|
240
|
+
}, z.core.$strip>;
|
|
241
|
+
/** Request type for listing webhook receipts. */
|
|
242
|
+
export type ListWebhookReceiptsRequest = z.infer<typeof ListWebhookReceiptsRequestSchema>;
|
|
243
|
+
export declare const ListWebhookDeliveriesRequestSchema: z.ZodObject<{
|
|
244
|
+
limit: z.ZodOptional<z.ZodNumber>;
|
|
245
|
+
offset: z.ZodOptional<z.ZodNumber>;
|
|
246
|
+
}, z.core.$strip>;
|
|
247
|
+
/** Request type for listing webhook deliveries. */
|
|
248
|
+
export type ListWebhookDeliveriesRequest = z.infer<typeof ListWebhookDeliveriesRequestSchema>;
|
|
249
|
+
//# sourceMappingURL=types.d.ts.map
|