@voltro/plugin-webhooks 0.84.0 → 0.85.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/errors.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import { Schema } from 'effect';
2
+ import { YieldableError } from 'effect/Cause';
2
3
 
3
4
  /**
4
5
  * Thrown by `WebhooksService.replay` when no delivery row exists for the
@@ -8,12 +9,10 @@ import { Schema } from 'effect';
8
9
  export declare class WebhookDeliveryNotFound extends WebhookDeliveryNotFound_base {
9
10
  }
10
11
 
11
- declare const WebhookDeliveryNotFound_base: Schema.TaggedErrorClass<WebhookDeliveryNotFound, "WebhookDeliveryNotFound", {
12
- readonly _tag: Schema.tag<"WebhookDeliveryNotFound">;
13
- } & {
12
+ declare const WebhookDeliveryNotFound_base: Schema.Class<WebhookDeliveryNotFound, Schema.TaggedStruct<"WebhookDeliveryNotFound", {
14
13
  /** The delivery id that did not resolve to a row. */
15
- deliveryId: typeof Schema.String;
16
- }>;
14
+ readonly deliveryId: Schema.String;
15
+ }>, YieldableError>;
17
16
 
18
17
  /**
19
18
  * Thrown by `WebhooksService.emit` when the payload does not decode
@@ -25,14 +24,12 @@ declare const WebhookDeliveryNotFound_base: Schema.TaggedErrorClass<WebhookDeliv
25
24
  export declare class WebhookPayloadInvalid extends WebhookPayloadInvalid_base {
26
25
  }
27
26
 
28
- declare const WebhookPayloadInvalid_base: Schema.TaggedErrorClass<WebhookPayloadInvalid, "WebhookPayloadInvalid", {
29
- readonly _tag: Schema.tag<"WebhookPayloadInvalid">;
30
- } & {
27
+ declare const WebhookPayloadInvalid_base: Schema.Class<WebhookPayloadInvalid, Schema.TaggedStruct<"WebhookPayloadInvalid", {
31
28
  /** The outgoing event id the payload was emitted for. */
32
- event: typeof Schema.String;
29
+ readonly event: Schema.String;
33
30
  /** Tree-formatted schema decode issues (one line per violation). */
34
- issues: typeof Schema.String;
35
- }>;
31
+ readonly issues: Schema.String;
32
+ }>, YieldableError>;
36
33
 
37
34
  /**
38
35
  * Raised by the delivery workflow's wire-encoder when the target's
@@ -47,14 +44,12 @@ declare const WebhookPayloadInvalid_base: Schema.TaggedErrorClass<WebhookPayload
47
44
  export declare class WebhookPayloadUnrepresentable extends WebhookPayloadUnrepresentable_base {
48
45
  }
49
46
 
50
- declare const WebhookPayloadUnrepresentable_base: Schema.TaggedErrorClass<WebhookPayloadUnrepresentable, "WebhookPayloadUnrepresentable", {
51
- readonly _tag: Schema.tag<"WebhookPayloadUnrepresentable">;
52
- } & {
47
+ declare const WebhookPayloadUnrepresentable_base: Schema.Class<WebhookPayloadUnrepresentable, Schema.TaggedStruct<"WebhookPayloadUnrepresentable", {
53
48
  /** The wire format that could not represent the payload. */
54
- format: Schema.Literal<["json", "form", "xml"]>;
49
+ readonly format: Schema.Literals<readonly ["json", "form", "xml"]>;
55
50
  /** Human-readable detail — which shape/key defeated the encoder. */
56
- reason: typeof Schema.String;
57
- }>;
51
+ readonly reason: Schema.String;
52
+ }>, YieldableError>;
58
53
 
