@codingfactory/messenger-client 0.1.0

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.
@@ -0,0 +1,17 @@
1
+ import type { Conversation, ConversationFolder } from '../../types/messaging';
2
+ export interface CreateFolderPayload {
3
+ name: string;
4
+ color?: string;
5
+ icon?: string;
6
+ }
7
+ export type UpdateFolderPayload = Partial<CreateFolderPayload>;
8
+ export declare const messagingApi: {
9
+ fetchFolders(): Promise<ConversationFolder[]>;
10
+ createFolder(data: CreateFolderPayload): Promise<ConversationFolder>;
11
+ updateFolder(id: string, data: UpdateFolderPayload): Promise<ConversationFolder>;
12
+ deleteFolder(id: string): Promise<void>;
13
+ reorderFolders(order: string[]): Promise<void>;
14
+ assignFolder(conversationId: string, folderId: string | null): Promise<Conversation>;
15
+ acceptRequest(conversationId: string): Promise<Conversation>;
16
+ declineRequest(conversationId: string): Promise<void>;
17
+ };
@@ -0,0 +1,17 @@
1
+ export interface MessagingHttpClient {
2
+ get(url: string, config?: Record<string, unknown>): Promise<{
3
+ data: any;
4
+ }>;
5
+ post(url: string, data?: unknown, config?: Record<string, unknown>): Promise<{
6
+ data: any;
7
+ }>;
8
+ patch(url: string, data?: unknown, config?: Record<string, unknown>): Promise<{
9
+ data: any;
10
+ }>;
11
+ delete(url: string, config?: Record<string, unknown>): Promise<{
12
+ data: any;
13
+ }>;
14
+ }
15
+ export declare let api: MessagingHttpClient;
16
+ export declare function setMessagingApiClient(client: MessagingHttpClient): void;
17
+ export declare function resetMessagingApiClient(): void;
@@ -0,0 +1,84 @@
1
+ import type { Message, ReactionSummary } from '../stores/messaging';
2
+ export type ConnectionStatus = 'connecting' | 'connected' | 'disconnected' | 'error';
3
+ export interface EchoChannel {
4
+ listen(event: string, callback: (payload: unknown) => void): unknown;
5
+ stopListening?(event: string, callback?: (payload: unknown) => void): unknown;
6
+ }
7
+ export interface EchoClient {
8
+ private(channel: string): EchoChannel;
9
+ leave(channel: string): void;
10
+ }
11
+ export interface MessageSentEvent {
12
+ conversation_id: string;
13
+ author_id?: string;
14
+ message: Message;
15
+ }
16
+ export interface MessageReadEvent {
17
+ conversation_id: string;
18
+ user_id: string;
19
+ message_id: string;
20
+ read_at?: string | null;
21
+ }
22
+ export interface MessageEditedEvent {
23
+ conversation_id: string;
24
+ message: {
25
+ id: string;
26
+ body?: string;
27
+ edited_at?: string | null;
28
+ meta?: Record<string, unknown>;
29
+ };
30
+ }
31
+ export interface MessageDeletedEvent {
32
+ conversation_id: string;
33
+ message_id: string;
34
+ }
35
+ export interface ReactionToggledEvent {
36
+ conversation_id: string;
37
+ message_id: string;
38
+ reactions: ReactionSummary[];
39
+ }
40
+ export interface RequestAcceptedEvent {
41
+ conversation_id: string;
42
+ }
43
+ export interface ParticipantRemovedEvent {
44
+ conversation_id: string;
45
+ removed_user_id: string;
46
+ }
47
+ export interface PresenceStatusChangedEvent {
48
+ user_id: string;
49
+ tenant_id?: string | null;
50
+ tenant_scope?: string;
51
+ status: 'online' | 'idle' | 'dnd' | 'offline';
52
+ last_seen_at?: string | null;
53
+ ts?: string;
54
+ }
55
+ export interface ConversationSubscriptionCallbacks {
56
+ onMessageSent?(payload: MessageSentEvent): void;
57
+ onMessageRead?(payload: MessageReadEvent): void;
58
+ onMessageEdited?(payload: MessageEditedEvent): void;
59
+ onMessageDeleted?(payload: MessageDeletedEvent): void;
60
+ onReactionToggled?(payload: ReactionToggledEvent): void;
61
+ onRequestAccepted?(payload: RequestAcceptedEvent): void;
62
+ onParticipantRemoved?(payload: ParticipantRemovedEvent): void;
63
+ }
64
+ export interface EchoRuntimeConfig {
65
+ initializedEvent?: string;
66
+ getEcho?: () => EchoClient | null;
67
+ onConnectionStatusChange?: (callback: (status: ConnectionStatus) => void) => () => void;
68
+ subscribeToPresenceStatus?: (callback: (event: PresenceStatusChangedEvent) => void) => void;
69
+ unsubscribeFromPresenceStatus?: () => void;
70
+ subscribeToConversation?: (conversationId: string, callbacks: ConversationSubscriptionCallbacks) => () => void;
71
+ unsubscribeFromConversation?: (conversationId: string) => void;
72
+ }
73
+ export declare let ECHO_INITIALIZED_EVENT: string;
74
+ export declare let getEcho: () => EchoClient | null;
75
+ export declare let onConnectionStatusChange: (callback: (status: ConnectionStatus) => void) => () => void;
76
+ export declare let subscribeToPresenceStatus: (callback: (event: PresenceStatusChangedEvent) => void) => void;
77
+ export declare let unsubscribeFromPresenceStatus: () => void;
78
+ export declare let subscribeToConversation: (conversationId: string, callbacks: ConversationSubscriptionCallbacks) => () => void;
79
+ export declare let unsubscribeFromConversation: (conversationId: string) => void;
80
+ export declare function setEchoRuntimeConfig(config: EchoRuntimeConfig): void;
81
+ export declare function resetEchoRuntimeConfig(): void;
82
+ export declare function isValidMessageSentEvent(data: unknown): data is MessageSentEvent;
83
+ export declare function isValidMessageReadEvent(data: unknown): data is MessageReadEvent;
84
+ export declare function isValidRequestAcceptedEvent(data: unknown): data is RequestAcceptedEvent;
@@ -0,0 +1,11 @@
1
+ export interface UploadedMedia {
2
+ id: string;
3
+ mime_type?: string;
4
+ size?: number;
5
+ }
6
+ export interface MessagingMediaApi {
7
+ uploadImage(file: File): Promise<UploadedMedia>;
8
+ }
9
+ export declare let mediaApi: MessagingMediaApi;
10
+ export declare function setMessagingMediaApi(client: MessagingMediaApi): void;
11
+ export declare function resetMessagingMediaApi(): void;
@@ -0,0 +1,13 @@
1
+ export interface MessagingCurrentUser {
2
+ id: string;
3
+ name: string;
4
+ avatar?: string;
5
+ handle?: string;
6
+ }
7
+ export interface MessagingAuthStore {
8
+ currentUser: MessagingCurrentUser | null;
9
+ }
10
+ export type UseMessagingAuthStore = () => MessagingAuthStore;
11
+ export declare let useAuthStore: UseMessagingAuthStore;
12
+ export declare function setMessagingAuthStoreResolver(resolver: UseMessagingAuthStore): void;
13
+ export declare function resetMessagingAuthStoreResolver(): void;