sendblue 3.10.1 → 3.12.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 (263) hide show
  1. package/CHANGELOG.md +41 -0
  2. package/README.md +7 -7
  3. package/client.d.mts +46 -7
  4. package/client.d.mts.map +1 -1
  5. package/client.d.ts +46 -7
  6. package/client.d.ts.map +1 -1
  7. package/client.js +54 -6
  8. package/client.js.map +1 -1
  9. package/client.mjs +54 -6
  10. package/client.mjs.map +1 -1
  11. package/core/streaming.d.mts +33 -0
  12. package/core/streaming.d.mts.map +1 -0
  13. package/core/streaming.d.ts +33 -0
  14. package/core/streaming.d.ts.map +1 -0
  15. package/core/streaming.js +263 -0
  16. package/core/streaming.js.map +1 -0
  17. package/core/streaming.mjs +258 -0
  18. package/core/streaming.mjs.map +1 -0
  19. package/internal/decoders/line.d.mts +17 -0
  20. package/internal/decoders/line.d.mts.map +1 -0
  21. package/internal/decoders/line.d.ts +17 -0
  22. package/internal/decoders/line.d.ts.map +1 -0
  23. package/internal/decoders/line.js +113 -0
  24. package/internal/decoders/line.js.map +1 -0
  25. package/internal/decoders/line.mjs +108 -0
  26. package/internal/decoders/line.mjs.map +1 -0
  27. package/internal/parse.d.mts.map +1 -1
  28. package/internal/parse.d.ts.map +1 -1
  29. package/internal/parse.js +10 -0
  30. package/internal/parse.js.map +1 -1
  31. package/internal/parse.mjs +10 -0
  32. package/internal/parse.mjs.map +1 -1
  33. package/internal/request-options.d.mts +2 -0
  34. package/internal/request-options.d.mts.map +1 -1
  35. package/internal/request-options.d.ts +2 -0
  36. package/internal/request-options.d.ts.map +1 -1
  37. package/internal/request-options.js.map +1 -1
  38. package/internal/request-options.mjs.map +1 -1
  39. package/internal/tslib.js +17 -17
  40. package/package.json +11 -1
  41. package/resources/auth/auth.d.mts +10 -0
  42. package/resources/auth/auth.d.mts.map +1 -0
  43. package/resources/auth/auth.d.ts +10 -0
  44. package/resources/auth/auth.d.ts.map +1 -0
  45. package/resources/auth/auth.js +17 -0
  46. package/resources/auth/auth.js.map +1 -0
  47. package/resources/auth/auth.mjs +12 -0
  48. package/resources/auth/auth.mjs.map +1 -0
  49. package/resources/auth/index.d.mts +3 -0
  50. package/resources/auth/index.d.mts.map +1 -0
  51. package/resources/auth/index.d.ts +3 -0
  52. package/resources/auth/index.d.ts.map +1 -0
  53. package/resources/auth/index.js +9 -0
  54. package/resources/auth/index.js.map +1 -0
  55. package/resources/auth/index.mjs +4 -0
  56. package/resources/auth/index.mjs.map +1 -0
  57. package/resources/auth/tokens.d.mts +77 -0
  58. package/resources/auth/tokens.d.mts.map +1 -0
  59. package/resources/auth/tokens.d.ts +77 -0
  60. package/resources/auth/tokens.d.ts.map +1 -0
  61. package/resources/auth/tokens.js +51 -0
  62. package/resources/auth/tokens.js.map +1 -0
  63. package/resources/auth/tokens.mjs +47 -0
  64. package/resources/auth/tokens.mjs.map +1 -0
  65. package/resources/auth.d.mts +2 -0
  66. package/resources/auth.d.mts.map +1 -0
  67. package/resources/auth.d.ts +2 -0
  68. package/resources/auth.d.ts.map +1 -0
  69. package/resources/auth.js +6 -0
  70. package/resources/auth.js.map +1 -0
  71. package/resources/auth.mjs +3 -0
  72. package/resources/auth.mjs.map +1 -0
  73. package/resources/contacts/contacts.d.mts +8 -0
  74. package/resources/contacts/contacts.d.mts.map +1 -1
  75. package/resources/contacts/contacts.d.ts +8 -0
  76. package/resources/contacts/contacts.d.ts.map +1 -1
  77. package/resources/contacts/contacts.js.map +1 -1
  78. package/resources/contacts/contacts.mjs.map +1 -1
  79. package/resources/events.d.mts +45 -0
  80. package/resources/events.d.mts.map +1 -0
  81. package/resources/events.d.ts +45 -0
  82. package/resources/events.d.ts.map +1 -0
  83. package/resources/events.js +37 -0
  84. package/resources/events.js.map +1 -0
  85. package/resources/events.mjs +33 -0
  86. package/resources/events.mjs.map +1 -0
  87. package/resources/groups.d.mts +25 -0
  88. package/resources/groups.d.mts.map +1 -1
  89. package/resources/groups.d.ts +25 -0
  90. package/resources/groups.d.ts.map +1 -1
  91. package/resources/index.d.mts +8 -2
  92. package/resources/index.d.mts.map +1 -1
  93. package/resources/index.d.ts +8 -2
  94. package/resources/index.d.ts.map +1 -1
  95. package/resources/index.js +13 -1
  96. package/resources/index.js.map +1 -1
  97. package/resources/index.mjs +6 -0
  98. package/resources/index.mjs.map +1 -1
  99. package/resources/lines/call-forwarding.d.mts +3 -0
  100. package/resources/lines/call-forwarding.d.mts.map +1 -1
  101. package/resources/lines/call-forwarding.d.ts +3 -0
  102. package/resources/lines/call-forwarding.d.ts.map +1 -1
  103. package/resources/lines/call-forwarding.js +3 -0
  104. package/resources/lines/call-forwarding.js.map +1 -1
  105. package/resources/lines/call-forwarding.mjs +3 -0
  106. package/resources/lines/call-forwarding.mjs.map +1 -1
  107. package/resources/lines/index.d.mts +1 -1
  108. package/resources/lines/index.d.mts.map +1 -1
  109. package/resources/lines/index.d.ts +1 -1
  110. package/resources/lines/index.d.ts.map +1 -1
  111. package/resources/lines/index.js.map +1 -1
  112. package/resources/lines/index.mjs.map +1 -1
  113. package/resources/lines/lines.d.mts +30 -0
  114. package/resources/lines/lines.d.mts.map +1 -1
  115. package/resources/lines/lines.d.ts +30 -0
  116. package/resources/lines/lines.d.ts.map +1 -1
  117. package/resources/lines/lines.js +15 -0
  118. package/resources/lines/lines.js.map +1 -1
  119. package/resources/lines/lines.mjs +15 -0
  120. package/resources/lines/lines.mjs.map +1 -1
  121. package/resources/location.d.mts +156 -0
  122. package/resources/location.d.mts.map +1 -0
  123. package/resources/location.d.ts +156 -0
  124. package/resources/location.d.ts.map +1 -0
  125. package/resources/location.js +57 -0
  126. package/resources/location.js.map +1 -0
  127. package/resources/location.mjs +53 -0
  128. package/resources/location.mjs.map +1 -0
  129. package/resources/messages.d.mts +507 -9
  130. package/resources/messages.d.mts.map +1 -1
  131. package/resources/messages.d.ts +507 -9
  132. package/resources/messages.d.ts.map +1 -1
  133. package/resources/messages.js +16 -2
  134. package/resources/messages.js.map +1 -1
  135. package/resources/messages.mjs +16 -2
  136. package/resources/messages.mjs.map +1 -1
  137. package/resources/request-location.d.mts +54 -0
  138. package/resources/request-location.d.mts.map +1 -0
  139. package/resources/request-location.d.ts +54 -0
  140. package/resources/request-location.d.ts.map +1 -0
  141. package/resources/request-location.js +30 -0
  142. package/resources/request-location.js.map +1 -0
  143. package/resources/request-location.mjs +26 -0
  144. package/resources/request-location.mjs.map +1 -0
  145. package/resources/send-carousel.d.mts +67 -0
  146. package/resources/send-carousel.d.mts.map +1 -1
  147. package/resources/send-carousel.d.ts +67 -0
  148. package/resources/send-carousel.d.ts.map +1 -1
  149. package/resources/v2/groups.d.mts +82 -0
  150. package/resources/v2/groups.d.mts.map +1 -0
  151. package/resources/v2/groups.d.ts +82 -0
  152. package/resources/v2/groups.d.ts.map +1 -0
  153. package/resources/v2/groups.js +27 -0
  154. package/resources/v2/groups.js.map +1 -0
  155. package/resources/v2/groups.mjs +23 -0
  156. package/resources/v2/groups.mjs.map +1 -0
  157. package/resources/v2/index.d.mts +1 -0
  158. package/resources/v2/index.d.mts.map +1 -1
  159. package/resources/v2/index.d.ts +1 -0
  160. package/resources/v2/index.d.ts.map +1 -1
  161. package/resources/v2/index.js +3 -1
  162. package/resources/v2/index.js.map +1 -1
  163. package/resources/v2/index.mjs +1 -0
  164. package/resources/v2/index.mjs.map +1 -1
  165. package/resources/v2/v2.d.mts +4 -0
  166. package/resources/v2/v2.d.mts.map +1 -1
  167. package/resources/v2/v2.d.ts +4 -0
  168. package/resources/v2/v2.d.ts.map +1 -1
  169. package/resources/v2/v2.js +4 -0
  170. package/resources/v2/v2.js.map +1 -1
  171. package/resources/v2/v2.mjs +4 -0
  172. package/resources/v2/v2.mjs.map +1 -1
  173. package/resources/verified-contacts.d.mts +152 -0
  174. package/resources/verified-contacts.d.mts.map +1 -0
  175. package/resources/verified-contacts.d.ts +152 -0
  176. package/resources/verified-contacts.d.ts.map +1 -0
  177. package/resources/verified-contacts.js +56 -0
  178. package/resources/verified-contacts.js.map +1 -0
  179. package/resources/verified-contacts.mjs +52 -0
  180. package/resources/verified-contacts.mjs.map +1 -0
  181. package/resources/verify/index.d.mts +3 -0
  182. package/resources/verify/index.d.mts.map +1 -0
  183. package/resources/verify/index.d.ts +3 -0
  184. package/resources/verify/index.d.ts.map +1 -0
  185. package/resources/verify/index.js +9 -0
  186. package/resources/verify/index.js.map +1 -0
  187. package/resources/verify/index.mjs +4 -0
  188. package/resources/verify/index.mjs.map +1 -0
  189. package/resources/verify/verifications.d.mts +45 -0
  190. package/resources/verify/verifications.d.mts.map +1 -0
  191. package/resources/verify/verifications.d.ts +45 -0
  192. package/resources/verify/verifications.d.ts.map +1 -0
  193. package/resources/verify/verifications.js +19 -0
  194. package/resources/verify/verifications.js.map +1 -0
  195. package/resources/verify/verifications.mjs +15 -0
  196. package/resources/verify/verifications.mjs.map +1 -0
  197. package/resources/verify/verify.d.mts +10 -0
  198. package/resources/verify/verify.d.mts.map +1 -0
  199. package/resources/verify/verify.d.ts +10 -0
  200. package/resources/verify/verify.d.ts.map +1 -0
  201. package/resources/verify/verify.js +17 -0
  202. package/resources/verify/verify.js.map +1 -0
  203. package/resources/verify/verify.mjs +12 -0
  204. package/resources/verify/verify.mjs.map +1 -0
  205. package/resources/verify.d.mts +2 -0
  206. package/resources/verify.d.mts.map +1 -0
  207. package/resources/verify.d.ts +2 -0
  208. package/resources/verify.d.ts.map +1 -0
  209. package/resources/verify.js +6 -0
  210. package/resources/verify.js.map +1 -0
  211. package/resources/verify.mjs +3 -0
  212. package/resources/verify.mjs.map +1 -0
  213. package/resources/webhooks.d.mts +26 -10
  214. package/resources/webhooks.d.mts.map +1 -1
  215. package/resources/webhooks.d.ts +26 -10
  216. package/resources/webhooks.d.ts.map +1 -1
  217. package/resources/webhooks.js +13 -2
  218. package/resources/webhooks.js.map +1 -1
  219. package/resources/webhooks.mjs +13 -2
  220. package/resources/webhooks.mjs.map +1 -1
  221. package/src/client.ts +116 -15
  222. package/src/core/streaming.ts +319 -0
  223. package/src/internal/decoders/line.ts +135 -0
  224. package/src/internal/parse.ts +14 -0
  225. package/src/internal/request-options.ts +2 -0
  226. package/src/resources/auth/auth.ts +19 -0
  227. package/src/resources/auth/index.ts +4 -0
  228. package/src/resources/auth/tokens.ts +101 -0
  229. package/src/resources/auth.ts +3 -0
  230. package/src/resources/contacts/contacts.ts +10 -0
  231. package/src/resources/events.ts +75 -0
  232. package/src/resources/groups.ts +28 -0
  233. package/src/resources/index.ts +26 -1
  234. package/src/resources/lines/call-forwarding.ts +3 -0
  235. package/src/resources/lines/index.ts +1 -1
  236. package/src/resources/lines/lines.ts +44 -0
  237. package/src/resources/location.ts +237 -0
  238. package/src/resources/messages.ts +634 -9
  239. package/src/resources/request-location.ts +72 -0
  240. package/src/resources/send-carousel.ts +76 -0
  241. package/src/resources/v2/groups.ts +106 -0
  242. package/src/resources/v2/index.ts +1 -0
  243. package/src/resources/v2/v2.ts +6 -0
  244. package/src/resources/verified-contacts.ts +204 -0
  245. package/src/resources/verify/index.ts +9 -0
  246. package/src/resources/verify/verifications.ts +75 -0
  247. package/src/resources/verify/verify.ts +25 -0
  248. package/src/resources/verify.ts +3 -0
  249. package/src/resources/webhooks.ts +27 -10
  250. package/src/streaming.ts +2 -0
  251. package/src/version.ts +1 -1
  252. package/streaming.d.mts +3 -0
  253. package/streaming.d.mts.map +1 -0
  254. package/streaming.d.ts +3 -0
  255. package/streaming.d.ts.map +1 -0
  256. package/streaming.js +6 -0
  257. package/streaming.js.map +1 -0
  258. package/streaming.mjs +3 -0
  259. package/streaming.mjs.map +1 -0
  260. package/version.d.mts +1 -1
  261. package/version.d.ts +1 -1
  262. package/version.js +1 -1
  263. package/version.mjs +1 -1
