diff --git a/js-chat/package_template.json b/js-chat/package_template.json index 0337781b..f9d8e9bb 100644 --- a/js-chat/package_template.json +++ b/js-chat/package_template.json @@ -26,7 +26,6 @@ "@rollup/plugin-terser": "^0.4.3", "@rollup/plugin-commonjs": "28.0.1", "@types/jest": "29.5.0", - "@types/pubnub": "7.4.2", "babel-jest": "29.5.0", "dotenv": "16.0.3", "jest": "29.5.0", diff --git a/src/jsMain/resources/index.d.ts b/src/jsMain/resources/index.d.ts index 27ea9eb1..e697272e 100644 --- a/src/jsMain/resources/index.d.ts +++ b/src/jsMain/resources/index.d.ts @@ -1,16 +1,16 @@ /// import PubNub from "pubnub"; -import { GetMembershipsParametersv2, GetChannelMembersParameters, ObjectCustom, SetMembershipsParameters, ChannelMetadataObject, PublishParameters, SendFileParameters } from "pubnub"; +import { AppContext, Publish, FileSharing, Signal, Subscription, History } from "pubnub"; type MembershipFields = Pick; declare class Membership { private chat; readonly channel: Channel; readonly user: User; - readonly custom: ObjectCustom | null | undefined; + readonly custom: AppContext.CustomData | null | undefined; readonly updated: string; readonly eTag: string; update({ custom }: { - custom: ObjectCustom; + custom: AppContext.CustomData; }): Promise; /* * Updates @@ -33,7 +33,7 @@ declare class User { readonly externalId?: string; readonly profileUrl?: string; readonly email?: string; - readonly custom?: ObjectCustom; + readonly custom?: AppContext.CustomData; readonly status?: string; readonly type?: string; readonly updated?: string; @@ -57,7 +57,7 @@ declare class User { /* * Memberships */ - getMemberships(params?: Omit): Promise<{ + getMemberships(params?: Omit): Promise<{ page: { next: string | undefined; prev: string | undefined; @@ -79,7 +79,7 @@ declare class User { mute: boolean; reason: string | number | boolean | undefined; }>; - getChannelsRestrictions(params?: Pick): Promise<{ + getChannelsRestrictions(params?: Pick): Promise<{ page: { next: string | undefined; prev: string | undefined; @@ -97,7 +97,7 @@ declare class User { * Other */ /** @deprecated */ - DEPRECATED_report(reason: string): Promise; + DEPRECATED_report(reason: string): Promise; } type EventFields = Pick, "timetoken" | "type" | "payload" | "channelId" | "userId">; declare class Event { @@ -241,26 +241,26 @@ type MessageReferencedChannels = { name: string; }; }; -type MessageDraftOptions = Omit; -type SendTextOptionParams = Omit & { +type MessageDraftOptions = Omit; +type SendTextOptionParams = Omit & { mentionedUsers?: MessageMentionedUsers; referencedChannels?: MessageReferencedChannels; textLinks?: TextLink[]; quotedMessage?: Message; - files?: FileList | File[] | SendFileParameters["file"][]; + files?: FileList | File[] | FileSharing.SendFileParameters["file"][]; }; -type EnhancedMessageEvent = PubNub.MessageEvent & { +type EnhancedMessageEvent = Subscription.MessageEvent & { userMetadata?: { [key: string]: any; }; }; -type MessageDTOParams = PubNub.FetchMessagesResponse["channels"]["channel"][0] | EnhancedMessageEvent; +type MessageDTOParams = History.FetchMessagesResponse["channels"]["channel"][0] | EnhancedMessageEvent; type ThreadMessageDTOParams = MessageDTOParams & { parentChannelId: string; }; type MembershipResponse = Awaited>; type OptionalAllBut = Partial & Pick; -type ChannelDTOParams = OptionalAllBut, "id"> & { +type ChannelDTOParams = OptionalAllBut, "id"> & { status?: string | null; type?: ChannelType | null | string; }; @@ -394,11 +394,11 @@ declare class Message { /* * Other */ - forward(channelId: string): Promise; + forward(channelId: string): Promise; pin(): Promise; /** @deprecated */ - DEPRECATED_report(reason: string): Promise; - report(reason: string): Promise; + DEPRECATED_report(reason: string): Promise; + report(reason: string): Promise; /** * Threads */ @@ -427,13 +427,13 @@ export declare class MessageDraftV2 { get value(): string; quotedMessage: Message | undefined; readonly config: MessageDraftConfig; - files?: FileList | File[] | SendFileParameters["file"][]; + files?: FileList | File[] | FileSharing.SendFileParameters["file"][]; addQuote(message: Message): void; removeQuote(): void; addLinkedText(params: AddLinkedTextParams): void; removeLinkedText(positionInInput: number): void; getMessagePreview(): MixedTextTypedElement[]; - send(params?: MessageDraftOptions): Promise; + send(params?: MessageDraftOptions): Promise; addChangeListener(listener: (p0: MessageDraftState) => void): void; removeChangeListener(listener: (p0: MessageDraftState) => void): void; insertText(offset: number, text: string): void; @@ -463,7 +463,7 @@ declare class MessageDraft { value: string; quotedMessage: Message | undefined; readonly config: MessageDraftConfig; - files?: FileList | File[] | SendFileParameters["file"][]; + files?: FileList | File[] | FileSharing.SendFileParameters["file"][]; onChange(text: string): Promise<{ users: { nameOccurrenceIndex: number; @@ -497,7 +497,7 @@ declare class Channel { protected chat: Chat; readonly id: string; readonly name?: string; - readonly custom?: ObjectCustom; + readonly custom?: AppContext.CustomData; readonly description?: string; readonly updated?: string; readonly status?: string; @@ -513,9 +513,9 @@ declare class Channel { static streamUpdatesOn(channels: Channel[], callback: (channels: Channel[]) => unknown): () => void; streamUpdates(callback: (channel: Channel) => unknown): () => void; sendText(text: string, options?: SendTextOptionParams): Promise; - forwardMessage(message: Message): Promise; - startTyping(): Promise; - stopTyping(): Promise; + forwardMessage(message: Message): Promise; + startTyping(): Promise; + stopTyping(): Promise; getTyping(callback: (typingUserIds: string[]) => unknown): () => void; /* * Streaming messages @@ -539,14 +539,14 @@ declare class Channel { isMore: boolean; }>; getMessage(timetoken: string): Promise; - join(callback: (message: Message) => void, params?: Omit, "channels" | "include" | "filter"> & { - custom?: ObjectCustom; + join(callback: (message: Message) => void, params?: Omit, "channels" | "include" | "filter"> & { + custom?: AppContext.CustomData; }): Promise<{ membership: Membership; disconnect: () => void; }>; leave(): Promise; - getMembers(params?: Omit): Promise<{ + getMembers(params?: Omit): Promise<{ page: { next: string | undefined; prev: string | undefined; @@ -570,7 +570,7 @@ declare class Channel { streamReadReceipts(callback: (receipts: { [key: string]: string[]; }) => unknown): Promise<() => void>; - getFiles(params?: Omit): Promise<{ + getFiles(params?: Omit): Promise<{ files: { name: string; id: string; @@ -582,7 +582,7 @@ declare class Channel { deleteFile(params: { id: string; name: string; - }): Promise; + }): Promise; /** * Moderation restrictions */ @@ -596,7 +596,7 @@ declare class Channel { mute: boolean; reason: string | number | boolean | undefined; }>; - getUsersRestrictions(params?: Pick): Promise<{ + getUsersRestrictions(params?: Pick): Promise<{ page: { next: string | undefined; prev: string | undefined; @@ -649,13 +649,13 @@ type ChatConfig = { }; authKey?: string; }; -type ChatConstructor = Partial & PubNub.PubnubConfig; +type ChatConstructor = Partial & PubNub.PubNubConfiguration; declare class Chat { readonly sdk: PubNub; readonly config: ChatConfig; private user; static init(params: ChatConstructor): Promise; - emitEvent(event: EmitEventParams): Promise; + emitEvent(event: EmitEventParams): Promise; listenForEvents(event: GenericEventParams & { callback: (event: Event) => unknown; }): () => void; @@ -679,7 +679,7 @@ declare class Chat { createUser(id: string, data: Omit): Promise; updateUser(id: string, data: Omit): Promise; deleteUser(id: string, params?: DeleteParameters): Promise; - getUsers(params?: Omit): Promise<{ + getUsers(params?: Omit>, "include">): Promise<{ users: User[]; page: { next: string | undefined; @@ -692,7 +692,7 @@ declare class Chat { */ getChannel(id: string): Promise; updateChannel(id: string, data: Omit): Promise; - getChannels(params?: Omit): Promise<{ + getChannels(params?: Omit>, "include">): Promise<{ channels: Channel[]; page: { next: string | undefined; @@ -706,7 +706,7 @@ declare class Chat { */ createPublicConversation({ channelId, channelData }?: { channelId?: string; - channelData?: PubNub.ChannelMetadata; + channelData?: AppContext.SetChannelMetadataParameters; }): Promise; /** * Presence @@ -717,9 +717,9 @@ declare class Chat { createDirectConversation({ user, channelId, channelData, membershipData }: { user: User; channelId?: string; - channelData?: PubNub.ChannelMetadata; - membershipData?: Omit, "channels" | "include" | "filter"> & { - custom?: PubNub.ObjectCustom; + channelData?: AppContext.SetChannelMetadataParameters; + membershipData?: Omit, "channels" | "include" | "filter"> & { + custom?: AppContext.CustomData; }; }): Promise<{ channel: Channel; @@ -729,9 +729,9 @@ declare class Chat { createGroupConversation({ users, channelId, channelData, membershipData }: { users: User[]; channelId?: string; - channelData?: PubNub.ChannelMetadata; - membershipData?: Omit, "channels" | "include" | "filter"> & { - custom?: PubNub.ObjectCustom; + channelData?: AppContext.SetChannelMetadataParameters; + membershipData?: Omit, "channels" | "include" | "filter"> & { + custom?: AppContext.CustomData; }; }): Promise<{ channel: Channel; @@ -757,12 +757,12 @@ declare class Chat { enhancedMentionsData: UserMentionData[]; isMore: boolean; }>; - getUnreadMessagesCounts(params?: Omit): Promise<{ + getUnreadMessagesCounts(params?: Omit): Promise<{ channel: Channel; membership: Membership; count: number; }[]>; - markAllMessagesAsRead(params?: Omit): Promise<{ + markAllMessagesAsRead(params?: Omit): Promise<{ page: { next: string | undefined; prev: string | undefined;