commune-ai 0.3.1 → 0.3.5

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/client.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { AttachmentRecord, AttachmentUrl, AttachmentUploadResponse, CreateDomainPayload, DomainEntry, InboxEntry, MessageListParams, SendMessagePayload, UnifiedMessage, SearchFilter, SearchOptions, SearchResult, IndexConversationPayload, ThreadListParams, ThreadListResponse, SearchThreadsParams, SearchThreadResult, ThreadMetadataEntry, DeliveryMetricsParams, DeliveryEventEntry, DeliveryEventsParams, DeliverySuppressionsParams, SuppressionEntry } from './types.js';
1
+ import type { AttachmentRecord, AttachmentUrl, AttachmentUploadResponse, CreateDomainPayload, DomainEntry, InboxEntry, MessageListParams, SendMessagePayload, UnifiedMessage, SearchFilter, SearchOptions, SearchResult, IndexConversationPayload, ThreadListParams, ThreadListResponse, SearchThreadsParams, SearchThreadResult, ThreadMetadataEntry, DeliveryMetricsParams, DeliveryEventEntry, DeliveryEventsParams, DeliverySuppressionsParams, SuppressionEntry, PhoneNumber, UpdatePhoneNumberPayload, PhoneNumberWebhookPayload, AvailablePhoneNumber, ProvisionPhoneNumberPayload, SmsConversation, SmsConversationListParams, SmsMessage, SmsListParams, SmsSuppression, SendSmsPayload, SendSmsResult, SmsSearchParams, CreditBalance, CreditBundle, CreditCheckoutResult } from './types.js';
2
2
  export type ClientOptions = {
3
3
  baseUrl?: string;
4
4
  apiKey: string;
@@ -130,4 +130,41 @@ export declare class CommuneClient {
130
130
  expiresIn?: number;
131
131
  }) => Promise<AttachmentRecord | AttachmentUrl>;
132
132
  };
133
+ phoneNumbers: {
134
+ list: () => Promise<PhoneNumber[]>;
135
+ get: (phoneNumberId: string) => Promise<PhoneNumber>;
136
+ update: (phoneNumberId: string, payload: UpdatePhoneNumberPayload) => Promise<PhoneNumber>;
137
+ available: (params?: {
138
+ type?: "TollFree" | "Local";
139
+ country?: string;
140
+ area_code?: string;
141
+ limit?: number;
142
+ }) => Promise<AvailablePhoneNumber[]>;
143
+ provision: (payload?: ProvisionPhoneNumberPayload) => Promise<PhoneNumber>;
144
+ release: (phoneNumberId: string) => Promise<{
145
+ id: string;
146
+ status: string;
147
+ message: string;
148
+ }>;
149
+ setAllowList: (phoneNumberId: string, numbers: string[]) => Promise<PhoneNumber>;
150
+ setBlockList: (phoneNumberId: string, numbers: string[]) => Promise<PhoneNumber>;
151
+ setWebhook: (phoneNumberId: string, payload: PhoneNumberWebhookPayload) => Promise<PhoneNumber>;
152
+ };
153
+ sms: {
154
+ list: (params?: SmsListParams) => Promise<SmsMessage[]>;
155
+ send: (payload: SendSmsPayload) => Promise<SendSmsResult>;
156
+ conversations: (params?: SmsConversationListParams) => Promise<SmsConversation[]>;
157
+ thread: (remoteNumber: string, phoneNumberId?: string) => Promise<SmsMessage[]>;
158
+ search: (params: SmsSearchParams) => Promise<SmsMessage[]>;
159
+ suppressions: (phoneNumberId?: string) => Promise<SmsSuppression[]>;
160
+ removeSuppression: (phoneNumber: string) => Promise<{
161
+ removed: boolean;
162
+ phone_number: string;
163
+ }>;
164
+ };
165
+ credits: {
166
+ balance: () => Promise<CreditBalance>;
167
+ bundles: () => Promise<CreditBundle[]>;
168
+ checkout: (bundle: "starter" | "growth" | "scale", returnUrl?: string) => Promise<CreditCheckoutResult>;
169
+ };
133
170
  }
