@foxnose/sdk 0.7.0 → 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +65 -0
- package/dist/index.cjs +251 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +344 -3
- package/dist/index.d.ts +344 -3
- package/dist/index.js +246 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -93,8 +93,8 @@ interface RetryConfig {
|
|
|
93
93
|
methods: readonly string[];
|
|
94
94
|
}
|
|
95
95
|
declare const DEFAULT_RETRY_CONFIG: Readonly<RetryConfig>;
|
|
96
|
-
declare const SDK_VERSION = "0.
|
|
97
|
-
declare const DEFAULT_USER_AGENT = "foxnose-sdk-js/0.
|
|
96
|
+
declare const SDK_VERSION = "0.8.0";
|
|
97
|
+
declare const DEFAULT_USER_AGENT = "foxnose-sdk-js/0.8.0";
|
|
98
98
|
/**
|
|
99
99
|
* General transport-level configuration shared by all clients.
|
|
100
100
|
*/
|
|
@@ -289,6 +289,52 @@ declare class ContentValidationFailedError extends FoxnoseAPIError {
|
|
|
289
289
|
declare class UpstreamError extends FoxnoseAPIError {
|
|
290
290
|
constructor(options: APIErrorOptions);
|
|
291
291
|
}
|
|
292
|
+
/**
|
|
293
|
+
* Raised on HTTP 404 `webhook_endpoint_not_found`: no endpoint with this id in the
|
|
294
|
+
* environment.
|
|
295
|
+
*/
|
|
296
|
+
declare class WebhookEndpointNotFoundError extends FoxnoseAPIError {
|
|
297
|
+
constructor(options: APIErrorOptions);
|
|
298
|
+
}
|
|
299
|
+
/**
|
|
300
|
+
* Raised on HTTP 404 `webhook_event_not_found`: no such event in the environment
|
|
301
|
+
* within the last 30 days.
|
|
302
|
+
*/
|
|
303
|
+
declare class WebhookEventNotFoundError extends FoxnoseAPIError {
|
|
304
|
+
constructor(options: APIErrorOptions);
|
|
305
|
+
}
|
|
306
|
+
/**
|
|
307
|
+
* Raised on HTTP 409 `limit_exceeded`: the environment already has the most webhook
|
|
308
|
+
* endpoints it can have (20).
|
|
309
|
+
*/
|
|
310
|
+
declare class WebhookEndpointLimitExceededError extends FoxnoseAPIError {
|
|
311
|
+
constructor(options: APIErrorOptions);
|
|
312
|
+
}
|
|
313
|
+
/**
|
|
314
|
+
* Raised on HTTP 409 `endpoint_not_active`: the endpoint is paused, disabled or
|
|
315
|
+
* deleted, so a test event, a recovery or a redelivery cannot go to it.
|
|
316
|
+
*/
|
|
317
|
+
declare class WebhookEndpointNotActiveError extends FoxnoseAPIError {
|
|
318
|
+
/** The endpoint's state (`paused`, `disabled` or `deleted`) when the call named it. */
|
|
319
|
+
readonly reason?: string;
|
|
320
|
+
/** Endpoints a redelivery without `endpoint_id` passed over, each with `endpoint_id` and `reason`. */
|
|
321
|
+
readonly skipped: unknown[];
|
|
322
|
+
constructor(options: APIErrorOptions & {
|
|
323
|
+
reason?: string;
|
|
324
|
+
skipped?: unknown[];
|
|
325
|
+
});
|
|
326
|
+
}
|
|
327
|
+
/**
|
|
328
|
+
* Raised on HTTP 409 `endpoint_not_subscribed`: the endpoint's current event types or
|
|
329
|
+
* collection filter do not cover the event.
|
|
330
|
+
*/
|
|
331
|
+
declare class WebhookEndpointNotSubscribedError extends FoxnoseAPIError {
|
|
332
|
+
/** Endpoints a redelivery without `endpoint_id` passed over, each with `endpoint_id` and `reason`. */
|
|
333
|
+
readonly skipped: unknown[];
|
|
334
|
+
constructor(options: APIErrorOptions & {
|
|
335
|
+
skipped?: unknown[];
|
|
336
|
+
});
|
|
337
|
+
}
|
|
292
338
|
/**
|
|
293
339
|
* Raised when authentication headers cannot be generated.
|
|
294
340
|
*/
|
|
@@ -1323,6 +1369,211 @@ type APIRef = string | APIInfo;
|
|
|
1323
1369
|
declare function resolveKey(value: string | {
|
|
1324
1370
|
key: string;
|
|
1325
1371
|
}): string;
|
|
1372
|
+
/** What an endpoint receives: ids and links only, or a snapshot of the content. */
|
|
1373
|
+
type WebhookPayloadMode = 'references' | 'content';
|
|
1374
|
+
/** `active`, `paused`, or `disabled` by FoxNose after `410 Gone` or five days of failures. */
|
|
1375
|
+
type WebhookEndpointStatus = 'active' | 'paused' | 'disabled';
|
|
1376
|
+
/** Attempts of the last 24 hours: all of them and those answered with `2xx`. */
|
|
1377
|
+
interface WebhookStats24h {
|
|
1378
|
+
attempts: number;
|
|
1379
|
+
succeeded: number;
|
|
1380
|
+
}
|
|
1381
|
+
/**
|
|
1382
|
+
* A webhook endpoint. It never carries the signing secret. `stats_24h` is set on
|
|
1383
|
+
* the items of a list only.
|
|
1384
|
+
*/
|
|
1385
|
+
interface WebhookEndpoint {
|
|
1386
|
+
id: string;
|
|
1387
|
+
url: string;
|
|
1388
|
+
description: string;
|
|
1389
|
+
event_types: string[];
|
|
1390
|
+
collection_keys: string[];
|
|
1391
|
+
payload_mode: WebhookPayloadMode;
|
|
1392
|
+
version: number;
|
|
1393
|
+
status: WebhookEndpointStatus;
|
|
1394
|
+
/** `gone` (it answered `410 Gone`) or `failing` (no success for 5 days). */
|
|
1395
|
+
disabled_reason: string | null;
|
|
1396
|
+
failing_since: string | null;
|
|
1397
|
+
disabled_at: string | null;
|
|
1398
|
+
created_at: string;
|
|
1399
|
+
updated_at: string;
|
|
1400
|
+
stats_24h?: WebhookStats24h;
|
|
1401
|
+
}
|
|
1402
|
+
type WebhookEndpointList = PaginatedResponse<WebhookEndpoint>;
|
|
1403
|
+
/**
|
|
1404
|
+
* The answer to creating an endpoint: the endpoint and its signing secret.
|
|
1405
|
+
*
|
|
1406
|
+
* `secret` is not enumerable: `console.log`, `JSON.stringify`, `util.inspect` and a
|
|
1407
|
+
* spread leave it out, and only a direct read, `created.secret`, returns it. Read it
|
|
1408
|
+
* again later with {@link ManagementClient.getWebhookEndpointSecret}.
|
|
1409
|
+
*/
|
|
1410
|
+
interface WebhookEndpointCreated extends WebhookEndpoint {
|
|
1411
|
+
readonly secret: string;
|
|
1412
|
+
}
|
|
1413
|
+
/** The current signing secret. `secret` is not enumerable, like {@link WebhookEndpointCreated.secret}. */
|
|
1414
|
+
interface WebhookSecret {
|
|
1415
|
+
readonly secret: string | null;
|
|
1416
|
+
}
|
|
1417
|
+
/**
|
|
1418
|
+
* The answer to rotating a secret. `previous_secret_expires_at` is when the old
|
|
1419
|
+
* secret stops being used, or `null` when none is left. `secret` is not enumerable.
|
|
1420
|
+
*/
|
|
1421
|
+
interface WebhookSecretRotation {
|
|
1422
|
+
readonly secret: string;
|
|
1423
|
+
previous_secret_expires_at: string | null;
|
|
1424
|
+
}
|
|
1425
|
+
/** Body of {@link ManagementClient.createWebhookEndpoint}. */
|
|
1426
|
+
interface WebhookEndpointCreateRequest {
|
|
1427
|
+
/** The `https` URL deliveries are sent to. */
|
|
1428
|
+
url: string;
|
|
1429
|
+
/** Event types to receive, at least one. */
|
|
1430
|
+
event_types: string[];
|
|
1431
|
+
/** At most 255 characters. */
|
|
1432
|
+
description?: string;
|
|
1433
|
+
/** Collections to receive events from, at most 50. Empty or omitted for every collection. */
|
|
1434
|
+
collection_keys?: CollectionRef[];
|
|
1435
|
+
/** `references` (the default) or `content`. */
|
|
1436
|
+
payload_mode?: WebhookPayloadMode;
|
|
1437
|
+
/** Payload version; `1` is the only one. */
|
|
1438
|
+
version?: number;
|
|
1439
|
+
}
|
|
1440
|
+
/** Body of {@link ManagementClient.updateWebhookEndpoint}: send only the fields to change. */
|
|
1441
|
+
interface WebhookEndpointUpdateRequest extends Partial<WebhookEndpointCreateRequest> {
|
|
1442
|
+
/** `active` resumes a paused or disabled endpoint and clears its failure streak. */
|
|
1443
|
+
status?: 'active' | 'paused';
|
|
1444
|
+
}
|
|
1445
|
+
/** The endpoint of a delivery or an attempt; `deleted` once it was removed. */
|
|
1446
|
+
interface WebhookEndpointRef {
|
|
1447
|
+
id: string;
|
|
1448
|
+
deleted: boolean;
|
|
1449
|
+
}
|
|
1450
|
+
/** One event sent to one endpoint, with all its attempts. */
|
|
1451
|
+
interface WebhookDelivery {
|
|
1452
|
+
id: string;
|
|
1453
|
+
endpoint: WebhookEndpointRef;
|
|
1454
|
+
/** `pending`, `succeeded` or `dead`. */
|
|
1455
|
+
status: 'pending' | 'succeeded' | 'dead';
|
|
1456
|
+
attempts: number;
|
|
1457
|
+
last_status_code: number | null;
|
|
1458
|
+
last_error: string | null;
|
|
1459
|
+
created_at: string;
|
|
1460
|
+
finished_at: string | null;
|
|
1461
|
+
/** Set only while the delivery is pending. */
|
|
1462
|
+
next_attempt_at: string | null;
|
|
1463
|
+
}
|
|
1464
|
+
/** The event a delivery carries. */
|
|
1465
|
+
interface WebhookDeliveryEvent {
|
|
1466
|
+
id: string;
|
|
1467
|
+
type: string;
|
|
1468
|
+
test: boolean;
|
|
1469
|
+
}
|
|
1470
|
+
/** A delivery in an endpoint's delivery list. `event` is `null` once the event has aged out. */
|
|
1471
|
+
interface WebhookEndpointDelivery extends WebhookDelivery {
|
|
1472
|
+
event_id: string;
|
|
1473
|
+
event: WebhookDeliveryEvent | null;
|
|
1474
|
+
}
|
|
1475
|
+
type WebhookEndpointDeliveryList = PaginatedResponse<WebhookEndpointDelivery>;
|
|
1476
|
+
/** How many deliveries of an event are in each status. */
|
|
1477
|
+
interface WebhookDeliveryCounts {
|
|
1478
|
+
pending: number;
|
|
1479
|
+
succeeded: number;
|
|
1480
|
+
dead: number;
|
|
1481
|
+
}
|
|
1482
|
+
/** An event of the log. `delivery_counts` is set on the items of a list only. */
|
|
1483
|
+
interface WebhookEvent {
|
|
1484
|
+
id: string;
|
|
1485
|
+
type: string;
|
|
1486
|
+
created_at: string;
|
|
1487
|
+
test: boolean;
|
|
1488
|
+
collection_key: string | null;
|
|
1489
|
+
delivery_counts?: WebhookDeliveryCounts;
|
|
1490
|
+
}
|
|
1491
|
+
type WebhookEventList = PaginatedResponse<WebhookEvent>;
|
|
1492
|
+
/**
|
|
1493
|
+
* One event with its envelope and all its deliveries, oldest first. `envelope` is the
|
|
1494
|
+
* event as a references-only endpoint receives it; the log never returns content.
|
|
1495
|
+
*/
|
|
1496
|
+
interface WebhookEventDetail extends WebhookEvent {
|
|
1497
|
+
envelope: Record<string, unknown>;
|
|
1498
|
+
deliveries: WebhookDelivery[];
|
|
1499
|
+
}
|
|
1500
|
+
/**
|
|
1501
|
+
* One try to deliver an event. `response_excerpt` is the first 1 KB of what the
|
|
1502
|
+
* endpoint answered.
|
|
1503
|
+
*/
|
|
1504
|
+
interface WebhookAttempt {
|
|
1505
|
+
id: string;
|
|
1506
|
+
delivery_id: string;
|
|
1507
|
+
endpoint: WebhookEndpointRef;
|
|
1508
|
+
created_at: string;
|
|
1509
|
+
status_code: number | null;
|
|
1510
|
+
latency_ms: number;
|
|
1511
|
+
error_class: string | null;
|
|
1512
|
+
response_excerpt: string;
|
|
1513
|
+
}
|
|
1514
|
+
type WebhookAttemptList = PaginatedResponse<WebhookAttempt>;
|
|
1515
|
+
/** The answer to sending a test event. */
|
|
1516
|
+
interface WebhookTestEvent {
|
|
1517
|
+
event_id: string;
|
|
1518
|
+
delivery_id: string;
|
|
1519
|
+
}
|
|
1520
|
+
/**
|
|
1521
|
+
* The answer to recovering failed deliveries: `requeued` were queued, and `more` is
|
|
1522
|
+
* `true` when another call with the same `since` has more to do.
|
|
1523
|
+
*/
|
|
1524
|
+
interface WebhookRecovery {
|
|
1525
|
+
requeued: number;
|
|
1526
|
+
more: boolean;
|
|
1527
|
+
}
|
|
1528
|
+
/** A delivery created by redelivering an event. */
|
|
1529
|
+
interface WebhookRedelivery {
|
|
1530
|
+
id: string;
|
|
1531
|
+
endpoint_id: string;
|
|
1532
|
+
}
|
|
1533
|
+
/**
|
|
1534
|
+
* An endpoint an event was not redelivered to. `reason` is `deleted`, `paused`,
|
|
1535
|
+
* `disabled` or `endpoint_not_subscribed`.
|
|
1536
|
+
*/
|
|
1537
|
+
interface WebhookSkippedEndpoint {
|
|
1538
|
+
endpoint_id: string;
|
|
1539
|
+
reason: string;
|
|
1540
|
+
}
|
|
1541
|
+
/** The answer to redelivering an event. */
|
|
1542
|
+
interface WebhookRedeliveryResult {
|
|
1543
|
+
event_id: string;
|
|
1544
|
+
deliveries: WebhookRedelivery[];
|
|
1545
|
+
skipped: WebhookSkippedEndpoint[];
|
|
1546
|
+
}
|
|
1547
|
+
/** An event type of the catalogue. `collection_scoped` is true when every event of the type belongs to a collection. */
|
|
1548
|
+
interface WebhookEventType {
|
|
1549
|
+
name: string;
|
|
1550
|
+
description: string;
|
|
1551
|
+
collection_scoped: boolean;
|
|
1552
|
+
/** JSON Schemas (draft 2020-12) of the event's `data` per payload mode. */
|
|
1553
|
+
schemas: {
|
|
1554
|
+
references: Record<string, unknown>;
|
|
1555
|
+
content: Record<string, unknown>;
|
|
1556
|
+
};
|
|
1557
|
+
}
|
|
1558
|
+
/** The event-type catalogue; it is not paginated. */
|
|
1559
|
+
interface WebhookEventTypeList {
|
|
1560
|
+
results: WebhookEventType[];
|
|
1561
|
+
}
|
|
1562
|
+
/** Filters of {@link ManagementClient.listWebhookEvents}. */
|
|
1563
|
+
interface WebhookEventListParams {
|
|
1564
|
+
type?: string;
|
|
1565
|
+
/** An endpoint `id`. */
|
|
1566
|
+
endpoint?: string;
|
|
1567
|
+
status?: 'pending' | 'succeeded' | 'dead';
|
|
1568
|
+
/** `true` for test events only, `false` to leave them out. */
|
|
1569
|
+
test?: boolean;
|
|
1570
|
+
/** ISO 8601; a time without a zone is read as UTC. */
|
|
1571
|
+
after?: string;
|
|
1572
|
+
before?: string;
|
|
1573
|
+
/** At most 200. */
|
|
1574
|
+
limit?: number;
|
|
1575
|
+
offset?: number;
|
|
1576
|
+
}
|
|
1326
1577
|
|
|
1327
1578
|
interface ManagementClientOptions {
|
|
1328
1579
|
baseUrl?: string;
|
|
@@ -1767,6 +2018,96 @@ declare class ManagementClient {
|
|
|
1767
2018
|
* `404 environment_not_found`.
|
|
1768
2019
|
*/
|
|
1769
2020
|
getMyPermissions(): Promise<MyPermissions>;
|
|
2021
|
+
/**
|
|
2022
|
+
* List the environment's webhook endpoints, newest first. Each item carries
|
|
2023
|
+
* `stats_24h`; secrets are never included. `params` carries `status` (`active`,
|
|
2024
|
+
* `paused` or `disabled`), `limit` (at most 200) and `offset`.
|
|
2025
|
+
*/
|
|
2026
|
+
listWebhookEndpoints(params?: Record<string, any>): Promise<WebhookEndpointList>;
|
|
2027
|
+
/**
|
|
2028
|
+
* Create a webhook endpoint.
|
|
2029
|
+
*
|
|
2030
|
+
* The answer carries the signing `secret`, which is not enumerable: read it as
|
|
2031
|
+
* `created.secret`, and read it again later with {@link getWebhookEndpointSecret}.
|
|
2032
|
+
* An environment holds at most 20 endpoints ({@link WebhookEndpointLimitExceededError}).
|
|
2033
|
+
* A `content` endpoint also needs read access to the content it will deliver.
|
|
2034
|
+
*/
|
|
2035
|
+
createWebhookEndpoint(request: WebhookEndpointCreateRequest): Promise<WebhookEndpointCreated>;
|
|
2036
|
+
/** Read one webhook endpoint. It carries neither the secret nor `stats_24h`. */
|
|
2037
|
+
getWebhookEndpoint(endpointId: string): Promise<WebhookEndpoint>;
|
|
2038
|
+
/**
|
|
2039
|
+
* Change the given fields of an endpoint and leave the rest alone.
|
|
2040
|
+
*
|
|
2041
|
+
* `status: 'active'` resumes a paused or disabled endpoint and clears its failure
|
|
2042
|
+
* streak; events that happened meanwhile are not sent, but failed deliveries can be
|
|
2043
|
+
* sent again with {@link recoverWebhookDeliveries}.
|
|
2044
|
+
*/
|
|
2045
|
+
updateWebhookEndpoint(endpointId: string, changes: WebhookEndpointUpdateRequest): Promise<WebhookEndpoint>;
|
|
2046
|
+
/**
|
|
2047
|
+
* Delete an endpoint and its pending deliveries. Its finished deliveries and
|
|
2048
|
+
* attempts stay in the event log for 30 days, with `endpoint.deleted` true.
|
|
2049
|
+
*/
|
|
2050
|
+
deleteWebhookEndpoint(endpointId: string): Promise<void>;
|
|
2051
|
+
/**
|
|
2052
|
+
* List an endpoint's deliveries, newest first, each with the event it carries.
|
|
2053
|
+
* `params` carries `limit` (at most 200) and `offset`.
|
|
2054
|
+
*/
|
|
2055
|
+
listWebhookEndpointDeliveries(endpointId: string, params?: Record<string, any>): Promise<WebhookEndpointDeliveryList>;
|
|
2056
|
+
/**
|
|
2057
|
+
* Read the endpoint's current signing secret: the newest, during a rotation. Needs
|
|
2058
|
+
* `webhooks:update`. `secret` is not enumerable: read it as `response.secret`.
|
|
2059
|
+
*/
|
|
2060
|
+
getWebhookEndpointSecret(endpointId: string): Promise<WebhookSecret>;
|
|
2061
|
+
/**
|
|
2062
|
+
* Create a new signing secret and return it.
|
|
2063
|
+
*
|
|
2064
|
+
* The previous secret stays valid for 24 hours, and deliveries carry a signature for
|
|
2065
|
+
* each valid secret; with `expire_previous_now` it stops at once. Needs
|
|
2066
|
+
* `webhooks:update`. `secret` is not enumerable: read it as `rotation.secret`.
|
|
2067
|
+
*/
|
|
2068
|
+
rotateWebhookEndpointSecret(endpointId: string, options?: {
|
|
2069
|
+
expire_previous_now?: boolean;
|
|
2070
|
+
}): Promise<WebhookSecretRotation>;
|
|
2071
|
+
/**
|
|
2072
|
+
* Send a sample event of `eventType` to this endpoint only, with `test` true in the
|
|
2073
|
+
* envelope. It is sent whatever the endpoint's event types and collection filter,
|
|
2074
|
+
* but the endpoint must be active ({@link WebhookEndpointNotActiveError}).
|
|
2075
|
+
*/
|
|
2076
|
+
sendWebhookTestEvent(endpointId: string, eventType: string): Promise<WebhookTestEvent>;
|
|
2077
|
+
/**
|
|
2078
|
+
* Send again the endpoint's failed deliveries created at or after `since`.
|
|
2079
|
+
*
|
|
2080
|
+
* Each becomes a new pending delivery of the same event. One call queues at most
|
|
2081
|
+
* 10,000 deliveries; when `more` is true, call again with the same `since`. `since`
|
|
2082
|
+
* is an ISO 8601 time within the last 30 days; a time without a zone is read as UTC.
|
|
2083
|
+
*/
|
|
2084
|
+
recoverWebhookDeliveries(endpointId: string, since: string | Date): Promise<WebhookRecovery>;
|
|
2085
|
+
/**
|
|
2086
|
+
* List the events of the last 30 days, newest first, with `delivery_counts`.
|
|
2087
|
+
* `params` carries `type`, `endpoint` (an endpoint `id`), `status` (`pending`,
|
|
2088
|
+
* `succeeded` or `dead`), `test`, `after`, `before` (ISO 8601), `limit` (at most 200)
|
|
2089
|
+
* and `offset`.
|
|
2090
|
+
*/
|
|
2091
|
+
listWebhookEvents(params?: WebhookEventListParams): Promise<WebhookEventList>;
|
|
2092
|
+
/** Read one event with its envelope and all its deliveries, oldest first. */
|
|
2093
|
+
getWebhookEvent(eventId: string): Promise<WebhookEventDetail>;
|
|
2094
|
+
/**
|
|
2095
|
+
* List every attempt to deliver the event, across endpoints, oldest first. `params`
|
|
2096
|
+
* carries `limit` (at most 200) and `offset`.
|
|
2097
|
+
*/
|
|
2098
|
+
listWebhookEventAttempts(eventId: string, params?: Record<string, any>): Promise<WebhookAttemptList>;
|
|
2099
|
+
/**
|
|
2100
|
+
* Send the event again as a new delivery, with the same event `id`.
|
|
2101
|
+
*
|
|
2102
|
+
* With `endpoint_id` the event goes to that endpoint. Without it, the event goes to
|
|
2103
|
+
* every endpoint that had a delivery of it and is active and subscribed to it now;
|
|
2104
|
+
* the others are listed in `skipped`.
|
|
2105
|
+
*/
|
|
2106
|
+
redeliverWebhookEvent(eventId: string, options?: {
|
|
2107
|
+
endpoint_id?: string;
|
|
2108
|
+
}): Promise<WebhookRedeliveryResult>;
|
|
2109
|
+
/** List the event-type catalogue with the JSON Schema of each payload mode. */
|
|
2110
|
+
listWebhookEventTypes(): Promise<WebhookEventTypeList>;
|
|
1770
2111
|
private fileRoot;
|
|
1771
2112
|
}
|
|
1772
2113
|
|
|
@@ -2040,4 +2381,4 @@ declare class FluxClient {
|
|
|
2040
2381
|
close(): void;
|
|
2041
2382
|
}
|
|
2042
2383
|
|
|
2043
|
-
export { type APICollectionList, type APICollectionSummary, type APIFolderList, type APIFolderSummary, type APIInfo, type APIList, type APIRef, AnonymousAuth, type ApiFolderOptions, type ApiFolderRouteDescriptionOptions, type AuthStrategy, type BatchItemError, type BatchUpsertItem, type BatchUpsertResult, type BoostedSearchOptions, type CollectionList, CollectionNotWritableError, type CollectionRef, type CollectionSummary, type ComponentList, type ComponentRef, type ComponentSummary, type ComponentSyncConflictDetail, type ContentTypeAccess, ContentValidationFailedError, type CurrentUsage, DEFAULT_RETRY_CONFIG, DEFAULT_USER_AGENT, type EnvironmentAccess, type EnvironmentList, type EnvironmentRef, type EnvironmentSummary, ExternalIdConflictError, type FieldList, type FieldSummary, type FileActiveContent, type FileAnalysis, type FileCheck, type FileCopyAvailability, type FileDownload, type FileDownloadOptions, type FileEvidencePart, type FileFinding, type FileFindingGroup, type FileFindingsSummary, type FileInfo, type FileKind, type FileOrigin, type FileOriginActor, type FileOriginLink, type FilePageDetail, type FilePageFinding, type FilePagePii, type FilePageRedaction, type FilePageTable, type FileRecordOwner, type FileRecordView, type FileReviewItem, type FileReviewQueue, type FileSummary, type FileTextEvidence, type FileTombstone, type FileTombstoneList, type FileTrust, type FilesPolicy, type FilesPolicyBody, FilesQuotaExceededError, FilesQuotaUnavailableError, type FlatRoute, type FlatRouteSummary, type FluxAPIKeyBearerToken, type FluxAPIKeyList, type FluxAPIKeyRef, type FluxAPIKeySummary, FluxClient, type FluxClientOptions, type FluxRoleList, type FluxRoleRef, type FluxRoleSummary, type FolderList, type FolderRef, type FolderSummary, FoxnoseAPIError, FoxnoseAuthError, type FoxnoseConfig, FoxnoseError, FoxnoseTransportError, HttpTransport, type HybridConfig, type HybridSearchOptions, JWTAuth, type LocaleList, type LocaleSummary, type ManagementAPIKeyList, type ManagementAPIKeyRef, type ManagementAPIKeySummary, ManagementClient, type ManagementClientOptions, type ManagementRoleList, type ManagementRoleRef, type ManagementRoleSummary, type MyPermissions, type NestedFieldMeta, type OrgRef, type OrganizationList, type OrganizationOwner, type OrganizationPlanStatus, type OrganizationSummary, type OrganizationUsage, type PaginatedResponse, type PlanDetails, PlanExhaustedError, PlanLimitExceededError, type PlanLimits, type ProjectList, type ProjectRef, type ProjectSummary, RateLimitExceededError, type RegionInfo, type RequestData, type ResourceList, type ResourceRef, type ResourceSummary, type RetryConfig, type RevisionList, type RevisionRef, type RevisionSummary, type RolePermission, type RolePermissionObject, SDK_VERSION, type SchemaVersionList, type SchemaVersionRef, type SchemaVersionSummary, SearchMode, type SearchRequest, SecureKeyAuth, SimpleKeyAuth, SpendCapExceededError, StaticTokenProvider, type StorageUsage, type SyncComponentResponse, type SyncComponentSkippedItem, type TokenProvider, type UnitsUsage, type UploadFileProgress, type UploadFileStatus, type UploadLink, type UploadLinkCreateRequest, type UploadLinkCreated, type UploadLinkCreator, type UploadLinkFile, type UploadLinkList, type UploadLinkSession, type UploadSignature, type UploadStatus, UpstreamError, type UsageBreakdown, type UsageMetric, type UserReference, SDK_VERSION as VERSION, type VectorBoostConfig, type VectorFieldSearch, type VectorFieldSearchOptions, type VectorSearch, type VectorSearchOptions, buildSearchBody, createConfig, nestedFieldMeta, parseFindingEvidence, resolveKey };
|
|
2384
|
+
export { type APICollectionList, type APICollectionSummary, type APIFolderList, type APIFolderSummary, type APIInfo, type APIList, type APIRef, AnonymousAuth, type ApiFolderOptions, type ApiFolderRouteDescriptionOptions, type AuthStrategy, type BatchItemError, type BatchUpsertItem, type BatchUpsertResult, type BoostedSearchOptions, type CollectionList, CollectionNotWritableError, type CollectionRef, type CollectionSummary, type ComponentList, type ComponentRef, type ComponentSummary, type ComponentSyncConflictDetail, type ContentTypeAccess, ContentValidationFailedError, type CurrentUsage, DEFAULT_RETRY_CONFIG, DEFAULT_USER_AGENT, type EnvironmentAccess, type EnvironmentList, type EnvironmentRef, type EnvironmentSummary, ExternalIdConflictError, type FieldList, type FieldSummary, type FileActiveContent, type FileAnalysis, type FileCheck, type FileCopyAvailability, type FileDownload, type FileDownloadOptions, type FileEvidencePart, type FileFinding, type FileFindingGroup, type FileFindingsSummary, type FileInfo, type FileKind, type FileOrigin, type FileOriginActor, type FileOriginLink, type FilePageDetail, type FilePageFinding, type FilePagePii, type FilePageRedaction, type FilePageTable, type FileRecordOwner, type FileRecordView, type FileReviewItem, type FileReviewQueue, type FileSummary, type FileTextEvidence, type FileTombstone, type FileTombstoneList, type FileTrust, type FilesPolicy, type FilesPolicyBody, FilesQuotaExceededError, FilesQuotaUnavailableError, type FlatRoute, type FlatRouteSummary, type FluxAPIKeyBearerToken, type FluxAPIKeyList, type FluxAPIKeyRef, type FluxAPIKeySummary, FluxClient, type FluxClientOptions, type FluxRoleList, type FluxRoleRef, type FluxRoleSummary, type FolderList, type FolderRef, type FolderSummary, FoxnoseAPIError, FoxnoseAuthError, type FoxnoseConfig, FoxnoseError, FoxnoseTransportError, HttpTransport, type HybridConfig, type HybridSearchOptions, JWTAuth, type LocaleList, type LocaleSummary, type ManagementAPIKeyList, type ManagementAPIKeyRef, type ManagementAPIKeySummary, ManagementClient, type ManagementClientOptions, type ManagementRoleList, type ManagementRoleRef, type ManagementRoleSummary, type MyPermissions, type NestedFieldMeta, type OrgRef, type OrganizationList, type OrganizationOwner, type OrganizationPlanStatus, type OrganizationSummary, type OrganizationUsage, type PaginatedResponse, type PlanDetails, PlanExhaustedError, PlanLimitExceededError, type PlanLimits, type ProjectList, type ProjectRef, type ProjectSummary, RateLimitExceededError, type RegionInfo, type RequestData, type ResourceList, type ResourceRef, type ResourceSummary, type RetryConfig, type RevisionList, type RevisionRef, type RevisionSummary, type RolePermission, type RolePermissionObject, SDK_VERSION, type SchemaVersionList, type SchemaVersionRef, type SchemaVersionSummary, SearchMode, type SearchRequest, SecureKeyAuth, SimpleKeyAuth, SpendCapExceededError, StaticTokenProvider, type StorageUsage, type SyncComponentResponse, type SyncComponentSkippedItem, type TokenProvider, type UnitsUsage, type UploadFileProgress, type UploadFileStatus, type UploadLink, type UploadLinkCreateRequest, type UploadLinkCreated, type UploadLinkCreator, type UploadLinkFile, type UploadLinkList, type UploadLinkSession, type UploadSignature, type UploadStatus, UpstreamError, type UsageBreakdown, type UsageMetric, type UserReference, SDK_VERSION as VERSION, type VectorBoostConfig, type VectorFieldSearch, type VectorFieldSearchOptions, type VectorSearch, type VectorSearchOptions, type WebhookAttempt, type WebhookAttemptList, type WebhookDelivery, type WebhookDeliveryCounts, type WebhookDeliveryEvent, type WebhookEndpoint, type WebhookEndpointCreateRequest, type WebhookEndpointCreated, type WebhookEndpointDelivery, type WebhookEndpointDeliveryList, WebhookEndpointLimitExceededError, type WebhookEndpointList, WebhookEndpointNotActiveError, WebhookEndpointNotFoundError, WebhookEndpointNotSubscribedError, type WebhookEndpointRef, type WebhookEndpointStatus, type WebhookEndpointUpdateRequest, type WebhookEvent, type WebhookEventDetail, type WebhookEventList, type WebhookEventListParams, WebhookEventNotFoundError, type WebhookEventType, type WebhookEventTypeList, type WebhookPayloadMode, type WebhookRecovery, type WebhookRedelivery, type WebhookRedeliveryResult, type WebhookSecret, type WebhookSecretRotation, type WebhookSkippedEndpoint, type WebhookStats24h, type WebhookTestEvent, buildSearchBody, createConfig, nestedFieldMeta, parseFindingEvidence, resolveKey };
|
package/dist/index.js
CHANGED
|
@@ -180,6 +180,45 @@ var UpstreamError = class extends FoxnoseAPIError {
|
|
|
180
180
|
this.name = "UpstreamError";
|
|
181
181
|
}
|
|
182
182
|
};
|
|
183
|
+
var WebhookEndpointNotFoundError = class extends FoxnoseAPIError {
|
|
184
|
+
constructor(options) {
|
|
185
|
+
super(options);
|
|
186
|
+
this.name = "WebhookEndpointNotFoundError";
|
|
187
|
+
}
|
|
188
|
+
};
|
|
189
|
+
var WebhookEventNotFoundError = class extends FoxnoseAPIError {
|
|
190
|
+
constructor(options) {
|
|
191
|
+
super(options);
|
|
192
|
+
this.name = "WebhookEventNotFoundError";
|
|
193
|
+
}
|
|
194
|
+
};
|
|
195
|
+
var WebhookEndpointLimitExceededError = class extends FoxnoseAPIError {
|
|
196
|
+
constructor(options) {
|
|
197
|
+
super(options);
|
|
198
|
+
this.name = "WebhookEndpointLimitExceededError";
|
|
199
|
+
}
|
|
200
|
+
};
|
|
201
|
+
var WebhookEndpointNotActiveError = class extends FoxnoseAPIError {
|
|
202
|
+
/** The endpoint's state (`paused`, `disabled` or `deleted`) when the call named it. */
|
|
203
|
+
reason;
|
|
204
|
+
/** Endpoints a redelivery without `endpoint_id` passed over, each with `endpoint_id` and `reason`. */
|
|
205
|
+
skipped;
|
|
206
|
+
constructor(options) {
|
|
207
|
+
super(options);
|
|
208
|
+
this.name = "WebhookEndpointNotActiveError";
|
|
209
|
+
this.reason = options.reason;
|
|
210
|
+
this.skipped = options.skipped ?? [];
|
|
211
|
+
}
|
|
212
|
+
};
|
|
213
|
+
var WebhookEndpointNotSubscribedError = class extends FoxnoseAPIError {
|
|
214
|
+
/** Endpoints a redelivery without `endpoint_id` passed over, each with `endpoint_id` and `reason`. */
|
|
215
|
+
skipped;
|
|
216
|
+
constructor(options) {
|
|
217
|
+
super(options);
|
|
218
|
+
this.name = "WebhookEndpointNotSubscribedError";
|
|
219
|
+
this.skipped = options.skipped ?? [];
|
|
220
|
+
}
|
|
221
|
+
};
|
|
183
222
|
function isPlainObject(value) {
|
|
184
223
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
185
224
|
}
|
|
@@ -276,6 +315,30 @@ function buildAPIError(options) {
|
|
|
276
315
|
errorsTruncated: d.errors_truncated === true
|
|
277
316
|
});
|
|
278
317
|
}
|
|
318
|
+
if (statusCode === 404 && errorCode === "webhook_endpoint_not_found") {
|
|
319
|
+
return new WebhookEndpointNotFoundError(options);
|
|
320
|
+
}
|
|
321
|
+
if (statusCode === 404 && errorCode === "webhook_event_not_found") {
|
|
322
|
+
return new WebhookEventNotFoundError(options);
|
|
323
|
+
}
|
|
324
|
+
if (statusCode === 409 && errorCode === "limit_exceeded") {
|
|
325
|
+
return new WebhookEndpointLimitExceededError(options);
|
|
326
|
+
}
|
|
327
|
+
if (statusCode === 409 && errorCode === "endpoint_not_active") {
|
|
328
|
+
const d = isPlainObject(detail) ? detail : {};
|
|
329
|
+
return new WebhookEndpointNotActiveError({
|
|
330
|
+
...options,
|
|
331
|
+
reason: typeof d.reason === "string" ? d.reason : void 0,
|
|
332
|
+
skipped: Array.isArray(d.skipped) ? d.skipped : void 0
|
|
333
|
+
});
|
|
334
|
+
}
|
|
335
|
+
if (statusCode === 409 && errorCode === "endpoint_not_subscribed") {
|
|
336
|
+
const d = isPlainObject(detail) ? detail : {};
|
|
337
|
+
return new WebhookEndpointNotSubscribedError({
|
|
338
|
+
...options,
|
|
339
|
+
skipped: Array.isArray(d.skipped) ? d.skipped : void 0
|
|
340
|
+
});
|
|
341
|
+
}
|
|
279
342
|
if (statusCode === 502 && errorCode === "upstream_error") {
|
|
280
343
|
return new UpstreamError(options);
|
|
281
344
|
}
|
|
@@ -365,7 +428,7 @@ var DEFAULT_RETRY_CONFIG = {
|
|
|
365
428
|
statusCodes: [408, 425, 429, 500, 502, 503, 504],
|
|
366
429
|
methods: ["GET", "HEAD", "OPTIONS", "PUT", "DELETE"]
|
|
367
430
|
};
|
|
368
|
-
var SDK_VERSION = "0.
|
|
431
|
+
var SDK_VERSION = "0.8.0";
|
|
369
432
|
var DEFAULT_USER_AGENT = `foxnose-sdk-js/${SDK_VERSION}`;
|
|
370
433
|
function createConfig(options) {
|
|
371
434
|
if (!options.baseUrl) {
|
|
@@ -672,6 +735,10 @@ function managementPaths(environmentKey) {
|
|
|
672
735
|
fileTombstonesRoot: (collectionKey) => `/v1/${environmentKey}/collections/${collectionKey}/files/tombstones`,
|
|
673
736
|
filesPolicyRoot: (collectionKey) => `/v1/${environmentKey}/collections/${collectionKey}/files-policy`,
|
|
674
737
|
filesReviewRoot: () => `/v1/${environmentKey}/files/review`,
|
|
738
|
+
// Webhooks paths
|
|
739
|
+
webhooksRoot: () => `/v1/${environmentKey}/webhooks`,
|
|
740
|
+
webhookEndpointRoot: (endpointId) => `/v1/${environmentKey}/webhooks/endpoints/${encodeURIComponent(endpointId)}`,
|
|
741
|
+
webhookEventRoot: (eventId) => `/v1/${environmentKey}/webhooks/events/${encodeURIComponent(eventId)}`,
|
|
675
742
|
// Caller's own permissions
|
|
676
743
|
myPermissionsRoot: () => `/v1/${environmentKey}/permissions/me`,
|
|
677
744
|
// Management API key paths
|
|
@@ -705,6 +772,21 @@ function managementPaths(environmentKey) {
|
|
|
705
772
|
}
|
|
706
773
|
|
|
707
774
|
// src/management/client.ts
|
|
775
|
+
function hideSecret(response) {
|
|
776
|
+
if (response && typeof response === "object" && "secret" in response) {
|
|
777
|
+
Object.defineProperty(response, "secret", {
|
|
778
|
+
value: response.secret,
|
|
779
|
+
enumerable: false,
|
|
780
|
+
writable: false,
|
|
781
|
+
configurable: true
|
|
782
|
+
});
|
|
783
|
+
}
|
|
784
|
+
return response;
|
|
785
|
+
}
|
|
786
|
+
function webhookEndpointBody(request) {
|
|
787
|
+
const { collection_keys, ...rest } = request;
|
|
788
|
+
return collection_keys === void 0 ? rest : { ...rest, collection_keys: collection_keys.map((key) => resolveKey(key)) };
|
|
789
|
+
}
|
|
708
790
|
var ManagementClient = class {
|
|
709
791
|
environmentKey;
|
|
710
792
|
transport;
|
|
@@ -2098,6 +2180,164 @@ var ManagementClient = class {
|
|
|
2098
2180
|
async getMyPermissions() {
|
|
2099
2181
|
return this.request("GET", `${this.paths.myPermissionsRoot()}/`);
|
|
2100
2182
|
}
|
|
2183
|
+
// ------------------------------------------------------------------ //
|
|
2184
|
+
// Webhooks
|
|
2185
|
+
// ------------------------------------------------------------------ //
|
|
2186
|
+
/**
|
|
2187
|
+
* List the environment's webhook endpoints, newest first. Each item carries
|
|
2188
|
+
* `stats_24h`; secrets are never included. `params` carries `status` (`active`,
|
|
2189
|
+
* `paused` or `disabled`), `limit` (at most 200) and `offset`.
|
|
2190
|
+
*/
|
|
2191
|
+
async listWebhookEndpoints(params) {
|
|
2192
|
+
return this.request("GET", `${this.paths.webhooksRoot()}/endpoints/`, { params });
|
|
2193
|
+
}
|
|
2194
|
+
/**
|
|
2195
|
+
* Create a webhook endpoint.
|
|
2196
|
+
*
|
|
2197
|
+
* The answer carries the signing `secret`, which is not enumerable: read it as
|
|
2198
|
+
* `created.secret`, and read it again later with {@link getWebhookEndpointSecret}.
|
|
2199
|
+
* An environment holds at most 20 endpoints ({@link WebhookEndpointLimitExceededError}).
|
|
2200
|
+
* A `content` endpoint also needs read access to the content it will deliver.
|
|
2201
|
+
*/
|
|
2202
|
+
async createWebhookEndpoint(request) {
|
|
2203
|
+
const created = await this.transport.request(
|
|
2204
|
+
"POST",
|
|
2205
|
+
`${this.paths.webhooksRoot()}/endpoints/`,
|
|
2206
|
+
{
|
|
2207
|
+
jsonBody: webhookEndpointBody(request),
|
|
2208
|
+
allowRetries: false
|
|
2209
|
+
}
|
|
2210
|
+
);
|
|
2211
|
+
return hideSecret(created);
|
|
2212
|
+
}
|
|
2213
|
+
/** Read one webhook endpoint. It carries neither the secret nor `stats_24h`. */
|
|
2214
|
+
async getWebhookEndpoint(endpointId) {
|
|
2215
|
+
return this.request("GET", `${this.paths.webhookEndpointRoot(endpointId)}/`);
|
|
2216
|
+
}
|
|
2217
|
+
/**
|
|
2218
|
+
* Change the given fields of an endpoint and leave the rest alone.
|
|
2219
|
+
*
|
|
2220
|
+
* `status: 'active'` resumes a paused or disabled endpoint and clears its failure
|
|
2221
|
+
* streak; events that happened meanwhile are not sent, but failed deliveries can be
|
|
2222
|
+
* sent again with {@link recoverWebhookDeliveries}.
|
|
2223
|
+
*/
|
|
2224
|
+
async updateWebhookEndpoint(endpointId, changes) {
|
|
2225
|
+
return this.request("PATCH", `${this.paths.webhookEndpointRoot(endpointId)}/`, {
|
|
2226
|
+
jsonBody: webhookEndpointBody(changes)
|
|
2227
|
+
});
|
|
2228
|
+
}
|
|
2229
|
+
/**
|
|
2230
|
+
* Delete an endpoint and its pending deliveries. Its finished deliveries and
|
|
2231
|
+
* attempts stay in the event log for 30 days, with `endpoint.deleted` true.
|
|
2232
|
+
*/
|
|
2233
|
+
async deleteWebhookEndpoint(endpointId) {
|
|
2234
|
+
await this.request("DELETE", `${this.paths.webhookEndpointRoot(endpointId)}/`, {
|
|
2235
|
+
parseJson: false
|
|
2236
|
+
});
|
|
2237
|
+
}
|
|
2238
|
+
/**
|
|
2239
|
+
* List an endpoint's deliveries, newest first, each with the event it carries.
|
|
2240
|
+
* `params` carries `limit` (at most 200) and `offset`.
|
|
2241
|
+
*/
|
|
2242
|
+
async listWebhookEndpointDeliveries(endpointId, params) {
|
|
2243
|
+
return this.request("GET", `${this.paths.webhookEndpointRoot(endpointId)}/deliveries/`, {
|
|
2244
|
+
params
|
|
2245
|
+
});
|
|
2246
|
+
}
|
|
2247
|
+
/**
|
|
2248
|
+
* Read the endpoint's current signing secret: the newest, during a rotation. Needs
|
|
2249
|
+
* `webhooks:update`. `secret` is not enumerable: read it as `response.secret`.
|
|
2250
|
+
*/
|
|
2251
|
+
async getWebhookEndpointSecret(endpointId) {
|
|
2252
|
+
const response = await this.request(
|
|
2253
|
+
"GET",
|
|
2254
|
+
`${this.paths.webhookEndpointRoot(endpointId)}/secret/`
|
|
2255
|
+
);
|
|
2256
|
+
return hideSecret(response);
|
|
2257
|
+
}
|
|
2258
|
+
/**
|
|
2259
|
+
* Create a new signing secret and return it.
|
|
2260
|
+
*
|
|
2261
|
+
* The previous secret stays valid for 24 hours, and deliveries carry a signature for
|
|
2262
|
+
* each valid secret; with `expire_previous_now` it stops at once. Needs
|
|
2263
|
+
* `webhooks:update`. `secret` is not enumerable: read it as `rotation.secret`.
|
|
2264
|
+
*/
|
|
2265
|
+
async rotateWebhookEndpointSecret(endpointId, options) {
|
|
2266
|
+
const response = await this.transport.request(
|
|
2267
|
+
"POST",
|
|
2268
|
+
`${this.paths.webhookEndpointRoot(endpointId)}/secret/rotate/`,
|
|
2269
|
+
{
|
|
2270
|
+
jsonBody: { expire_previous_now: options?.expire_previous_now ?? false },
|
|
2271
|
+
allowRetries: false
|
|
2272
|
+
}
|
|
2273
|
+
);
|
|
2274
|
+
return hideSecret(response);
|
|
2275
|
+
}
|
|
2276
|
+
/**
|
|
2277
|
+
* Send a sample event of `eventType` to this endpoint only, with `test` true in the
|
|
2278
|
+
* envelope. It is sent whatever the endpoint's event types and collection filter,
|
|
2279
|
+
* but the endpoint must be active ({@link WebhookEndpointNotActiveError}).
|
|
2280
|
+
*/
|
|
2281
|
+
async sendWebhookTestEvent(endpointId, eventType) {
|
|
2282
|
+
return this.transport.request("POST", `${this.paths.webhookEndpointRoot(endpointId)}/test/`, {
|
|
2283
|
+
jsonBody: { event_type: eventType },
|
|
2284
|
+
allowRetries: false
|
|
2285
|
+
});
|
|
2286
|
+
}
|
|
2287
|
+
/**
|
|
2288
|
+
* Send again the endpoint's failed deliveries created at or after `since`.
|
|
2289
|
+
*
|
|
2290
|
+
* Each becomes a new pending delivery of the same event. One call queues at most
|
|
2291
|
+
* 10,000 deliveries; when `more` is true, call again with the same `since`. `since`
|
|
2292
|
+
* is an ISO 8601 time within the last 30 days; a time without a zone is read as UTC.
|
|
2293
|
+
*/
|
|
2294
|
+
async recoverWebhookDeliveries(endpointId, since) {
|
|
2295
|
+
return this.transport.request(
|
|
2296
|
+
"POST",
|
|
2297
|
+
`${this.paths.webhookEndpointRoot(endpointId)}/recover/`,
|
|
2298
|
+
{
|
|
2299
|
+
jsonBody: { since: since instanceof Date ? since.toISOString() : since },
|
|
2300
|
+
allowRetries: false
|
|
2301
|
+
}
|
|
2302
|
+
);
|
|
2303
|
+
}
|
|
2304
|
+
/**
|
|
2305
|
+
* List the events of the last 30 days, newest first, with `delivery_counts`.
|
|
2306
|
+
* `params` carries `type`, `endpoint` (an endpoint `id`), `status` (`pending`,
|
|
2307
|
+
* `succeeded` or `dead`), `test`, `after`, `before` (ISO 8601), `limit` (at most 200)
|
|
2308
|
+
* and `offset`.
|
|
2309
|
+
*/
|
|
2310
|
+
async listWebhookEvents(params) {
|
|
2311
|
+
return this.request("GET", `${this.paths.webhooksRoot()}/events/`, { params });
|
|
2312
|
+
}
|
|
2313
|
+
/** Read one event with its envelope and all its deliveries, oldest first. */
|
|
2314
|
+
async getWebhookEvent(eventId) {
|
|
2315
|
+
return this.request("GET", `${this.paths.webhookEventRoot(eventId)}/`);
|
|
2316
|
+
}
|
|
2317
|
+
/**
|
|
2318
|
+
* List every attempt to deliver the event, across endpoints, oldest first. `params`
|
|
2319
|
+
* carries `limit` (at most 200) and `offset`.
|
|
2320
|
+
*/
|
|
2321
|
+
async listWebhookEventAttempts(eventId, params) {
|
|
2322
|
+
return this.request("GET", `${this.paths.webhookEventRoot(eventId)}/attempts/`, { params });
|
|
2323
|
+
}
|
|
2324
|
+
/**
|
|
2325
|
+
* Send the event again as a new delivery, with the same event `id`.
|
|
2326
|
+
*
|
|
2327
|
+
* With `endpoint_id` the event goes to that endpoint. Without it, the event goes to
|
|
2328
|
+
* every endpoint that had a delivery of it and is active and subscribed to it now;
|
|
2329
|
+
* the others are listed in `skipped`.
|
|
2330
|
+
*/
|
|
2331
|
+
async redeliverWebhookEvent(eventId, options) {
|
|
2332
|
+
return this.transport.request("POST", `${this.paths.webhookEventRoot(eventId)}/redeliver/`, {
|
|
2333
|
+
jsonBody: options?.endpoint_id !== void 0 ? { endpoint_id: options.endpoint_id } : {},
|
|
2334
|
+
allowRetries: false
|
|
2335
|
+
});
|
|
2336
|
+
}
|
|
2337
|
+
/** List the event-type catalogue with the JSON Schema of each payload mode. */
|
|
2338
|
+
async listWebhookEventTypes() {
|
|
2339
|
+
return this.request("GET", `${this.paths.webhooksRoot()}/event-types/`);
|
|
2340
|
+
}
|
|
2101
2341
|
fileRoot(collectionKey, resourceKey) {
|
|
2102
2342
|
return this.paths.fileRoot(resolveKey(collectionKey), resolveKey(resourceKey));
|
|
2103
2343
|
}
|
|
@@ -2559,6 +2799,11 @@ export {
|
|
|
2559
2799
|
StaticTokenProvider,
|
|
2560
2800
|
UpstreamError,
|
|
2561
2801
|
SDK_VERSION as VERSION,
|
|
2802
|
+
WebhookEndpointLimitExceededError,
|
|
2803
|
+
WebhookEndpointNotActiveError,
|
|
2804
|
+
WebhookEndpointNotFoundError,
|
|
2805
|
+
WebhookEndpointNotSubscribedError,
|
|
2806
|
+
WebhookEventNotFoundError,
|
|
2562
2807
|
buildSearchBody,
|
|
2563
2808
|
createConfig,
|
|
2564
2809
|
nestedFieldMeta,
|