@secondlayer/sdk 15.1.0 → 15.3.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/dist/index.d.ts +16 -6
- package/dist/index.js +17 -15
- package/dist/index.js.map +4 -4
- package/dist/subgraphs/index.d.ts +15 -5
- package/dist/subgraphs/index.js +5 -5
- package/dist/subgraphs/index.js.map +3 -3
- package/dist/webhooks/doctor.d.ts +1 -1
- package/dist/webhooks/doctor.js +13 -11
- package/dist/webhooks/doctor.js.map +3 -3
- package/package.json +3 -3
package/dist/index.d.ts
CHANGED
|
@@ -3707,16 +3707,26 @@ declare class Webhooks extends BaseClient {
|
|
|
3707
3707
|
* Built for the webhook's format and SSRF-guarded. Logged as a delivery
|
|
3708
3708
|
* row, visible via `deliveries`. */
|
|
3709
3709
|
test(id: string): Promise<WebhookTestResult>;
|
|
3710
|
-
/** The last 100 delivery attempts, newest first. The server caps the
|
|
3711
|
-
* there is nothing to page.
|
|
3712
|
-
|
|
3710
|
+
/** The last 100 delivery attempts, newest first. The server caps the
|
|
3711
|
+
* result; there is nothing to page. Pass `window` (ISO timestamps, at most
|
|
3712
|
+
* 31 days wide) to read only the attempts dispatched in `[from, to)`, for
|
|
3713
|
+
* example one hour of the heat strip; `total` then counts that window. */
|
|
3714
|
+
deliveries(id: string, window?: {
|
|
3715
|
+
from: string;
|
|
3716
|
+
to: string;
|
|
3717
|
+
}): Promise<{
|
|
3718
|
+
total: number;
|
|
3713
3719
|
data: DeliveryRow[];
|
|
3714
3720
|
}>;
|
|
3715
3721
|
/** Get a webhook's hourly delivery counts for the last 7 days.
|
|
3716
3722
|
*
|
|
3717
3723
|
* Each hour has delivered, waiting, and gave-up counts, plus the current
|
|
3718
|
-
* queue depth
|
|
3719
|
-
|
|
3724
|
+
* queue depth, failed attempts per hour, and the usual band. Pass
|
|
3725
|
+
* `{ days: 30 }` to also get 30 daily totals. This is the events chart on
|
|
3726
|
+
* the detail page. */
|
|
3727
|
+
activity(id: string, opts?: {
|
|
3728
|
+
days?: 30;
|
|
3729
|
+
}): Promise<WebhookActivity>;
|
|
3720
3730
|
/** Get one delivery attempt with its payload and response.
|
|
3721
3731
|
*
|
|
3722
3732
|
* Includes the outbox context (payload, response headers). This is the
|
|
@@ -3859,6 +3869,7 @@ declare function getSubgraph<T extends {
|
|
|
3859
3869
|
schema: Record<string, unknown>;
|
|
3860
3870
|
}>(def: T, options?: Partial<SecondLayerOptions> | SecondLayer | Subgraphs): InferSubgraphClient2<T>;
|
|
3861
3871
|
import { SubgraphAgentSchema as SubgraphAgentSchema3, SubgraphSpecFormat as SubgraphSpecFormat2, SubgraphSpecOptions as SubgraphSpecOptions3 } from "@secondlayer/shared/subgraphs/spec";
|
|
3872
|
+
import { DOWN_MIN_CONSECUTIVE } from "@secondlayer/shared/insights/thresholds";
|
|
3862
3873
|
import { DeadRow as DeadRow3, DeliveryRow as DeliveryRow3, WebhookDetail as WebhookDetail3, WebhookSummary as WebhookSummary3 } from "@secondlayer/shared/schemas/webhooks";
|
|
3863
3874
|
/**
|
|
3864
3875
|
* Webhook diagnosis, shared by `secondlayer webhooks doctor` and the
|
|
@@ -3911,7 +3922,6 @@ interface DoctorReport {
|
|
|
3911
3922
|
* the rest underneath. */
|
|
3912
3923
|
primary: DoctorIssue | null;
|
|
3913
3924
|
}
|
|
3914
|
-
declare const DOWN_MIN_CONSECUTIVE = 5;
|
|
3915
3925
|
declare function buildDoctorReport(input: {
|
|
3916
3926
|
webhook: WebhookDetail3;
|
|
3917
3927
|
deliveries: DeliveryRow3[];
|
package/dist/index.js
CHANGED
|
@@ -2675,11 +2675,11 @@ class Webhooks extends BaseClient {
|
|
|
2675
2675
|
async test(id) {
|
|
2676
2676
|
return this.request("POST", `/api/webhooks/${seg(id)}/test`);
|
|
2677
2677
|
}
|
|
2678
|
-
async deliveries(id) {
|
|
2679
|
-
return this.request("GET", `/api/webhooks/${seg(id)}/deliveries`);
|
|
2678
|
+
async deliveries(id, window) {
|
|
2679
|
+
return this.request("GET", `/api/webhooks/${seg(id)}/deliveries${buildQuery({ from: window?.from, to: window?.to })}`);
|
|
2680
2680
|
}
|
|
2681
|
-
async activity(id) {
|
|
2682
|
-
return this.request("GET", `/api/webhooks/${seg(id)}/activity`);
|
|
2681
|
+
async activity(id, opts) {
|
|
2682
|
+
return this.request("GET", `/api/webhooks/${seg(id)}/activity${buildQuery({ days: opts?.days })}`);
|
|
2683
2683
|
}
|
|
2684
2684
|
async delivery(id, deliveryId) {
|
|
2685
2685
|
return this.request("GET", `/api/webhooks/${seg(id)}/deliveries/${seg(deliveryId)}`);
|
|
@@ -2834,19 +2834,21 @@ function getSubgraph(def, options = {}) {
|
|
|
2834
2834
|
return new Subgraphs(options).typed(def);
|
|
2835
2835
|
}
|
|
2836
2836
|
// src/webhooks/doctor.ts
|
|
2837
|
+
import {
|
|
2838
|
+
DOWN_MIN_CONSECUTIVE,
|
|
2839
|
+
LAG_MIN_SAMPLES,
|
|
2840
|
+
LAG_THRESHOLD_MS,
|
|
2841
|
+
LAG_WINDOW,
|
|
2842
|
+
RATE_LIMITED_MIN_ATTEMPTS,
|
|
2843
|
+
RATE_LIMITED_MIN_RATIO,
|
|
2844
|
+
REJECTS_MIN_CONSECUTIVE,
|
|
2845
|
+
SLOW_MIN_SAMPLES,
|
|
2846
|
+
SLOW_TIMEOUT_RATIO,
|
|
2847
|
+
SLOW_WINDOW
|
|
2848
|
+
} from "@secondlayer/shared/insights/thresholds";
|
|
2837
2849
|
function isSuccessDelivery(row) {
|
|
2838
2850
|
return row.statusCode !== null && row.statusCode >= 200 && row.statusCode < 300;
|
|
2839
2851
|
}
|
|
2840
|
-
var RATE_LIMITED_MIN_ATTEMPTS = 10;
|
|
2841
|
-
var RATE_LIMITED_MIN_RATIO = 0.5;
|
|
2842
|
-
var DOWN_MIN_CONSECUTIVE = 5;
|
|
2843
|
-
var REJECTS_MIN_CONSECUTIVE = 5;
|
|
2844
|
-
var SLOW_WINDOW = 20;
|
|
2845
|
-
var SLOW_MIN_SAMPLES = 5;
|
|
2846
|
-
var SLOW_TIMEOUT_RATIO = 0.5;
|
|
2847
|
-
var LAG_WINDOW = 20;
|
|
2848
|
-
var LAG_MIN_SAMPLES = 5;
|
|
2849
|
-
var LAG_THRESHOLD_MS = 60000;
|
|
2850
2852
|
var ERROR_SNIPPET_MAX = 200;
|
|
2851
2853
|
function median(values) {
|
|
2852
2854
|
if (values.length === 0)
|
|
@@ -3457,5 +3459,5 @@ export {
|
|
|
3457
3459
|
verifyWebhookSignature
|
|
3458
3460
|
};
|
|
3459
3461
|
|
|
3460
|
-
//# debugId=
|
|
3462
|
+
//# debugId=545A34D54279EA6E64756E2164756E21
|
|
3461
3463
|
//# sourceMappingURL=index.js.map
|