package/dist/client.js CHANGED
@@ -273,6 +273,101 @@ export class CommuneClient {
273
273
  return this.request(`/v1/attachments/${encodeURIComponent(attachmentId)}`);
274
274
  },
275
275
  };
276
+ this.phoneNumbers = {
277
+ list: async () => {
278
+ return this.request('/v1/phone-numbers');
279
+ },
280
+ get: async (phoneNumberId) => {
281
+ return this.request(`/v1/phone-numbers/${encodeURIComponent(phoneNumberId)}`);
282
+ },
283
+ update: async (phoneNumberId, payload) => {
284
+ return this.request(`/v1/phone-numbers/${encodeURIComponent(phoneNumberId)}`, { method: 'PATCH', json: payload });
285
+ },
286
+ available: async (params) => {
287
+ return this.request(`/v1/phone-numbers/available${buildQuery({
288
+ type: params?.type,
289
+ country: params?.country,
290
+ area_code: params?.area_code,
291
+ limit: params?.limit,
292
+ })}`);
293
+ },
294
+ provision: async (payload) => {
295
+ return this.request('/v1/phone-numbers', {
296
+ method: 'POST',
297
+ json: (payload ?? {}),
298
+ });
299
+ },
300
+ release: async (phoneNumberId) => {
301
+ return this.request(`/v1/phone-numbers/${encodeURIComponent(phoneNumberId)}`, { method: 'DELETE' });
302
+ },
303
+ setAllowList: async (phoneNumberId, numbers) => {
304
+ return this.request(`/v1/phone-numbers/${encodeURIComponent(phoneNumberId)}/allow-list`, { method: 'PUT', json: { numbers } });
305
+ },
306
+ setBlockList: async (phoneNumberId, numbers) => {
307
+ return this.request(`/v1/phone-numbers/${encodeURIComponent(phoneNumberId)}/block-list`, { method: 'PUT', json: { numbers } });
308
+ },
309
+ setWebhook: async (phoneNumberId, payload) => {
310
+ return this.request(`/v1/phone-numbers/${encodeURIComponent(phoneNumberId)}`, { method: 'PATCH', json: { webhook: payload } });
311
+ },
312
+ };
313
+ this.sms = {
314
+ list: async (params = {}) => {
315
+ return this.request(`/v1/sms${buildQuery({
316
+ phone_number_id: params.phone_number_id,
317
+ limit: params.limit,
318
+ before: params.before,
319
+ after: params.after,
320
+ })}`);
321
+ },
322
+ send: async (payload) => {
323
+ return this.request('/v1/sms/send', {
324
+ method: 'POST',
325
+ json: payload,
326
+ });
327
+ },
328
+ conversations: async (params = {}) => {
329
+ return this.request(`/v1/sms/conversations${buildQuery({
330
+ phone_number_id: params.phone_number_id,
331
+ limit: params.limit,
332
+ cursor: params.cursor,
333
+ })}`);
334
+ },
335
+ thread: async (remoteNumber, phoneNumberId) => {
336
+ return this.request(`/v1/sms/conversations/${encodeURIComponent(remoteNumber)}${buildQuery({
337
+ phone_number_id: phoneNumberId,
338
+ })}`);
339
+ },
340
+ search: async (params) => {
341
+ return this.request(`/v1/sms/search${buildQuery({
342
+ q: params.q,
343
+ phone_number_id: params.phone_number_id,
344
+ limit: params.limit,
345
+ })}`);
346
+ },
347
+ suppressions: async (phoneNumberId) => {
348
+ return this.request(`/v1/sms/suppressions${buildQuery({ phone_number_id: phoneNumberId })}`);
349
+ },
350
+ removeSuppression: async (phoneNumber) => {
351
+ return this.request(`/v1/sms/suppressions/${encodeURIComponent(phoneNumber)}`, { method: 'DELETE' });
352
+ },
353
+ };
354
+ this.credits = {
355
+ balance: async () => {
356
+ return this.request('/v1/credits');
357
+ },
358
+ bundles: async () => {
359
+ return this.request('/v1/credits/bundles');
360
+ },
361
+ checkout: async (bundle, returnUrl) => {
362
+ return this.request('/v1/credits/checkout', {
363
+ method: 'POST',
364
+ json: {
365
+ bundle,
366
+ ...(returnUrl ? { success_url: returnUrl, cancel_url: returnUrl } : {}),
367
+ },
368
+ });
369
+ },
370
+ };
276
371
  this.baseUrl = (options.baseUrl || DEFAULT_BASE_URL).replace(/\/$/, '');