59
54
  /**
60
55
  * Thrown by `WebhooksService.updateTargetPayloadVersion` when the
@@ -63,12 +58,10 @@ declare const WebhookPayloadUnrepresentable_base: Schema.TaggedErrorClass<Webhoo
63
58
  export declare class WebhookPayloadVersionInvalid extends WebhookPayloadVersionInvalid_base {
64
59
  }
65
60
 
66
- declare const WebhookPayloadVersionInvalid_base: Schema.TaggedErrorClass<WebhookPayloadVersionInvalid, "WebhookPayloadVersionInvalid", {
67
- readonly _tag: Schema.tag<"WebhookPayloadVersionInvalid">;
68
- } & {
61
+ declare const WebhookPayloadVersionInvalid_base: Schema.Class<WebhookPayloadVersionInvalid, Schema.TaggedStruct<"WebhookPayloadVersionInvalid", {
69
62
  /** The rejected version value (as supplied by the caller). */
70
- version: typeof Schema.Number;
71
- }>;
63
+ readonly version: Schema.Number;
64
+ }>, YieldableError>;
72
65
 
73
66
  /**
74
67
  * Thrown by `WebhooksService.subscribe` (via `validateSubscribe`) when
@@ -78,26 +71,23 @@ declare const WebhookPayloadVersionInvalid_base: Schema.TaggedErrorClass<Webhook
78
71
  * `reason` is the human-readable detail (carries the offending value).
79
72
  */
80
73
  export declare class WebhookSubscribeInvalid extends WebhookSubscribeInvalid_base {
74
+ get message(): string;
81
75
  }
82
76
 
83
- declare const WebhookSubscribeInvalid_base: Schema.TaggedErrorClass<WebhookSubscribeInvalid, "WebhookSubscribeInvalid", {
84
- readonly _tag: Schema.tag<"WebhookSubscribeInvalid">;
85
- } & {
77
+ declare const WebhookSubscribeInvalid_base: Schema.Class<WebhookSubscribeInvalid, Schema.TaggedStruct<"WebhookSubscribeInvalid", {
86
78
  /** The offending subscribe-input field: `'url'` | `'event'` |
87
79
  * `'secret'` | `'retry'` | `'rateLimitPerMinute'`. */
88
- field: typeof Schema.String;
80
+ readonly field: Schema.String;
89
81
  /** Human-readable detail, including the offending value. */
90
- reason: typeof Schema.String;
91
- }>;
82
+ readonly reason: Schema.String;
83
+ }>, YieldableError>;
92
84
 
93
85
  /** A target selected for management no longer exists. */
94
86
  export declare class WebhookTargetNotFound extends WebhookTargetNotFound_base {
95
87
  }
96
88
 
97
- declare const WebhookTargetNotFound_base: Schema.TaggedErrorClass<WebhookTargetNotFound, "WebhookTargetNotFound", {
98
- readonly _tag: Schema.tag<"WebhookTargetNotFound">;
99
- } & {
100
- targetId: typeof Schema.String;
101
- }>;
89
+ declare const WebhookTargetNotFound_base: Schema.Class<WebhookTargetNotFound, Schema.TaggedStruct<"WebhookTargetNotFound", {
90
+ readonly targetId: Schema.String;
91
+ }>, YieldableError>;
102
92
 
103
93
  export { }
package/dist/errors.js CHANGED
@@ -3,11 +3,19 @@ import { Schema as e } from "effect";
3
3
  var t = class extends e.TaggedError()("WebhookSubscribeInvalid", {
4
4
  field: e.String,
5
5
  reason: e.String
6
- }) {}, n = class extends e.TaggedError()("WebhookDeliveryNotFound", { deliveryId: e.String }) {}, r = class extends e.TaggedError()("WebhookTargetNotFound", { targetId: e.String }) {}, i = class extends e.TaggedError()("WebhookPayloadVersionInvalid", { version: e.Number }) {}, a = class extends e.TaggedError()("WebhookPayloadInvalid", {
6
+ }) {
7
+ get message() {
8
+ return `${this.field}: ${this.reason}`;
9
+ }
10
+ }, n = class extends e.TaggedError()("WebhookDeliveryNotFound", { deliveryId: e.String }) {}, r = class extends e.TaggedError()("WebhookTargetNotFound", { targetId: e.String }) {}, i = class extends e.TaggedError()("WebhookPayloadVersionInvalid", { version: e.Number }) {}, a = class extends e.TaggedError()("WebhookPayloadInvalid", {
7
11
  event: e.String,
8
12
  issues: e.String
9
13
  }) {}, o = class extends e.TaggedError()("WebhookPayloadUnrepresentable", {
10
- format: e.Literal("json", "form", "xml"),
14
+ format: e.Literals([
15
+ "json",
16
+ "form",
17
+ "xml"
18
+ ]),
11
19
  reason: e.String
12
20
  }) {};
