samva 0.18.0 → 0.19.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.
Files changed (47) hide show
  1. package/README.md +2 -0
  2. package/dist/client/sdk.gen.d.ts +39 -23
  3. package/dist/client/sdk.gen.js +83 -21
  4. package/dist/client/types.gen.d.ts +175 -44
  5. package/dist/effect/contact-groups.d.ts +39 -3
  6. package/dist/effect/contacts.d.ts +216 -13
  7. package/dist/effect/contacts.js +3 -1
  8. package/dist/effect/conversations.d.ts +11 -11
  9. package/dist/effect/extension-installations.d.ts +12 -12
  10. package/dist/effect/extensions.d.ts +3 -3
  11. package/dist/effect/generated/contact-groups.d.ts +33 -3
  12. package/dist/effect/generated/contacts.d.ts +477 -54
  13. package/dist/effect/generated/contacts.js +39 -9
  14. package/dist/effect/generated/conversations.d.ts +25 -25
  15. package/dist/effect/generated/conversations.js +1 -1
  16. package/dist/effect/generated/extension-installations.d.ts +44 -44
  17. package/dist/effect/generated/extension-installations.js +6 -0
  18. package/dist/effect/generated/extensions.d.ts +10 -10
  19. package/dist/effect/generated/extensions.js +2 -0
  20. package/dist/effect/generated/mailboxes.d.ts +310 -0
  21. package/dist/effect/generated/mailboxes.js +37 -4
  22. package/dist/effect/generated/messages.d.ts +31 -0
  23. package/dist/effect/generated/messages.js +7 -1
  24. package/dist/effect/generated/organizations.d.ts +13 -11
  25. package/dist/effect/generated/organizations.js +7 -3
  26. package/dist/effect/generated/shared.d.ts +70 -20
  27. package/dist/effect/generated/shared.js +27 -7
  28. package/dist/effect/generated/unsubscribe-groups.d.ts +173 -78
  29. package/dist/effect/generated/unsubscribe-groups.js +75 -58
  30. package/dist/effect/generated/webhooks.d.ts +19 -19
  31. package/dist/effect/generated/webhooks.js +8 -0
  32. package/dist/effect/generated-metadata.d.ts +7 -2
  33. package/dist/effect/generated-metadata.js +331 -325
  34. package/dist/effect/mailboxes.d.ts +133 -1
  35. package/dist/effect/messages.d.ts +5 -0
  36. package/dist/effect/organizations.d.ts +4 -4
  37. package/dist/effect/unsubscribe-groups.d.ts +29 -18
  38. package/dist/effect/unsubscribe-groups.js +5 -5
  39. package/dist/effect/webhooks.d.ts +8 -8
  40. package/dist/mailbox-events.d.ts +31 -4
  41. package/dist/mailbox-events.js +39 -11
  42. package/dist/package.js +1 -1
  43. package/dist/promises/index.d.ts +1 -1
  44. package/dist/promises/types.gen.d.ts +1 -1
  45. package/dist/service-map.d.ts +9 -4
  46. package/dist/service-map.js +10 -2
  47. package/package.json +2 -2
@@ -1,5 +1,5 @@
1
1
  export { events } from "./internal/mailbox-events";
