commune-ai 0.3.2 → 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 +23 -1
- package/dist/client.js +49 -0
- package/dist/index.d.ts +1 -1
- package/dist/types.d.ts +46 -2
- package/package.json +1 -1
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, PhoneNumber, UpdatePhoneNumberPayload, SmsConversation, SmsConversationListParams, SmsMessage, SendSmsPayload, SendSmsResult, SmsSearchParams, CreditBalance, CreditBundle } 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;
|
|
@@ -134,15 +134,37 @@ export declare class CommuneClient {
|
|
|
134
134
|
list: () => Promise<PhoneNumber[]>;
|
|
135
135
|
get: (phoneNumberId: string) => Promise<PhoneNumber>;
|
|
136
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>;
|
|
137
152
|
};
|
|
138
153
|
sms: {
|
|
154
|
+
list: (params?: SmsListParams) => Promise<SmsMessage[]>;
|
|
139
155
|
send: (payload: SendSmsPayload) => Promise<SendSmsResult>;
|
|
140
156
|
conversations: (params?: SmsConversationListParams) => Promise<SmsConversation[]>;
|
|
141
157
|
thread: (remoteNumber: string, phoneNumberId?: string) => Promise<SmsMessage[]>;
|
|
142
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
|
+
}>;
|
|
143
164
|
};
|
|
144
165
|
credits: {
|
|
145
166
|
balance: () => Promise<CreditBalance>;
|
|
146
167
|
bundles: () => Promise<CreditBundle[]>;
|
|
168
|
+
checkout: (bundle: "starter" | "growth" | "scale", returnUrl?: string) => Promise<CreditCheckoutResult>;
|
|
147
169
|
};
|
|
148
170
|
}
|
package/dist/client.js
CHANGED
|
@@ -283,8 +283,42 @@ export class CommuneClient {
|
|
|
283
283
|
update: async (phoneNumberId, payload) => {
|
|
284
284
|
return this.request(`/v1/phone-numbers/${encodeURIComponent(phoneNumberId)}`, { method: 'PATCH', json: payload });
|
|
285
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
|
+
},
|
|
286
312
|
};
|
|
287
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
|
+
},
|
|
288
322
|
send: async (payload) => {
|
|
289
323
|
return this.request('/v1/sms/send', {
|
|
290
324
|
method: 'POST',
|
|
@@ -310,6 +344,12 @@ export class CommuneClient {
|
|
|
310
344
|
limit: params.limit,
|
|
311
345
|
})}`);
|
|
312
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
|
+
},
|
|
313
353
|
};
|
|
314
354
|
this.credits = {
|
|
315
355
|
balance: async () => {
|
|
@@ -318,6 +358,15 @@ export class CommuneClient {
|
|
|
318
358
|
bundles: async () => {
|
|
319
359
|
return this.request('/v1/credits/bundles');
|
|
320
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
|
+
},
|
|
321
370
|
};
|
|
322
371
|
this.baseUrl = (options.baseUrl || DEFAULT_BASE_URL).replace(/\/$/, '');
|
|
323
372
|
this.apiKey = options.apiKey;
|
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, PhoneNumber, UpdatePhoneNumberPayload, SmsConversation, SmsConversationListParams, SmsMessage, SendSmsPayload, SendSmsResult, SmsSearchParams, CreditBalance, CreditBundle, } 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,6 +367,25 @@ 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
|
+
}
|
|
370
389
|
export interface PhoneNumber {
|
|
371
390
|
id: string;
|
|
372
391
|
number: string;
|
|
@@ -386,11 +405,17 @@ export interface PhoneNumber {
|
|
|
386
405
|
createdAt: string;
|
|
387
406
|
updatedAt: string;
|
|
388
407
|
}
|
|
408
|
+
export interface PhoneNumberWebhookPayload {
|
|
409
|
+
endpoint?: string;
|
|
410
|
+
secret?: string;
|
|
411
|
+
events?: string[];
|
|
412
|
+
}
|
|
389
413
|
export interface UpdatePhoneNumberPayload {
|
|
390
414
|
friendlyName?: string;
|
|
391
415
|
autoReply?: string | null;
|
|
392
416
|
allowList?: string[];
|
|
393
417
|
blockList?: string[];
|
|
418
|
+
webhook?: PhoneNumberWebhookPayload;
|
|
394
419
|
}
|
|
395
420
|
export interface SmsConversation {
|
|
396
421
|
thread_id: string;
|
|
@@ -443,6 +468,19 @@ export interface SmsSearchParams {
|
|
|
443
468
|
phone_number_id?: string;
|
|
444
469
|
limit?: number;
|
|
445
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
|
+
}
|
|
446
484
|
export interface CreditBalance {
|
|
447
485
|
included: number;
|
|
448
486
|
purchased: number;
|
|
@@ -453,6 +491,12 @@ export interface CreditBundle {
|
|
|
453
491
|
id: string;
|
|
454
492
|
credits: number;
|
|
455
493
|
price: number;
|
|
456
|
-
|
|
457
|
-
available
|
|
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;
|
|
458
502
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "commune-ai",
|
|
3
|
-
"version": "0.3.
|
|
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",
|