@@ -0,0 +1,135 @@
1
+ import { concatBytes, decodeUTF8, encodeUTF8 } from '../utils/bytes';
2
+
3
+ export type Bytes = string | ArrayBuffer | Uint8Array | null | undefined;
4
+
5
+ /**
6
+ * A re-implementation of httpx's `LineDecoder` in Python that handles incrementally
7
+ * reading lines from text.
8
+ *
9
+ * https://github.com/encode/httpx/blob/920333ea98118e9cf617f246905d7b202510941c/httpx/_decoders.py#L258
10
+ */
11
+ export class LineDecoder {
12
+ // prettier-ignore
13
+ static NEWLINE_CHARS = new Set(['\n', '\r']);
14
+ static NEWLINE_REGEXP = /\r\n|[\n\r]/g;
15
+
16
+ #buffer: Uint8Array;
17
+ #carriageReturnIndex: number | null;
18
+
19
+ constructor() {
20
+ this.#buffer = new Uint8Array();
21
+ this.#carriageReturnIndex = null;
22
+ }
23
+
24
+ decode(chunk: Bytes): string[] {
25
+ if (chunk == null) {
26
+ return [];
27
+ }
28
+
29
+ const binaryChunk =
30
+ chunk instanceof ArrayBuffer ? new Uint8Array(chunk)
31
+ : typeof chunk === 'string' ? encodeUTF8(chunk)
32
+ : chunk;
33
+
34
+ this.#buffer = concatBytes([this.#buffer, binaryChunk]);
35
+
36
+ const lines: string[] = [];
37
+ let patternIndex;
38
+ while ((patternIndex = findNewlineIndex(this.#buffer, this.#carriageReturnIndex)) != null) {
39
+ if (patternIndex.carriage && this.#carriageReturnIndex == null) {
40
+ // skip until we either get a corresponding `\n`, a new `\r` or nothing
41
+ this.#carriageReturnIndex = patternIndex.index;
42
+ continue;
43
+ }
44
+
45
+ // we got double \r or \rtext\n
46
+ if (
47
+ this.#carriageReturnIndex != null &&
48
+ (patternIndex.index !== this.#carriageReturnIndex + 1 || patternIndex.carriage)
49
+ ) {
50
+ lines.push(decodeUTF8(this.#buffer.subarray(0, this.#carriageReturnIndex - 1)));
51
+ this.#buffer = this.#buffer.subarray(this.#carriageReturnIndex);
52
+ this.#carriageReturnIndex = null;
53
+ continue;
54
+ }
55
+
56
+ const endIndex =
57
+ this.#carriageReturnIndex !== null ? patternIndex.preceding - 1 : patternIndex.preceding;
58
+
59
+ const line = decodeUTF8(this.#buffer.subarray(0, endIndex));
60
+ lines.push(line);
61
+
62
+ this.#buffer = this.#buffer.subarray(patternIndex.index);
63
+ this.#carriageReturnIndex = null;
64
+ }
65
+
66
+ return lines;
67
+ }
68
+
69
+ flush(): string[] {
70
+ if (!this.#buffer.length) {
71
+ return [];
72
+ }
73
+ return this.decode('\n');
74
+ }
75
+ }
76
+
77
+ /**
78
+ * This function searches the buffer for the end patterns, (\r or \n)
79
+ * and returns an object with the index preceding the matched newline and the
80
+ * index after the newline char. `null` is returned if no new line is found.
81
+ *
82
+ * ```ts
83
+ * findNewLineIndex('abc\ndef') -> { preceding: 2, index: 3 }
84
+ * ```
85
+ */
86
+ function findNewlineIndex(
87
+ buffer: Uint8Array,
88
+ startIndex: number | null,
89
+ ): { preceding: number; index: number; carriage: boolean } | null {
90
+ const newline = 0x0a; // \n
91
+ const carriage = 0x0d; // \r
92
+
93
+ for (let i = startIndex ?? 0; i < buffer.length; i++) {
94
+ if (buffer[i] === newline) {
95
+ return { preceding: i, index: i + 1, carriage: false };
96
+ }
97
+
98
+ if (buffer[i] === carriage) {
99
+ return { preceding: i, index: i + 1, carriage: true };
100
+ }
101
+ }
102
+
103
+ return null;
104
+ }
105
+
106
+ export function findDoubleNewlineIndex(buffer: Uint8Array): number {
107
+ // This function searches the buffer for the end patterns (\r\r, \n\n, \r\n\r\n)
108
+ // and returns the index right after the first occurrence of any pattern,
109
+ // or -1 if none of the patterns are found.
110
+ const newline = 0x0a; // \n
111
+ const carriage = 0x0d; // \r
112
+
113
+ for (let i = 0; i < buffer.length - 1; i++) {
114
+ if (buffer[i] === newline && buffer[i + 1] === newline) {
115
+ // \n\n
116
+ return i + 2;
117
+ }
118
+ if (buffer[i] === carriage && buffer[i + 1] === carriage) {
119
+ // \r\r
120
+ return i + 2;
121
+ }
122
+ if (
123
+ buffer[i] === carriage &&
124
+ buffer[i + 1] === newline &&
125
+ i + 3 < buffer.length &&
126
+ buffer[i + 2] === carriage &&
127
+ buffer[i + 3] === newline
128
+ ) {
129
+ // \r\n\r\n
130
+ return i + 4;
131
+ }
132
+ }
133
+
134
+ return -1;
135
+ }
@@ -1,6 +1,7 @@
1
1
  // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
2
 
3
3
  import type { FinalRequestOptions } from './request-options';
4
+ import { Stream } from '../core/streaming';
4
5
  import { type SendblueAPI } from '../client';
5
6
  import { formatRequestDetails, loggerFor } from './utils/log';
6
7
 
@@ -16,6 +17,19 @@ export type APIResponseProps = {
16
17
  export async function defaultParseResponse<T>(client: SendblueAPI, props: APIResponseProps): Promise<T> {
17
18
  const { response, requestLogID, retryOfRequestLogID, startTime } = props;
18
19
  const body = await (async () => {
20
+ if (props.options.stream) {
21
+ loggerFor(client).debug('response', response.status, response.url, response.headers, response.body);
22
+
23
+ // Note: there is an invariant here that isn't represented in the type system
24
+ // that if you set `stream: true` the response type must also be `Stream<T>`
25
+
26
+ if (props.options.__streamClass) {
27
+ return props.options.__streamClass.fromSSEResponse(response, props.controller, client) as any;
28
+ }
29
+
30
+ return Stream.fromSSEResponse(response, props.controller, client) as any;
31
+ }
32
+
19
33
  // fetch refuses to read the body when the status code is 204.
20
34
  if (response.status === 204) {
21
35
  return null as T;
@@ -3,6 +3,7 @@
3
3
  import { NullableHeaders } from './headers';
4
4
 
5
5
  import type { BodyInit } from './builtin-types';
6
+ import { Stream } from '../core/streaming';
6
7
  import type { HTTPMethod, MergedRequestInit } from './types';
7
8
  import { type HeadersLike } from './headers';
8
9
 
@@ -76,6 +77,7 @@ export type RequestOptions = {
76
77
  defaultBaseURL?: string | undefined;
77
78
 
78
79
  __binaryResponse?: boolean | undefined;
80
+ __streamClass?: typeof Stream;
79
81
  };
80
82
 
81
83
  export type EncodedContent = { bodyHeaders: HeadersLike; body: BodyInit };
@@ -0,0 +1,19 @@
1
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
+
3
+ import { APIResource } from '../../core/resource';
4
+ import * as TokensAPI from './tokens';
5
+ import { TokenCreateParams, TokenCreateResponse, Tokens } from './tokens';
6
+
7
+ export class Auth extends APIResource {
8
+ tokens: TokensAPI.Tokens = new TokensAPI.Tokens(this._client);
9
+ }
10
+
11
+ Auth.Tokens = Tokens;
12
+
13
+ export declare namespace Auth {
14
+ export {
15
+ Tokens as Tokens,
16
+ type TokenCreateResponse as TokenCreateResponse,
17
+ type TokenCreateParams as TokenCreateParams,
18
+ };
19
+ }
@@ -0,0 +1,4 @@
1
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
+
3
+ export { Auth } from './auth';
4
+ export { Tokens, type TokenCreateResponse, type TokenCreateParams } from './tokens';
@@ -0,0 +1,101 @@
1
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
+
3
+ import { APIResource } from '../../core/resource';
4
+ import { APIPromise } from '../../core/api-promise';
5
+ import { buildHeaders } from '../../internal/headers';
6
+ import { RequestOptions } from '../../internal/request-options';
7
+ import { path } from '../../internal/utils/path';
8
+
9
+ /**
10
+ * Operations for minting and revoking temporary account API tokens
11
+ */
12
+ export class Tokens extends APIResource {
13
+ /**
14
+ * Creates a short-lived bearer token for the authenticated account. This endpoint
15
+ * must be called with live account API keys; temporary bearer tokens and test API
16
+ * keys cannot mint additional tokens.
17
+ *
18
+ * When `phone_number` or `phone_numbers` is supplied, the token is scoped to those
19
+ * Sendblue phone numbers. When no phone selector is supplied, the token is an
20
+ * account-scoped temporary token.
21
+ *
22
+ * The plaintext token is returned only once.
23
+ *
24
+ * @example
25
+ * ```ts
26
+ * const token = await client.auth.tokens.create();
27
+ * ```
28
+ */
29
+ create(
30
+ body: TokenCreateParams | null | undefined = {},
31
+ options?: RequestOptions,
32
+ ): APIPromise<TokenCreateResponse> {
33
+ return this._client.post('/v3/auth/tokens', { body, ...options });
34
+ }
35
+
36
+ /**
37
+ * Revokes a temporary bearer token owned by the authenticated account. This
38
+ * endpoint must be called with live account API keys; temporary bearer tokens and
39
+ * test API keys cannot revoke tokens.
40
+ *
41
+ * @example
42
+ * ```ts
43
+ * await client.auth.tokens.revoke(
44
+ * '11111111-1111-4111-8111-111111111111',
45
+ * );
46
+ * ```
47
+ */
48
+ revoke(tokenID: string, options?: RequestOptions): APIPromise<void> {
49
+ return this._client.delete(path`/v3/auth/tokens/${tokenID}`, {
50
+ ...options,
51
+ headers: buildHeaders([{ Accept: '*/*' }, options?.headers]),
52
+ });
53
+ }
54
+ }
55
+
56
+ export interface TokenCreateResponse {
57
+ /**
58
+ * Plaintext temporary bearer token. Store it securely; it is returned only once.
59
+ */
60
+ token: string;
61
+
62
+ /**
63
+ * ISO timestamp when the token expires.
64
+ */
65
+ expires_at: string;
66
+
67
+ /**
68
+ * Phone-number scope for this token. Empty means the token is account-scoped.
69
+ */
70
+ phone_numbers: Array<string>;
71
+
72
+ /**
73
+ * Token identifier used for revocation.
74
+ */
75
+ token_id: string;
76
+
77
+ token_type: 'Bearer';
78
+ }
79
+
80
+ export interface TokenCreateParams {
81
+ /**
82
+ * Token lifetime in seconds. Defaults to 900 seconds when omitted.
83
+ */
84
+ expires_in_seconds?: number;
85
+
86
+ /**
87
+ * Single Sendblue phone number to scope the token to. Cannot be combined with
88
+ * `phone_numbers`.
89
+ */
90
+ phone_number?: string;
91
+
92
+ /**
93
+ * Sendblue phone numbers to scope the token to. Cannot be combined with
94
+ * `phone_number`.
95
+ */
96
+ phone_numbers?: Array<string>;
97
+ }
98
+
99
+ export declare namespace Tokens {
100
+ export { type TokenCreateResponse as TokenCreateResponse, type TokenCreateParams as TokenCreateParams };
101
+ }
@@ -0,0 +1,3 @@
1
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
+
3
+ export * from './auth/index';
@@ -140,6 +140,11 @@ export interface Contact {
140
140
  */
141
141
  company_name?: string;
142
142
 
143
+ /**
144
+ * Immutable contact identity (included by list responses for event recovery)
145
+ */
146
+ contact_id?: string;
147
+
143
148
  /**
144
149
  * When the contact was created
145
150
  */
@@ -384,6 +389,11 @@ export interface ContactListParams {
384
389
  */
385
390
  cid?: string;
386
391
 
392
+ /**
393
+ * Filter contacts created at or after this ISO 8601 timestamp (event recovery)
394
+ */
395
+ created_at_gte?: string;
396
+
387
397
  /**
388
398
  * Maximum number of contacts to return. Defaults to 100, capped at 1000.
389
399
  */
@@ -0,0 +1,75 @@
1
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
+
3
+ import { APIResource } from '../core/resource';
4
+ import { APIPromise } from '../core/api-promise';
5
+ import { Stream } from '../core/streaming';
6
+ import { buildHeaders } from '../internal/headers';
7
+ import { RequestOptions } from '../internal/request-options';
8
+
9
+ /**
10
+ * Authenticated live account events and recovery contracts
11
+ */
12
+ export class Events extends APIResource {
13
+ /**
14
+ * Opens an authenticated Server-Sent Events stream scoped exclusively to the
15
+ * account resolved by the supplied credentials. The stream is live and
16
+ * intentionally not a durable replay log. It sends a heartbeat every 15 seconds
17
+ * and rotates after at most 15 minutes. A temporary-token stream closes no later
18
+ * than that token's `expires_at`; clients should reconnect and repair gaps via:
19
+ *
20
+ * - `GET /api/v2/messages?updated_at_gte=...&order_by=updated_at&order_direction=asc`
21
+ * - `GET /api/v2/contacts?created_at_gte=...&order_by=created_at&order_direction=asc`
22
+ * - `GET /api/v2/lines/state`
23
+ * - `GET /api/v2/verify/verifications?updated_at_gte=...`
24
+ *
25
+ * Each event contains a stable `id`, a `type`, `occurred_at`, and a minimal `data`
26
+ * object. Consumers must deduplicate by ID. Typing indicators are ephemeral and
27
+ * cannot be recovered.
28
+ */
29
+ stream(
30
+ query: EventStreamParams | undefined = {},
31
+ options?: RequestOptions,
32
+ ): APIPromise<Stream<AccountEvent>> {
33
+ return this._client.get('/api/v2/events', {
34
+ query,
35
+ ...options,
36
+ headers: buildHeaders([{ Accept: 'text/event-stream' }, options?.headers]),
37
+ stream: true,
38
+ }) as APIPromise<Stream<AccountEvent>>;
39
+ }
40
+ }
41
+
42
+ export interface AccountEvent {
43
+ id: string;
44
+
45
+ data: { [key: string]: unknown };
46
+
47
+ occurred_at: string;
48
+
49
+ type:
50
+ | 'message.received'
51
+ | 'message.created'
52
+ | 'message.updated'
53
+ | 'typing.changed'
54
+ | 'line.assigned'
55
+ | 'line.unassigned'
56
+ | 'line.status.changed'
57
+ | 'line.blocked'
58
+ | 'contact.created'
59
+ | 'verification.approved'
60
+ | 'verification.expired'
61
+ | 'verification.canceled';
62
+
63
+ version: 1;
64
+ }
65
+
66
+ export interface EventStreamParams {
67
+ /**
68
+ * Optional comma-separated allowlist of event types
69
+ */
70
+ types?: string;
71
+ }
72
+
73
+ export declare namespace Events {
74
+ export { type AccountEvent as AccountEvent, type EventStreamParams as EventStreamParams };
75
+ }
@@ -95,6 +95,12 @@ export interface GroupSendMessageParams {
95
95
  */
96
96
  numbers?: Array<string>;
97
97
 
98
+ /**
99
+ * Immediate parent of an iMessage inline reply. The target must belong to the same
100
+ * account, conversation, and sending line.
101
+ */
102
+ reply_to?: GroupSendMessageParams.ReplyTo;
103
+
98
104
  /**
99
105
  * Optional. Identifies the seat (user) sending the group message so it is
100
106
  * attributed to a specific rep. Accepts either the seat UUID or the Firebase Auth
@@ -104,6 +110,28 @@ export interface GroupSendMessageParams {
104
110
  seat_id?: string;
105
111
  }
106
112
 
113
+ export namespace GroupSendMessageParams {
114
+ /**
115
+ * Immediate parent of an iMessage inline reply. The target must belong to the same
116
+ * account, conversation, and sending line.
117
+ */
118
+ export interface ReplyTo {
119
+ /**
120
+ * Public handle of the immediate parent message
121
+ */
122
+ message_handle: string;
123
+
124
+ /**
125
+ * Advanced override for a known part of a multipart target. Omit this in normal
126
+ * reply requests and never guess it; requests default to 0. When replying to an
127
+ * attachment represented by its own webhook, use that webhook's `message_handle`
128
+ * and omit `part_index` so Sendblue can use the stored authoritative part.
129
+ * Responses omit it when no authoritative immediate-parent part is available.
130
+ */
131
+ part_index?: number;
132
+ }
133
+ }
134
+
107
135
  export declare namespace Groups {
108
136
  export {
109
137
  type GroupModifyResponse as GroupModifyResponse,
@@ -1,5 +1,6 @@
1
1
  // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
2
 
3
+ export { Auth } from './auth/auth';
3
4
  export {
4
5
  Contacts,
5
6
  type Contact,
@@ -17,13 +18,23 @@ export {
17
18
  type ContactOptOutParams,
18
19
  type ContactVerifyParams,
19
20
  } from './contacts/contacts';
21
+ export { Events, type AccountEvent, type EventStreamParams } from './events';
20
22
  export {
21
23
  Groups,
22
24
  type GroupModifyResponse,
23
25
  type GroupModifyParams,
24
26
  type GroupSendMessageParams,
25
27
  } from './groups';
26
- export { Lines } from './lines/lines';
28
+ export { Lines, type LineState, type LineGetStateResponse } from './lines/lines';
29
+ export {
30
+ Location,
31
+ type LocationRetrieveResponse,
32
+ type LocationListResponse,
33
+ type LocationWatchResponse,
34
+ type LocationRetrieveParams,
35
+ type LocationListParams,
36
+ type LocationWatchParams,
37
+ } from './location';
27
38
  export { Lookups, type LookupLookupNumberResponse, type LookupLookupNumberParams } from './lookups';
28
39
  export { MediaObjects, type MediaObjectUploadResponse, type MediaObjectUploadParams } from './media-objects';
29
40
  export {
@@ -35,7 +46,13 @@ export {
35
46
  type MessageListParams,
36
47
  type MessageGetStatusParams,
37
48
  type MessageSendParams,
49
+ type MessageUpdateAppCardParams,
38
50
  } from './messages';
51
+ export {
52
+ RequestLocation,
53
+ type RequestLocationCreateResponse,
54
+ type RequestLocationCreateParams,
55
+ } from './request-location';
39
56
  export { SendCarousel, type SendCarouselSendResponse, type SendCarouselSendParams } from './send-carousel';
40
57
  export {
41
58
  TypingIndicators,
@@ -43,6 +60,14 @@ export {
43
60
  type TypingIndicatorSendParams,
44
61
  } from './typing-indicators';
45
62
  export { V2 } from './v2/v2';
63
+ export {
64
+ VerifiedContacts,
65
+ type VerifiedContactCreateResponse,
66
+ type VerifiedContactRetrieveResponse,
67
+ type VerifiedContactListResponse,
68
+ type VerifiedContactCreateParams,
69
+ } from './verified-contacts';
70
+ export { Verify } from './verify/verify';
46
71
  export {
47
72
  Webhooks,
48
73
  type WebhookConfiguration,
@@ -5,6 +5,9 @@ import { APIPromise } from '../../core/api-promise';
5
5
  import { RequestOptions } from '../../internal/request-options';
6
6
  import { path } from '../../internal/utils/path';
7
7
 
8
+ /**
9
+ * Sendblue line configuration and health state
10
+ */
8
11
  export class CallForwarding extends APIResource {
9
12
  /**
10
13
  * Returns the current call forwarding number for a dedicated phone line.
@@ -7,4 +7,4 @@ export {
7
7
  type CallForwardingDeleteResponse,
8
8
  type CallForwardingUpdateParams,
9
9
  } from './call-forwarding';
10
- export { Lines } from './lines';
10
+ export { Lines, type LineState, type LineGetStateResponse } from './lines';
@@ -9,14 +9,58 @@ import {
9
9
  CallForwardingUpdateParams,
10
10
  CallForwardingUpdateResponse,
11
11
  } from './call-forwarding';
12
+ import { APIPromise } from '../../core/api-promise';
13
+ import { RequestOptions } from '../../internal/request-options';
12
14
 
15
+ /**
16
+ * Sendblue line configuration and health state
17
+ */
13
18
  export class Lines extends APIResource {
14
19
  callForwarding: CallForwardingAPI.CallForwarding = new CallForwardingAPI.CallForwarding(this._client);
20
+
21
+ /**
22
+ * Returns the authenticated account's current line membership and latest persisted
23
+ * health transition.
24
+ *
25
+ * @example
26
+ * ```ts
27
+ * const response = await client.lines.getState();
28
+ * ```
29
+ */
30
+ getState(options?: RequestOptions): APIPromise<LineGetStateResponse> {
31
+ return this._client.get('/api/v2/lines/state', options);
32
+ }
33
+ }
34
+
35
+ export interface LineState {
36
+ assignment: 'assigned' | 'shared' | 'grace_period';
37
+
38
+ sendblue_number: string | null;
39
+
40
+ status: 'ONLINE' | 'OFFLINE' | 'DEGRADED' | 'UNKNOWN';
41
+
42
+ worker_id: string;
43
+
44
+ degraded_since?: string | null;
45
+
46
+ effective_until?: string | null;
47
+
48
+ status_changed_at?: string | null;
49
+ }
50
+
51
+ export interface LineGetStateResponse {
52
+ data: Array<LineState>;
53
+
54
+ snapshot_at: string;
55
+
56
+ status: 'OK';
15
57
  }
16
58
 
17
59
  Lines.CallForwarding = CallForwarding;
18
60
 
19
61
  export declare namespace Lines {
62
+ export { type LineState as LineState, type LineGetStateResponse as LineGetStateResponse };
63
+
20
64
  export {
21
65
  CallForwarding as CallForwarding,
22
66
  type CallForwardingRetrieveResponse as CallForwardingRetrieveResponse,