277
372
  this.apiKey = options.apiKey;
278
373
  this.headers = options.headers;
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  export { CommuneClient } from './client.js';
2
- export type { ApiError, ApiResponse, AttachmentRecord, Channel, ConversationListParams, CreateDomainPayload, CreateInboxPayload, Direction, DomainEntry, DomainWebhook, InboxEntry, InboxWebhook, InboundEmailWebhookPayload, MessageListParams, MessageMetadata, Participant, ParticipantRole, SendMessagePayload, SearchThreadResult, SearchThreadsParams, ThreadMetadataEntry, SvixHeaders, SuppressionEntry, Thread, DeliveryEventEntry, DeliveryEventsParams, DeliveryMetricsParams, DeliverySuppressionsParams, ThreadListParams, ThreadListResponse, UnifiedMessage, } from './types.js';
2
+ export type { ApiError, ApiResponse, AttachmentRecord, Channel, ConversationListParams, CreateDomainPayload, CreateInboxPayload, Direction, DomainEntry, DomainWebhook, InboxEntry, InboxWebhook, InboundEmailWebhookPayload, MessageListParams, MessageMetadata, Participant, ParticipantRole, SendMessagePayload, SearchThreadResult, SearchThreadsParams, ThreadMetadataEntry, SvixHeaders, SuppressionEntry, Thread, DeliveryEventEntry, DeliveryEventsParams, DeliveryMetricsParams, DeliverySuppressionsParams, ThreadListParams, ThreadListResponse, UnifiedMessage, PhoneNumber, UpdatePhoneNumberPayload, PhoneNumberWebhookPayload, AvailablePhoneNumber, ProvisionPhoneNumberPayload, SmsConversation, SmsConversationListParams, SmsMessage, SmsListParams, SmsSuppression, SendSmsPayload, SendSmsResult, SmsSearchParams, CreditBalance, CreditBundle, CreditCheckoutResult, } from './types.js';
3
3
  export { verifyResendWebhook, verifyCommuneWebhook, computeCommuneSignature } from './webhooks.js';
4
4
  export type { CommuneWebhookHeaders } from './webhooks.js';
5
5
  export { createWebhookHandler } from './listener.js';
package/dist/types.d.ts CHANGED
@@ -367,3 +367,136 @@ export interface DeliverySuppressionsParams {
367
367
  domainId?: string;
368
368
  limit?: number;
369
369
  }
