@solveo-ai/react-native 0.1.0 → 0.1.1

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/README.md CHANGED
@@ -47,6 +47,26 @@ function ChatScreen() {
47
47
  }
48
48
  ```
49
49
 
50
+ ## Development
51
+
52
+ From the repo root (monorepo), install and build:
53
+
54
+ ```bash
55
+ # From platform root
56
+ npm install
57
+ npm run build --workspace=@solveo-ai/react-native
58
+ ```
59
+
60
+ Or from this package:
61
+
62
+ ```bash
63
+ cd sdks/react-native
64
+ npm install
65
+ npm run build
66
+ ```
67
+
68
+ This produces `dist/index.js`, `dist/index.mjs`, and `dist/index.d.ts`. Type declarations are included; `prepublishOnly` runs the build before publishing so published packages include `dist` and types.
69
+
50
70
  ## Documentation
51
71
 
52
72
  See [full documentation](https://docs.solveoai.io/sdk/react-native).
@@ -0,0 +1,182 @@
1
+ import React, { ReactNode } from 'react';
2
+ import { SolveoClientConfig, SolveoSDK, Socket, CustomerSocketManager, AgentSocketManager, StreamingSocket, Conversation, Message, HumanAgent, Widget, WidgetConfig, Device, MessageAttachment, Agent, AgentCreateRequest, AgentUpdateRequest, ConversationMetrics, SentimentDistribution, FeedbackStats, TokenUsageMetrics } from '@solveo-ai/sdk-core';
3
+ export { Agent, Conversation, ConversationStatus, FeedbackType, Message, MessageAttachment, SentimentType, Widget } from '@solveo-ai/sdk-core';
4
+
5
+ interface SolveoContextValue {
6
+ sdk: SolveoSDK;
7
+ config: SolveoProviderConfig;
8
+ customerSocket: Socket | null;
9
+ customerSocketManager: CustomerSocketManager | null;
10
+ agentSocket: Socket | null;
11
+ agentSocketManager: AgentSocketManager | null;
12
+ streamingSocket: StreamingSocket | null;
13
+ connectCustomerSocket: (conversationId: string) => void;
14
+ disconnectCustomerSocket: () => void;
15
+ connectAgentSocket: (token: string) => void;
16
+ disconnectAgentSocket: () => void;
17
+ connectStreamingSocket: (conversationId: string) => void;
18
+ disconnectStreamingSocket: () => void;
19
+ }
20
+ interface SolveoProviderConfig extends Omit<SolveoClientConfig, 'platform'> {
21
+ user?: {
22
+ email?: string;
23
+ name?: string;
24
+ id?: string;
25
+ };
26
+ autoConnectCustomer?: boolean;
27
+ autoConnectAgent?: boolean;
28
+ conversationId?: string;
29
+ onError?: (error: Error) => void;
30
+ }
31
+ interface SolveoProviderProps {
32
+ children: ReactNode;
33
+ config: SolveoProviderConfig;
34
+ }
35
+ declare function SolveoProvider({ children, config }: SolveoProviderProps): React.JSX.Element;
36
+ declare function useSolveo(): SolveoContextValue;
37
+
38
+ interface UseChatOptions {
39
+ widgetId?: string;
40
+ agentId?: string;
41
+ persistConversation?: boolean;
42
+ }
43
+ declare function useChat(options?: UseChatOptions): {
44
+ conversation: Conversation | null;
45
+ messages: Message[];
46
+ isLoading: boolean;
47
+ isStreaming: boolean;
48
+ streamingContent: string;
49
+ error: Error | null;
50
+ createConversation: () => Promise<Conversation>;
51
+ sendMessage: (content: string) => Promise<void>;
52
+ loadMessages: (conversationId: string) => Promise<void>;
53
+ submitFeedback: (messageId: string, rating: "THUMBS_UP" | "THUMBS_DOWN") => Promise<void>;
54
+ };
55
+
56
+ declare function useRealtime(): {
57
+ isConnected: boolean;
58
+ agentTyping: boolean;
59
+ queuePosition: number | null;
60
+ estimatedWait: number | null;
61
+ };
62
+
63
+ declare function useEscalation(): {
64
+ escalationId: string | null;
65
+ assignedAgent: HumanAgent | null;
66
+ status: "idle" | "requesting" | "queued" | "active" | "resolved";
67
+ requestHuman: (conversationId: string) => void;
68
+ endChat: () => void;
69
+ submitCSAT: (rating: number) => void;
70
+ };
71
+
72
+ declare function useWidgetConfig(widgetId?: string): {
73
+ widget: Widget | null;
74
+ widgetConfig: WidgetConfig | null;
75
+ isLoading: boolean;
76
+ error: Error | null;
77
+ reload: () => Promise<void>;
78
+ };
79
+
80
+ /**
81
+ * Push notification event handlers
82
+ */
83
+ interface PushNotificationHandlers {
84
+ onNotificationReceived?: (notification: any) => void;
85
+ onNotificationTapped?: (notification: any) => void;
86
+ }
87
+ /**
88
+ * Hook options
89
+ */
90
+ interface UsePushNotificationsOptions {
91
+ mode?: 'widget' | 'agent';
92
+ conversationId?: string;
93
+ autoRegister?: boolean;
94
+ handlers?: PushNotificationHandlers;
95
+ }
96
+ /**
97
+ * Enhanced Push Notifications Hook for React Native
98
+ *
99
+ * Supports both customer (widget) and agent (dashboard) modes.
100
+ * Handles permissions, registration, and notification events.
101
+ *
102
+ * SETUP INSTRUCTIONS:
103
+ * 1. Install peer dependencies:
104
+ * npm install @react-native-firebase/app @react-native-firebase/messaging
105
+ * (or expo-notifications for Expo projects)
106
+ *
107
+ * 2. Configure Firebase/APNs:
108
+ * - Android: Add google-services.json to android/app/
109
+ * - iOS: Add GoogleService-Info.plist to ios/ and configure APNs
110
+ *
111
+ * 3. Add permissions to manifests:
112
+ * - Android: INTERNET, VIBRATE, RECEIVE_BOOT_COMPLETED
113
+ * - iOS: User Notifications capability
114
+ */
115
+ declare function usePushNotifications(options?: UsePushNotificationsOptions): {
116
+ requestPermission: () => Promise<boolean>;
117
+ registerDevice: (convId?: string, pushToken?: string, bundleId?: string) => Promise<Device | null>;
118
+ registerAgentDevice: (pushToken?: string, deviceName?: string) => Promise<any>;
119
+ unregisterDevice: () => Promise<void>;
120
+ device: Device | null;
121
+ isRegistered: boolean;
122
+ isInitialized: boolean;
123
+ permissionStatus: "granted" | "denied" | "undetermined";
124
+ };
125
+
126
+ declare function useAttachments(conversationId?: string): {
127
+ uploading: boolean;
128
+ uploadProgress: number;
129
+ uploadAttachment: (file: {
130
+ uri: string;
131
+ type?: string;
132
+ name?: string;
133
+ }, attachmentType: "IMAGE" | "AUDIO" | "VIDEO" | "DOCUMENT" | "VOICE_NOTE") => Promise<MessageAttachment>;
134
+ };
135
+
136
+ declare function useAgents(accountId?: string): {
137
+ agents: Agent[];
138
+ isLoading: boolean;
139
+ error: Error | null;
140
+ createAgent: (data: AgentCreateRequest) => Promise<Agent>;
141
+ updateAgent: (id: string, data: AgentUpdateRequest) => Promise<Agent>;
142
+ deleteAgent: (id: string) => Promise<void>;
143
+ reload: () => Promise<void>;
144
+ };
145
+
146
+ declare function useConversations(accountId?: string): {
147
+ conversations: Conversation[];
148
+ isLoading: boolean;
149
+ error: Error | null;
150
+ resolveConversation: (id: string) => Promise<void>;
151
+ reload: () => Promise<void>;
152
+ };
153
+
154
+ declare function useAnalytics(accountId?: string, days?: number): {
155
+ metrics: ConversationMetrics | null;
156
+ sentiment: SentimentDistribution | null;
157
+ feedback: FeedbackStats | null;
158
+ tokenUsage: TokenUsageMetrics | null;
159
+ isLoading: boolean;
160
+ error: Error | null;
161
+ reload: () => Promise<void>;
162
+ };
163
+
164
+ declare const storage: {
165
+ getConversationId(): Promise<string | null>;
166
+ setConversationId(id: string): Promise<void>;
167
+ clearConversationId(): Promise<void>;
168
+ getMessages(conversationId: string): Promise<any[]>;
169
+ setMessages(conversationId: string, messages: any[]): Promise<void>;
170
+ getUserIdentity(): Promise<{
171
+ email?: string;
172
+ name?: string;
173
+ } | null>;
174
+ setUserIdentity(identity: {
175
+ email?: string;
176
+ name?: string;
177
+ }): Promise<void>;
178
+ getWidgetConfig(widgetId: string): Promise<any | null>;
179
+ setWidgetConfig(widgetId: string, config: any): Promise<void>;
180
+ };
181
+
182
+ export { SolveoProvider, type SolveoProviderConfig, type SolveoProviderProps, storage, useAgents, useAnalytics, useAttachments, useChat, useConversations, useEscalation, usePushNotifications, useRealtime, useSolveo, useWidgetConfig };
@@ -0,0 +1,182 @@
1
+ import React, { ReactNode } from 'react';
2
+ import { SolveoClientConfig, SolveoSDK, Socket, CustomerSocketManager, AgentSocketManager, StreamingSocket, Conversation, Message, HumanAgent, Widget, WidgetConfig, Device, MessageAttachment, Agent, AgentCreateRequest, AgentUpdateRequest, ConversationMetrics, SentimentDistribution, FeedbackStats, TokenUsageMetrics } from '@solveo-ai/sdk-core';
3
+ export { Agent, Conversation, ConversationStatus, FeedbackType, Message, MessageAttachment, SentimentType, Widget } from '@solveo-ai/sdk-core';
4
+
5
+ interface SolveoContextValue {
6
+ sdk: SolveoSDK;
7
+ config: SolveoProviderConfig;
8
+ customerSocket: Socket | null;
9
+ customerSocketManager: CustomerSocketManager | null;
10
+ agentSocket: Socket | null;
11
+ agentSocketManager: AgentSocketManager | null;
12
+ streamingSocket: StreamingSocket | null;
13
+ connectCustomerSocket: (conversationId: string) => void;
14
+ disconnectCustomerSocket: () => void;
15
+ connectAgentSocket: (token: string) => void;
16
+ disconnectAgentSocket: () => void;
17
+ connectStreamingSocket: (conversationId: string) => void;
18
+ disconnectStreamingSocket: () => void;
19
+ }
20
+ interface SolveoProviderConfig extends Omit<SolveoClientConfig, 'platform'> {
21
+ user?: {
22
+ email?: string;
23
+ name?: string;
24
+ id?: string;
25
+ };
26
+ autoConnectCustomer?: boolean;
27
+ autoConnectAgent?: boolean;
28
+ conversationId?: string;
29
+ onError?: (error: Error) => void;
30
+ }
31
+ interface SolveoProviderProps {
32
+ children: ReactNode;
33
+ config: SolveoProviderConfig;
34
+ }
35
+ declare function SolveoProvider({ children, config }: SolveoProviderProps): React.JSX.Element;
36
+ declare function useSolveo(): SolveoContextValue;
37
+
38
+ interface UseChatOptions {
39
+ widgetId?: string;
40
+ agentId?: string;
41
+ persistConversation?: boolean;
42
+ }
43
+ declare function useChat(options?: UseChatOptions): {
44
+ conversation: Conversation | null;
45
+ messages: Message[];
46
+ isLoading: boolean;
47
+ isStreaming: boolean;
48
+ streamingContent: string;
49
+ error: Error | null;
50
+ createConversation: () => Promise<Conversation>;
51
+ sendMessage: (content: string) => Promise<void>;
52
+ loadMessages: (conversationId: string) => Promise<void>;
53
+ submitFeedback: (messageId: string, rating: "THUMBS_UP" | "THUMBS_DOWN") => Promise<void>;
54
+ };
55
+
56
+ declare function useRealtime(): {
57
+ isConnected: boolean;
58
+ agentTyping: boolean;
59
+ queuePosition: number | null;
60
+ estimatedWait: number | null;
61
+ };
62
+
63
+ declare function useEscalation(): {
64
+ escalationId: string | null;
65
+ assignedAgent: HumanAgent | null;
66
+ status: "idle" | "requesting" | "queued" | "active" | "resolved";
67
+ requestHuman: (conversationId: string) => void;
68
+ endChat: () => void;
69
+ submitCSAT: (rating: number) => void;
70
+ };
71
+
72
+ declare function useWidgetConfig(widgetId?: string): {
73
+ widget: Widget | null;
74
+ widgetConfig: WidgetConfig | null;
75
+ isLoading: boolean;
76
+ error: Error | null;
77
+ reload: () => Promise<void>;
78
+ };
79
+
80
+ /**
81
+ * Push notification event handlers
82
+ */
83
+ interface PushNotificationHandlers {
84
+ onNotificationReceived?: (notification: any) => void;
85
+ onNotificationTapped?: (notification: any) => void;
86
+ }
87
+ /**
88
+ * Hook options
89
+ */
90
+ interface UsePushNotificationsOptions {
91
+ mode?: 'widget' | 'agent';
92
+ conversationId?: string;
93
+ autoRegister?: boolean;
94
+ handlers?: PushNotificationHandlers;
95
+ }
96
+ /**
97
+ * Enhanced Push Notifications Hook for React Native
98
+ *
99
+ * Supports both customer (widget) and agent (dashboard) modes.
100
+ * Handles permissions, registration, and notification events.
101
+ *
102
+ * SETUP INSTRUCTIONS:
103
+ * 1. Install peer dependencies:
104
+ * npm install @react-native-firebase/app @react-native-firebase/messaging
105
+ * (or expo-notifications for Expo projects)
106
+ *
107
+ * 2. Configure Firebase/APNs:
108
+ * - Android: Add google-services.json to android/app/
109
+ * - iOS: Add GoogleService-Info.plist to ios/ and configure APNs
110
+ *
111
+ * 3. Add permissions to manifests:
112
+ * - Android: INTERNET, VIBRATE, RECEIVE_BOOT_COMPLETED
113
+ * - iOS: User Notifications capability
114
+ */
115
+ declare function usePushNotifications(options?: UsePushNotificationsOptions): {
116
+ requestPermission: () => Promise<boolean>;
117
+ registerDevice: (convId?: string, pushToken?: string, bundleId?: string) => Promise<Device | null>;
118
+ registerAgentDevice: (pushToken?: string, deviceName?: string) => Promise<any>;
119
+ unregisterDevice: () => Promise<void>;
120
+ device: Device | null;
121
+ isRegistered: boolean;
122
+ isInitialized: boolean;
123
+ permissionStatus: "granted" | "denied" | "undetermined";
124
+ };
125
+
126
+ declare function useAttachments(conversationId?: string): {
127
+ uploading: boolean;
128
+ uploadProgress: number;
129
+ uploadAttachment: (file: {
130
+ uri: string;
131
+ type?: string;
132
+ name?: string;
133
+ }, attachmentType: "IMAGE" | "AUDIO" | "VIDEO" | "DOCUMENT" | "VOICE_NOTE") => Promise<MessageAttachment>;
134
+ };
135
+
136
+ declare function useAgents(accountId?: string): {
137
+ agents: Agent[];
138
+ isLoading: boolean;
139
+ error: Error | null;
140
+ createAgent: (data: AgentCreateRequest) => Promise<Agent>;
141
+ updateAgent: (id: string, data: AgentUpdateRequest) => Promise<Agent>;
142
+ deleteAgent: (id: string) => Promise<void>;
143
+ reload: () => Promise<void>;
144
+ };
145
+
146
+ declare function useConversations(accountId?: string): {
147
+ conversations: Conversation[];
148
+ isLoading: boolean;
149
+ error: Error | null;
150
+ resolveConversation: (id: string) => Promise<void>;
151
+ reload: () => Promise<void>;
152
+ };
153
+
154
+ declare function useAnalytics(accountId?: string, days?: number): {
155
+ metrics: ConversationMetrics | null;
156
+ sentiment: SentimentDistribution | null;
157
+ feedback: FeedbackStats | null;
158
+ tokenUsage: TokenUsageMetrics | null;
159
+ isLoading: boolean;
160
+ error: Error | null;
161
+ reload: () => Promise<void>;
162
+ };
163
+
164
+ declare const storage: {
165
+ getConversationId(): Promise<string | null>;
166
+ setConversationId(id: string): Promise<void>;
167
+ clearConversationId(): Promise<void>;
168
+ getMessages(conversationId: string): Promise<any[]>;
169
+ setMessages(conversationId: string, messages: any[]): Promise<void>;
170
+ getUserIdentity(): Promise<{
171
+ email?: string;
172
+ name?: string;
173
+ } | null>;
174
+ setUserIdentity(identity: {
175
+ email?: string;
176
+ name?: string;
177
+ }): Promise<void>;
178
+ getWidgetConfig(widgetId: string): Promise<any | null>;
179
+ setWidgetConfig(widgetId: string, config: any): Promise<void>;
180
+ };
181
+
182
+ export { SolveoProvider, type SolveoProviderConfig, type SolveoProviderProps, storage, useAgents, useAnalytics, useAttachments, useChat, useConversations, useEscalation, usePushNotifications, useRealtime, useSolveo, useWidgetConfig };