@signalwire/js
Advanced tools
Comparing version 3.28.0-dev.202407111259.a268237.0 to 3.28.0-dev.202407111512.bcc83b9.0
import { type ConversationEventParams } from '@signalwire/core'; | ||
import { HTTPClient } from './HTTPClient'; | ||
import { WSClient } from './WSClient'; | ||
import type { GetMessagesParams, GetConversationsParams, GetConversationMessagesParams, ConversationMessage, SendConversationMessageParams, ConversationChatMessage, GetMessagesResult, GetConversationMessagesResult, SendConversationMessageResult, GetConversationChatMessageParams, GetConversationsResult } from './types'; | ||
declare type Callback = (event: ConversationEventParams) => unknown; | ||
import type { GetMessagesParams, GetConversationsParams, GetConversationMessagesParams, SendConversationMessageParams, GetMessagesResult, GetConversationMessagesResult, SendConversationMessageResult, GetConversationChatMessageParams, GetConversationsResult, CoversationSubscribeCallback, ConversationChatMessagesSubsribeParams, ConversationChatMessagesSubsribeResult, GetConversationChatMessageResult } from './types'; | ||
interface ConversationOptions { | ||
@@ -16,20 +15,9 @@ httpClient: HTTPClient; | ||
constructor(options: ConversationOptions); | ||
sendMessage(options: SendConversationMessageParams): SendConversationMessageResult; | ||
getConversations(options?: GetConversationsParams): GetConversationsResult; | ||
getMessages(options?: GetMessagesParams): GetMessagesResult; | ||
getConversationMessages(options: GetConversationMessagesParams): GetConversationMessagesResult; | ||
getChatMessages({ addressId, pageSize }: GetConversationChatMessageParams): Promise<{ | ||
data: ConversationChatMessage[]; | ||
hasNext: boolean | undefined; | ||
hasPrev: boolean | undefined; | ||
nextPage: () => Promise<import("./types").PaginatedResult<ConversationMessage> | undefined> | undefined; | ||
prevPage: () => Promise<import("./types").PaginatedResult<ConversationMessage> | undefined> | undefined; | ||
}>; | ||
subscribe(callback: Callback): Promise<void>; | ||
subscribeChatMessages({ addressId, onMessage }: { | ||
addressId: string; | ||
onMessage: Callback; | ||
}): Promise<{ | ||
cancel: () => Callback[]; | ||
}>; | ||
sendMessage(options: SendConversationMessageParams): Promise<SendConversationMessageResult>; | ||
getConversations(options?: GetConversationsParams): Promise<GetConversationsResult>; | ||
getMessages(options?: GetMessagesParams): Promise<GetMessagesResult>; | ||
getConversationMessages(options: GetConversationMessagesParams): Promise<GetConversationMessagesResult>; | ||
getChatMessages(params: GetConversationChatMessageParams): Promise<GetConversationChatMessageResult>; | ||
subscribe(callback: CoversationSubscribeCallback): Promise<void>; | ||
subscribeChatMessages(params: ConversationChatMessagesSubsribeParams): Promise<ConversationChatMessagesSubsribeResult>; | ||
/** @internal */ | ||
@@ -36,0 +24,0 @@ handleEvent(event: ConversationEventParams): void; |
import { Conversation } from './Conversation'; | ||
import { ConversationResponse } from './types'; | ||
export interface ConversationAPISendMessageOptions { | ||
text: string; | ||
} | ||
export interface ConversationAPIGetMessagesOptions { | ||
pageSize?: number; | ||
} | ||
import { ConversationAPIGetMessagesParams, ConversationAPISendMessageParams, ConversationResponse } from './types'; | ||
export declare class ConversationAPI { | ||
@@ -18,5 +12,5 @@ private conversation; | ||
constructor(conversation: Conversation, data: ConversationResponse); | ||
sendMessage(options: ConversationAPISendMessageOptions): import("./types").SendConversationMessageResult; | ||
getMessages(options: ConversationAPIGetMessagesOptions | undefined): import("./types").GetConversationMessagesResult; | ||
sendMessage(params: ConversationAPISendMessageParams): Promise<import("./types").SendConversationMessageResponse>; | ||
getMessages(params?: ConversationAPIGetMessagesParams): Promise<import("./types").GetConversationMessagesResult>; | ||
} | ||
//# sourceMappingURL=ConversationAPI.d.ts.map |
import { type UserOptions } from '@signalwire/core'; | ||
import type { GetAddressesParams, SubscriberInfoResponse, RegisterDeviceParams, UnregisterDeviceParams, GetAddressParams, GetAddressResult, GetAddressesResult, RegisterDeviceResult } from './types'; | ||
import type { GetAddressesParams, RegisterDeviceParams, UnregisterDeviceParams, GetAddressParams, GetAddressResult, GetAddressesResult, RegisterDeviceResult, GetSubscriberInfoResponse } from './types'; | ||
import { CreateHttpClient } from './createHttpClient'; | ||
@@ -10,10 +10,10 @@ export declare class HTTPClient { | ||
get httpHost(): string; | ||
getAddress(params: GetAddressParams): GetAddressResult; | ||
getAddresses(params?: GetAddressesParams): GetAddressesResult; | ||
registerDevice(params: RegisterDeviceParams): RegisterDeviceResult; | ||
getAddress(params: GetAddressParams): Promise<GetAddressResult>; | ||
getAddresses(params?: GetAddressesParams): Promise<GetAddressesResult>; | ||
registerDevice(params: RegisterDeviceParams): Promise<RegisterDeviceResult>; | ||
unregisterDevice(params: UnregisterDeviceParams): Promise<{ | ||
body: void; | ||
}>; | ||
getSubscriberInfo(): Promise<SubscriberInfoResponse>; | ||
getSubscriberInfo(): Promise<GetSubscriberInfoResponse>; | ||
} | ||
//# sourceMappingURL=HTTPClient.d.ts.map |
@@ -1,2 +0,2 @@ | ||
import type { UserOptions } from '@signalwire/core'; | ||
import type { ConversationEventParams, UserOptions } from '@signalwire/core'; | ||
import { HTTPClient } from './HTTPClient'; | ||
@@ -124,3 +124,3 @@ import { WSClient } from './WSClient'; | ||
export interface PaginatedResult<T> { | ||
data: Array<T> | []; | ||
data: Array<T>; | ||
self(): Promise<PaginatedResult<T> | undefined>; | ||
@@ -160,6 +160,6 @@ nextPage(): Promise<PaginatedResult<T> | undefined>; | ||
} | ||
export declare type GetAddressResult = Promise<Address>; | ||
export declare type GetAddressResult = Address; | ||
export interface GetAddressesResponse extends PaginatedResponse<Address> { | ||
} | ||
export declare type GetAddressesResult = Promise<PaginatedResult<Address>>; | ||
export declare type GetAddressesResult = PaginatedResult<Address>; | ||
/** | ||
@@ -183,8 +183,4 @@ * Conversations | ||
name: string; | ||
sendMessage(params: { | ||
text: string; | ||
}): Promise<SendConversationMessageResponse>; | ||
getMessages(params: { | ||
pageSize?: number; | ||
}): Promise<PaginatedResult<ConversationMessage>>; | ||
sendMessage(params: ConversationAPISendMessageParams): Promise<SendConversationMessageResponse>; | ||
getMessages(params: ConversationAPIGetMessagesParams): Promise<GetConversationMessagesResult>; | ||
} | ||
@@ -197,6 +193,14 @@ export interface SendConversationMessageResponse { | ||
} | ||
export declare type SendConversationMessageResult = Promise<SendConversationMessageResponse>; | ||
export declare type SendConversationMessageResult = SendConversationMessageResponse; | ||
export interface FetchConversationsResponse extends PaginatedResponse<ConversationResponse> { | ||
} | ||
export declare type GetConversationsResult = Promise<PaginatedResult<ConversationAPI>>; | ||
export declare type GetConversationsResult = PaginatedResult<ConversationAPI>; | ||
export declare type CoversationSubscribeCallback = (event: ConversationEventParams) => unknown; | ||
export interface ConversationChatMessagesSubsribeParams { | ||
addressId: string; | ||
onMessage: CoversationSubscribeCallback; | ||
} | ||
export interface ConversationChatMessagesSubsribeResult { | ||
cancel: () => CoversationSubscribeCallback[]; | ||
} | ||
/** | ||
@@ -219,3 +223,3 @@ * Conversation Messages | ||
} | ||
export declare type GetMessagesResult = Promise<PaginatedResult<ConversationMessage>>; | ||
export declare type GetMessagesResult = PaginatedResult<ConversationMessage>; | ||
export declare type ConversationChatMessage = Omit<ConversationMessage, 'kind'> & { | ||
@@ -228,4 +232,4 @@ text: string; | ||
} | ||
export declare type GetConversationChatMessageResult = Promise<PaginatedResult<ConversationChatMessage>>; | ||
export interface FetchConversationMessagesResponse extends PaginatedResponse<ConversationMessage> { | ||
export declare type GetConversationChatMessageResult = PaginatedResult<ConversationChatMessage>; | ||
export interface GetConversationMessagesResponse extends PaginatedResponse<ConversationMessage> { | ||
} | ||
@@ -236,7 +240,16 @@ export interface GetConversationMessagesParams { | ||
} | ||
export declare type GetConversationMessagesResult = Promise<PaginatedResult<ConversationMessage>>; | ||
export declare type GetConversationMessagesResult = PaginatedResult<ConversationMessage>; | ||
/** | ||
* Conversation API | ||
*/ | ||
export interface ConversationAPISendMessageParams { | ||
text: string; | ||
} | ||
export interface ConversationAPIGetMessagesParams { | ||
pageSize?: number; | ||
} | ||
/** | ||
* Subsriber info | ||
*/ | ||
export interface SubscriberInfoResponse { | ||
export interface GetSubscriberInfoResponse { | ||
id: string; | ||
@@ -258,2 +271,3 @@ email: string; | ||
} | ||
export declare type GetSubscriberInfoResult = GetSubscriberInfoResponse; | ||
/** | ||
@@ -278,4 +292,4 @@ * Device registration | ||
} | ||
export declare type RegisterDeviceResult = Promise<RegisterDeviceResponse>; | ||
export declare type RegisterDeviceResult = RegisterDeviceResponse; | ||
export { CallFabricRoomSession }; | ||
//# sourceMappingURL=types.d.ts.map |
@@ -6,3 +6,3 @@ { | ||
"license": "MIT", | ||
"version": "3.28.0-dev.202407111259.a268237.0", | ||
"version": "3.28.0-dev.202407111512.bcc83b9.0", | ||
"main": "dist/index.js", | ||
@@ -43,4 +43,4 @@ "module": "dist/index.esm.js", | ||
"dependencies": { | ||
"@signalwire/core": "4.2.0-dev.202407111259.a268237.0", | ||
"@signalwire/webrtc": "3.12.2-dev.202407111259.a268237.0", | ||
"@signalwire/core": "4.2.0-dev.202407111512.bcc83b9.0", | ||
"@signalwire/webrtc": "3.12.2-dev.202407111512.bcc83b9.0", | ||
"jwt-decode": "^3.1.2" | ||
@@ -47,0 +47,0 @@ }, |
@@ -9,3 +9,3 @@ import { type ConversationEventParams } from '@signalwire/core' | ||
GetConversationMessagesParams, | ||
FetchConversationMessagesResponse, | ||
GetConversationMessagesResponse, | ||
ConversationMessage, | ||
@@ -20,2 +20,6 @@ SendConversationMessageParams, | ||
GetConversationsResult, | ||
CoversationSubscribeCallback, | ||
ConversationChatMessagesSubsribeParams, | ||
ConversationChatMessagesSubsribeResult, | ||
GetConversationChatMessageResult, | ||
} from './types' | ||
@@ -29,4 +33,2 @@ import { conversationWorker } from './workers' | ||
type Callback = (event: ConversationEventParams) => unknown | ||
interface ConversationOptions { | ||
@@ -40,3 +42,3 @@ httpClient: HTTPClient | ||
private wsClient: WSClient | ||
private callbacks: Callback[] = [ | ||
private callbacks: CoversationSubscribeCallback[] = [ | ||
(event: ConversationEventParams) => { | ||
@@ -50,3 +52,3 @@ if(event.subtype !== 'chat') return | ||
] | ||
private chatSubscriptions: Record<string, Callback[]> = {} | ||
private chatSubscriptions: Record<string, CoversationSubscribeCallback[]> = {} | ||
@@ -67,3 +69,3 @@ constructor(options: ConversationOptions) { | ||
options: SendConversationMessageParams | ||
): SendConversationMessageResult { | ||
): Promise<SendConversationMessageResult> { | ||
try { | ||
@@ -88,3 +90,3 @@ const { addressId, text } = options | ||
options?: GetConversationsParams | ||
): GetConversationsResult { | ||
): Promise<GetConversationsResult> { | ||
try { | ||
@@ -112,3 +114,5 @@ const { pageSize } = options || {} | ||
public async getMessages(options?: GetMessagesParams): GetMessagesResult { | ||
public async getMessages( | ||
options?: GetMessagesParams | ||
): Promise<GetMessagesResult> { | ||
try { | ||
@@ -124,3 +128,3 @@ const { pageSize } = options || {} | ||
const { body } = | ||
await this.httpClient.fetch<FetchConversationMessagesResponse>( | ||
await this.httpClient.fetch<GetConversationMessagesResponse>( | ||
makeQueryParamsUrls(path, queryParams) | ||
@@ -140,3 +144,3 @@ ) | ||
options: GetConversationMessagesParams | ||
): GetConversationMessagesResult { | ||
): Promise<GetConversationMessagesResult> { | ||
try { | ||
@@ -152,3 +156,3 @@ const { addressId, pageSize } = options || {} | ||
const { body } = | ||
await this.httpClient.fetch<FetchConversationMessagesResponse>( | ||
await this.httpClient.fetch<GetConversationMessagesResponse>( | ||
makeQueryParamsUrls(path, queryParams) | ||
@@ -166,3 +170,6 @@ ) | ||
public async getChatMessages({addressId, pageSize = DEFAULT_CHAT_MESSAGES_PAGE_SIZE}: GetConversationChatMessageParams) { | ||
public async getChatMessages( | ||
params: GetConversationChatMessageParams | ||
): Promise<GetConversationChatMessageResult> { | ||
const { addressId, pageSize = DEFAULT_CHAT_MESSAGES_PAGE_SIZE } = params | ||
const chatMessages = [] | ||
@@ -183,10 +190,12 @@ const isValid = (item: ConversationMessage) => (item.conversation_id == addressId && item.subtype == 'chat') | ||
data: chatMessages as ConversationChatMessage[], | ||
hasNext: conversationMessages?.hasNext, | ||
hasPrev: conversationMessages?.hasPrev, | ||
nextPage: () => conversationMessages?.nextPage(), | ||
prevPage: () => conversationMessages?.prevPage() | ||
hasNext: !!conversationMessages?.hasNext, | ||
hasPrev: !!conversationMessages?.hasPrev, | ||
// @ts-expect-error | ||
nextPage: conversationMessages?.nextPage, | ||
// @ts-expect-error | ||
prevPage: conversationMessages?.prevPage, | ||
} | ||
} | ||
public async subscribe(callback: Callback) { | ||
public async subscribe(callback: CoversationSubscribeCallback) { | ||
// Connect the websocket client first | ||
@@ -198,3 +207,7 @@ this.wsClient.connect() | ||
public async subscribeChatMessages({addressId, onMessage}: {addressId: string, onMessage: Callback}) { | ||
public async subscribeChatMessages( | ||
params: ConversationChatMessagesSubsribeParams | ||
): Promise<ConversationChatMessagesSubsribeResult> { | ||
const { addressId, onMessage } = params | ||
// Connect the websocket client first | ||
@@ -201,0 +214,0 @@ await this.wsClient.connect() |
import { Conversation } from './Conversation' | ||
import { ConversationResponse } from './types' | ||
import { | ||
ConversationAPIGetMessagesParams, | ||
ConversationAPISendMessageParams, | ||
ConversationResponse, | ||
} from './types' | ||
export interface ConversationAPISendMessageOptions { | ||
text: string | ||
} | ||
export interface ConversationAPIGetMessagesOptions { | ||
pageSize?: number | ||
} | ||
export class ConversationAPI { | ||
@@ -37,14 +34,15 @@ get id() { | ||
sendMessage(options: ConversationAPISendMessageOptions) { | ||
sendMessage(params: ConversationAPISendMessageParams) { | ||
return this.conversation.sendMessage({ | ||
addressId: this.id, | ||
text: options.text, | ||
text: params.text, | ||
}) | ||
} | ||
getMessages(options: ConversationAPIGetMessagesOptions | undefined) { | ||
getMessages(params?: ConversationAPIGetMessagesParams) { | ||
return this.conversation.getConversationMessages({ | ||
addressId: this.id, | ||
...options, | ||
...params, | ||
}) | ||
} | ||
} |
@@ -7,3 +7,2 @@ import jwtDecode from 'jwt-decode' | ||
GetAddressesParams, | ||
SubscriberInfoResponse, | ||
RegisterDeviceParams, | ||
@@ -17,2 +16,3 @@ UnregisterDeviceParams, | ||
RegisterDeviceResult, | ||
GetSubscriberInfoResponse, | ||
} from './types' | ||
@@ -60,3 +60,3 @@ import { CreateHttpClient, createHttpClient } from './createHttpClient' | ||
public async getAddress(params: GetAddressParams): GetAddressResult { | ||
public async getAddress(params: GetAddressParams): Promise<GetAddressResult> { | ||
const { id } = params | ||
@@ -69,3 +69,5 @@ let path = `/api/fabric/addresses/${id}` | ||
public async getAddresses(params?: GetAddressesParams): GetAddressesResult { | ||
public async getAddresses( | ||
params?: GetAddressesParams | ||
): Promise<GetAddressesResult> { | ||
const { type, displayName, pageSize } = params || {} | ||
@@ -95,3 +97,3 @@ | ||
params: RegisterDeviceParams | ||
): RegisterDeviceResult { | ||
): Promise<RegisterDeviceResult> { | ||
const { deviceType, deviceToken } = params | ||
@@ -123,3 +125,3 @@ | ||
const { body } = await this.httpClient<SubscriberInfoResponse>(path) | ||
const { body } = await this.httpClient<GetSubscriberInfoResponse>(path) | ||
@@ -126,0 +128,0 @@ return body |
@@ -1,2 +0,2 @@ | ||
import type { UserOptions } from '@signalwire/core' | ||
import type { ConversationEventParams, UserOptions } from '@signalwire/core' | ||
import { HTTPClient } from './HTTPClient' | ||
@@ -142,3 +142,3 @@ import { WSClient } from './WSClient' | ||
export interface PaginatedResult<T> { | ||
data: Array<T> | [] | ||
data: Array<T> | ||
self(): Promise<PaginatedResult<T> | undefined> | ||
@@ -183,7 +183,7 @@ nextPage(): Promise<PaginatedResult<T> | undefined> | ||
export type GetAddressResult = Promise<Address> | ||
export type GetAddressResult = Address | ||
export interface GetAddressesResponse extends PaginatedResponse<Address> {} | ||
export type GetAddressesResult = Promise<PaginatedResult<Address>> | ||
export type GetAddressesResult = PaginatedResult<Address> | ||
@@ -210,8 +210,4 @@ /** | ||
name: string | ||
sendMessage(params: { | ||
text: string | ||
}): Promise<SendConversationMessageResponse> | ||
getMessages(params: { | ||
pageSize?: number | ||
}): Promise<PaginatedResult<ConversationMessage>> | ||
sendMessage(params: ConversationAPISendMessageParams): Promise<SendConversationMessageResponse> | ||
getMessages(params: ConversationAPIGetMessagesParams): Promise<GetConversationMessagesResult> | ||
} | ||
@@ -226,4 +222,3 @@ | ||
export type SendConversationMessageResult = | ||
Promise<SendConversationMessageResponse> | ||
export type SendConversationMessageResult = SendConversationMessageResponse | ||
@@ -233,4 +228,17 @@ export interface FetchConversationsResponse | ||
export type GetConversationsResult = Promise<PaginatedResult<ConversationAPI>> | ||
export type GetConversationsResult = PaginatedResult<ConversationAPI> | ||
export type CoversationSubscribeCallback = ( | ||
event: ConversationEventParams | ||
) => unknown | ||
export interface ConversationChatMessagesSubsribeParams { | ||
addressId: string | ||
onMessage: CoversationSubscribeCallback | ||
} | ||
export interface ConversationChatMessagesSubsribeResult { | ||
cancel: () => CoversationSubscribeCallback[] | ||
} | ||
/** | ||
@@ -255,3 +263,3 @@ * Conversation Messages | ||
export type GetMessagesResult = Promise<PaginatedResult<ConversationMessage>> | ||
export type GetMessagesResult = PaginatedResult<ConversationMessage> | ||
@@ -267,7 +275,6 @@ export type ConversationChatMessage = Omit<ConversationMessage, 'kind'> & { | ||
export type GetConversationChatMessageResult = Promise< | ||
export type GetConversationChatMessageResult = | ||
PaginatedResult<ConversationChatMessage> | ||
> | ||
export interface FetchConversationMessagesResponse | ||
export interface GetConversationMessagesResponse | ||
extends PaginatedResponse<ConversationMessage> {} | ||
@@ -280,10 +287,19 @@ | ||
export type GetConversationMessagesResult = Promise< | ||
PaginatedResult<ConversationMessage> | ||
> | ||
export type GetConversationMessagesResult = PaginatedResult<ConversationMessage> | ||
/** | ||
* Conversation API | ||
*/ | ||
export interface ConversationAPISendMessageParams { | ||
text: string | ||
} | ||
export interface ConversationAPIGetMessagesParams { | ||
pageSize?: number | ||
} | ||
/** | ||
* Subsriber info | ||
*/ | ||
export interface SubscriberInfoResponse { | ||
export interface GetSubscriberInfoResponse { | ||
id: string | ||
@@ -306,2 +322,4 @@ email: string | ||
export type GetSubscriberInfoResult = GetSubscriberInfoResponse | ||
/** | ||
@@ -330,4 +348,4 @@ * Device registration | ||
export type RegisterDeviceResult = Promise<RegisterDeviceResponse> | ||
export type RegisterDeviceResult = RegisterDeviceResponse | ||
export { CallFabricRoomSession } |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
3060265
30697
+ Added@signalwire/core@4.2.0-dev.202407111512.bcc83b9.0(transitive)
+ Added@signalwire/webrtc@3.12.2-dev.202407111512.bcc83b9.0(transitive)
- Removed@signalwire/core@4.2.0-dev.202407111259.a268237.0(transitive)
- Removed@signalwire/webrtc@3.12.2-dev.202407111259.a268237.0(transitive)