@nestarc/webhook 0.8.0 → 0.10.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 +76 -25
- package/dist/adapters/fetch-http-client.d.ts.map +1 -1
- package/dist/adapters/fetch-http-client.js +1 -1
- package/dist/adapters/fetch-http-client.js.map +1 -1
- package/dist/adapters/plaintext-secret-vault.d.ts.map +1 -1
- package/dist/adapters/plaintext-secret-vault.js +12 -2
- package/dist/adapters/plaintext-secret-vault.js.map +1 -1
- package/dist/adapters/prisma-delivery.repository.d.ts +12 -6
- package/dist/adapters/prisma-delivery.repository.d.ts.map +1 -1
- package/dist/adapters/prisma-delivery.repository.js +234 -46
- package/dist/adapters/prisma-delivery.repository.js.map +1 -1
- package/dist/adapters/prisma-endpoint.repository.d.ts +4 -3
- package/dist/adapters/prisma-endpoint.repository.d.ts.map +1 -1
- package/dist/adapters/prisma-endpoint.repository.js +41 -6
- package/dist/adapters/prisma-endpoint.repository.js.map +1 -1
- package/dist/index.d.ts +11 -6
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +9 -2
- package/dist/index.js.map +1 -1
- package/dist/interfaces/webhook-delivery.interface.d.ts +17 -0
- package/dist/interfaces/webhook-delivery.interface.d.ts.map +1 -1
- package/dist/interfaces/webhook-endpoint.interface.d.ts +11 -1
- package/dist/interfaces/webhook-endpoint.interface.d.ts.map +1 -1
- package/dist/interfaces/webhook-options.interface.d.ts +8 -6
- package/dist/interfaces/webhook-options.interface.d.ts.map +1 -1
- package/dist/ports/webhook-delivery.repository.d.ts +30 -10
- package/dist/ports/webhook-delivery.repository.d.ts.map +1 -1
- package/dist/ports/webhook-endpoint.repository.d.ts +24 -4
- package/dist/ports/webhook-endpoint.repository.d.ts.map +1 -1
- package/dist/ports/webhook-event.repository.d.ts +3 -1
- package/dist/ports/webhook-event.repository.d.ts.map +1 -1
- package/dist/ports/webhook-http-client.d.ts +4 -0
- package/dist/ports/webhook-http-client.d.ts.map +1 -1
- package/dist/ports/webhook-secret-vault.d.ts +1 -0
- package/dist/ports/webhook-secret-vault.d.ts.map +1 -1
- package/dist/webhook.admin.service.d.ts +6 -4
- package/dist/webhook.admin.service.d.ts.map +1 -1
- package/dist/webhook.admin.service.js +8 -2
- package/dist/webhook.admin.service.js.map +1 -1
- package/dist/webhook.circuit-breaker.d.ts +6 -4
- package/dist/webhook.circuit-breaker.d.ts.map +1 -1
- package/dist/webhook.circuit-breaker.js +10 -8
- package/dist/webhook.circuit-breaker.js.map +1 -1
- package/dist/webhook.constants.d.ts +9 -2
- package/dist/webhook.constants.d.ts.map +1 -1
- package/dist/webhook.constants.js +11 -4
- package/dist/webhook.constants.js.map +1 -1
- package/dist/webhook.delivery-admin.service.d.ts +2 -1
- package/dist/webhook.delivery-admin.service.d.ts.map +1 -1
- package/dist/webhook.delivery-admin.service.js +3 -0
- package/dist/webhook.delivery-admin.service.js.map +1 -1
- package/dist/webhook.delivery-worker.d.ts +4 -0
- package/dist/webhook.delivery-worker.d.ts.map +1 -1
- package/dist/webhook.delivery-worker.js +49 -22
- package/dist/webhook.delivery-worker.js.map +1 -1
- package/dist/webhook.dispatcher.d.ts +1 -0
- package/dist/webhook.dispatcher.d.ts.map +1 -1
- package/dist/webhook.dispatcher.js +13 -6
- package/dist/webhook.dispatcher.js.map +1 -1
- package/dist/webhook.endpoint-admin.service.d.ts +4 -1
- package/dist/webhook.endpoint-admin.service.d.ts.map +1 -1
- package/dist/webhook.endpoint-admin.service.js +36 -9
- package/dist/webhook.endpoint-admin.service.js.map +1 -1
- package/dist/webhook.module.d.ts.map +1 -1
- package/dist/webhook.module.js +22 -13
- package/dist/webhook.module.js.map +1 -1
- package/dist/webhook.signer.d.ts +2 -0
- package/dist/webhook.signer.d.ts.map +1 -1
- package/dist/webhook.signer.js +28 -14
- package/dist/webhook.signer.js.map +1 -1
- package/package.json +4 -4
- package/src/sql/create-webhook-tables.sql +27 -1
- package/src/sql/migrations/v0.9.0.sql +32 -0
package/dist/index.js
CHANGED
|
@@ -1,20 +1,24 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.WebhookUrlValidationError = exports.resolveAndValidateHost = exports.validateWebhookUrl = exports.DEFAULT_STALE_SENDING_MINUTES = exports.DEFAULT_CIRCUIT_BREAKER_COOLDOWN_MINUTES = exports.DEFAULT_CIRCUIT_BREAKER_THRESHOLD = exports.DEFAULT_POLLING_BATCH_SIZE = exports.DEFAULT_POLLING_INTERVAL = exports.DEFAULT_MAX_RETRIES = exports.DEFAULT_DELIVERY_TIMEOUT = exports.DEFAULT_BACKOFF_SCHEDULE = exports.WEBHOOK_HTTP_CLIENT = exports.WEBHOOK_DELIVERY_REPOSITORY = exports.WEBHOOK_ENDPOINT_REPOSITORY = exports.WEBHOOK_EVENT_REPOSITORY = exports.WEBHOOK_MODULE_OPTIONS = exports.PlaintextSecretVault = exports.FetchHttpClient = exports.PrismaDeliveryRepository = exports.PrismaEndpointRepository = exports.PrismaEventRepository = exports.WebhookAdminService = exports.WebhookDeliveryAdminService = exports.WebhookEndpointAdminService = exports.WebhookEvent = exports.WebhookCircuitBreaker = exports.WebhookSigner = exports.WebhookRetryPolicy = exports.WebhookDispatcher = exports.WebhookDeliveryWorker = exports.WebhookService = exports.WebhookModule = void 0;
|
|
3
|
+
exports.WebhookUrlValidationError = exports.resolveAndValidateHost = exports.validateWebhookUrl = exports.DEFAULT_STALE_SENDING_MINUTES = exports.ENDPOINT_DISABLED_REASON_CONSECUTIVE_FAILURES_EXCEEDED = exports.DEFAULT_CIRCUIT_BREAKER_COOLDOWN_MINUTES = exports.DEFAULT_CIRCUIT_BREAKER_THRESHOLD = exports.DEFAULT_POLLING_BATCH_SIZE = exports.DEFAULT_POLLING_INTERVAL = exports.DEFAULT_MAX_RETRIES = exports.DEFAULT_DELIVERY_TIMEOUT = exports.DEFAULT_BACKOFF_SCHEDULE = exports.WEBHOOK_SECRET_VAULT = exports.WEBHOOK_HTTP_CLIENT = exports.WEBHOOK_DELIVERY_REPOSITORY = exports.WEBHOOK_ENDPOINT_REPOSITORY = exports.WEBHOOK_EVENT_REPOSITORY = exports.WEBHOOK_MODULE_OPTIONS = exports.PlaintextSecretVault = exports.FetchHttpClient = exports.PrismaDeliveryRepository = exports.PrismaEndpointRepository = exports.PrismaEventRepository = exports.WebhookAdminService = exports.WebhookDeliveryAdminService = exports.WebhookEndpointAdminService = exports.WebhookEvent = exports.WebhookCircuitBreaker = exports.WebhookSigner = exports.WebhookRetryPolicy = exports.WebhookDispatcher = exports.WebhookDeliveryWorker = exports.WebhookService = exports.WebhookModule = void 0;
|
|
4
4
|
// Module
|
|
5
5
|
var webhook_module_1 = require("./webhook.module");
|
|
6
6
|
Object.defineProperty(exports, "WebhookModule", { enumerable: true, get: function () { return webhook_module_1.WebhookModule; } });
|
|
7
7
|
// Core services
|
|
8
8
|
var webhook_service_1 = require("./webhook.service");
|
|
9
9
|
Object.defineProperty(exports, "WebhookService", { enumerable: true, get: function () { return webhook_service_1.WebhookService; } });
|
|
10
|
+
/** @internal Wired automatically by WebhookModule. Exported for advanced testing/custom integration only. */
|
|
10
11
|
var webhook_delivery_worker_1 = require("./webhook.delivery-worker");
|
|
11
12
|
Object.defineProperty(exports, "WebhookDeliveryWorker", { enumerable: true, get: function () { return webhook_delivery_worker_1.WebhookDeliveryWorker; } });
|
|
13
|
+
/** @internal Wired automatically by WebhookModule. Exported for advanced testing/custom integration only. */
|
|
12
14
|
var webhook_dispatcher_1 = require("./webhook.dispatcher");
|
|
13
15
|
Object.defineProperty(exports, "WebhookDispatcher", { enumerable: true, get: function () { return webhook_dispatcher_1.WebhookDispatcher; } });
|
|
16
|
+
/** @internal Wired automatically by WebhookModule. Exported for advanced testing/custom integration only. */
|
|
14
17
|
var webhook_retry_policy_1 = require("./webhook.retry-policy");
|
|
15
18
|
Object.defineProperty(exports, "WebhookRetryPolicy", { enumerable: true, get: function () { return webhook_retry_policy_1.WebhookRetryPolicy; } });
|
|
16
19
|
var webhook_signer_1 = require("./webhook.signer");
|
|
17
20
|
Object.defineProperty(exports, "WebhookSigner", { enumerable: true, get: function () { return webhook_signer_1.WebhookSigner; } });
|
|
21
|
+
/** @internal Wired automatically by WebhookModule. Exported for advanced testing/custom integration only. */
|
|
18
22
|
var webhook_circuit_breaker_1 = require("./webhook.circuit-breaker");
|
|
19
23
|
Object.defineProperty(exports, "WebhookCircuitBreaker", { enumerable: true, get: function () { return webhook_circuit_breaker_1.WebhookCircuitBreaker; } });
|
|
20
24
|
var webhook_event_1 = require("./webhook.event");
|
|
@@ -24,7 +28,7 @@ var webhook_endpoint_admin_service_1 = require("./webhook.endpoint-admin.service
|
|
|
24
28
|
Object.defineProperty(exports, "WebhookEndpointAdminService", { enumerable: true, get: function () { return webhook_endpoint_admin_service_1.WebhookEndpointAdminService; } });
|
|
25
29
|
var webhook_delivery_admin_service_1 = require("./webhook.delivery-admin.service");
|
|
26
30
|
Object.defineProperty(exports, "WebhookDeliveryAdminService", { enumerable: true, get: function () { return webhook_delivery_admin_service_1.WebhookDeliveryAdminService; } });
|
|
27
|
-
/** @deprecated Use WebhookEndpointAdminService and WebhookDeliveryAdminService */
|
|
31
|
+
/** @deprecated since v0.2.0. Will be removed in v1.0.0. Use {@link WebhookEndpointAdminService} and {@link WebhookDeliveryAdminService}. */
|
|
28
32
|
var webhook_admin_service_1 = require("./webhook.admin.service");
|
|
29
33
|
Object.defineProperty(exports, "WebhookAdminService", { enumerable: true, get: function () { return webhook_admin_service_1.WebhookAdminService; } });
|
|
30
34
|
// Default adapters
|
|
@@ -45,6 +49,7 @@ Object.defineProperty(exports, "WEBHOOK_EVENT_REPOSITORY", { enumerable: true, g
|
|
|
45
49
|
Object.defineProperty(exports, "WEBHOOK_ENDPOINT_REPOSITORY", { enumerable: true, get: function () { return webhook_constants_1.WEBHOOK_ENDPOINT_REPOSITORY; } });
|
|
46
50
|
Object.defineProperty(exports, "WEBHOOK_DELIVERY_REPOSITORY", { enumerable: true, get: function () { return webhook_constants_1.WEBHOOK_DELIVERY_REPOSITORY; } });
|
|
47
51
|
Object.defineProperty(exports, "WEBHOOK_HTTP_CLIENT", { enumerable: true, get: function () { return webhook_constants_1.WEBHOOK_HTTP_CLIENT; } });
|
|
52
|
+
Object.defineProperty(exports, "WEBHOOK_SECRET_VAULT", { enumerable: true, get: function () { return webhook_constants_1.WEBHOOK_SECRET_VAULT; } });
|
|
48
53
|
Object.defineProperty(exports, "DEFAULT_BACKOFF_SCHEDULE", { enumerable: true, get: function () { return webhook_constants_1.DEFAULT_BACKOFF_SCHEDULE; } });
|
|
49
54
|
Object.defineProperty(exports, "DEFAULT_DELIVERY_TIMEOUT", { enumerable: true, get: function () { return webhook_constants_1.DEFAULT_DELIVERY_TIMEOUT; } });
|
|
50
55
|
Object.defineProperty(exports, "DEFAULT_MAX_RETRIES", { enumerable: true, get: function () { return webhook_constants_1.DEFAULT_MAX_RETRIES; } });
|
|
@@ -52,7 +57,9 @@ Object.defineProperty(exports, "DEFAULT_POLLING_INTERVAL", { enumerable: true, g
|
|
|
52
57
|
Object.defineProperty(exports, "DEFAULT_POLLING_BATCH_SIZE", { enumerable: true, get: function () { return webhook_constants_1.DEFAULT_POLLING_BATCH_SIZE; } });
|
|
53
58
|
Object.defineProperty(exports, "DEFAULT_CIRCUIT_BREAKER_THRESHOLD", { enumerable: true, get: function () { return webhook_constants_1.DEFAULT_CIRCUIT_BREAKER_THRESHOLD; } });
|
|
54
59
|
Object.defineProperty(exports, "DEFAULT_CIRCUIT_BREAKER_COOLDOWN_MINUTES", { enumerable: true, get: function () { return webhook_constants_1.DEFAULT_CIRCUIT_BREAKER_COOLDOWN_MINUTES; } });
|
|
60
|
+
Object.defineProperty(exports, "ENDPOINT_DISABLED_REASON_CONSECUTIVE_FAILURES_EXCEEDED", { enumerable: true, get: function () { return webhook_constants_1.ENDPOINT_DISABLED_REASON_CONSECUTIVE_FAILURES_EXCEEDED; } });
|
|
55
61
|
Object.defineProperty(exports, "DEFAULT_STALE_SENDING_MINUTES", { enumerable: true, get: function () { return webhook_constants_1.DEFAULT_STALE_SENDING_MINUTES; } });
|
|
62
|
+
// URL validation
|
|
56
63
|
var webhook_url_validator_1 = require("./webhook.url-validator");
|
|
57
64
|
Object.defineProperty(exports, "validateWebhookUrl", { enumerable: true, get: function () { return webhook_url_validator_1.validateWebhookUrl; } });
|
|
58
65
|
Object.defineProperty(exports, "resolveAndValidateHost", { enumerable: true, get: function () { return webhook_url_validator_1.resolveAndValidateHost; } });
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,SAAS;AACT,mDAAiD;AAAxC,+GAAA,aAAa,OAAA;AAEtB,gBAAgB;AAChB,qDAAmD;AAA1C,iHAAA,cAAc,OAAA;AACvB,qEAAkE;AAAzD,gIAAA,qBAAqB,OAAA;AAC9B,2DAAyD;AAAhD,uHAAA,iBAAiB,OAAA;AAC1B,+DAA4D;AAAnD,0HAAA,kBAAkB,OAAA;AAC3B,mDAAwE;AAA/D,+GAAA,aAAa,OAAA;AACtB,qEAAkE;AAAzD,gIAAA,qBAAqB,OAAA;AAC9B,iDAA+C;AAAtC,6GAAA,YAAY,OAAA;AAErB,iBAAiB;AACjB,mFAA+E;AAAtE,6IAAA,2BAA2B,OAAA;AACpC,mFAA+E;AAAtE,6IAAA,2BAA2B,OAAA;AACpC,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,SAAS;AACT,mDAAiD;AAAxC,+GAAA,aAAa,OAAA;AAEtB,gBAAgB;AAChB,qDAAmD;AAA1C,iHAAA,cAAc,OAAA;AACvB,6GAA6G;AAC7G,qEAAkE;AAAzD,gIAAA,qBAAqB,OAAA;AAC9B,6GAA6G;AAC7G,2DAAyD;AAAhD,uHAAA,iBAAiB,OAAA;AAC1B,6GAA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 'FAILED';
|
|
2
|
+
export type DeliveryAttemptStatus = Exclude<DeliveryStatus, 'SENDING'>;
|
|
2
3
|
export interface DeliveryRecord {
|
|
3
4
|
id: string;
|
|
4
5
|
eventId: string;
|
|
5
6
|
endpointId: string;
|
|
7
|
+
/** Destination URL used for this delivery. Uses the queued snapshot when available. */
|
|
8
|
+
destinationUrl: string;
|
|
9
|
+
/** Null when the endpoint is global rather than tenant-scoped. */
|
|
10
|
+
tenantId: string | null;
|
|
6
11
|
status: DeliveryStatus;
|
|
7
12
|
attempts: number;
|
|
8
13
|
maxAttempts: number;
|
|
@@ -14,6 +19,18 @@ export interface DeliveryRecord {
|
|
|
14
19
|
latencyMs: number | null;
|
|
15
20
|
lastError: string | null;
|
|
16
21
|
}
|
|
22
|
+
export interface DeliveryAttemptRecord {
|
|
23
|
+
id: string;
|
|
24
|
+
deliveryId: string;
|
|
25
|
+
attemptNumber: number;
|
|
26
|
+
status: DeliveryAttemptStatus;
|
|
27
|
+
responseStatus: number | null;
|
|
28
|
+
responseBody: string | null;
|
|
29
|
+
responseBodyTruncated: boolean;
|
|
30
|
+
latencyMs: number | null;
|
|
31
|
+
lastError: string | null;
|
|
32
|
+
createdAt: Date;
|
|
33
|
+
}
|
|
17
34
|
export interface EventRecord {
|
|
18
35
|
id: string;
|
|
19
36
|
eventType: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webhook-delivery.interface.d.ts","sourceRoot":"","sources":["../../src/interfaces/webhook-delivery.interface.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,cAAc,GAAG,SAAS,GAAG,SAAS,GAAG,MAAM,GAAG,QAAQ,CAAC;AAEvE,MAAM,WAAW,cAAc;IAC7B,EAAE,EAAE,MAAM,CAAC;IACX,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,cAAc,CAAC;IACvB,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,MAAM,CAAC;IACpB,aAAa,EAAE,IAAI,GAAG,IAAI,CAAC;IAC3B,aAAa,EAAE,IAAI,GAAG,IAAI,CAAC;IAC3B,WAAW,EAAE,IAAI,GAAG,IAAI,CAAC;IACzB,cAAc,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9B,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;CAC1B;AAED,MAAM,WAAW,WAAW;IAC1B,EAAE,EAAE,MAAM,CAAC;IACX,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACjC,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,SAAS,EAAE,IAAI,CAAC;CACjB;AAED,MAAM,WAAW,cAAc;IAC7B,OAAO,EAAE,OAAO,CAAC;IACjB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,kBAAkB;IACjC,MAAM,CAAC,EAAE,cAAc,CAAC;IACxB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,IAAI,CAAC;IACb,KAAK,CAAC,EAAE,IAAI,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB"}
|
|
1
|
+
{"version":3,"file":"webhook-delivery.interface.d.ts","sourceRoot":"","sources":["../../src/interfaces/webhook-delivery.interface.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,cAAc,GAAG,SAAS,GAAG,SAAS,GAAG,MAAM,GAAG,QAAQ,CAAC;AACvE,MAAM,MAAM,qBAAqB,GAAG,OAAO,CAAC,cAAc,EAAE,SAAS,CAAC,CAAC;A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AAM,WAAW,cAAc;IAC7B,OAAO,EAAE,OAAO,CAAC;IACjB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,kBAAkB;IACjC,MAAM,CAAC,EAAE,cAAc,CAAC;IACxB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,IAAI,CAAC;IACb,KAAK,CAAC,EAAE,IAAI,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB"}
|
|
@@ -9,6 +9,7 @@ export interface EndpointRecord {
|
|
|
9
9
|
consecutiveFailures: number;
|
|
10
10
|
disabledAt: Date | null;
|
|
11
11
|
disabledReason: string | null;
|
|
12
|
+
previousSecretExpiresAt: Date | null;
|
|
12
13
|
createdAt: Date;
|
|
13
14
|
updatedAt: Date;
|
|
14
15
|
}
|
|
@@ -19,8 +20,10 @@ export interface EndpointRecordWithSecret extends EndpointRecord {
|
|
|
19
20
|
export interface CreateEndpointDto {
|
|
20
21
|
url: string;
|
|
21
22
|
events: string[];
|
|
22
|
-
|
|
23
|
+
/** Pass `'auto'` or omit the field to generate a secure base64 signing secret. */
|
|
24
|
+
secret?: string;
|
|
23
25
|
description?: string;
|
|
26
|
+
/** JSON-serializable metadata stored as jsonb. Dates become strings; BigInt is not supported. */
|
|
24
27
|
metadata?: Record<string, unknown>;
|
|
25
28
|
tenantId?: string;
|
|
26
29
|
}
|
|
@@ -28,7 +31,14 @@ export interface UpdateEndpointDto {
|
|
|
28
31
|
url?: string;
|
|
29
32
|
events?: string[];
|
|
30
33
|
description?: string;
|
|
34
|
+
/** JSON-serializable metadata stored as jsonb. Dates become strings; BigInt is not supported. */
|
|
31
35
|
metadata?: Record<string, unknown>;
|
|
32
36
|
active?: boolean;
|
|
33
37
|
}
|
|
38
|
+
export interface RotateEndpointSecretDto {
|
|
39
|
+
/** Pass `'auto'` or omit the field to generate a secure base64 signing secret. */
|
|
40
|
+
secret?: string;
|
|
41
|
+
/** Keep the previous secret valid until this timestamp so queued receivers can overlap during rotation. */
|
|
42
|
+
previousSecretExpiresAt: Date;
|
|
43
|
+
}
|
|
34
44
|
//# sourceMappingURL=webhook-endpoint.interface.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webhook-endpoint.interface.d.ts","sourceRoot":"","sources":["../../src/interfaces/webhook-endpoint.interface.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,cAAc;IAC7B,EAAE,EAAE,MAAM,CAAC;IACX,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,MAAM,EAAE,OAAO,CAAC;IAChB,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC;IACzC,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,mBAAmB,EAAE,MAAM,CAAC;IAC5B,UAAU,EAAE,IAAI,GAAG,IAAI,CAAC;IACxB,cAAc,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9B,SAAS,EAAE,IAAI,CAAC;IAChB,SAAS,EAAE,IAAI,CAAC;CACjB;AAED,0HAA0H;AAC1H,MAAM,WAAW,wBAAyB,SAAQ,cAAc;IAC9D,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,iBAAiB;IAChC,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,MAAM,CAAC,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"webhook-endpoint.interface.d.ts","sourceRoot":"","sources":["../../src/interfaces/webhook-endpoint.interface.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,cAAc;IAC7B,EAAE,EAA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IAChB,2GAA2G;IAC3G,uBAAuB,EAAE,IAAI,CAAC;CAC/B"}
|
|
@@ -1,13 +1,15 @@
|
|
|
1
|
-
import { ModuleMetadata, Type } from '@nestjs/common';
|
|
1
|
+
import { InjectionToken, ModuleMetadata, OptionalFactoryDependency, Type } from '@nestjs/common';
|
|
2
2
|
import { WebhookEventRepository } from '../ports/webhook-event.repository';
|
|
3
3
|
import { WebhookEndpointRepository } from '../ports/webhook-endpoint.repository';
|
|
4
4
|
import { WebhookDeliveryRepository } from '../ports/webhook-delivery.repository';
|
|
5
5
|
import { WebhookHttpClient } from '../ports/webhook-http-client';
|
|
6
6
|
import { WebhookSecretVault } from '../ports/webhook-secret-vault';
|
|
7
|
+
import type { EndpointDisabledReason } from '../webhook.constants';
|
|
7
8
|
import { WebhookUrlValidationReason } from '../webhook.url-validator';
|
|
8
9
|
export interface DeliveryOptions {
|
|
9
10
|
timeout?: number;
|
|
10
11
|
maxRetries?: number;
|
|
12
|
+
/** @deprecated Retry backoff is currently fixed to the default exponential schedule. */
|
|
11
13
|
backoff?: 'exponential';
|
|
12
14
|
jitter?: boolean;
|
|
13
15
|
}
|
|
@@ -40,7 +42,7 @@ export interface DeliveryFailedContext {
|
|
|
40
42
|
maxAttempts: number;
|
|
41
43
|
lastError: string | null;
|
|
42
44
|
responseStatus: number | null;
|
|
43
|
-
/** High-level classification.
|
|
45
|
+
/** High-level classification. Built-in workers set this in v0.8.0+; optional for custom/legacy producers. */
|
|
44
46
|
failureKind?: DeliveryFailureKind;
|
|
45
47
|
/** Set only when `failureKind === 'url_validation'` — structured reason from `WebhookUrlValidationError`. */
|
|
46
48
|
validationReason?: WebhookUrlValidationReason;
|
|
@@ -54,12 +56,12 @@ export interface EndpointDisabledContext {
|
|
|
54
56
|
/** Null when the endpoint is not scoped to a tenant. */
|
|
55
57
|
tenantId: string | null;
|
|
56
58
|
url: string;
|
|
57
|
-
reason:
|
|
59
|
+
reason: EndpointDisabledReason;
|
|
58
60
|
consecutiveFailures: number;
|
|
59
61
|
}
|
|
60
|
-
export interface WebhookModuleOptions {
|
|
62
|
+
export interface WebhookModuleOptions<TPrisma = unknown> {
|
|
61
63
|
/** PrismaClient instance — used by default Prisma adapters. Not needed if all custom repositories are provided. */
|
|
62
|
-
prisma?:
|
|
64
|
+
prisma?: TPrisma;
|
|
63
65
|
delivery?: DeliveryOptions;
|
|
64
66
|
circuitBreaker?: CircuitBreakerOptions;
|
|
65
67
|
polling?: PollingOptions;
|
|
@@ -82,7 +84,7 @@ export interface WebhookOptionsFactory {
|
|
|
82
84
|
}
|
|
83
85
|
export interface WebhookModuleAsyncOptions extends Pick<ModuleMetadata, 'imports'> {
|
|
84
86
|
useFactory?: (...args: any[]) => Promise<WebhookModuleOptions> | WebhookModuleOptions;
|
|
85
|
-
inject?:
|
|
87
|
+
inject?: Array<InjectionToken | OptionalFactoryDependency>;
|
|
86
88
|
useClass?: Type<WebhookOptionsFactory>;
|
|
87
89
|
useExisting?: Type<WebhookOptionsFactory>;
|
|
88
90
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webhook-options.interface.d.ts","sourceRoot":"","sources":["../../src/interfaces/webhook-options.interface.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"webhook-options.interface.d.ts","sourceRoot":"","sources":["../../src/interfaces/webhook-options.interface.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,cAAc,EACd,cAAc,EACd,yBAAyB,EACzB,IAAI,EACL,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,sBAAsB,EAAE,MAAM,mCAAmC,CAAC;AAC3E,OAAO,EAAE,yBAAyB,EAAE,MAAM,sCAAsC,CAAC;AACjF,OAAO,EAAE,yBAAyB,EAAE,MAAM,sCAAsC,CAAC;AACjF,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AACjE,OAAO,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AACnE,OAAO,KAAK,EA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;IACtF,MAAM,CAAC,EAAE,KAAK,CAAC,cAAc,GAAG,yBAAyB,CAAC,CAAC;IAC3D,QAAQ,CAAC,EAAE,IAAI,CAAC,qBAAqB,CAAC,CAAC;IACvC,WAAW,CAAC,EAAE,IAAI,CAAC,qBAAqB,CAAC,CAAC;CAC3C"}
|
|
@@ -1,27 +1,47 @@
|
|
|
1
|
-
import { DeliveryLogFilters, DeliveryRecord, DeliveryResult } from '../interfaces/webhook-delivery.interface';
|
|
2
|
-
|
|
1
|
+
import { DeliveryAttemptRecord, DeliveryLogFilters, DeliveryRecord, DeliveryResult } from '../interfaces/webhook-delivery.interface';
|
|
2
|
+
declare const webhookTransactionBrand: unique symbol;
|
|
3
|
+
/** Opaque transaction token created by repository adapters. */
|
|
4
|
+
export type WebhookTransaction = {
|
|
5
|
+
readonly [webhookTransactionBrand]: 'WebhookTransaction';
|
|
6
|
+
};
|
|
7
|
+
/** A delivery row claimed by the worker but not yet enriched with endpoint/event data. */
|
|
8
|
+
export interface ClaimedDelivery {
|
|
3
9
|
id: string;
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
tenant_id: string | null;
|
|
10
|
+
eventId: string;
|
|
11
|
+
endpointId: string;
|
|
7
12
|
attempts: number;
|
|
8
|
-
|
|
13
|
+
maxAttempts: number;
|
|
14
|
+
}
|
|
15
|
+
/** A claimed delivery enriched with endpoint URL, signing secrets, and event payload. Ready to dispatch. */
|
|
16
|
+
export interface PendingDelivery extends ClaimedDelivery {
|
|
17
|
+
tenantId: string | null;
|
|
9
18
|
url: string;
|
|
10
19
|
secret: string;
|
|
11
|
-
|
|
20
|
+
additionalSecrets: string[];
|
|
21
|
+
eventType: string;
|
|
12
22
|
payload: Record<string, unknown>;
|
|
13
23
|
}
|
|
14
24
|
export interface WebhookDeliveryRepository {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
25
|
+
/**
|
|
26
|
+
* Creates queued delivery rows inside the provided transaction.
|
|
27
|
+
* No-op when endpointIds is empty.
|
|
28
|
+
*/
|
|
29
|
+
createDeliveriesInTransaction(tx: WebhookTransaction, eventId: string, endpointIds: string[], maxAttempts: number): Promise<void>;
|
|
30
|
+
/** Runs the callback in one repository transaction. Pass the tx only to other *InTransaction port methods. */
|
|
31
|
+
runInTransaction<T>(fn: (tx: WebhookTransaction) => Promise<T>): Promise<T>;
|
|
32
|
+
/** Atomically claims pending rows and returns the minimal delivery identity needed for enrichment. */
|
|
33
|
+
claimPendingDeliveries(batchSize: number): Promise<ClaimedDelivery[]>;
|
|
18
34
|
enrichDeliveries(deliveryIds: string[]): Promise<PendingDelivery[]>;
|
|
19
35
|
markSent(deliveryId: string, attempts: number, result: DeliveryResult): Promise<void>;
|
|
20
36
|
markFailed(deliveryId: string, attempts: number, result: DeliveryResult): Promise<void>;
|
|
21
37
|
markRetry(deliveryId: string, attempts: number, nextAt: Date, result: DeliveryResult): Promise<void>;
|
|
38
|
+
/** @returns number of stale SENDING deliveries recovered or failed. */
|
|
22
39
|
recoverStaleSending(stalenessMinutes: number): Promise<number>;
|
|
23
40
|
getDeliveryLogs(endpointId: string, filters?: DeliveryLogFilters): Promise<DeliveryRecord[]>;
|
|
41
|
+
/** @returns attempts sorted by attemptNumber ASC. */
|
|
42
|
+
getDeliveryAttempts(deliveryId: string): Promise<DeliveryAttemptRecord[]>;
|
|
24
43
|
retryDelivery(deliveryId: string): Promise<boolean>;
|
|
25
44
|
createTestDelivery(eventId: string, endpointId: string): Promise<void>;
|
|
26
45
|
}
|
|
46
|
+
export {};
|
|
27
47
|
//# sourceMappingURL=webhook-delivery.repository.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webhook-delivery.repository.d.ts","sourceRoot":"","sources":["../../src/ports/webhook-delivery.repository.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,kBAAkB,EAClB,cAAc,EACd,cAAc,EACf,MAAM,0CAA0C,CAAC;AAElD,MAAM,WAAW,eAAe;IAC9B,EAAE,EAAE,MAAM,CAAC;IACX,
|
|
1
|
+
{"version":3,"file":"webhook-delivery.repository.d.ts","sourceRoot":"","sources":["../../src/ports/webhook-delivery.repository.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,qBAAqB,EACrB,kBAAkB,EAClB,cAAc,EACd,cAAc,EACf,MAAM,0CAA0C,CAAC;AAElD,OAAO,CAAC,MAAM,uBAAuB,EAAE,OAAO,MAAM,CAAC;AAErD,+DAA+D;AAC/D,MAAM,MAAM,kBAAkB,GAAG;IAC/B,QAAQ,CAAC,CAAC,uBAAuB,CAAC,EAAE,oBAAoB,CAAC;CAC1D,CAAC;AAEF,0FAA0F;AAC1F,MAAM,WAAW,eAAe;IAC9B,EAAE,EAAE,MAAM,CAAC;IACX,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,4GAA4G;AAC5G,MAAM,WAAW,eAAgB,SAAQ,eAAe;IACtD,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,EAAE,MAAM,CAAC;IACf,iBAAiB,EAAE,MAAM,EAAE,CAAC;IAC5B,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAClC;AAED,MAAM,WAAW,yBAAyB;IACxC;;;OAGG;IACH,6BAA6B,CAC3B,EAAE,EAAE,kBAAkB,EACtB,OAAO,EAAE,MAAM,EACf,WAAW,EAAE,MAAM,EAAE,EACrB,WAAW,EAAE,MAAM,GAClB,OAAO,CAAC,IAAI,CAAC,CAAC;IAEjB,8GAA8G;IAC9G,gBAAgB,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,EAAE,kBAAkB,KAAK,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;IAE5E,sGAAsG;IACtG,sBAAsB,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,EAAE,CAAC,CAAC;IACtE,gBAAgB,CAAC,WAAW,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,eAAe,EAAE,CAAC,CAAC;IAEpE,QAAQ,CAAC,UAAU,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACtF,UAAU,CAAC,UAAU,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACxF,SAAS,CAAC,UAAU,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAErG,uEAAuE;IACvE,mBAAmB,CAAC,gBAAgB,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IAC/D,eAAe,CAAC,UAAU,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,kBAAkB,GAAG,OAAO,CAAC,cAAc,EAAE,CAAC,CAAC;IAC7F,qDAAqD;IACrD,mBAAmB,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,qBAAqB,EAAE,CAAC,CAAC;IAC1E,aAAa,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IACpD,kBAAkB,CAAC,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CACxE"}
|
|
@@ -1,15 +1,35 @@
|
|
|
1
|
-
import { EndpointRecord, EndpointRecordWithSecret, UpdateEndpointDto } from '../interfaces/webhook-endpoint.interface';
|
|
1
|
+
import { EndpointRecord, EndpointRecordWithSecret, RotateEndpointSecretDto, UpdateEndpointDto } from '../interfaces/webhook-endpoint.interface';
|
|
2
|
+
import { WebhookTransaction } from './webhook-delivery.repository';
|
|
3
|
+
export interface ResolvedCreateEndpointInput {
|
|
4
|
+
url: string;
|
|
5
|
+
secret: string;
|
|
6
|
+
events: string[];
|
|
7
|
+
description: string | null;
|
|
8
|
+
metadata: Record<string, unknown> | null;
|
|
9
|
+
tenantId: string | null;
|
|
10
|
+
}
|
|
11
|
+
export interface ResolvedRotateEndpointSecretInput extends Required<RotateEndpointSecretDto> {
|
|
12
|
+
}
|
|
2
13
|
export interface WebhookEndpointRepository {
|
|
3
14
|
findMatchingEndpoints(eventType: string, tenantId: string | undefined): Promise<EndpointRecord[]>;
|
|
4
|
-
|
|
5
|
-
|
|
15
|
+
/** Use only with a transaction object received from WebhookDeliveryRepository.runInTransaction(). */
|
|
16
|
+
findMatchingEndpointsInTransaction(tx: WebhookTransaction, eventType: string, tenantId: string | undefined): Promise<EndpointRecord[]>;
|
|
17
|
+
createEndpoint(input: ResolvedCreateEndpointInput): Promise<EndpointRecordWithSecret>;
|
|
6
18
|
getEndpoint(id: string): Promise<EndpointRecord | null>;
|
|
7
19
|
listEndpoints(tenantId?: string): Promise<EndpointRecord[]>;
|
|
8
20
|
updateEndpoint(id: string, dto: UpdateEndpointDto): Promise<EndpointRecord | null>;
|
|
21
|
+
rotateSecret(id: string, input: ResolvedRotateEndpointSecretInput): Promise<EndpointRecord | null>;
|
|
22
|
+
/**
|
|
23
|
+
* @returns true if a row was deleted, false if the endpoint did not exist.
|
|
24
|
+
* May reject when existing delivery rows still reference the endpoint.
|
|
25
|
+
*/
|
|
9
26
|
deleteEndpoint(id: string): Promise<boolean>;
|
|
10
27
|
resetFailures(endpointId: string): Promise<void>;
|
|
28
|
+
/** Atomically increments consecutive failures and returns the new value. */
|
|
11
29
|
incrementFailures(endpointId: string): Promise<number>;
|
|
12
|
-
|
|
30
|
+
/** @returns true when the endpoint transitioned from active to inactive. */
|
|
31
|
+
disableEndpoint(endpointId: string, reason: string): Promise<boolean>;
|
|
32
|
+
/** @returns number of endpoints recovered after cooldown. */
|
|
13
33
|
recoverEligibleEndpoints(cooldownMinutes: number): Promise<number>;
|
|
14
34
|
}
|
|
15
35
|
//# sourceMappingURL=webhook-endpoint.repository.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webhook-endpoint.repository.d.ts","sourceRoot":"","sources":["../../src/ports/webhook-endpoint.repository.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,cAAc,EACd,wBAAwB,EACxB,iBAAiB,EAClB,MAAM,0CAA0C,CAAC;
|
|
1
|
+
{"version":3,"file":"webhook-endpoint.repository.d.ts","sourceRoot":"","sources":["../../src/ports/webhook-endpoint.repository.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,cAAc,EACd,wBAAwB,EACxB,uBAAuB,EACvB,iBAAiB,EAClB,MAAM,0CAA0C,CAAC;AAClD,OAAO,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AAEnE,MAAM,WAAW,2BAA2B;IAC1C,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC;IACzC,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;CACzB;AAED,MAAM,WAAW,iCACf,SAAQ,QAAQ,CAAC,uBAAuB,CAAC;CAAG;AAE9C,MAAM,WAAW,yBAAyB;IACxC,qBAAqB,CACnB,SAAS,EAAE,MAAM,EACjB,QAAQ,EAAE,MAAM,GAAG,SAAS,GAC3B,OAAO,CAAC,cAAc,EAAE,CAAC,CAAC;IAE7B,qGAAqG;IACrG,kCAAkC,CAChC,EAAE,EAAE,kBAAkB,EACtB,SAAS,EAAE,MAAM,EACjB,QAAQ,EAAE,MAAM,GAAG,SAAS,GAC3B,OAAO,CAAC,cAAc,EAAE,CAAC,CAAC;IAE7B,cAAc,CAAC,KAAK,EAAE,2BAA2B,GAAG,OAAO,CAAC,wBAAwB,CAAC,CAAC;IAEtF,WAAW,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,GAAG,IAAI,CAAC,CAAC;IACxD,aAAa,CAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,EAAE,CAAC,CAAC;IAC5D,cAAc,CAAC,EAAE,EAAE,MAAM,EAAE,GAAG,EAAE,iBAAiB,GAAG,OAAO,CAAC,cAAc,GAAG,IAAI,CAAC,CAAC;IACnF,YAAY,CACV,EAAE,EAAE,MAAM,EACV,KAAK,EAAE,iCAAiC,GACvC,OAAO,CAAC,cAAc,GAAG,IAAI,CAAC,CAAC;IAClC;;;OAGG;IACH,cAAc,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IAE7C,aAAa,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACjD,4EAA4E;IAC5E,iBAAiB,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IACvD,4EAA4E;IAC5E,eAAe,CAAC,UAAU,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IACtE,6DAA6D;IAC7D,wBAAwB,CAAC,eAAe,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;CACpE"}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
+
import { WebhookTransaction } from './webhook-delivery.repository';
|
|
1
2
|
export interface WebhookEventRepository {
|
|
2
3
|
saveEvent(eventType: string, payload: Record<string, unknown>, tenantId: string | null): Promise<string>;
|
|
3
|
-
|
|
4
|
+
/** Use only with a transaction object received from WebhookDeliveryRepository.runInTransaction(). */
|
|
5
|
+
saveEventInTransaction(tx: WebhookTransaction, eventType: string, payload: Record<string, unknown>, tenantId: string | null): Promise<string>;
|
|
4
6
|
}
|
|
5
7
|
//# sourceMappingURL=webhook-event.repository.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webhook-event.repository.d.ts","sourceRoot":"","sources":["../../src/ports/webhook-event.repository.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,sBAAsB;IACrC,SAAS,CACP,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAChC,QAAQ,EAAE,MAAM,GAAG,IAAI,GACtB,OAAO,CAAC,MAAM,CAAC,CAAC;IAEnB,sBAAsB,CACpB,EAAE,EAAE,
|
|
1
|
+
{"version":3,"file":"webhook-event.repository.d.ts","sourceRoot":"","sources":["../../src/ports/webhook-event.repository.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AAEnE,MAAM,WAAW,sBAAsB;IACrC,SAAS,CACP,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAChC,QAAQ,EAAE,MAAM,GAAG,IAAI,GACtB,OAAO,CAAC,MAAM,CAAC,CAAC;IAEnB,qGAAqG;IACrG,sBAAsB,CACpB,EAAE,EAAE,kBAAkB,EACtB,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAChC,QAAQ,EAAE,MAAM,GAAG,IAAI,GACtB,OAAO,CAAC,MAAM,CAAC,CAAC;CACpB"}
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import { DeliveryResult } from '../interfaces/webhook-delivery.interface';
|
|
2
2
|
export interface WebhookHttpClient {
|
|
3
|
+
/**
|
|
4
|
+
* @param timeout milliseconds before the request is aborted.
|
|
5
|
+
* @returns DeliveryResult with success false on timeout/network failure; implementations should not throw for HTTP failures.
|
|
6
|
+
*/
|
|
3
7
|
post(url: string, headers: Record<string, string>, body: string, timeout: number): Promise<DeliveryResult>;
|
|
4
8
|
}
|
|
5
9
|
//# sourceMappingURL=webhook-http-client.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webhook-http-client.d.ts","sourceRoot":"","sources":["../../src/ports/webhook-http-client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,0CAA0C,CAAC;AAE1E,MAAM,WAAW,iBAAiB;IAChC,IAAI,CACF,GAAG,EAAE,MAAM,EACX,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EAC/B,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,MAAM,GACd,OAAO,CAAC,cAAc,CAAC,CAAC;CAC5B"}
|
|
1
|
+
{"version":3,"file":"webhook-http-client.d.ts","sourceRoot":"","sources":["../../src/ports/webhook-http-client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,0CAA0C,CAAC;AAE1E,MAAM,WAAW,iBAAiB;IAChC;;;OAGG;IACH,IAAI,CACF,GAAG,EAAE,MAAM,EACX,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EAC/B,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,MAAM,GACd,OAAO,CAAC,cAAc,CAAC,CAAC;CAC5B"}
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
* Port for encrypting/decrypting endpoint signing secrets at rest.
|
|
3
3
|
* Implement this interface to provide custom encryption (e.g. AES-256-GCM).
|
|
4
4
|
* The default PlaintextSecretVault passes values through unchanged.
|
|
5
|
+
* Throws are propagated to callers; implementations should retry transient KMS/network failures internally.
|
|
5
6
|
*/
|
|
6
7
|
export interface WebhookSecretVault {
|
|
7
8
|
encrypt(plainSecret: string): Promise<string>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webhook-secret-vault.d.ts","sourceRoot":"","sources":["../../src/ports/webhook-secret-vault.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"webhook-secret-vault.d.ts","sourceRoot":"","sources":["../../src/ports/webhook-secret-vault.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,MAAM,WAAW,kBAAkB;IACjC,OAAO,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IAC9C,OAAO,CAAC,eAAe,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;CACnD"}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { WebhookEndpointAdminService } from './webhook.endpoint-admin.service';
|
|
2
2
|
import { WebhookDeliveryAdminService } from './webhook.delivery-admin.service';
|
|
3
|
-
import { CreateEndpointDto, EndpointRecord, EndpointRecordWithSecret, UpdateEndpointDto } from './interfaces/webhook-endpoint.interface';
|
|
4
|
-
import { DeliveryLogFilters, DeliveryRecord } from './interfaces/webhook-delivery.interface';
|
|
3
|
+
import { CreateEndpointDto, EndpointRecord, EndpointRecordWithSecret, RotateEndpointSecretDto, UpdateEndpointDto } from './interfaces/webhook-endpoint.interface';
|
|
4
|
+
import { DeliveryAttemptRecord, DeliveryLogFilters, DeliveryRecord } from './interfaces/webhook-delivery.interface';
|
|
5
5
|
/**
|
|
6
|
-
* @deprecated
|
|
7
|
-
*
|
|
6
|
+
* @deprecated since v0.2.0. Will be removed in v1.0.0.
|
|
7
|
+
* Use WebhookEndpointAdminService and WebhookDeliveryAdminService directly.
|
|
8
8
|
*/
|
|
9
9
|
export declare class WebhookAdminService {
|
|
10
10
|
private readonly endpoints;
|
|
@@ -14,8 +14,10 @@ export declare class WebhookAdminService {
|
|
|
14
14
|
listEndpoints(tenantId?: string): Promise<EndpointRecord[]>;
|
|
15
15
|
getEndpoint(endpointId: string): Promise<EndpointRecord | null>;
|
|
16
16
|
updateEndpoint(endpointId: string, dto: UpdateEndpointDto): Promise<EndpointRecord | null>;
|
|
17
|
+
rotateSecret(endpointId: string, dto: RotateEndpointSecretDto): Promise<EndpointRecordWithSecret | null>;
|
|
17
18
|
deleteEndpoint(endpointId: string): Promise<boolean>;
|
|
18
19
|
getDeliveryLogs(endpointId: string, filters?: DeliveryLogFilters): Promise<DeliveryRecord[]>;
|
|
20
|
+
getDeliveryAttempts(deliveryId: string): Promise<DeliveryAttemptRecord[]>;
|
|
19
21
|
retryDelivery(deliveryId: string): Promise<boolean>;
|
|
20
22
|
sendTestEvent(endpointId: string): Promise<string | null>;
|
|
21
23
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webhook.admin.service.d.ts","sourceRoot":"","sources":["../src/webhook.admin.service.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,2BAA2B,EAAE,MAAM,kCAAkC,CAAC;AAC/E,OAAO,EAAE,2BAA2B,EAAE,MAAM,kCAAkC,CAAC;AAC/E,OAAO,EACL,iBAAiB,EACjB,cAAc,EACd,wBAAwB,EACxB,iBAAiB,EAClB,MAAM,yCAAyC,CAAC;AACjD,OAAO,EACL,kBAAkB,EAClB,cAAc,EACf,MAAM,yCAAyC,CAAC;AAEjD;;;GAGG;AACH,qBACa,mBAAmB;IAE5B,OAAO,CAAC,QAAQ,CAAC,SAAS;IAC1B,OAAO,CAAC,QAAQ,CAAC,UAAU;gBADV,SAAS,EAAE,2BAA2B,EACtC,UAAU,EAAE,2BAA2B;IAGpD,cAAc,CAAC,GAAG,EAAE,iBAAiB,GAAG,OAAO,CAAC,wBAAwB,CAAC;IAIzE,aAAa,CAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,EAAE,CAAC;IAI3D,WAAW,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,GAAG,IAAI,CAAC;IAI/D,cAAc,CAClB,UAAU,EAAE,MAAM,EAClB,GAAG,EAAE,iBAAiB,GACrB,OAAO,CAAC,cAAc,GAAG,IAAI,CAAC;IAI3B,cAAc,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,O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AAC,wBAAwB,GAAG,IAAI,CAAC;IAIrC,cAAc,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAIpD,eAAe,CACnB,UAAU,EAAE,MAAM,EAClB,OAAO,CAAC,EAAE,kBAAkB,GAC3B,OAAO,CAAC,cAAc,EAAE,CAAC;IAItB,mBAAmB,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,qBAAqB,EAAE,CAAC;IAIzE,aAAa,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAInD,aAAa,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC;CAGhE"}
|
|
@@ -14,8 +14,8 @@ const common_1 = require("@nestjs/common");
|
|
|
14
14
|
const webhook_endpoint_admin_service_1 = require("./webhook.endpoint-admin.service");
|
|
15
15
|
const webhook_delivery_admin_service_1 = require("./webhook.delivery-admin.service");
|
|
16
16
|
/**
|
|
17
|
-
* @deprecated
|
|
18
|
-
*
|
|
17
|
+
* @deprecated since v0.2.0. Will be removed in v1.0.0.
|
|
18
|
+
* Use WebhookEndpointAdminService and WebhookDeliveryAdminService directly.
|
|
19
19
|
*/
|
|
20
20
|
let WebhookAdminService = class WebhookAdminService {
|
|
21
21
|
endpoints;
|
|
@@ -36,12 +36,18 @@ let WebhookAdminService = class WebhookAdminService {
|
|
|
36
36
|
async updateEndpoint(endpointId, dto) {
|
|
37
37
|
return this.endpoints.updateEndpoint(endpointId, dto);
|
|
38
38
|
}
|
|
39
|
+
async rotateSecret(endpointId, dto) {
|
|
40
|
+
return this.endpoints.rotateSecret(endpointId, dto);
|
|
41
|
+
}
|
|
39
42
|
async deleteEndpoint(endpointId) {
|
|
40
43
|
return this.endpoints.deleteEndpoint(endpointId);
|
|
41
44
|
}
|
|
42
45
|
async getDeliveryLogs(endpointId, filters) {
|
|
43
46
|
return this.deliveries.getDeliveryLogs(endpointId, filters);
|
|
44
47
|
}
|
|
48
|
+
async getDeliveryAttempts(deliveryId) {
|
|
49
|
+
return this.deliveries.getDeliveryAttempts(deliveryId);
|
|
50
|
+
}
|
|
45
51
|
async retryDelivery(deliveryId) {
|
|
46
52
|
return this.deliveries.retryDelivery(deliveryId);
|
|
47
53
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webhook.admin.service.js","sourceRoot":"","sources":["../src/webhook.admin.service.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2CAA4C;AAC5C,qFAA+E;AAC/E,qFAA+E;
|
|
1
|
+
{"version":3,"file":"webhook.admin.service.js","sourceRoot":"","sources":["../src/webhook.admin.service.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2CAA4C;AAC5C,qFAA+E;AAC/E,qFAA+E;AAc/E;;;GAGG;AAEI,IAAM,mBAAmB,GAAzB,MAAM,mBAAmB;IAEX;IACA;IAFnB,YACmB,SAAsC,EACtC,UAAuC;QADvC,cAAS,GAAT,SAAS,CAA6B;QACtC,eAAU,GAAV,UAAU,CAA6B;IACvD,CAAC;IAEJ,KAAK,CAAC,cAAc,CAAC,GAAsB;QACzC,OAAO,IAAI,CAAC,SAAS,CAAC,cAAc,CAAC,GAAG,CAAC,CAAC;IAC5C,CAAC;IAED,KAAK,CAAC,aAAa,CAAC,QAAiB;QACnC,OAAO,IAAI,CAAC,SAAS,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAC;IAChD,CAAC;IAED,KAAK,CAAC,WAAW,CAAC,UAAkB;QAClC,OAAO,IAAI,CAAC,SAAS,CAAC,WAAW,CAAC,UAAU,CAAC,CAAC;IAChD,CAAC;IAED,KAAK,CAAC,cAAc,CAClB,UAAkB,EAClB,GAAsB;QAEtB,OAAO,IAAI,CAAC,SAAS,CAAC,cAAc,CAAC,UAAU,EAAE,GAAG,CAAC,CAAC;IACxD,CAAC;IAED,KAAK,CAAC,YAAY,CAChB,UAAkB,EAClB,GAA4B;QAE5B,OAAO,IAAI,CAAC,SAAS,CAAC,YAAY,CAAC,UAAU,EAAE,GAAG,CAAC,CAAC;IACtD,CAAC;IAED,KAAK,CAAC,cAAc,CAAC,UAAkB;QACrC,OAAO,IAAI,CAAC,SAAS,CAAC,cAAc,CAAC,UAAU,CAAC,CAAC;IACnD,CAAC;IAED,KAAK,CAAC,eAAe,CACnB,UAAkB,EAClB,OAA4B;QAE5B,OAAO,IAAI,CAAC,UAAU,CAAC,eAAe,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC;IAC9D,CAAC;IAED,KAAK,CAAC,mBAAmB,CAAC,UAAkB;QAC1C,OAAO,IAAI,CAAC,UAAU,CAAC,mBAAmB,CAAC,UAAU,CAAC,CAAC;IACzD,CAAC;IAED,KAAK,CAAC,aAAa,CAAC,UAAkB;QACpC,OAAO,IAAI,CAAC,UAAU,CAAC,aAAa,CAAC,UAAU,CAAC,CAAC;IACnD,CAAC;IAED,KAAK,CAAC,aAAa,CAAC,UAAkB;QACpC,OAAO,IAAI,CAAC,SAAS,CAAC,aAAa,CAAC,UAAU,CAAC,CAAC;IAClD,CAAC;CACF,CAAA;AAtDY,kDAAmB;8BAAnB,mBAAmB;IAD/B,IAAA,mBAAU,GAAE;qCAGmB,4DAA2B;QAC1B,4DAA2B;GAH/C,mBAAmB,CAsD/B"}
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import { WebhookModuleOptions } from './interfaces/webhook-options.interface';
|
|
2
2
|
import { WebhookEndpointRepository } from './ports/webhook-endpoint.repository';
|
|
3
|
+
interface DeliveryEndpointMeta {
|
|
4
|
+
tenantId: string | null;
|
|
5
|
+
url: string;
|
|
6
|
+
}
|
|
3
7
|
export declare class WebhookCircuitBreaker {
|
|
4
8
|
private readonly endpointRepo;
|
|
5
9
|
private readonly options;
|
|
@@ -7,10 +11,8 @@ export declare class WebhookCircuitBreaker {
|
|
|
7
11
|
private readonly failureThreshold;
|
|
8
12
|
private readonly cooldownMinutes;
|
|
9
13
|
constructor(endpointRepo: WebhookEndpointRepository, options: WebhookModuleOptions);
|
|
10
|
-
afterDelivery(endpointId: string, success: boolean, meta
|
|
11
|
-
tenantId: string | null;
|
|
12
|
-
url: string;
|
|
13
|
-
}): Promise<void>;
|
|
14
|
+
afterDelivery(endpointId: string, success: boolean, meta: DeliveryEndpointMeta): Promise<void>;
|
|
14
15
|
recoverEligibleEndpoints(): Promise<number>;
|
|
15
16
|
}
|
|
17
|
+
export {};
|
|
16
18
|
//# sourceMappingURL=webhook.circuit-breaker.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webhook.circuit-breaker.d.ts","sourceRoot":"","sources":["../src/webhook.circuit-breaker.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"webhook.circuit-breaker.d.ts","sourceRoot":"","sources":["../src/webhook.circuit-breaker.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,oBAAoB,EAAE,MAAM,wCAAwC,CAAC;AAC9E,OAAO,EAAE,yBAAyB,EAAE,MAAM,qCAAqC,CAAC;AAEhF,UAAU,oBAAoB;IAC5B,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,GAAG,EAAE,MAAM,CAAC;CACb;AAED,qBACa,qBAAqB;IAO9B,OAAO,CAAC,QAAQ,CAAC,YAAY;IAE7B,OAAO,CAAC,QAAQ,CAAC,OAAO;IAR1B,OAAO,CAAC,QAAQ,CAAC,MAAM,CAA0C;IACjE,OAAO,CAAC,QAAQ,CAAC,gBAAgB,CAAS;IAC1C,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAS;gBAItB,YAAY,EAAE,yBAAyB,EAEvC,OAAO,EAAE,oBAAoB;IAQ1C,aAAa,CACjB,UAAU,EAAE,MAAM,EAClB,OAAO,EAAE,OAAO,EAChB,IAAI,EAAE,oBAAoB,GACzB,OAAO,CAAC,IAAI,CAAC;IAkCV,wBAAwB,IAAI,OAAO,CAAC,MAAM,CAAC;CASlD"}
|
|
@@ -37,16 +37,18 @@ let WebhookCircuitBreaker = WebhookCircuitBreaker_1 = class WebhookCircuitBreake
|
|
|
37
37
|
else {
|
|
38
38
|
const failures = await this.endpointRepo.incrementFailures(endpointId);
|
|
39
39
|
if (failures >= this.failureThreshold) {
|
|
40
|
-
await this.endpointRepo.disableEndpoint(endpointId,
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
40
|
+
const disabled = await this.endpointRepo.disableEndpoint(endpointId, webhook_constants_1.ENDPOINT_DISABLED_REASON_CONSECUTIVE_FAILURES_EXCEEDED);
|
|
41
|
+
if (!disabled)
|
|
42
|
+
return;
|
|
43
|
+
this.logger.warn(`Endpoint ${endpointId} disabled: ${webhook_constants_1.ENDPOINT_DISABLED_REASON_CONSECUTIVE_FAILURES_EXCEEDED} (threshold=${this.failureThreshold})`);
|
|
44
|
+
// Fire only on active->inactive transition to prevent duplicate notifications
|
|
45
|
+
// and still notify if a prior disable attempt failed at the exact threshold.
|
|
46
|
+
if (this.options.onEndpointDisabled) {
|
|
45
47
|
void Promise.resolve(this.options.onEndpointDisabled({
|
|
46
48
|
endpointId,
|
|
47
|
-
tenantId: meta
|
|
48
|
-
url: meta
|
|
49
|
-
reason:
|
|
49
|
+
tenantId: meta.tenantId,
|
|
50
|
+
url: meta.url,
|
|
51
|
+
reason: webhook_constants_1.ENDPOINT_DISABLED_REASON_CONSECUTIVE_FAILURES_EXCEEDED,
|
|
50
52
|
consecutiveFailures: failures,
|
|
51
53
|
})).catch((hookError) => {
|
|
52
54
|
this.logger.error(`onEndpointDisabled callback error: ${hookError}`);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webhook.circuit-breaker.js","sourceRoot":"","sources":["../src/webhook.circuit-breaker.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2CAA4D;AAC5D,
|
|
1
|
+
{"version":3,"file":"webhook.circuit-breaker.js","sourceRoot":"","sources":["../src/webhook.circuit-breaker.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2CAA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QAAQ,EAAE,IAAI,CAAC,QAAQ;wBACvB,GAAG,EAAE,IAAI,CAAC,GAAG;wBACb,MAAM,EAAE,0EAAsD;wBAC9D,mBAAmB,EAAE,QAAQ;qBAC9B,CAAC,CACH,CAAC,KAAK,CAAC,CAAC,SAAS,EAAE,EAAE;wBACpB,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,sCAAsC,SAAS,EAAE,CAAC,CAAC;oBACvE,CAAC,CAAC,CAAC;gBACL,CAAC;YACH,CAAC;QACH,CAAC;IACH,CAAC;IAED,KAAK,CAAC,wBAAwB;QAC5B,MAAM,KAAK,GAAG,MAAM,IAAI,CAAC,YAAY,CAAC,wBAAwB,CAC5D,IAAI,CAAC,eAAe,CACrB,CAAC;QACF,IAAI,KAAK,GAAG,CAAC,EAAE,CAAC;YACd,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,aAAa,KAAK,6BAA6B,CAAC,CAAC;QACnE,CAAC;QACD,OAAO,KAAK,CAAC;IACf,CAAC;CACF,CAAA;AAhEY,sDAAqB;gCAArB,qBAAqB;IADjC,IAAA,mBAAU,GAAE;IAOR,WAAA,IAAA,eAAM,EAAC,+CAA2B,CAAC,CAAA;IAEnC,WAAA,IAAA,eAAM,EAAC,0CAAsB,CAAC,CAAA;;GARtB,qBAAqB,CAgEjC"}
|
|
@@ -3,15 +3,22 @@ export declare const WEBHOOK_EVENT_REPOSITORY = "WEBHOOK_EVENT_REPOSITORY";
|
|
|
3
3
|
export declare const WEBHOOK_ENDPOINT_REPOSITORY = "WEBHOOK_ENDPOINT_REPOSITORY";
|
|
4
4
|
export declare const WEBHOOK_DELIVERY_REPOSITORY = "WEBHOOK_DELIVERY_REPOSITORY";
|
|
5
5
|
export declare const WEBHOOK_HTTP_CLIENT = "WEBHOOK_HTTP_CLIENT";
|
|
6
|
+
export declare const WEBHOOK_SECRET_VAULT = "WEBHOOK_SECRET_VAULT";
|
|
6
7
|
/** Svix/Stripe-style exponential backoff schedule (seconds) */
|
|
7
|
-
export declare const DEFAULT_BACKOFF_SCHEDULE:
|
|
8
|
+
export declare const DEFAULT_BACKOFF_SCHEDULE: readonly [30, 300, 1800, 7200, 86400];
|
|
8
9
|
export declare const DEFAULT_DELIVERY_TIMEOUT = 10000;
|
|
9
10
|
export declare const DEFAULT_MAX_RETRIES = 5;
|
|
10
11
|
export declare const DEFAULT_JITTER_FACTOR = 0.1;
|
|
11
12
|
export declare const DEFAULT_CIRCUIT_BREAKER_THRESHOLD = 5;
|
|
12
13
|
export declare const DEFAULT_CIRCUIT_BREAKER_COOLDOWN_MINUTES = 60;
|
|
14
|
+
export declare const ENDPOINT_DISABLED_REASON_CONSECUTIVE_FAILURES_EXCEEDED: "consecutive_failures_exceeded";
|
|
15
|
+
export type EndpointDisabledReason = typeof ENDPOINT_DISABLED_REASON_CONSECUTIVE_FAILURES_EXCEEDED;
|
|
13
16
|
export declare const DEFAULT_POLLING_INTERVAL = 5000;
|
|
14
17
|
export declare const DEFAULT_POLLING_BATCH_SIZE = 50;
|
|
15
18
|
export declare const DEFAULT_STALE_SENDING_MINUTES = 5;
|
|
16
|
-
|
|
19
|
+
/** Max JavaScript string length (UTF-16 code units) retained for response bodies. */
|
|
20
|
+
export declare const RESPONSE_BODY_MAX_LENGTH = 4096;
|
|
21
|
+
/** Mirrors RESPONSE_BODY_MAX_LENGTH for attempt logs; kept separate for future schema divergence. */
|
|
22
|
+
export declare const ATTEMPT_RESPONSE_BODY_MAX_LENGTH = 4096;
|
|
23
|
+
export declare const DEFAULT_USER_AGENT: string;
|
|
17
24
|
//# sourceMappingURL=webhook.constants.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webhook.constants.d.ts","sourceRoot":"","sources":["../src/webhook.constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,sBAAsB,2BAA2B,CAAC;AAE/D,eAAO,MAAM,wBAAwB,6BAA6B,CAAC;AACnE,eAAO,MAAM,2BAA2B,gCAAgC,CAAC;AACzE,eAAO,MAAM,2BAA2B,gCAAgC,CAAC;AACzE,eAAO,MAAM,mBAAmB,wBAAwB,CAAC;
|
|
1
|
+
{"version":3,"file":"webhook.constants.d.ts","sourceRoot":"","sources":["../src/webhook.constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,sBAAsB,2BAA2B,CAAC;AAE/D,eAAO,MAAM,wBAAwB,6BAA6B,CAAC;AACnE,eAAO,MAAM,2BAA2B,gCAAgC,CAAC;AACzE,eAAO,MAAM,2BAA2B,gCAAgC,CAAC;AACzE,eAAO,MAAM,mBAAmB,wBAAwB,CAAC;AACzD,eAAO,MAAM,oBAAoB,yBAAyB,CAAC;AAI3D,+DAA+D;AAC/D,eAAO,MAAM,wBAAwB,uCAM1B,CAAC;AAEZ,eAAO,MAAM,wBAAwB,QAAS,CAAC;AAC/C,eAAO,MAAM,mBAAmB,IAAI,CAAC;AACrC,eAAO,MAAM,qBAAqB,MAAM,CAAC;AAEzC,eAAO,MAAM,iCAAiC,IAAI,CAAC;AACnD,eAAO,MAAM,wCAAwC,KAAK,CAAC;AAC3D,eAAO,MAAM,sDAAsD,EACjE,+BAAwC,CAAC;AAC3C,MAAM,MAAM,sBAAsB,GAChC,OAAO,sDAAsD,CAAC;AAEhE,eAAO,MAAM,wBAAwB,OAAQ,CAAC;AAC9C,eAAO,MAAM,0BAA0B,KAAK,CAAC;AAC7C,eAAO,MAAM,6BAA6B,IAAI,CAAC;AAE/C,qFAAqF;AACrF,eAAO,MAAM,wBAAwB,OAAO,CAAC;AAC7C,qGAAqG;AACrG,eAAO,MAAM,gCAAgC,OAA2B,CAAC;AACzE,eAAO,MAAM,kBAAkB,QAAwC,CAAC"}
|