13
21
  //#endregion
package/dist/index.d.ts CHANGED
@@ -13,10 +13,11 @@ import { PluginPermission } from '@voltro/protocol';
13
13
  import { Schema } from 'effect';
14
14
  import { Table } from '@voltro/database';
15
15
  import { VoltroPlugin } from '@voltro/protocol';
16
- import { Workflow } from '@effect/workflow';
17
- import { WorkflowEngine } from '@effect/workflow/WorkflowEngine';
18
- import { WorkflowInstance } from '@effect/workflow/WorkflowEngine';
16
+ import { Workflow } from 'effect/workflow';
17
+ import { WorkflowEngine } from 'effect/workflow/WorkflowEngine';
18
+ import { WorkflowInstance } from 'effect/workflow/WorkflowEngine';
19
19
  import { WorkflowRunHandle } from '@voltro/protocol';
20
+ import { YieldableError } from 'effect/Cause';
20
21
 
21
22
  /**
22
23
  * Acquire one slot in EVERY scope for the window containing `now`
@@ -166,22 +167,20 @@ declare interface DeliverInput {
166
167
  readonly event: string;
167
168
  readonly eventId: string;
168
169
  readonly payloadJson: string;
169
- readonly attemptEpoch?: number;
170
+ readonly attemptEpoch?: number | undefined;
170
171
  }
171
172
 
172
173
  export declare const deliverWebhookWorkflow: Workflow.Workflow<"voltro.deliverWebhook", Schema.Struct<{
173
- deliveryId: typeof Schema.String;
174
- targetId: typeof Schema.String;
175
- event: typeof Schema.String;
176
- eventId: typeof Schema.String;
177
- payloadJson: typeof Schema.String;
178
- attemptEpoch: Schema.optionalWith<typeof Schema.Number, {
179
- default: () => number;
180
- }>;
174
+ deliveryId: Schema.String;
175
+ targetId: Schema.String;
176
+ event: Schema.String;
177
+ eventId: Schema.String;
178
+ payloadJson: Schema.String;
179
+ attemptEpoch: Schema.optional<Schema.Number>;
181
180
  }>, Schema.Struct<{
182
- finalStatus: Schema.Literal<["succeeded", "failed", "deferred"]>;
183
- attempts: typeof Schema.Number;
184
- }>, typeof Schema.Never>;
181
+ readonly finalStatus: Schema.Literals<readonly ["succeeded", "failed", "deferred"]>;
182
+ readonly attempts: Schema.Number;
183
+ }>, Schema.Never>;
185
184
 
186
185
  declare interface DeliverWorkflowOptions {
187
186
  /** Discovered outgoing events (declared events with a `webhook:` block,
@@ -255,6 +254,14 @@ export declare type DurationLiteral = `${number}${'ms' | 's' | 'm' | 'h' | 'd'}`
255
254
  export declare interface EmitOptions {
256
255
  /** Only deliver to targets of this tenant. Absent ⇒ every target. */
257
256
  readonly tenantId?: string | null;
