@garuhq/node 2.0.0 → 4.0.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/CHANGELOG.md +104 -10
- package/README.md +37 -29
- package/dist/index.cjs +57 -66
- package/dist/index.d.cts +79 -45
- package/dist/index.d.ts +79 -45
- package/dist/index.js +57 -66
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -390,7 +390,13 @@ interface ScheduledChargeRecord {
|
|
|
390
390
|
/** YYYY-MM-DD in São Paulo time. */
|
|
391
391
|
dueDate: string;
|
|
392
392
|
methods: ScheduledPaymentMethod[];
|
|
393
|
+
recurrence: RecurrenceConfig | null;
|
|
393
394
|
status: ScheduledChargeStatus;
|
|
395
|
+
subscriptionId: number | null;
|
|
396
|
+
/** ISO-8601. Set only when the series was created with `trialDays`. */
|
|
397
|
+
trialEndsAt: string | null;
|
|
398
|
+
/** Recurring only. Toggle with `setCancelAtPeriodEnd`. */
|
|
399
|
+
cancelAtPeriodEnd: boolean;
|
|
394
400
|
externalReference: string | null;
|
|
395
401
|
/**
|
|
396
402
|
* Max days past `dueDate` the daily recovery sweep will still auto-bill a
|
|
@@ -425,7 +431,7 @@ interface ScheduledChargeEvent {
|
|
|
425
431
|
}
|
|
426
432
|
interface ScheduledChargeLinkedTransaction {
|
|
427
433
|
id: number;
|
|
428
|
-
/**
|
|
434
|
+
/** Decimal BRL (e.g. `297.50`), never centavos. */
|
|
429
435
|
value: number;
|
|
430
436
|
paymentMethod: string;
|
|
431
437
|
status: string;
|
|
@@ -438,7 +444,14 @@ interface ScheduledChargeDetail {
|
|
|
438
444
|
events: ScheduledChargeEvent[];
|
|
439
445
|
transactions: ScheduledChargeLinkedTransaction[];
|
|
440
446
|
}
|
|
441
|
-
|
|
447
|
+
interface ScheduledChargeList {
|
|
448
|
+
data: ScheduledChargeRecord[];
|
|
449
|
+
/** Items on this page. */
|
|
450
|
+
count: number;
|
|
451
|
+
/** Total matches across all pages. */
|
|
452
|
+
totalCount: number;
|
|
453
|
+
totalPages: number;
|
|
454
|
+
}
|
|
442
455
|
/** Source of a billing attempt — see SPEC §3.1. */
|
|
443
456
|
type ScheduledChargeAttemptSource = 'cycle1_interactive' | 'silent_charge' | 'card_retry' | 'manual_mark_paid' | 'fallback_pix';
|
|
444
457
|
type ScheduledChargeAttemptStatus = 'pending' | 'succeeded' | 'declined' | 'canceled' | 'errored';
|
|
@@ -460,7 +473,14 @@ interface ScheduledChargeAttempt {
|
|
|
460
473
|
gatewayChargeId: number | null;
|
|
461
474
|
transactionId: number | null;
|
|
462
475
|
}
|
|
463
|
-
|
|
476
|
+
interface ScheduledChargeAttemptList {
|
|
477
|
+
data: ScheduledChargeAttempt[];
|
|
478
|
+
/** Items on this page. */
|
|
479
|
+
count: number;
|
|
480
|
+
/** Total matches across all pages. */
|
|
481
|
+
totalCount: number;
|
|
482
|
+
totalPages: number;
|
|
483
|
+
}
|
|
464
484
|
interface ListScheduledChargeAttemptsParams {
|
|
465
485
|
page?: number;
|
|
466
486
|
limit?: number;
|
|
@@ -770,9 +790,14 @@ interface WebhookEventEndpoint {
|
|
|
770
790
|
events: string[];
|
|
771
791
|
[key: string]: unknown;
|
|
772
792
|
}
|
|
793
|
+
/**
|
|
794
|
+
* Public API v1 webhook-event representation. Keyed on `uuid` — there is no
|
|
795
|
+
* numeric id in this shape. `webhookEndpoint.id` stays numeric: endpoint
|
|
796
|
+
* *configuration* (create/update/delete) is still dashboard-only and did
|
|
797
|
+
* not move to `/api/v1`.
|
|
798
|
+
*/
|
|
773
799
|
interface WebhookEvent {
|
|
774
|
-
|
|
775
|
-
endpointId: number;
|
|
800
|
+
uuid: string;
|
|
776
801
|
/** Eager-loaded endpoint snapshot. */
|
|
777
802
|
webhookEndpoint: WebhookEventEndpoint;
|
|
778
803
|
/** Garu event type, e.g. `transaction.payment.paid`. */
|
|
@@ -791,17 +816,24 @@ interface WebhookEvent {
|
|
|
791
816
|
/** Response body from the most recent attempt, truncated by the gateway. */
|
|
792
817
|
responseBody: string | null;
|
|
793
818
|
/**
|
|
794
|
-
* When this row is a clone produced by `webhookEvents.resend(
|
|
795
|
-
* the
|
|
796
|
-
*
|
|
797
|
-
*
|
|
798
|
-
*
|
|
819
|
+
* When this row is a clone produced by `webhookEvents.resend(uuid)`, this
|
|
820
|
+
* is the uuid of the original event the clone was forked from. `null` on
|
|
821
|
+
* every originally-fired event (and on events resurrected via the legacy
|
|
822
|
+
* `webhookEvents.retry(uuid)` mutation, which mutates in place instead of
|
|
823
|
+
* cloning).
|
|
799
824
|
*/
|
|
800
|
-
manualResendOf:
|
|
825
|
+
manualResendOf: string | null;
|
|
801
826
|
createdAt: string;
|
|
802
827
|
[key: string]: unknown;
|
|
803
828
|
}
|
|
804
|
-
|
|
829
|
+
interface WebhookEventList {
|
|
830
|
+
data: WebhookEvent[];
|
|
831
|
+
/** Items on this page. */
|
|
832
|
+
count: number;
|
|
833
|
+
/** Total matches across all pages. */
|
|
834
|
+
totalCount: number;
|
|
835
|
+
totalPages: number;
|
|
836
|
+
}
|
|
805
837
|
interface ListWebhookEventsParams {
|
|
806
838
|
page?: number;
|
|
807
839
|
limit?: number;
|
|
@@ -1561,9 +1593,13 @@ declare class ScheduledCharges {
|
|
|
1561
1593
|
private readonly http;
|
|
1562
1594
|
constructor(http: HttpClient);
|
|
1563
1595
|
/**
|
|
1564
|
-
* Create a new scheduled charge.
|
|
1565
|
-
* (UUIDv4
|
|
1566
|
-
*
|
|
1596
|
+
* Create a new scheduled charge. The SDK attaches an `X-Idempotency-Key`
|
|
1597
|
+
* header (UUIDv4 unless you pass `idempotencyKey`), but the gateway does
|
|
1598
|
+
* not currently deduplicate `/scheduled-charges` creates against it — a
|
|
1599
|
+
* retry after a network failure can create more than one series. Pair
|
|
1600
|
+
* this with your own retry-suppression (e.g. check `list` for an existing
|
|
1601
|
+
* series with the same `externalReference`) if that matters for your
|
|
1602
|
+
* integration.
|
|
1567
1603
|
*
|
|
1568
1604
|
* @example
|
|
1569
1605
|
* const charge = await garu.scheduledCharges.create({
|
|
@@ -1680,17 +1716,15 @@ declare class ScheduledCharges {
|
|
|
1680
1716
|
* const result = await garu.scheduledCharges.chargeNow('sch_abc123');
|
|
1681
1717
|
* switch (result.outcome) {
|
|
1682
1718
|
* case 'dispatched':
|
|
1683
|
-
*
|
|
1719
|
+
* result.cycleNumber; // billed this cycle
|
|
1684
1720
|
* break;
|
|
1685
1721
|
* case 'already_sent':
|
|
1686
|
-
*
|
|
1687
|
-
* break;
|
|
1722
|
+
* break; // nothing to do
|
|
1688
1723
|
* case 'failed':
|
|
1689
|
-
*
|
|
1690
|
-
* console.error(`Falha na cobrança: ${result.reason}. ${result.message}`);
|
|
1724
|
+
* result.reason; // e.g. 'card_expired' or a gateway decline code
|
|
1691
1725
|
* break;
|
|
1692
1726
|
* case 'not_sent':
|
|
1693
|
-
*
|
|
1727
|
+
* result.reason;
|
|
1694
1728
|
* break;
|
|
1695
1729
|
* }
|
|
1696
1730
|
*/
|
|
@@ -1754,7 +1788,8 @@ declare class ScheduledCharges {
|
|
|
1754
1788
|
/**
|
|
1755
1789
|
* Webhook events — the seller-facing delivery log for outbound webhooks.
|
|
1756
1790
|
*
|
|
1757
|
-
*
|
|
1791
|
+
* Backed by `/api/v1/webhook-events`, keyed on `uuid`. Every time the
|
|
1792
|
+
* gateway fires a webhook (e.g. `transaction.payment.paid`,
|
|
1758
1793
|
* `scheduled_charge.cycle_failed`), it persists one row per destination
|
|
1759
1794
|
* endpoint with the full payload, the HTTP outcome, and the retry schedule.
|
|
1760
1795
|
* Use this resource to audit deliveries from the seller's API key — the
|
|
@@ -1762,6 +1797,7 @@ declare class ScheduledCharges {
|
|
|
1762
1797
|
*
|
|
1763
1798
|
* Webhook endpoint *configuration* (URL, subscribed events, secret) is still
|
|
1764
1799
|
* dashboard-only — this resource only covers the event log + manual retries.
|
|
1800
|
+
* `webhookEndpoint.id` on every event stays a numeric id for that reason.
|
|
1765
1801
|
*/
|
|
1766
1802
|
declare class WebhookEvents {
|
|
1767
1803
|
private readonly http;
|
|
@@ -1784,16 +1820,14 @@ declare class WebhookEvents {
|
|
|
1784
1820
|
*/
|
|
1785
1821
|
list(params?: ListWebhookEventsParams): Promise<WebhookEventList>;
|
|
1786
1822
|
/**
|
|
1787
|
-
* Fetch one webhook event by
|
|
1823
|
+
* Fetch one webhook event by uuid — includes the full payload, the
|
|
1788
1824
|
* embedded endpoint snapshot, and the most recent response status/body.
|
|
1789
1825
|
*
|
|
1790
1826
|
* @example
|
|
1791
|
-
* const event = await garu.webhookEvents.get(
|
|
1792
|
-
*
|
|
1793
|
-
* console.log(event.responseStatus, event.responseBody);
|
|
1794
|
-
* }
|
|
1827
|
+
* const event = await garu.webhookEvents.get('a1b2c3d4-e5f6-7890-abcd-ef1234567890');
|
|
1828
|
+
* event.status === 'failed' && event.responseStatus;
|
|
1795
1829
|
*/
|
|
1796
|
-
get(
|
|
1830
|
+
get(uuid: string): Promise<WebhookEvent>;
|
|
1797
1831
|
/**
|
|
1798
1832
|
* @deprecated For most cases prefer {@link resend}, which preserves the
|
|
1799
1833
|
* original event's audit trail by cloning rather than mutating. `retry()`
|
|
@@ -1802,21 +1836,21 @@ declare class WebhookEvents {
|
|
|
1802
1836
|
* explicitly want the legacy in-place semantics (and for backwards
|
|
1803
1837
|
* compatibility with older CLI / MCP releases).
|
|
1804
1838
|
*
|
|
1805
|
-
* Re-deliver a webhook event by
|
|
1839
|
+
* Re-deliver a webhook event by uuid. Resets it to `pending`, clears the
|
|
1806
1840
|
* retry schedule, and triggers an immediate delivery attempt. Works on
|
|
1807
1841
|
* any status (`success`, `failed`, `pending`).
|
|
1808
1842
|
*
|
|
1809
1843
|
* @example
|
|
1810
1844
|
* const failed = await garu.webhookEvents.list({ status: 'failed', limit: 5 });
|
|
1811
1845
|
* for (const event of failed.data) {
|
|
1812
|
-
* await garu.webhookEvents.retry(event.
|
|
1846
|
+
* await garu.webhookEvents.retry(event.uuid);
|
|
1813
1847
|
* }
|
|
1814
1848
|
*/
|
|
1815
|
-
retry(
|
|
1849
|
+
retry(uuid: string): Promise<WebhookEvent>;
|
|
1816
1850
|
/**
|
|
1817
|
-
* Re-deliver a webhook event by
|
|
1851
|
+
* Re-deliver a webhook event by uuid, audit-trail preserving. Unlike
|
|
1818
1852
|
* {@link retry}, this does *not* mutate the original row — it inserts a
|
|
1819
|
-
* fresh event (new
|
|
1853
|
+
* fresh event (new uuid) that points back at the source via
|
|
1820
1854
|
* `manualResendOf`, then dispatches that clone. The original row is
|
|
1821
1855
|
* untouched, so the historical record of the prior failure (and its
|
|
1822
1856
|
* response status / body) is preserved.
|
|
@@ -1827,27 +1861,27 @@ declare class WebhookEvents {
|
|
|
1827
1861
|
* delivery's outcome to remain on the record.
|
|
1828
1862
|
*
|
|
1829
1863
|
* **Outbound delivery semantics**: the gateway POSTs the clone with
|
|
1830
|
-
* `Idempotency-Key: resend_<
|
|
1831
|
-
* of the source event, not the clone). Recipient handlers that key off
|
|
1864
|
+
* `Idempotency-Key: resend_<cloneUuid>`. Recipient handlers that key off
|
|
1832
1865
|
* `Idempotency-Key` will see this as a distinct delivery from the
|
|
1833
1866
|
* original — distinguishable both by the `resend_` prefix and by reading
|
|
1834
1867
|
* the response payload's `manualResendOf` field.
|
|
1835
1868
|
*
|
|
1836
|
-
*
|
|
1837
|
-
*
|
|
1838
|
-
*
|
|
1839
|
-
*
|
|
1869
|
+
* The SDK also attaches an `X-Idempotency-Key` header (UUIDv4 unless you
|
|
1870
|
+
* pass `idempotencyKey`); the gateway does not currently deduplicate
|
|
1871
|
+
* `/resend` calls against it, so retrying this call from your own code
|
|
1872
|
+
* after a network failure can create more than one clone — pair it with
|
|
1873
|
+
* your own retry-suppression if that matters for your integration.
|
|
1840
1874
|
*
|
|
1841
|
-
* Returns the *clone* event (new
|
|
1875
|
+
* Returns the *clone* event (new uuid), not the original. The original is
|
|
1842
1876
|
* unchanged on the server.
|
|
1843
1877
|
*
|
|
1844
1878
|
* @example
|
|
1845
|
-
* const event = await garu.webhookEvents.get(
|
|
1846
|
-
* const clone = await garu.webhookEvents.resend(
|
|
1847
|
-
* clone.
|
|
1848
|
-
* clone.manualResendOf === event.
|
|
1879
|
+
* const event = await garu.webhookEvents.get('a1b2c3d4-e5f6-7890-abcd-ef1234567890');
|
|
1880
|
+
* const clone = await garu.webhookEvents.resend(event.uuid);
|
|
1881
|
+
* clone.uuid !== event.uuid; // true — clone has its own uuid
|
|
1882
|
+
* clone.manualResendOf === event.uuid; // true — points back at the source
|
|
1849
1883
|
*/
|
|
1850
|
-
resend(
|
|
1884
|
+
resend(uuid: string, params?: ResendWebhookEventParams): Promise<WebhookEvent>;
|
|
1851
1885
|
}
|
|
1852
1886
|
|
|
1853
1887
|
interface GaruOptions {
|
package/dist/index.d.ts
CHANGED
|
@@ -390,7 +390,13 @@ interface ScheduledChargeRecord {
|
|
|
390
390
|
/** YYYY-MM-DD in São Paulo time. */
|
|
391
391
|
dueDate: string;
|
|
392
392
|
methods: ScheduledPaymentMethod[];
|
|
393
|
+
recurrence: RecurrenceConfig | null;
|
|
393
394
|
status: ScheduledChargeStatus;
|
|
395
|
+
subscriptionId: number | null;
|
|
396
|
+
/** ISO-8601. Set only when the series was created with `trialDays`. */
|
|
397
|
+
trialEndsAt: string | null;
|
|
398
|
+
/** Recurring only. Toggle with `setCancelAtPeriodEnd`. */
|
|
399
|
+
cancelAtPeriodEnd: boolean;
|
|
394
400
|
externalReference: string | null;
|
|
395
401
|
/**
|
|
396
402
|
* Max days past `dueDate` the daily recovery sweep will still auto-bill a
|
|
@@ -425,7 +431,7 @@ interface ScheduledChargeEvent {
|
|
|
425
431
|
}
|
|
426
432
|
interface ScheduledChargeLinkedTransaction {
|
|
427
433
|
id: number;
|
|
428
|
-
/**
|
|
434
|
+
/** Decimal BRL (e.g. `297.50`), never centavos. */
|
|
429
435
|
value: number;
|
|
430
436
|
paymentMethod: string;
|
|
431
437
|
status: string;
|
|
@@ -438,7 +444,14 @@ interface ScheduledChargeDetail {
|
|
|
438
444
|
events: ScheduledChargeEvent[];
|
|
439
445
|
transactions: ScheduledChargeLinkedTransaction[];
|
|
440
446
|
}
|
|
441
|
-
|
|
447
|
+
interface ScheduledChargeList {
|
|
448
|
+
data: ScheduledChargeRecord[];
|
|
449
|
+
/** Items on this page. */
|
|
450
|
+
count: number;
|
|
451
|
+
/** Total matches across all pages. */
|
|
452
|
+
totalCount: number;
|
|
453
|
+
totalPages: number;
|
|
454
|
+
}
|
|
442
455
|
/** Source of a billing attempt — see SPEC §3.1. */
|
|
443
456
|
type ScheduledChargeAttemptSource = 'cycle1_interactive' | 'silent_charge' | 'card_retry' | 'manual_mark_paid' | 'fallback_pix';
|
|
444
457
|
type ScheduledChargeAttemptStatus = 'pending' | 'succeeded' | 'declined' | 'canceled' | 'errored';
|
|
@@ -460,7 +473,14 @@ interface ScheduledChargeAttempt {
|
|
|
460
473
|
gatewayChargeId: number | null;
|
|
461
474
|
transactionId: number | null;
|
|
462
475
|
}
|
|
463
|
-
|
|
476
|
+
interface ScheduledChargeAttemptList {
|
|
477
|
+
data: ScheduledChargeAttempt[];
|
|
478
|
+
/** Items on this page. */
|
|
479
|
+
count: number;
|
|
480
|
+
/** Total matches across all pages. */
|
|
481
|
+
totalCount: number;
|
|
482
|
+
totalPages: number;
|
|
483
|
+
}
|
|
464
484
|
interface ListScheduledChargeAttemptsParams {
|
|
465
485
|
page?: number;
|
|
466
486
|
limit?: number;
|
|
@@ -770,9 +790,14 @@ interface WebhookEventEndpoint {
|
|
|
770
790
|
events: string[];
|
|
771
791
|
[key: string]: unknown;
|
|
772
792
|
}
|
|
793
|
+
/**
|
|
794
|
+
* Public API v1 webhook-event representation. Keyed on `uuid` — there is no
|
|
795
|
+
* numeric id in this shape. `webhookEndpoint.id` stays numeric: endpoint
|
|
796
|
+
* *configuration* (create/update/delete) is still dashboard-only and did
|
|
797
|
+
* not move to `/api/v1`.
|
|
798
|
+
*/
|
|
773
799
|
interface WebhookEvent {
|
|
774
|
-
|
|
775
|
-
endpointId: number;
|
|
800
|
+
uuid: string;
|
|
776
801
|
/** Eager-loaded endpoint snapshot. */
|
|
777
802
|
webhookEndpoint: WebhookEventEndpoint;
|
|
778
803
|
/** Garu event type, e.g. `transaction.payment.paid`. */
|
|
@@ -791,17 +816,24 @@ interface WebhookEvent {
|
|
|
791
816
|
/** Response body from the most recent attempt, truncated by the gateway. */
|
|
792
817
|
responseBody: string | null;
|
|
793
818
|
/**
|
|
794
|
-
* When this row is a clone produced by `webhookEvents.resend(
|
|
795
|
-
* the
|
|
796
|
-
*
|
|
797
|
-
*
|
|
798
|
-
*
|
|
819
|
+
* When this row is a clone produced by `webhookEvents.resend(uuid)`, this
|
|
820
|
+
* is the uuid of the original event the clone was forked from. `null` on
|
|
821
|
+
* every originally-fired event (and on events resurrected via the legacy
|
|
822
|
+
* `webhookEvents.retry(uuid)` mutation, which mutates in place instead of
|
|
823
|
+
* cloning).
|
|
799
824
|
*/
|
|
800
|
-
manualResendOf:
|
|
825
|
+
manualResendOf: string | null;
|
|
801
826
|
createdAt: string;
|
|
802
827
|
[key: string]: unknown;
|
|
803
828
|
}
|
|
804
|
-
|
|
829
|
+
interface WebhookEventList {
|
|
830
|
+
data: WebhookEvent[];
|
|
831
|
+
/** Items on this page. */
|
|
832
|
+
count: number;
|
|
833
|
+
/** Total matches across all pages. */
|
|
834
|
+
totalCount: number;
|
|
835
|
+
totalPages: number;
|
|
836
|
+
}
|
|
805
837
|
interface ListWebhookEventsParams {
|
|
806
838
|
page?: number;
|
|
807
839
|
limit?: number;
|
|
@@ -1561,9 +1593,13 @@ declare class ScheduledCharges {
|
|
|
1561
1593
|
private readonly http;
|
|
1562
1594
|
constructor(http: HttpClient);
|
|
1563
1595
|
/**
|
|
1564
|
-
* Create a new scheduled charge.
|
|
1565
|
-
* (UUIDv4
|
|
1566
|
-
*
|
|
1596
|
+
* Create a new scheduled charge. The SDK attaches an `X-Idempotency-Key`
|
|
1597
|
+
* header (UUIDv4 unless you pass `idempotencyKey`), but the gateway does
|
|
1598
|
+
* not currently deduplicate `/scheduled-charges` creates against it — a
|
|
1599
|
+
* retry after a network failure can create more than one series. Pair
|
|
1600
|
+
* this with your own retry-suppression (e.g. check `list` for an existing
|
|
1601
|
+
* series with the same `externalReference`) if that matters for your
|
|
1602
|
+
* integration.
|
|
1567
1603
|
*
|
|
1568
1604
|
* @example
|
|
1569
1605
|
* const charge = await garu.scheduledCharges.create({
|
|
@@ -1680,17 +1716,15 @@ declare class ScheduledCharges {
|
|
|
1680
1716
|
* const result = await garu.scheduledCharges.chargeNow('sch_abc123');
|
|
1681
1717
|
* switch (result.outcome) {
|
|
1682
1718
|
* case 'dispatched':
|
|
1683
|
-
*
|
|
1719
|
+
* result.cycleNumber; // billed this cycle
|
|
1684
1720
|
* break;
|
|
1685
1721
|
* case 'already_sent':
|
|
1686
|
-
*
|
|
1687
|
-
* break;
|
|
1722
|
+
* break; // nothing to do
|
|
1688
1723
|
* case 'failed':
|
|
1689
|
-
*
|
|
1690
|
-
* console.error(`Falha na cobrança: ${result.reason}. ${result.message}`);
|
|
1724
|
+
* result.reason; // e.g. 'card_expired' or a gateway decline code
|
|
1691
1725
|
* break;
|
|
1692
1726
|
* case 'not_sent':
|
|
1693
|
-
*
|
|
1727
|
+
* result.reason;
|
|
1694
1728
|
* break;
|
|
1695
1729
|
* }
|
|
1696
1730
|
*/
|
|
@@ -1754,7 +1788,8 @@ declare class ScheduledCharges {
|
|
|
1754
1788
|
/**
|
|
1755
1789
|
* Webhook events — the seller-facing delivery log for outbound webhooks.
|
|
1756
1790
|
*
|
|
1757
|
-
*
|
|
1791
|
+
* Backed by `/api/v1/webhook-events`, keyed on `uuid`. Every time the
|
|
1792
|
+
* gateway fires a webhook (e.g. `transaction.payment.paid`,
|
|
1758
1793
|
* `scheduled_charge.cycle_failed`), it persists one row per destination
|
|
1759
1794
|
* endpoint with the full payload, the HTTP outcome, and the retry schedule.
|
|
1760
1795
|
* Use this resource to audit deliveries from the seller's API key — the
|
|
@@ -1762,6 +1797,7 @@ declare class ScheduledCharges {
|
|
|
1762
1797
|
*
|
|
1763
1798
|
* Webhook endpoint *configuration* (URL, subscribed events, secret) is still
|
|
1764
1799
|
* dashboard-only — this resource only covers the event log + manual retries.
|
|
1800
|
+
* `webhookEndpoint.id` on every event stays a numeric id for that reason.
|
|
1765
1801
|
*/
|
|
1766
1802
|
declare class WebhookEvents {
|
|
1767
1803
|
private readonly http;
|
|
@@ -1784,16 +1820,14 @@ declare class WebhookEvents {
|
|
|
1784
1820
|
*/
|
|
1785
1821
|
list(params?: ListWebhookEventsParams): Promise<WebhookEventList>;
|
|
1786
1822
|
/**
|
|
1787
|
-
* Fetch one webhook event by
|
|
1823
|
+
* Fetch one webhook event by uuid — includes the full payload, the
|
|
1788
1824
|
* embedded endpoint snapshot, and the most recent response status/body.
|
|
1789
1825
|
*
|
|
1790
1826
|
* @example
|
|
1791
|
-
* const event = await garu.webhookEvents.get(
|
|
1792
|
-
*
|
|
1793
|
-
* console.log(event.responseStatus, event.responseBody);
|
|
1794
|
-
* }
|
|
1827
|
+
* const event = await garu.webhookEvents.get('a1b2c3d4-e5f6-7890-abcd-ef1234567890');
|
|
1828
|
+
* event.status === 'failed' && event.responseStatus;
|
|
1795
1829
|
*/
|
|
1796
|
-
get(
|
|
1830
|
+
get(uuid: string): Promise<WebhookEvent>;
|
|
1797
1831
|
/**
|
|
1798
1832
|
* @deprecated For most cases prefer {@link resend}, which preserves the
|
|
1799
1833
|
* original event's audit trail by cloning rather than mutating. `retry()`
|
|
@@ -1802,21 +1836,21 @@ declare class WebhookEvents {
|
|
|
1802
1836
|
* explicitly want the legacy in-place semantics (and for backwards
|
|
1803
1837
|
* compatibility with older CLI / MCP releases).
|
|
1804
1838
|
*
|
|
1805
|
-
* Re-deliver a webhook event by
|
|
1839
|
+
* Re-deliver a webhook event by uuid. Resets it to `pending`, clears the
|
|
1806
1840
|
* retry schedule, and triggers an immediate delivery attempt. Works on
|
|
1807
1841
|
* any status (`success`, `failed`, `pending`).
|
|
1808
1842
|
*
|
|
1809
1843
|
* @example
|
|
1810
1844
|
* const failed = await garu.webhookEvents.list({ status: 'failed', limit: 5 });
|
|
1811
1845
|
* for (const event of failed.data) {
|
|
1812
|
-
* await garu.webhookEvents.retry(event.
|
|
1846
|
+
* await garu.webhookEvents.retry(event.uuid);
|
|
1813
1847
|
* }
|
|
1814
1848
|
*/
|
|
1815
|
-
retry(
|
|
1849
|
+
retry(uuid: string): Promise<WebhookEvent>;
|
|
1816
1850
|
/**
|
|
1817
|
-
* Re-deliver a webhook event by
|
|
1851
|
+
* Re-deliver a webhook event by uuid, audit-trail preserving. Unlike
|
|
1818
1852
|
* {@link retry}, this does *not* mutate the original row — it inserts a
|
|
1819
|
-
* fresh event (new
|
|
1853
|
+
* fresh event (new uuid) that points back at the source via
|
|
1820
1854
|
* `manualResendOf`, then dispatches that clone. The original row is
|
|
1821
1855
|
* untouched, so the historical record of the prior failure (and its
|
|
1822
1856
|
* response status / body) is preserved.
|
|
@@ -1827,27 +1861,27 @@ declare class WebhookEvents {
|
|
|
1827
1861
|
* delivery's outcome to remain on the record.
|
|
1828
1862
|
*
|
|
1829
1863
|
* **Outbound delivery semantics**: the gateway POSTs the clone with
|
|
1830
|
-
* `Idempotency-Key: resend_<
|
|
1831
|
-
* of the source event, not the clone). Recipient handlers that key off
|
|
1864
|
+
* `Idempotency-Key: resend_<cloneUuid>`. Recipient handlers that key off
|
|
1832
1865
|
* `Idempotency-Key` will see this as a distinct delivery from the
|
|
1833
1866
|
* original — distinguishable both by the `resend_` prefix and by reading
|
|
1834
1867
|
* the response payload's `manualResendOf` field.
|
|
1835
1868
|
*
|
|
1836
|
-
*
|
|
1837
|
-
*
|
|
1838
|
-
*
|
|
1839
|
-
*
|
|
1869
|
+
* The SDK also attaches an `X-Idempotency-Key` header (UUIDv4 unless you
|
|
1870
|
+
* pass `idempotencyKey`); the gateway does not currently deduplicate
|
|
1871
|
+
* `/resend` calls against it, so retrying this call from your own code
|
|
1872
|
+
* after a network failure can create more than one clone — pair it with
|
|
1873
|
+
* your own retry-suppression if that matters for your integration.
|
|
1840
1874
|
*
|
|
1841
|
-
* Returns the *clone* event (new
|
|
1875
|
+
* Returns the *clone* event (new uuid), not the original. The original is
|
|
1842
1876
|
* unchanged on the server.
|
|
1843
1877
|
*
|
|
1844
1878
|
* @example
|
|
1845
|
-
* const event = await garu.webhookEvents.get(
|
|
1846
|
-
* const clone = await garu.webhookEvents.resend(
|
|
1847
|
-
* clone.
|
|
1848
|
-
* clone.manualResendOf === event.
|
|
1879
|
+
* const event = await garu.webhookEvents.get('a1b2c3d4-e5f6-7890-abcd-ef1234567890');
|
|
1880
|
+
* const clone = await garu.webhookEvents.resend(event.uuid);
|
|
1881
|
+
* clone.uuid !== event.uuid; // true — clone has its own uuid
|
|
1882
|
+
* clone.manualResendOf === event.uuid; // true — points back at the source
|
|
1849
1883
|
*/
|
|
1850
|
-
resend(
|
|
1884
|
+
resend(uuid: string, params?: ResendWebhookEventParams): Promise<WebhookEvent>;
|
|
1851
1885
|
}
|
|
1852
1886
|
|
|
1853
1887
|
interface GaruOptions {
|