@textbee/sdk 0.3.0 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -8,6 +8,8 @@ Official JavaScript SDK for [textbee.dev](https://textbee.dev), the open source
8
8
 
9
9
  Zero dependencies, TypeScript types included, works in Node 18+, Bun, Deno, Cloudflare Workers, and Vercel Edge.
10
10
 
11
+ Writing Python? Use the official [Python SDK](https://github.com/textbee/textbee-python): `pip install textbee`.
12
+
11
13
  ## Install
12
14
 
13
15
  ```bash
@@ -229,7 +231,7 @@ new Textbee({ apiKey, baseUrl: 'https://sms.example.com/api/v1' })
229
231
  new Textbee({ apiKey, baseUrl: 'http://localhost:3001' })
230
232
  ```
231
233
 
232
- If the API sits under a path prefix, give the full path, for example `https://example.com/textbee/api/v1`. Any path other than `/api/v1` is used as given, so a proxy that maps `/sms` onto the API keeps working with `https://example.com/sms`. A value with no scheme gets `https://`. An invalid URL, or one with a username or password, throws a `TypeError` instead of falling back to the hosted API, so a typo never sends your key to textbee.dev.
234
+ If the API sits under a path prefix, give the prefix: `https://example.com/textbee` reaches `https://example.com/textbee/api/v1`. The SDK adds `/api/v1` unless the path already contains it, the same rule the textbee MCP server uses for `TEXTBEE_BASE_URL`. A value with no scheme gets `https://`. An invalid URL, or one with a username or password, throws a `TypeError` instead of falling back to the hosted API, so a typo never sends your key to textbee.dev.
233
235
 
234
236
  ## What is not covered yet
235
237
 
package/dist/index.cjs CHANGED
@@ -48,7 +48,7 @@ var TextbeeError = class extends Error {
48
48
 
49
49
  // src/client.ts
50
50
  var DEFAULT_BASE_URL = "https://api.textbee.dev/api/v1";
51
- var CLIENT_ID = `textbee-js/${"0.3.0"}`;
51
+ var CLIENT_ID = `textbee-js/${"0.4.0"}`;
52
52
  var Textbee = class {
53
53
  #apiKey;
54
54
  #baseUrl;
@@ -224,10 +224,8 @@ function normalizeBaseUrl(raw) {
224
224
  }
225
225
  }
226
226
  let path;
227
- if (segments.length === 0) {
228
- path = ["api", "v1"];
229
- } else if (cut === -1) {
230
- path = segments;
227
+ if (cut === -1) {
228
+ path = [...segments, "api", "v1"];
231
229
  } else {
232
230
  path = [...segments.slice(0, cut - 2), "api", "v1"];
233
231
  }
package/dist/index.d.cts CHANGED
@@ -4,9 +4,9 @@ interface TextbeeOptions {
4
4
  /**
5
5
  * Your self-hosted textbee API. Defaults to `https://api.textbee.dev/api/v1`.
6
6
  *
7
- * A bare origin such as `https://sms.example.com` gets `/api/v1` added. A URL
7
+ * `/api/v1` is added unless the path already contains it, so
8
+ * `https://sms.example.com` and `https://example.com/textbee` both work. A URL
8
9
  * that contains `/api/v1` is cut there, so a pasted endpoint URL still works.
9
- * Any other path is used as given, for proxies that map a prefix onto the API.
10
10
  * A value with no scheme gets `https://`. An invalid URL throws a `TypeError`
11
11
  * rather than falling back, so a typo never sends your key to the public API.
12
12
  */
@@ -136,6 +136,20 @@ interface MessageDevice {
136
136
  buildId?: string;
137
137
  enabled?: boolean;
138
138
  }
139
+ /** Where a failure was reported from. */
140
+ type MessageIssueSource = 'push' | 'device' | 'server';
141
+ /** One failure a message had. Kept after the message later succeeds. */
142
+ interface MessageIssueEntry {
143
+ code: string;
144
+ message?: string;
145
+ /** When the failure happened. ISO date. */
146
+ at: string;
147
+ source: MessageIssueSource;
148
+ /** Set on entries rebuilt from old message fields. */
149
+ backfilled?: boolean;
150
+ /** True when the entry is a delivery report that did not confirm delivery. The message was sent; this is not a send failure. */
151
+ deliveryReport?: boolean;
152
+ }
139
153
  interface Message {
140
154
  _id: string;
141
155
  message: string;
@@ -160,10 +174,15 @@ interface Message {
160
174
  dispatchedAt?: string;
161
175
  sentAt?: string;
162
176
  deliveredAt?: string;
177
+ /** When the message failed. Present only while status is `failed`. */
163
178
  failedAt?: string;
164
179
  receivedAt?: string;
180
+ /** Current failure code. Present only while status is `failed` (test accounts can keep `FCM_SEND_SKIPPED`). */
165
181
  errorCode?: string;
182
+ /** Current failure text. Present only while status is `failed`, or as a timeout note on `unknown`. */
166
183
  errorMessage?: string;
184
+ /** Every failure the message had, plus delivery reports that did not confirm delivery (`deliveryReport: true`, not failures). Oldest first. At most 15: the first 5 and the newest 10. */
185
+ issueHistory?: MessageIssueEntry[];
167
186
  simSubscriptionId?: number;
168
187
  smsBatch?: string;
169
188
  createdAt?: string;
@@ -400,4 +419,4 @@ interface VerifyWebhookSignatureOptions {
400
419
  */
401
420
  declare function verifyWebhookSignature(options: VerifyWebhookSignatureOptions): Promise<boolean>;
402
421
 
403
- export { type Device, type IterateMessagesOptions, type ListMessagesOptions, type Message, type MessageDevice, type MessageList, type MessageListMeta, type NormalizePhoneNumberOptions, type SanitizeForGsm7Options, type SendSmsImmediateResponse, type SendSmsQueuedResponse, type SendSmsRequest, type SendSmsResponse, type SendSmsWarning, type Sms, type SmsBatch, type SmsBatchResult, type SmsEncoding, type SmsSegmentInfo, Textbee, TextbeeError, type TextbeeOptions, type VerifyWebhookSignatureOptions, type WebhookEvent, countSmsSegments, findNonGsm7Characters, getSmsEncoding, isValidE164, normalizePhoneNumber, sanitizeForGsm7, verifyWebhookSignature };
422
+ export { type Device, type IterateMessagesOptions, type ListMessagesOptions, type Message, type MessageDevice, type MessageIssueEntry, type MessageIssueSource, type MessageList, type MessageListMeta, type NormalizePhoneNumberOptions, type SanitizeForGsm7Options, type SendSmsImmediateResponse, type SendSmsQueuedResponse, type SendSmsRequest, type SendSmsResponse, type SendSmsWarning, type Sms, type SmsBatch, type SmsBatchResult, type SmsEncoding, type SmsSegmentInfo, Textbee, TextbeeError, type TextbeeOptions, type VerifyWebhookSignatureOptions, type WebhookEvent, countSmsSegments, findNonGsm7Characters, getSmsEncoding, isValidE164, normalizePhoneNumber, sanitizeForGsm7, verifyWebhookSignature };
package/dist/index.d.ts CHANGED
@@ -4,9 +4,9 @@ interface TextbeeOptions {
4
4
  /**
5
5
  * Your self-hosted textbee API. Defaults to `https://api.textbee.dev/api/v1`.
6
6
  *
7
- * A bare origin such as `https://sms.example.com` gets `/api/v1` added. A URL
7
+ * `/api/v1` is added unless the path already contains it, so
8
+ * `https://sms.example.com` and `https://example.com/textbee` both work. A URL
8
9
  * that contains `/api/v1` is cut there, so a pasted endpoint URL still works.
9
- * Any other path is used as given, for proxies that map a prefix onto the API.
10
10
  * A value with no scheme gets `https://`. An invalid URL throws a `TypeError`
11
11
  * rather than falling back, so a typo never sends your key to the public API.
12
12
  */
@@ -136,6 +136,20 @@ interface MessageDevice {
136
136
  buildId?: string;
137
137
  enabled?: boolean;
138
138
  }
139
+ /** Where a failure was reported from. */
140
+ type MessageIssueSource = 'push' | 'device' | 'server';
141
+ /** One failure a message had. Kept after the message later succeeds. */
142
+ interface MessageIssueEntry {
143
+ code: string;
144
+ message?: string;
145
+ /** When the failure happened. ISO date. */
146
+ at: string;
147
+ source: MessageIssueSource;
148
+ /** Set on entries rebuilt from old message fields. */
149
+ backfilled?: boolean;
150
+ /** True when the entry is a delivery report that did not confirm delivery. The message was sent; this is not a send failure. */
151
+ deliveryReport?: boolean;
152
+ }
139
153
  interface Message {
140
154
  _id: string;
141
155
  message: string;
@@ -160,10 +174,15 @@ interface Message {
160
174
  dispatchedAt?: string;
161
175
  sentAt?: string;
162
176
  deliveredAt?: string;
177
+ /** When the message failed. Present only while status is `failed`. */
163
178
  failedAt?: string;
164
179
  receivedAt?: string;
180
+ /** Current failure code. Present only while status is `failed` (test accounts can keep `FCM_SEND_SKIPPED`). */
165
181
  errorCode?: string;
182
+ /** Current failure text. Present only while status is `failed`, or as a timeout note on `unknown`. */
166
183
  errorMessage?: string;
184
+ /** Every failure the message had, plus delivery reports that did not confirm delivery (`deliveryReport: true`, not failures). Oldest first. At most 15: the first 5 and the newest 10. */
185
+ issueHistory?: MessageIssueEntry[];
167
186
  simSubscriptionId?: number;
168
187
  smsBatch?: string;
169
188
  createdAt?: string;
@@ -400,4 +419,4 @@ interface VerifyWebhookSignatureOptions {
400
419
  */
401
420
  declare function verifyWebhookSignature(options: VerifyWebhookSignatureOptions): Promise<boolean>;
402
421
 
403
- export { type Device, type IterateMessagesOptions, type ListMessagesOptions, type Message, type MessageDevice, type MessageList, type MessageListMeta, type NormalizePhoneNumberOptions, type SanitizeForGsm7Options, type SendSmsImmediateResponse, type SendSmsQueuedResponse, type SendSmsRequest, type SendSmsResponse, type SendSmsWarning, type Sms, type SmsBatch, type SmsBatchResult, type SmsEncoding, type SmsSegmentInfo, Textbee, TextbeeError, type TextbeeOptions, type VerifyWebhookSignatureOptions, type WebhookEvent, countSmsSegments, findNonGsm7Characters, getSmsEncoding, isValidE164, normalizePhoneNumber, sanitizeForGsm7, verifyWebhookSignature };
422
+ export { type Device, type IterateMessagesOptions, type ListMessagesOptions, type Message, type MessageDevice, type MessageIssueEntry, type MessageIssueSource, type MessageList, type MessageListMeta, type NormalizePhoneNumberOptions, type SanitizeForGsm7Options, type SendSmsImmediateResponse, type SendSmsQueuedResponse, type SendSmsRequest, type SendSmsResponse, type SendSmsWarning, type Sms, type SmsBatch, type SmsBatchResult, type SmsEncoding, type SmsSegmentInfo, Textbee, TextbeeError, type TextbeeOptions, type VerifyWebhookSignatureOptions, type WebhookEvent, countSmsSegments, findNonGsm7Characters, getSmsEncoding, isValidE164, normalizePhoneNumber, sanitizeForGsm7, verifyWebhookSignature };
package/dist/index.js CHANGED
@@ -14,7 +14,7 @@ var TextbeeError = class extends Error {
14
14
 
15
15
  // src/client.ts
16
16
  var DEFAULT_BASE_URL = "https://api.textbee.dev/api/v1";
17
- var CLIENT_ID = `textbee-js/${"0.3.0"}`;
17
+ var CLIENT_ID = `textbee-js/${"0.4.0"}`;
18
18
  var Textbee = class {
19
19
  #apiKey;
20
20
  #baseUrl;
@@ -190,10 +190,8 @@ function normalizeBaseUrl(raw) {
190
190
  }
191
191
  }
192
192
  let path;
193
- if (segments.length === 0) {
194
- path = ["api", "v1"];
195
- } else if (cut === -1) {
196
- path = segments;
193
+ if (cut === -1) {
194
+ path = [...segments, "api", "v1"];
197
195
  } else {
198
196
  path = [...segments.slice(0, cut - 2), "api", "v1"];
199
197
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@textbee/sdk",
3
- "version": "0.3.0",
3
+ "version": "0.4.0",
4
4
  "description": "Official JavaScript SDK for textbee.dev, the open source SMS gateway",
5
5
  "license": "MIT",
6
6
  "packageManager": "pnpm@9.14.2",