257
+ /**
258
+ * The event's id, as every delivery of it records it (`eventId`, sent as
259
+ * `x-voltro-event-id`). Absent ⇒ a fresh one. A
260
+ * deferred emit passes its outbox row id, so a retried delivery of the same
261
+ * intent keeps one id and a trace links the request, the outbox row and
262
+ * every delivery.
263
+ */
264
+ readonly eventId?: string;
258
265
  /**
259
266
  * Dispatch NOW instead of after the enclosing transaction commits.
260
267
  *
@@ -1489,12 +1496,10 @@ export declare const WEBHOOK_VERIFICATION_PROPERTY: "voltroWebhookVerification";
1489
1496
  export declare class WebhookDeliveryNotFound extends WebhookDeliveryNotFound_base {
1490
1497
  }
1491
1498
 
1492
- declare const WebhookDeliveryNotFound_base: Schema.TaggedErrorClass<WebhookDeliveryNotFound, "WebhookDeliveryNotFound", {
1493
- readonly _tag: Schema.tag<"WebhookDeliveryNotFound">;
1494
- } & {
1499
+ declare const WebhookDeliveryNotFound_base: Schema.Class<WebhookDeliveryNotFound, Schema.TaggedStruct<"WebhookDeliveryNotFound", {
1495
1500
  /** The delivery id that did not resolve to a row. */
1496
- deliveryId: typeof Schema.String;
1497
- }>;
1501
+ readonly deliveryId: Schema.String;
1502
+ }>, YieldableError>;
1498
1503
 
1499
1504
  export declare type WebhookDescriptor = OutgoingEventDescriptor<unknown> | IncomingWebhookDescriptor<unknown> | WebhookProviderDescriptor;
1500
1505
 
@@ -1531,14 +1536,12 @@ export declare type WebhookId = string;
1531
1536
  export declare class WebhookPayloadInvalid extends WebhookPayloadInvalid_base {
1532
1537
  }
1533
1538
 
1534
- declare const WebhookPayloadInvalid_base: Schema.TaggedErrorClass<WebhookPayloadInvalid, "WebhookPayloadInvalid", {
1535
- readonly _tag: Schema.tag<"WebhookPayloadInvalid">;
1536
- } & {
1539
+ declare const WebhookPayloadInvalid_base: Schema.Class<WebhookPayloadInvalid, Schema.TaggedStruct<"WebhookPayloadInvalid", {
1537
1540
  /** The outgoing event id the payload was emitted for. */
1538
- event: typeof Schema.String;
1541
+ readonly event: Schema.String;
1539
1542
  /** Tree-formatted schema decode issues (one line per violation). */
1540
- issues: typeof Schema.String;
1541
- }>;
1543
+ readonly issues: Schema.String;
1544
+ }>, YieldableError>;
1542
1545
 
1543
1546
  /**
1544
1547
  * Raised by the delivery workflow's wire-encoder when the target's
@@ -1553,14 +1556,12 @@ declare const WebhookPayloadInvalid_base: Schema.TaggedErrorClass<WebhookPayload
1553
1556
  export declare class WebhookPayloadUnrepresentable extends WebhookPayloadUnrepresentable_base {
1554
1557
  }
1555
1558
 
1556
- declare const WebhookPayloadUnrepresentable_base: Schema.TaggedErrorClass<WebhookPayloadUnrepresentable, "WebhookPayloadUnrepresentable", {
1557
- readonly _tag: Schema.tag<"WebhookPayloadUnrepresentable">;
1558
- } & {
1559
+ declare const WebhookPayloadUnrepresentable_base: Schema.Class<WebhookPayloadUnrepresentable, Schema.TaggedStruct<"WebhookPayloadUnrepresentable", {
1559
1560
  /** The wire format that could not represent the payload. */
1560
- format: Schema.Literal<["json", "form", "xml"]>;
1561
+ readonly format: Schema.Literals<readonly ["json", "form", "xml"]>;
1561
1562
  /** Human-readable detail — which shape/key defeated the encoder. */
1562
- reason: typeof Schema.String;
1563
- }>;
1563
+ readonly reason: Schema.String;
1564
+ }>, YieldableError>;
1564
1565
 