370
+ export interface AvailablePhoneNumber {
371
+ phoneNumber: string;
372
+ friendlyName: string;
373
+ capabilities: {
374
+ sms: boolean;
375
+ mms: boolean;
376
+ voice: boolean;
377
+ };
378
+ region?: string;
379
+ locality?: string;
380
+ postalCode?: string;
381
+ }
382
+ export interface ProvisionPhoneNumberPayload {
383
+ phone_number?: string;
384
+ type?: 'tollfree' | 'local';
385
+ country?: string;
386
+ friendly_name?: string;
387
+ area_code?: string;
388
+ }
389
+ export interface PhoneNumber {
390
+ id: string;
391
+ number: string;
392
+ numberType: 'tollfree' | 'local' | 'shortcode';
393
+ friendlyName: string | null;
394
+ country: string;
395
+ capabilities: {
396
+ sms: boolean;
397
+ mms: boolean;
398
+ voice: boolean;
399
+ };
400
+ status: 'active' | 'released' | 'suspended_non_payment';
401
+ allowList: string[];
402
+ blockList: string[];
403
+ creditCostPerMonth: number;
404
+ autoReply: string | null;
405
+ createdAt: string;
406
+ updatedAt: string;
407
+ }
408
+ export interface PhoneNumberWebhookPayload {
409
+ endpoint?: string;
410
+ secret?: string;
411
+ events?: string[];
412
+ }
413
+ export interface UpdatePhoneNumberPayload {
414
+ friendlyName?: string;
415
+ autoReply?: string | null;
416
+ allowList?: string[];
417
+ blockList?: string[];
418
+ webhook?: PhoneNumberWebhookPayload;
419
+ }
420
+ export interface SmsConversation {
421
+ thread_id: string;
422
+ remote_number: string;
423
+ phone_number_id: string;
424
+ last_message_at: string;
425
+ last_message_preview: string | null;
426
+ message_count: number;
427
+ unread_count: number;
428
+ }
429
+ export interface SmsMessage {
430
+ message_id: string;
431
+ thread_id: string;
432
+ direction: 'inbound' | 'outbound';
433
+ content: string | null;
434
+ created_at: string;
435
+ metadata: {
436
+ delivery_status: string | null;
437
+ from_number: string | null;
438
+ to_number: string | null;
439
+ phone_number_id: string | null;
440
+ message_sid: string | null;
441
+ credits_charged: number | null;
442
+ sms_segments: number | null;
443
+ has_attachments: boolean;
444
+ mms_media: unknown[] | null;
445
+ };
446
+ }
447
+ export interface SendSmsPayload {
448
+ to: string;
449
+ body: string;
450
+ phone_number_id?: string;
451
+ media_url?: string[];
452
+ }
453
+ export interface SendSmsResult {
454
+ message_id: string;
455
+ thread_id: string;
456
+ message_sid: string;
457
+ status: string;
458
+ credits_charged: number;
459
+ segments: number;
460
+ }
461
+ export interface SmsConversationListParams {
462
+ phone_number_id?: string;
463
+ limit?: number;
464
+ cursor?: string;
465
+ }
466
+ export interface SmsSearchParams {
467
+ q: string;
468
+ phone_number_id?: string;
469
+ limit?: number;
470
+ }
471
+ export interface SmsListParams {
472
+ phone_number_id?: string;
473
+ limit?: number;
474
+ before?: string;
475
+ after?: string;
476
+ }
477
+ export interface SmsSuppression {
478
+ phone_number: string;
479
+ orgId: string;
480
+ phone_number_id?: string;
481
+ reason?: string;
482
+ created_at?: string;
483
+ }
484
+ export interface CreditBalance {
485
+ included: number;
486
+ purchased: number;
487
+ total: number;
488
+ usedThisCycle: number;
489
+ }
490
+ export interface CreditBundle {
491
+ id: string;
492
+ credits: number;
493
+ price: number;
494
+ price_per_credit: string;
495
+ available?: boolean;
496
+ }
497
+ export interface CreditCheckoutResult {
498
+ checkout_url: string;
499
+ bundle: string;
500
+ credits: number;
501
+ price: number;
502
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "commune-ai",
3
- "version": "0.3.1",
3
+ "version": "0.3.5",
4
4
  "description": "Email infrastructure for agents — set up an inbox and send your first email in 30 seconds. Programmatic inboxes (~1 line), consistent threads, custom domains, attachments, and structured data.",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",