commune-ai 0.3.1 → 0.3.2

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, SmsConversation, SmsConversationListParams, SmsMessage, SendSmsPayload, SendSmsResult, SmsSearchParams, CreditBalance, CreditBundle } from './types.js';
2
2
  export type ClientOptions = {
3
3
  baseUrl?: string;
4
4
  apiKey: string;
@@ -130,4 +130,19 @@ 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
+ };
138
+ sms: {
139
+ send: (payload: SendSmsPayload) => Promise<SendSmsResult>;
140
+ conversations: (params?: SmsConversationListParams) => Promise<SmsConversation[]>;
141
+ thread: (remoteNumber: string, phoneNumberId?: string) => Promise<SmsMessage[]>;
142
+ search: (params: SmsSearchParams) => Promise<SmsMessage[]>;
143
+ };
144
+ credits: {
145
+ balance: () => Promise<CreditBalance>;
146
+ bundles: () => Promise<CreditBundle[]>;
147
+ };
133
148
  }
package/dist/client.js CHANGED
@@ -273,6 +273,52 @@ 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
+ };
287
+ this.sms = {
288
+ send: async (payload) => {
289
+ return this.request('/v1/sms/send', {
290
+ method: 'POST',
291
+ json: payload,
292
+ });
293
+ },
294
+ conversations: async (params = {}) => {
295
+ return this.request(`/v1/sms/conversations${buildQuery({
296
+ phone_number_id: params.phone_number_id,
297
+ limit: params.limit,
298
+ cursor: params.cursor,
299
+ })}`);
300
+ },
301
+ thread: async (remoteNumber, phoneNumberId) => {
302
+ return this.request(`/v1/sms/conversations/${encodeURIComponent(remoteNumber)}${buildQuery({
303
+ phone_number_id: phoneNumberId,
304
+ })}`);
305
+ },
306
+ search: async (params) => {
307
+ return this.request(`/v1/sms/search${buildQuery({
308
+ q: params.q,
309
+ phone_number_id: params.phone_number_id,
310
+ limit: params.limit,
311
+ })}`);
312
+ },
313
+ };
314
+ this.credits = {
315
+ balance: async () => {
316
+ return this.request('/v1/credits');
317
+ },
318
+ bundles: async () => {
319
+ return this.request('/v1/credits/bundles');
320
+ },
321
+ };
276
322
  this.baseUrl = (options.baseUrl || DEFAULT_BASE_URL).replace(/\/$/, '');
277
323
  this.apiKey = options.apiKey;
278
324
  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, SmsConversation, SmsConversationListParams, SmsMessage, SendSmsPayload, SendSmsResult, SmsSearchParams, CreditBalance, CreditBundle, } 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,92 @@ export interface DeliverySuppressionsParams {
367
367
  domainId?: string;
368
368
  limit?: number;
369
369
  }
370
+ export interface PhoneNumber {
371
+ id: string;
372
+ number: string;
373
+ numberType: 'tollfree' | 'local' | 'shortcode';
374
+ friendlyName: string | null;
375
+ country: string;
376
+ capabilities: {
377
+ sms: boolean;
378
+ mms: boolean;
379
+ voice: boolean;
380
+ };
381
+ status: 'active' | 'released' | 'suspended_non_payment';
382
+ allowList: string[];
383
+ blockList: string[];
384
+ creditCostPerMonth: number;
385
+ autoReply: string | null;
386
+ createdAt: string;
387
+ updatedAt: string;
388
+ }
389
+ export interface UpdatePhoneNumberPayload {
390
+ friendlyName?: string;
391
+ autoReply?: string | null;
392
+ allowList?: string[];
393
+ blockList?: string[];
394
+ }
395
+ export interface SmsConversation {
396
+ thread_id: string;
397
+ remote_number: string;
398
+ phone_number_id: string;
399
+ last_message_at: string;
400
+ last_message_preview: string | null;
401
+ message_count: number;
402
+ unread_count: number;
403
+ }
404
+ export interface SmsMessage {
405
+ message_id: string;
406
+ thread_id: string;
407
+ direction: 'inbound' | 'outbound';
408
+ content: string | null;
409
+ created_at: string;
410
+ metadata: {
411
+ delivery_status: string | null;
412
+ from_number: string | null;
413
+ to_number: string | null;
414
+ phone_number_id: string | null;
415
+ message_sid: string | null;
416
+ credits_charged: number | null;
417
+ sms_segments: number | null;
418
+ has_attachments: boolean;
419
+ mms_media: unknown[] | null;
420
+ };
421
+ }
422
+ export interface SendSmsPayload {
423
+ to: string;
424
+ body: string;
425
+ phone_number_id?: string;
426
+ media_url?: string[];
427
+ }
428
+ export interface SendSmsResult {
429
+ message_id: string;
430
+ thread_id: string;
431
+ message_sid: string;
432
+ status: string;
433
+ credits_charged: number;
434
+ segments: number;
435
+ }
436
+ export interface SmsConversationListParams {
437
+ phone_number_id?: string;
438
+ limit?: number;
439
+ cursor?: string;
440
+ }
441
+ export interface SmsSearchParams {
442
+ q: string;
443
+ phone_number_id?: string;
444
+ limit?: number;
445
+ }
446
+ export interface CreditBalance {
447
+ included: number;
448
+ purchased: number;
449
+ total: number;
450
+ usedThisCycle: number;
451
+ }
452
+ export interface CreditBundle {
453
+ id: string;
454
+ credits: number;
455
+ price: number;
456
+ pricePerCredit: string;
457
+ available: boolean;
458
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "commune-ai",
3
- "version": "0.3.1",
3
+ "version": "0.3.2",
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",