2
- export { type MailboxEvent, MailboxEventStreamError, type MailboxEventStreamErrorFields, type MailboxEventStreamErrorTag, type MailboxEventStreamFailure, type MailboxEventStreamOptions, type MailboxEventType, } from "../mailbox-events";
2
+ export { type MailboxEvent, MailboxEventStreamError, type MailboxEventStreamErrorFields, type MailboxEventStreamErrorReason, type MailboxEventStreamErrorTag, type MailboxEventStreamFailure, type MailboxEventStreamOptions, type MailboxEventStreamReconnect, type MailboxEventType, } from "../mailbox-events";
3
3
  export declare const list: ((input?: {
4
4
  readonly limit?: string | null | undefined;
5
5
  readonly cursor?: string | null | undefined;
@@ -2215,6 +2215,17 @@ export declare const listActions: ((input: {
2215
2215
  readonly source: "grant" | "installation" | "policy" | null;
2216
2216
  readonly decidedAt: string;
2217
2217
  } | null;
2218
+ readonly resolution: {
2219
+ readonly outcome: "approved" | "cancelled" | "denied";
2220
+ readonly actor: {
2221
+ readonly kind: "apiKey" | "extension" | "externalAgent" | "samvaAgent" | "system" | "user";
2222
+ readonly id: string;
2223
+ readonly displayName?: string | null;
2224
+ readonly source: "extension" | "externalAgent" | "externalApi" | "humanUi" | "system";
2225
+ };
2226
+ readonly resolvedAt: string;
2227
+ readonly reason: string | null;
2228
+ } | null;
2218
2229
  readonly createdAt: string;
2219
2230
  readonly updatedAt: string;
2220
2231
  readonly type: "reply" | "sendMessage";
@@ -2328,6 +2339,17 @@ export declare const listActions: ((input: {
2328
2339
  readonly source: "grant" | "installation" | "policy" | null;
2329
2340
  readonly decidedAt: string;
2330
2341
  } | null;
2342
+ readonly resolution: {
2343
+ readonly outcome: "approved" | "cancelled" | "denied";
2344
+ readonly actor: {
2345
+ readonly kind: "apiKey" | "extension" | "externalAgent" | "samvaAgent" | "system" | "user";
2346
+ readonly id: string;
2347
+ readonly displayName?: string | null;
2348
+ readonly source: "extension" | "externalAgent" | "externalApi" | "humanUi" | "system";
2349
+ };
2350
+ readonly resolvedAt: string;
2351
+ readonly reason: string | null;
2352
+ } | null;
2331
2353
  readonly createdAt: string;
2332
2354
  readonly updatedAt: string;
2333
2355
  readonly type: "assignThread" | "call" | "changeThreadState" | "createNote" | "extensionRequest" | "updateDraft";
@@ -2361,6 +2383,17 @@ export declare const listActions: ((input: {
2361
2383
  readonly source: "grant" | "installation" | "policy" | null;
2362
2384
  readonly decidedAt: string;
2363
2385
  } | null;
2386
+ readonly resolution: {
2387
+ readonly outcome: "approved" | "cancelled" | "denied";
2388
+ readonly actor: {
2389
+ readonly kind: "apiKey" | "extension" | "externalAgent" | "samvaAgent" | "system" | "user";
2390
+ readonly id: string;
2391
+ readonly displayName?: string | null;
2392
+ readonly source: "extension" | "externalAgent" | "externalApi" | "humanUi" | "system";
2393
+ };
2394
+ readonly resolvedAt: string;
2395
+ readonly reason: string | null;
2396
+ } | null;
2364
2397
  readonly createdAt: string;
2365
2398
  readonly updatedAt: string;
2366
2399
  readonly type: "reply" | "sendMessage";
@@ -2474,6 +2507,17 @@ export declare const listActions: ((input: {
2474
2507
  readonly source: "grant" | "installation" | "policy" | null;
2475
2508
  readonly decidedAt: string;
2476
2509
  } | null;
2510
+ readonly resolution: {
2511
+ readonly outcome: "approved" | "cancelled" | "denied";
2512
+ readonly actor: {
2513
+ readonly kind: "apiKey" | "extension" | "externalAgent" | "samvaAgent" | "system" | "user";
2514
+ readonly id: string;
2515
+ readonly displayName?: string | null;
2516
+ readonly source: "extension" | "externalAgent" | "externalApi" | "humanUi" | "system";
2517
+ };
2518
+ readonly resolvedAt: string;
2519
+ readonly reason: string | null;
2520
+ } | null;
2477
2521
  readonly createdAt: string;
2478
2522
  readonly updatedAt: string;
2479
2523
  readonly type: "assignThread" | "call" | "changeThreadState" | "createNote" | "extensionRequest" | "updateDraft";
@@ -2506,6 +2550,17 @@ export declare const listActions: ((input: {
2506
2550
  readonly source: "grant" | "installation" | "policy" | null;
2507
2551
  readonly decidedAt: string;
2508
2552
  } | null;
2553
+ readonly resolution: {
2554
+ readonly outcome: "approved" | "cancelled" | "denied";
2555
+ readonly actor: {
2556
+ readonly kind: "apiKey" | "extension" | "externalAgent" | "samvaAgent" | "system" | "user";
2557
+ readonly id: string;
2558
+ readonly displayName?: string | null;
2559
+ readonly source: "extension" | "externalAgent" | "externalApi" | "humanUi" | "system";
2560
+ };
2561
+ readonly resolvedAt: string;
2562
+ readonly reason: string | null;
2563
+ } | null;
2509
2564
  readonly createdAt: string;
2510
2565
  readonly updatedAt: string;
2511
2566
  readonly type: "reply" | "sendMessage";
@@ -2619,6 +2674,17 @@ export declare const listActions: ((input: {
2619
2674
  readonly source: "grant" | "installation" | "policy" | null;
2620
2675
  readonly decidedAt: string;
2621
2676
  } | null;
2677
+ readonly resolution: {
2678
+ readonly outcome: "approved" | "cancelled" | "denied";
2679
+ readonly actor: {
2680
+ readonly kind: "apiKey" | "extension" | "externalAgent" | "samvaAgent" | "system" | "user";
2681
+ readonly id: string;
2682
+ readonly displayName?: string | null;
2683
+ readonly source: "extension" | "externalAgent" | "externalApi" | "humanUi" | "system";
2684
+ };
2685
+ readonly resolvedAt: string;
2686
+ readonly reason: string | null;
2687
+ } | null;
2622
2688
  readonly createdAt: string;
2623
2689
  readonly updatedAt: string;
2624
2690
  readonly type: "assignThread" | "call" | "changeThreadState" | "createNote" | "extensionRequest" | "updateDraft";
@@ -2645,6 +2711,17 @@ export declare const getAction: (input: {
2645
2711
  readonly source: "grant" | "installation" | "policy" | null;
2646
2712
  readonly decidedAt: string;
2647
2713
  } | null;
2714
+ readonly resolution: {
2715
+ readonly outcome: "approved" | "cancelled" | "denied";
2716
+ readonly actor: {
2717
+ readonly kind: "apiKey" | "extension" | "externalAgent" | "samvaAgent" | "system" | "user";
2718
+ readonly id: string;
2719
+ readonly displayName?: string | null;
2720
+ readonly source: "extension" | "externalAgent" | "externalApi" | "humanUi" | "system";
2721
+ };
2722
+ readonly resolvedAt: string;
2723
+ readonly reason: string | null;
2724
+ } | null;
2648
2725
  readonly createdAt: string;
2649
2726
  readonly updatedAt: string;
2650
2727
  readonly type: "reply" | "sendMessage";
@@ -2758,6 +2835,17 @@ export declare const getAction: (input: {
2758
2835
  readonly source: "grant" | "installation" | "policy" | null;
2759
2836
  readonly decidedAt: string;
2760
2837
  } | null;
2838
+ readonly resolution: {
2839
+ readonly outcome: "approved" | "cancelled" | "denied";
2840
+ readonly actor: {
2841
+ readonly kind: "apiKey" | "extension" | "externalAgent" | "samvaAgent" | "system" | "user";
2842
+ readonly id: string;
2843
+ readonly displayName?: string | null;
2844
+ readonly source: "extension" | "externalAgent" | "externalApi" | "humanUi" | "system";
2845
+ };
2846
+ readonly resolvedAt: string;
2847
+ readonly reason: string | null;
2848
+ } | null;
2761
2849
  readonly createdAt: string;
2762
2850
  readonly updatedAt: string;
2763
2851
  readonly type: "assignThread" | "call" | "changeThreadState" | "createNote" | "extensionRequest" | "updateDraft";
@@ -3063,6 +3151,17 @@ export declare const approveAction: (input: {
3063
3151
  readonly source: "grant" | "installation" | "policy" | null;
3064
3152
  readonly decidedAt: string;
3065
3153
  } | null;
3154
+ readonly resolution: {
3155
+ readonly outcome: "approved" | "cancelled" | "denied";
3156
+ readonly actor: {
3157
+ readonly kind: "apiKey" | "extension" | "externalAgent" | "samvaAgent" | "system" | "user";
3158
+ readonly id: string;
3159
+ readonly displayName?: string | null;
3160
+ readonly source: "extension" | "externalAgent" | "externalApi" | "humanUi" | "system";
3161
+ };
3162
+ readonly resolvedAt: string;
3163
+ readonly reason: string | null;
3164
+ } | null;
3066
3165
  readonly createdAt: string;
3067
3166
  readonly updatedAt: string;
3068
3167
  readonly type: "reply" | "sendMessage";
@@ -3176,6 +3275,17 @@ export declare const approveAction: (input: {
3176
3275
  readonly source: "grant" | "installation" | "policy" | null;
3177
3276
  readonly decidedAt: string;
3178
3277
  } | null;
3278
+ readonly resolution: {
3279
+ readonly outcome: "approved" | "cancelled" | "denied";
3280
+ readonly actor: {
3281
+ readonly kind: "apiKey" | "extension" | "externalAgent" | "samvaAgent" | "system" | "user";
3282
+ readonly id: string;
3283
+ readonly displayName?: string | null;
3284
+ readonly source: "extension" | "externalAgent" | "externalApi" | "humanUi" | "system";
3285
+ };
3286
+ readonly resolvedAt: string;
3287
+ readonly reason: string | null;
3288
+ } | null;
3179
3289
  readonly createdAt: string;
3180
3290
  readonly updatedAt: string;
3181
3291
  readonly type: "assignThread" | "call" | "changeThreadState" | "createNote" | "extensionRequest" | "updateDraft";
@@ -3202,6 +3312,17 @@ export declare const denyAction: (input: {
3202
3312
  readonly source: "grant" | "installation" | "policy" | null;
3203
3313
  readonly decidedAt: string;
3204
3314
  } | null;
3315
+ readonly resolution: {
3316
+ readonly outcome: "approved" | "cancelled" | "denied";
3317
+ readonly actor: {
3318
+ readonly kind: "apiKey" | "extension" | "externalAgent" | "samvaAgent" | "system" | "user";
3319
+ readonly id: string;
3320
+ readonly displayName?: string | null;
3321
+ readonly source: "extension" | "externalAgent" | "externalApi" | "humanUi" | "system";
3322
+ };
3323
+ readonly resolvedAt: string;
3324
+ readonly reason: string | null;
3325
+ } | null;
3205
3326
  readonly createdAt: string;
3206
3327
  readonly updatedAt: string;
3207
3328
  readonly type: "reply" | "sendMessage";
@@ -3315,6 +3436,17 @@ export declare const denyAction: (input: {
3315
3436
  readonly source: "grant" | "installation" | "policy" | null;
3316
3437
  readonly decidedAt: string;
3317
3438
  } | null;
3439
+ readonly resolution: {
3440
+ readonly outcome: "approved" | "cancelled" | "denied";
3441
+ readonly actor: {
3442
+ readonly kind: "apiKey" | "extension" | "externalAgent" | "samvaAgent" | "system" | "user";
3443
+ readonly id: string;
3444
+ readonly displayName?: string | null;
3445
+ readonly source: "extension" | "externalAgent" | "externalApi" | "humanUi" | "system";
3446
+ };
3447
+ readonly resolvedAt: string;
3448
+ readonly reason: string | null;
3449
+ } | null;
3318
3450
  readonly createdAt: string;
3319
3451
  readonly updatedAt: string;
3320
3452
  readonly type: "assignThread" | "call" | "changeThreadState" | "createNote" | "extensionRequest" | "updateDraft";
@@ -455,6 +455,11 @@ export declare const listDeliveries: (input: {
455
455
  readonly message: string | null;
456
456
  readonly retryable: boolean | null;
457
457
  } | null;
458
+ readonly estimatedProviderCost: {
459
+ readonly amount: string;
460
+ readonly currency: string;
461
+ readonly billingMode: "pass_through";
462
+ } | null;
458
463
  readonly createdAt: string;
459
464
  readonly updatedAt: string;
460
465
  }[];
@@ -5,7 +5,7 @@ export declare const create: (input: {
5
5
  readonly billingAccountId: string;
6
6
  readonly name: string;
7
7
  readonly slug: string;
8
- readonly countryCode: string;
8
+ readonly defaultRegion: string | null;
9
9
  readonly timezone: string;
10
10
  readonly plan: string;
11
11
  readonly isActive: boolean;
@@ -30,7 +30,7 @@ export declare const get: (_?: never) => import("effect/Effect").Effect<{
30
30
  readonly billingAccountId: string;
31
31
  readonly name: string;
32
32
  readonly slug: string;
33
- readonly countryCode: string;
33
+ readonly defaultRegion: string | null;
34
34
  readonly timezone: string;
35
35
  readonly plan: string;
36
36
  readonly isActive: boolean;
@@ -88,7 +88,7 @@ export declare const getTrustTier: (_?: never) => import("effect/Effect").Effect
88
88
  export declare const update: (input?: {
89
89
  readonly name?: string | null | undefined;
90
90
  readonly slug?: string | null | undefined;
91
- readonly countryCode?: string | null | undefined;
91
+ readonly defaultRegion?: string | null | undefined;
92
92
  readonly timezone?: string | null | undefined;
93
93
  readonly isActive?: boolean | null | undefined;
94
94
  readonly metadata?: {
@@ -125,7 +125,7 @@ export declare const update: (input?: {
125
125
  readonly billingAccountId: string;
126
126
  readonly name: string;
127
127
  readonly slug: string;
128
- readonly countryCode: string;
128
+ readonly defaultRegion: string | null;
129
129
  readonly timezone: string;
130
130
  readonly plan: string;
131
131
  readonly isActive: boolean;
@@ -60,9 +60,8 @@ export declare const listMembers: ((input: {
60
60
  readonly cursor?: string | null | undefined;
61
61
  }) => import("effect/Effect").Effect<{
62
62
  readonly items: readonly {
63
- readonly id: string;
64
- readonly email: string;
65
- readonly contactId: string | null;
63
+ readonly id: string & import("effect/Brand").Brand<"UnsubscribeGroupMemberId">;
64
+ readonly contactId: string & import("effect/Brand").Brand<"ContactId">;
66
65
  readonly source: "api" | "complaint" | "link" | "manual";
67
66
  readonly unsubscribedAt: string;
68
67
  readonly createdAt: string;
@@ -75,9 +74,8 @@ export declare const listMembers: ((input: {
75
74
  readonly cursor?: string | null | undefined;
76
75
  }) => import("effect/Stream").Stream<{
77
76
  readonly items: readonly {
78
- readonly id: string;
79
- readonly email: string;
80
- readonly contactId: string | null;
77
+ readonly id: string & import("effect/Brand").Brand<"UnsubscribeGroupMemberId">;
78
+ readonly contactId: string & import("effect/Brand").Brand<"ContactId">;
81
79
  readonly source: "api" | "complaint" | "link" | "manual";
82
80
  readonly unsubscribedAt: string;
83
81
  readonly createdAt: string;
@@ -89,33 +87,46 @@ export declare const listMembers: ((input: {
89
87
  readonly limit?: string | null | undefined;
90
88
  readonly cursor?: string | null | undefined;
91
89
  }) => import("effect/Stream").Stream<{
92
- readonly id: string;
93
- readonly email: string;
94
- readonly contactId: string | null;
90
+ readonly id: string & import("effect/Brand").Brand<"UnsubscribeGroupMemberId">;
91
+ readonly contactId: string & import("effect/Brand").Brand<"ContactId">;
95
92
  readonly source: "api" | "complaint" | "link" | "manual";
96
93
  readonly unsubscribedAt: string;
97
94
  readonly createdAt: string;
98
95
  }, import("./errors").ForbiddenError | import("./errors").GatewayTimeoutError | import("effect/http/HttpClientError").HttpClientError | import("./errors").InternalError | import("./errors").ResourceNotFoundError | import("effect/Schema").SchemaError | import("./errors").UnauthorizedError | import("./errors").ValidationError, import("./client").Service>;
99
96
  };
100
- export declare const addEmails: (input: {
97
+ export declare const addMembers: (input: {
101
98
  readonly id: string;
102
- readonly emails: readonly string[];
99
+ readonly members: readonly ({
100
+ readonly contactId: string;
101
+ } | {
102
+ readonly email: string;
103
+ } | {
104
+ readonly phone: string;
105
+ })[];
103
106
  readonly source?: "api" | "complaint" | "link" | "manual" | null | undefined;
104
107
  }) => import("effect/Effect").Effect<{
105
108
  readonly added: number;
106
109
  readonly skipped: number;
107
- }, import("./errors").ForbiddenError | import("./errors").GatewayTimeoutError | import("effect/http/HttpClientError").HttpClientError | import("./errors").InternalError | import("./errors").ResourceNotFoundError | import("effect/Schema").SchemaError | import("./errors").UnauthorizedError | import("./errors").ValidationError, import("./client").Service>;
108
- export declare const removeEmails: (input: {
110
+ }, import("./errors").BillingProviderError | import("./errors").ForbiddenError | import("./errors").GatewayTimeoutError | import("effect/http/HttpClientError").HttpClientError | import("./errors").InternalError | import("./errors").PaymentRequiredError | import("./errors").ResourceNotFoundError | import("effect/Schema").SchemaError | import("./errors").UnauthorizedError | import("./errors").ValidationError, import("./client").Service>;
111
+ export declare const removeMembers: (input: {
109
112
  readonly id: string;
110
- readonly emails: readonly string[];
113
+ readonly members: readonly ({
114
+ readonly contactId: string;
115
+ } | {
116
+ readonly email: string;
117
+ } | {
118
+ readonly phone: string;
119
+ })[];
111
120
  }) => import("effect/Effect").Effect<{
112
121
  readonly removed: number;
113
122
  }, import("./errors").ForbiddenError | import("./errors").GatewayTimeoutError | import("effect/http/HttpClientError").HttpClientError | import("./errors").InternalError | import("./errors").ResourceNotFoundError | import("effect/Schema").SchemaError | import("./errors").UnauthorizedError | import("./errors").ValidationError, import("./client").Service>;
114
- export declare const checkSubscription: (input: {
115
- readonly email: string;
123
+ export declare const checkSubscription: (input?: {
124
+ readonly contactId?: string | null | undefined;
125
+ readonly email?: string | null | undefined;
126
+ readonly phone?: string | null | undefined;
116
127
  readonly groupIds?: string | null | undefined;
117
- }) => import("effect/Effect").Effect<{
118
- readonly email: string;
128
+ } | undefined) => import("effect/Effect").Effect<{
129
+ readonly contactId: (string & import("effect/Brand").Brand<"ContactId">) | null;
119
130
  readonly unsubscribedGroups: readonly {
120
131
  readonly groupId: string;
121
132
  readonly groupName: string;
@@ -3,13 +3,13 @@ import { forGroup } from "./internal/operation.js";
3
3
  import { UnsubscribeGroupsGroup } from "./generated/unsubscribe-groups.js";
4
4
  //#region src/effect/unsubscribe-groups.ts
5
5
  var unsubscribe_groups_exports = /* @__PURE__ */ __exportAll({
6
- addEmails: () => addEmails,
6
+ addMembers: () => addMembers,
7
7
  checkSubscription: () => checkSubscription,
8
8
  create: () => create,
9
9
  list: () => list,
10
10
  listMembers: () => listMembers,
11
11
  remove: () => remove,
12
- removeEmails: () => removeEmails,
12
+ removeMembers: () => removeMembers,
13
13
  setDefault: () => setDefault,
14
14
  update: () => update
15
15
  });
@@ -20,10 +20,10 @@ const update = /* @__PURE__ */ make("unsubscribeUpdate");
20
20
  const remove = /* @__PURE__ */ make("unsubscribeRemove");
21
21
  const setDefault = /* @__PURE__ */ make("unsubscribeSetDefault");
22
22
  const listMembers = /* @__PURE__ */ make("unsubscribeListMembers");
23
- const addEmails = /* @__PURE__ */ make("unsubscribeAddEmails");
24
- const removeEmails = /* @__PURE__ */ make("unsubscribeRemoveEmails");
23
+ const addMembers = /* @__PURE__ */ make("unsubscribeAddMembers");
24
+ const removeMembers = /* @__PURE__ */ make("unsubscribeRemoveMembers");
25
25
  const checkSubscription = /* @__PURE__ */ make("unsubscribeCheckSubscription");
26
26
  //#endregion
27
- export { addEmails, checkSubscription, create, list, listMembers, remove, removeEmails, setDefault, unsubscribe_groups_exports, update };
27
+ export { addMembers, checkSubscription, create, list, listMembers, remove, removeMembers, setDefault, unsubscribe_groups_exports, update };
28
28
 
29
29
  //# sourceMappingURL=unsubscribe-groups.js.map
@@ -9,7 +9,7 @@ export declare const list: ((input?: {
9
9
  readonly id: string & import("effect/Brand").Brand<"WebhookEndpointId">;
10
10
  readonly name: string;
11
11
  readonly url: string;
12
- readonly eventTypes: readonly ("contact.created" | "contact.deleted" | "contact.resubscribed" | "contact.subscribed" | "contact.unsubscribed" | "contact.updated" | "conversation.archived" | "conversation.created" | "conversation.updated" | "domain.updated" | "domain.warming.updated" | "journey.webhook" | "mailbox.action.pending_approval" | "mailbox.message.discarded" | "mailbox.message.quarantined" | "mailbox.message.received" | "mailbox.message.released" | "mailbox.message.sent" | "message.bounced" | "message.clicked" | "message.complained" | "message.delivered" | "message.failed" | "message.opened" | "message.read" | "message.received" | "message.sent" | "webhook.created" | "webhook.deleted" | "webhook.test" | "webhook.updated")[];
12
+ readonly eventTypes: readonly ("contact.consent_changed" | "contact.created" | "contact.deleted" | "contact.resubscribed" | "contact.subscribed" | "contact.unsubscribed" | "contact.updated" | "conversation.archived" | "conversation.created" | "conversation.updated" | "domain.updated" | "domain.warming.updated" | "journey.webhook" | "mailbox.action.pending_approval" | "mailbox.action.resolved" | "mailbox.message.discarded" | "mailbox.message.quarantined" | "mailbox.message.received" | "mailbox.message.released" | "mailbox.message.sent" | "message.bounced" | "message.clicked" | "message.complained" | "message.delivered" | "message.failed" | "message.opened" | "message.read" | "message.received" | "message.sent" | "webhook.created" | "webhook.deleted" | "webhook.test" | "webhook.updated")[];
13
13
  readonly channels: readonly "email"[] | null;
14
14
  readonly mailboxIds: readonly (string & import("effect/Brand").Brand<"MailboxId">)[] | null;
15
15
  readonly namespaceId: (string & import("effect/Brand").Brand<"NamespaceId">) | null;
@@ -39,7 +39,7 @@ export declare const list: ((input?: {
39
39
  readonly id: string & import("effect/Brand").Brand<"WebhookEndpointId">;
40
40
  readonly name: string;
41
41
  readonly url: string;
42
- readonly eventTypes: readonly ("contact.created" | "contact.deleted" | "contact.resubscribed" | "contact.subscribed" | "contact.unsubscribed" | "contact.updated" | "conversation.archived" | "conversation.created" | "conversation.updated" | "domain.updated" | "domain.warming.updated" | "journey.webhook" | "mailbox.action.pending_approval" | "mailbox.message.discarded" | "mailbox.message.quarantined" | "mailbox.message.received" | "mailbox.message.released" | "mailbox.message.sent" | "message.bounced" | "message.clicked" | "message.complained" | "message.delivered" | "message.failed" | "message.opened" | "message.read" | "message.received" | "message.sent" | "webhook.created" | "webhook.deleted" | "webhook.test" | "webhook.updated")[];
42
+ readonly eventTypes: readonly ("contact.consent_changed" | "contact.created" | "contact.deleted" | "contact.resubscribed" | "contact.subscribed" | "contact.unsubscribed" | "contact.updated" | "conversation.archived" | "conversation.created" | "conversation.updated" | "domain.updated" | "domain.warming.updated" | "journey.webhook" | "mailbox.action.pending_approval" | "mailbox.action.resolved" | "mailbox.message.discarded" | "mailbox.message.quarantined" | "mailbox.message.received" | "mailbox.message.released" | "mailbox.message.sent" | "message.bounced" | "message.clicked" | "message.complained" | "message.delivered" | "message.failed" | "message.opened" | "message.read" | "message.received" | "message.sent" | "webhook.created" | "webhook.deleted" | "webhook.test" | "webhook.updated")[];
43
43
  readonly channels: readonly "email"[] | null;
44
44
  readonly mailboxIds: readonly (string & import("effect/Brand").Brand<"MailboxId">)[] | null;
45
45
  readonly namespaceId: (string & import("effect/Brand").Brand<"NamespaceId">) | null;
@@ -68,7 +68,7 @@ export declare const list: ((input?: {
68
68
  readonly id: string & import("effect/Brand").Brand<"WebhookEndpointId">;
69
69
  readonly name: string;
70
70
  readonly url: string;
71
- readonly eventTypes: readonly ("contact.created" | "contact.deleted" | "contact.resubscribed" | "contact.subscribed" | "contact.unsubscribed" | "contact.updated" | "conversation.archived" | "conversation.created" | "conversation.updated" | "domain.updated" | "domain.warming.updated" | "journey.webhook" | "mailbox.action.pending_approval" | "mailbox.message.discarded" | "mailbox.message.quarantined" | "mailbox.message.received" | "mailbox.message.released" | "mailbox.message.sent" | "message.bounced" | "message.clicked" | "message.complained" | "message.delivered" | "message.failed" | "message.opened" | "message.read" | "message.received" | "message.sent" | "webhook.created" | "webhook.deleted" | "webhook.test" | "webhook.updated")[];
71
+ readonly eventTypes: readonly ("contact.consent_changed" | "contact.created" | "contact.deleted" | "contact.resubscribed" | "contact.subscribed" | "contact.unsubscribed" | "contact.updated" | "conversation.archived" | "conversation.created" | "conversation.updated" | "domain.updated" | "domain.warming.updated" | "journey.webhook" | "mailbox.action.pending_approval" | "mailbox.action.resolved" | "mailbox.message.discarded" | "mailbox.message.quarantined" | "mailbox.message.received" | "mailbox.message.released" | "mailbox.message.sent" | "message.bounced" | "message.clicked" | "message.complained" | "message.delivered" | "message.failed" | "message.opened" | "message.read" | "message.received" | "message.sent" | "webhook.created" | "webhook.deleted" | "webhook.test" | "webhook.updated")[];
72
72
  readonly channels: readonly "email"[] | null;
73
73
  readonly mailboxIds: readonly (string & import("effect/Brand").Brand<"MailboxId">)[] | null;
74
74
  readonly namespaceId: (string & import("effect/Brand").Brand<"NamespaceId">) | null;
@@ -90,7 +90,7 @@ export declare const list: ((input?: {
90
90
  export declare const create: (input: {
91
91
  readonly name: string;
92
92
  readonly url: string;
93
- readonly eventTypes: readonly ("contact.created" | "contact.deleted" | "contact.resubscribed" | "contact.subscribed" | "contact.unsubscribed" | "contact.updated" | "conversation.archived" | "conversation.created" | "conversation.updated" | "domain.updated" | "domain.warming.updated" | "journey.webhook" | "mailbox.action.pending_approval" | "mailbox.message.discarded" | "mailbox.message.quarantined" | "mailbox.message.received" | "mailbox.message.released" | "mailbox.message.sent" | "message.bounced" | "message.clicked" | "message.complained" | "message.delivered" | "message.failed" | "message.opened" | "message.read" | "message.received" | "message.sent" | "webhook.created" | "webhook.deleted" | "webhook.test" | "webhook.updated")[];
93
+ readonly eventTypes: readonly ("contact.consent_changed" | "contact.created" | "contact.deleted" | "contact.resubscribed" | "contact.subscribed" | "contact.unsubscribed" | "contact.updated" | "conversation.archived" | "conversation.created" | "conversation.updated" | "domain.updated" | "domain.warming.updated" | "journey.webhook" | "mailbox.action.pending_approval" | "mailbox.action.resolved" | "mailbox.message.discarded" | "mailbox.message.quarantined" | "mailbox.message.received" | "mailbox.message.released" | "mailbox.message.sent" | "message.bounced" | "message.clicked" | "message.complained" | "message.delivered" | "message.failed" | "message.opened" | "message.read" | "message.received" | "message.sent" | "webhook.created" | "webhook.deleted" | "webhook.test" | "webhook.updated")[];
94
94
  readonly channels?: readonly "email"[] | null | undefined;
95
95
  readonly mailboxIds?: readonly string[] | null | undefined;
96
96
  readonly namespaceId?: string | null | undefined;
@@ -103,7 +103,7 @@ export declare const create: (input: {
103
103
  readonly id: string & import("effect/Brand").Brand<"WebhookEndpointId">;
104
104
  readonly name: string;
105
105
  readonly url: string;
106
- readonly eventTypes: readonly ("contact.created" | "contact.deleted" | "contact.resubscribed" | "contact.subscribed" | "contact.unsubscribed" | "contact.updated" | "conversation.archived" | "conversation.created" | "conversation.updated" | "domain.updated" | "domain.warming.updated" | "journey.webhook" | "mailbox.action.pending_approval" | "mailbox.message.discarded" | "mailbox.message.quarantined" | "mailbox.message.received" | "mailbox.message.released" | "mailbox.message.sent" | "message.bounced" | "message.clicked" | "message.complained" | "message.delivered" | "message.failed" | "message.opened" | "message.read" | "message.received" | "message.sent" | "webhook.created" | "webhook.deleted" | "webhook.test" | "webhook.updated")[];
106
+ readonly eventTypes: readonly ("contact.consent_changed" | "contact.created" | "contact.deleted" | "contact.resubscribed" | "contact.subscribed" | "contact.unsubscribed" | "contact.updated" | "conversation.archived" | "conversation.created" | "conversation.updated" | "domain.updated" | "domain.warming.updated" | "journey.webhook" | "mailbox.action.pending_approval" | "mailbox.action.resolved" | "mailbox.message.discarded" | "mailbox.message.quarantined" | "mailbox.message.received" | "mailbox.message.released" | "mailbox.message.sent" | "message.bounced" | "message.clicked" | "message.complained" | "message.delivered" | "message.failed" | "message.opened" | "message.read" | "message.received" | "message.sent" | "webhook.created" | "webhook.deleted" | "webhook.test" | "webhook.updated")[];
107
107
  readonly channels: readonly "email"[] | null;
108
108
  readonly mailboxIds: readonly (string & import("effect/Brand").Brand<"MailboxId">)[] | null;
109
109
  readonly namespaceId: (string & import("effect/Brand").Brand<"NamespaceId">) | null;
@@ -122,7 +122,7 @@ export declare const get: (input: {
122
122
  readonly id: string & import("effect/Brand").Brand<"WebhookEndpointId">;
123
123
  readonly name: string;
124
124
  readonly url: string;
125
- readonly eventTypes: readonly ("contact.created" | "contact.deleted" | "contact.resubscribed" | "contact.subscribed" | "contact.unsubscribed" | "contact.updated" | "conversation.archived" | "conversation.created" | "conversation.updated" | "domain.updated" | "domain.warming.updated" | "journey.webhook" | "mailbox.action.pending_approval" | "mailbox.message.discarded" | "mailbox.message.quarantined" | "mailbox.message.received" | "mailbox.message.released" | "mailbox.message.sent" | "message.bounced" | "message.clicked" | "message.complained" | "message.delivered" | "message.failed" | "message.opened" | "message.read" | "message.received" | "message.sent" | "webhook.created" | "webhook.deleted" | "webhook.test" | "webhook.updated")[];
125
+ readonly eventTypes: readonly ("contact.consent_changed" | "contact.created" | "contact.deleted" | "contact.resubscribed" | "contact.subscribed" | "contact.unsubscribed" | "contact.updated" | "conversation.archived" | "conversation.created" | "conversation.updated" | "domain.updated" | "domain.warming.updated" | "journey.webhook" | "mailbox.action.pending_approval" | "mailbox.action.resolved" | "mailbox.message.discarded" | "mailbox.message.quarantined" | "mailbox.message.received" | "mailbox.message.released" | "mailbox.message.sent" | "message.bounced" | "message.clicked" | "message.complained" | "message.delivered" | "message.failed" | "message.opened" | "message.read" | "message.received" | "message.sent" | "webhook.created" | "webhook.deleted" | "webhook.test" | "webhook.updated")[];
126
126
  readonly channels: readonly "email"[] | null;
127
127
  readonly mailboxIds: readonly (string & import("effect/Brand").Brand<"MailboxId">)[] | null;
128
128
  readonly namespaceId: (string & import("effect/Brand").Brand<"NamespaceId">) | null;
@@ -142,7 +142,7 @@ export declare const update: (input: {
142
142
  readonly id: string;
143
143
  readonly name?: string | null | undefined;
144
144
  readonly url?: string | null | undefined;
145
- readonly eventTypes?: readonly ("contact.created" | "contact.deleted" | "contact.resubscribed" | "contact.subscribed" | "contact.unsubscribed" | "contact.updated" | "conversation.archived" | "conversation.created" | "conversation.updated" | "domain.updated" | "domain.warming.updated" | "journey.webhook" | "mailbox.action.pending_approval" | "mailbox.message.discarded" | "mailbox.message.quarantined" | "mailbox.message.received" | "mailbox.message.released" | "mailbox.message.sent" | "message.bounced" | "message.clicked" | "message.complained" | "message.delivered" | "message.failed" | "message.opened" | "message.read" | "message.received" | "message.sent" | "webhook.created" | "webhook.deleted" | "webhook.test" | "webhook.updated")[] | null | undefined;
145
+ readonly eventTypes?: readonly ("contact.consent_changed" | "contact.created" | "contact.deleted" | "contact.resubscribed" | "contact.subscribed" | "contact.unsubscribed" | "contact.updated" | "conversation.archived" | "conversation.created" | "conversation.updated" | "domain.updated" | "domain.warming.updated" | "journey.webhook" | "mailbox.action.pending_approval" | "mailbox.action.resolved" | "mailbox.message.discarded" | "mailbox.message.quarantined" | "mailbox.message.received" | "mailbox.message.released" | "mailbox.message.sent" | "message.bounced" | "message.clicked" | "message.complained" | "message.delivered" | "message.failed" | "message.opened" | "message.read" | "message.received" | "message.sent" | "webhook.created" | "webhook.deleted" | "webhook.test" | "webhook.updated")[] | null | undefined;
146
146
  readonly channels?: readonly "email"[] | null | undefined;
147
147
  readonly mailboxIds?: readonly string[] | null | undefined;
148
148
  readonly namespaceId?: string | null | undefined;
@@ -154,7 +154,7 @@ export declare const update: (input: {
154
154
  readonly id: string & import("effect/Brand").Brand<"WebhookEndpointId">;
155
155
  readonly name: string;
156
156
  readonly url: string;
157
- readonly eventTypes: readonly ("contact.created" | "contact.deleted" | "contact.resubscribed" | "contact.subscribed" | "contact.unsubscribed" | "contact.updated" | "conversation.archived" | "conversation.created" | "conversation.updated" | "domain.updated" | "domain.warming.updated" | "journey.webhook" | "mailbox.action.pending_approval" | "mailbox.message.discarded" | "mailbox.message.quarantined" | "mailbox.message.received" | "mailbox.message.released" | "mailbox.message.sent" | "message.bounced" | "message.clicked" | "message.complained" | "message.delivered" | "message.failed" | "message.opened" | "message.read" | "message.received" | "message.sent" | "webhook.created" | "webhook.deleted" | "webhook.test" | "webhook.updated")[];
157
+ readonly eventTypes: readonly ("contact.consent_changed" | "contact.created" | "contact.deleted" | "contact.resubscribed" | "contact.subscribed" | "contact.unsubscribed" | "contact.updated" | "conversation.archived" | "conversation.created" | "conversation.updated" | "domain.updated" | "domain.warming.updated" | "journey.webhook" | "mailbox.action.pending_approval" | "mailbox.action.resolved" | "mailbox.message.discarded" | "mailbox.message.quarantined" | "mailbox.message.received" | "mailbox.message.released" | "mailbox.message.sent" | "message.bounced" | "message.clicked" | "message.complained" | "message.delivered" | "message.failed" | "message.opened" | "message.read" | "message.received" | "message.sent" | "webhook.created" | "webhook.deleted" | "webhook.test" | "webhook.updated")[];
158
158
  readonly channels: readonly "email"[] | null;
159
159
  readonly mailboxIds: readonly (string & import("effect/Brand").Brand<"MailboxId">)[] | null;
160
160
  readonly namespaceId: (string & import("effect/Brand").Brand<"NamespaceId">) | null;
@@ -5,7 +5,8 @@
5
5
  * {@link MailboxEventStream} is an async iterable. The loop body handling an event is the
6
6
  * acknowledgement: asking for the next event marks the previous one handled, and the stream
7
7
  * resumes from the last handled event whenever it reconnects. Transient closes reconnect by
8
- * themselves; a close the caller has to act on ends the loop with a {@link MailboxEventStreamError}.
8
+ * themselves, and a normal close (1000) from the host ends the loop after the events already
9
+ * received; a close the caller has to act on ends the loop with a {@link MailboxEventStreamError}.
9
10
  *
10
11
  * This module has no runtime dependencies so the Promise and Effect clients share it.
11
12
  */
@@ -29,7 +30,7 @@ export declare const MailboxEventStreamCloseCode: {
29
30
  readonly accessUnavailable: 4503;
30
31
  };
31
32
  /** The event types the stream carries: the `mailbox.*` webhook events. */
32
- export type MailboxEventType = "mailbox.message.received" | "mailbox.message.sent" | "mailbox.action.pending_approval" | "mailbox.message.quarantined" | "mailbox.message.released" | "mailbox.message.discarded";
33
+ export type MailboxEventType = "mailbox.message.received" | "mailbox.message.sent" | "mailbox.action.pending_approval" | "mailbox.action.resolved" | "mailbox.message.quarantined" | "mailbox.message.released" | "mailbox.message.discarded";
33
34
  /** One event, as a webhook delivery of it would carry it, plus its stream position. */
34
35
  export interface MailboxEvent {
35
36
  /** The stream position of this event. Persist it after handling to resume from here. */
@@ -44,12 +45,19 @@ export interface MailboxEvent {
44
45
  /**
45
46
  * Why a stream ended, as the `_tag` of its {@link MailboxEventStreamError}. The first nine are the
46
47
  * API error tags the events host refuses with, or that a close code stands for. The rest are the
47
- * client's own: `StreamDisconnectedError` is a close or an unreachable host that was not retried
48
- * because `reconnect` is `false`, `StreamClientError` is a request this client could not make,
48
+ * client's own: `StreamDisconnectedError` is a close, an idle timeout, or an unreachable host that
49
+ * was not retried because `reconnect` is `false`, `StreamClientError` is a request this client could not make,
49
50
  * `StreamProtocolError` is a frame from the host it could not read, and `StreamRefusedError` is a refusal whose tag and status this client
50
51
  * does not know (`serverTag` carries the tag the host sent).
51
52
  */
52
53
  export type MailboxEventStreamErrorTag = "UnauthorizedError" | "ForbiddenError" | "ResourceNotFoundError" | "CursorExpiredError" | "ValidationError" | "UpgradeRequiredError" | "RateLimitedError" | "ServiceUnavailableError" | "MethodNotAllowedError" | "StreamDisconnectedError" | "StreamClientError" | "StreamProtocolError" | "StreamRefusedError";
54
+ /**
55
+ * Why a {@link MailboxEventStreamError} ended a stream, when `_tag` alone does not say.
56
+ * `idleTimeout`: the client heard no frame, not even a pong, for
57
+ * {@link MAILBOX_EVENT_STREAM_IDLE_MILLIS}, so it closed the connection itself. No close code
58
+ * accompanies it; a `closeCode` of `1006` is a close the client observed without a status.
59
+ */
60
+ export type MailboxEventStreamErrorReason = "idleTimeout";
53
61
  /** Field-level validation messages, keyed by dotted path, as a `ValidationError` carries them. */
54
62
  export type MailboxEventStreamErrorFields = Readonly<Record<string, ReadonlyArray<string>>>;
55
63
  /**
@@ -76,6 +84,8 @@ export declare class MailboxEventStreamError<Tag extends MailboxEventStreamError
76
84
  readonly retryAfterSeconds: number | undefined;
77
85
  /** The tag the host sent, when it is not one this client maps. */
78
86
  readonly serverTag: string | undefined;
87
+ /** Set when the client ended the connection itself; see {@link MailboxEventStreamErrorReason}. */
88
+ readonly reason: MailboxEventStreamErrorReason | undefined;
79
89
  constructor(input: {
80
90
  readonly _tag: Tag;
81
91
  readonly message: string;
@@ -85,6 +95,7 @@ export declare class MailboxEventStreamError<Tag extends MailboxEventStreamError
85
95
  readonly fields?: MailboxEventStreamErrorFields | undefined;
86
96
  readonly retryAfterSeconds?: number | undefined;
87
97
  readonly serverTag?: string | undefined;
98
+ readonly reason?: MailboxEventStreamErrorReason | undefined;
88
99
  });
89
100
  }
90
101
  /** Every stream error as a union over `_tag`, so `Effect.catchTag` can narrow it. */
@@ -113,6 +124,17 @@ export interface MailboxEventStreamSocket {
113
124
  export type MailboxEventStreamWebSocket = new (url: string, options: {
114
125
  readonly headers: Readonly<Record<string, string>>;
115
126
  }) => MailboxEventStreamSocket;
127
+ /** A reconnect the stream is about to make. */
128
+ export interface MailboxEventStreamReconnect {
129
+ /** Why the connection ended: the error the stream would have ended with had it not retried. */
130
+ readonly error: MailboxEventStreamError;
131
+ /** The cursor the next connection resumes from; undefined when the stream started live and has none yet. */
132
+ readonly cursor: string | undefined;
133
+ /** Failed attempts in a row, starting at 1; a connection that went live resets it. */
134
+ readonly attempt: number;
135
+ /** How long the stream waits before connecting again. */
136
+ readonly delayMillis: number;
137
+ }
116
138
  export interface MailboxEventStreamOptions {
117
139
  /** Resume after this cursor: every retained event after it, then live. Omit to start live. */
118
140
  readonly cursor?: string | undefined;
@@ -124,6 +146,11 @@ export interface MailboxEventStreamOptions {
124
146
  readonly onLive?: (() => void) | undefined;
125
147
  /** Reconnect after transient closes. Defaults to `true`. */
126
148
  readonly reconnect?: boolean | undefined;
149
+ /**
150
+ * Called when a transient failure ends a connection and the stream is about to reconnect from
151
+ * its last handled cursor, before the backoff wait. Never called when `reconnect` is `false`.
152
+ */
153
+ readonly onReconnect?: ((reconnect: MailboxEventStreamReconnect) => void) | undefined;
127
154
  /**
128
155
  * The events origin, such as `wss://events.samva.dev`. Defaults to the API origin with its
129
156
  * `api` host label replaced by `events`.