1565
1566
  /**
1566
1567
  * Thrown by `WebhooksService.updateTargetPayloadVersion` when the
@@ -1569,12 +1570,10 @@ declare const WebhookPayloadUnrepresentable_base: Schema.TaggedErrorClass<Webhoo
1569
1570
  export declare class WebhookPayloadVersionInvalid extends WebhookPayloadVersionInvalid_base {
1570
1571
  }
1571
1572
 
1572
- declare const WebhookPayloadVersionInvalid_base: Schema.TaggedErrorClass<WebhookPayloadVersionInvalid, "WebhookPayloadVersionInvalid", {
1573
- readonly _tag: Schema.tag<"WebhookPayloadVersionInvalid">;
1574
- } & {
1573
+ declare const WebhookPayloadVersionInvalid_base: Schema.Class<WebhookPayloadVersionInvalid, Schema.TaggedStruct<"WebhookPayloadVersionInvalid", {
1575
1574
  /** The rejected version value (as supplied by the caller). */
1576
- version: typeof Schema.Number;
1577
- }>;
1575
+ readonly version: Schema.Number;
1576
+ }>, YieldableError>;
1578
1577
 
1579
1578
  export declare interface WebhookProviderDescriptor {
1580
1579
  readonly _tag: 'webhookProvider';
@@ -1640,7 +1639,7 @@ export declare interface WebhooksPluginOptions {
1640
1639
  export declare class WebhooksService extends WebhooksService_base {
1641
1640
  }
1642
1641
 
1643
- declare const WebhooksService_base: Context.TagClass<WebhooksService, "@voltro/webhooks/WebhooksService", WebhooksServiceShape>;
1642
+ declare const WebhooksService_base: Context.ServiceClass<WebhooksService, "@voltro/webhooks/WebhooksService", WebhooksServiceShape>;
1644
1643
 
1645
1644
  export declare interface WebhooksServiceOptions {
1646
1645
  /** Discovered outgoing events (projected from declared events). When present,
@@ -1770,17 +1769,16 @@ export declare interface WebhooksServiceShape {
1770
1769
  * `reason` is the human-readable detail (carries the offending value).
1771
1770
  */
1772
1771
  export declare class WebhookSubscribeInvalid extends WebhookSubscribeInvalid_base {
1772
+ get message(): string;
1773
1773
  }
1774
1774
 
1775
- declare const WebhookSubscribeInvalid_base: Schema.TaggedErrorClass<WebhookSubscribeInvalid, "WebhookSubscribeInvalid", {
1776
- readonly _tag: Schema.tag<"WebhookSubscribeInvalid">;
1777
- } & {
1775
+ declare const WebhookSubscribeInvalid_base: Schema.Class<WebhookSubscribeInvalid, Schema.TaggedStruct<"WebhookSubscribeInvalid", {
1778
1776
  /** The offending subscribe-input field: `'url'` | `'event'` |
1779
1777
  * `'secret'` | `'retry'` | `'rateLimitPerMinute'`. */
1780
- field: typeof Schema.String;
1778
+ readonly field: Schema.String;
1781
1779
  /** Human-readable detail, including the offending value. */
1782
- reason: typeof Schema.String;
1783
- }>;
1780
+ readonly reason: Schema.String;
1781
+ }>, YieldableError>;
1784
1782
 
1785
1783
  /**
1786
1784
  * The three bookkeeping tables, as a TUPLE rather than a plain array.
@@ -1987,11 +1985,9 @@ export declare const webhookTables: () => readonly [ Table<"_voltro_webhook_targ
1987
1985
  export declare class WebhookTargetNotFound extends WebhookTargetNotFound_base {
1988
1986
  }
1989
1987
 
1990
- declare const WebhookTargetNotFound_base: Schema.TaggedErrorClass<WebhookTargetNotFound, "WebhookTargetNotFound", {
1991
- readonly _tag: Schema.tag<"WebhookTargetNotFound">;
1992
- } & {
1993
- targetId: typeof Schema.String;
1994
- }>;
1988
+ declare const WebhookTargetNotFound_base: Schema.Class<WebhookTargetNotFound, Schema.TaggedStruct<"WebhookTargetNotFound", {
1989
+ readonly targetId: Schema.String;
1990
+ }>, YieldableError>;
1995
1991
 
1996
1992
  export declare type WireFormat = 'json' | 'form' | 'xml';
1997
1993