feeddo-react-native 0.0.0-stage → 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.
- package/LICENSE +21 -0
- package/README.md +401 -2
- package/android/build.gradle +39 -0
- package/android/src/main/AndroidManifest.xml +1 -0
- package/android/src/main/java/dev/feeddo/reactnative/FeeddoReactNativeModule.java +380 -0
- package/android/src/main/java/dev/feeddo/reactnative/FeeddoReactNativePackage.java +25 -0
- package/dist/Feeddo.d.ts +131 -0
- package/dist/Feeddo.d.ts.map +1 -0
- package/dist/Feeddo.js +176 -0
- package/dist/Feeddo.js.map +1 -0
- package/dist/FeeddoClient.d.ts +151 -0
- package/dist/FeeddoClient.d.ts.map +1 -0
- package/dist/FeeddoClient.js +690 -0
- package/dist/FeeddoClient.js.map +1 -0
- package/dist/FeeddoProvider.d.ts +23 -0
- package/dist/FeeddoProvider.d.ts.map +1 -0
- package/dist/FeeddoProvider.js +76 -0
- package/dist/FeeddoProvider.js.map +1 -0
- package/dist/config/FeeddoConfig.d.ts +10 -0
- package/dist/config/FeeddoConfig.d.ts.map +1 -0
- package/dist/config/FeeddoConfig.js +10 -0
- package/dist/config/FeeddoConfig.js.map +1 -0
- package/dist/index.d.ts +36 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +38 -0
- package/dist/index.js.map +1 -0
- package/dist/models/Conversation.d.ts +27 -0
- package/dist/models/Conversation.d.ts.map +1 -0
- package/dist/models/Conversation.js +24 -0
- package/dist/models/Conversation.js.map +1 -0
- package/dist/models/EndUser.d.ts +49 -0
- package/dist/models/EndUser.d.ts.map +1 -0
- package/dist/models/EndUser.js +2 -0
- package/dist/models/EndUser.js.map +1 -0
- package/dist/models/FeeddoNotification.d.ts +15 -0
- package/dist/models/FeeddoNotification.d.ts.map +1 -0
- package/dist/models/FeeddoNotification.js +15 -0
- package/dist/models/FeeddoNotification.js.map +1 -0
- package/dist/models/HomeData.d.ts +16 -0
- package/dist/models/HomeData.d.ts.map +1 -0
- package/dist/models/HomeData.js +19 -0
- package/dist/models/HomeData.js.map +1 -0
- package/dist/models/Message.d.ts +12 -0
- package/dist/models/Message.d.ts.map +1 -0
- package/dist/models/Message.js +25 -0
- package/dist/models/Message.js.map +1 -0
- package/dist/models/PushProvider.d.ts +14 -0
- package/dist/models/PushProvider.d.ts.map +1 -0
- package/dist/models/PushProvider.js +9 -0
- package/dist/models/PushProvider.js.map +1 -0
- package/dist/models/Task.d.ts +17 -0
- package/dist/models/Task.d.ts.map +1 -0
- package/dist/models/Task.js +22 -0
- package/dist/models/Task.js.map +1 -0
- package/dist/models/TaskComment.d.ts +11 -0
- package/dist/models/TaskComment.d.ts.map +1 -0
- package/dist/models/TaskComment.js +27 -0
- package/dist/models/TaskComment.js.map +1 -0
- package/dist/models/Ticket.d.ts +13 -0
- package/dist/models/Ticket.d.ts.map +1 -0
- package/dist/models/Ticket.js +14 -0
- package/dist/models/Ticket.js.map +1 -0
- package/dist/native/FeeddoNative.d.ts +58 -0
- package/dist/native/FeeddoNative.d.ts.map +1 -0
- package/dist/native/FeeddoNative.js +22 -0
- package/dist/native/FeeddoNative.js.map +1 -0
- package/dist/push/FeeddoPushNotificationApns.d.ts +73 -0
- package/dist/push/FeeddoPushNotificationApns.d.ts.map +1 -0
- package/dist/push/FeeddoPushNotificationApns.js +301 -0
- package/dist/push/FeeddoPushNotificationApns.js.map +1 -0
- package/dist/services/ApiService.d.ts +64 -0
- package/dist/services/ApiService.d.ts.map +1 -0
- package/dist/services/ApiService.js +406 -0
- package/dist/services/ApiService.js.map +1 -0
- package/dist/services/ConversationService.d.ts +45 -0
- package/dist/services/ConversationService.d.ts.map +1 -0
- package/dist/services/ConversationService.js +259 -0
- package/dist/services/ConversationService.js.map +1 -0
- package/dist/services/WebSocketService.d.ts +26 -0
- package/dist/services/WebSocketService.d.ts.map +1 -0
- package/dist/services/WebSocketService.js +157 -0
- package/dist/services/WebSocketService.js.map +1 -0
- package/dist/theme/FeeddoTheme.d.ts +31 -0
- package/dist/theme/FeeddoTheme.d.ts.map +1 -0
- package/dist/theme/FeeddoTheme.js +60 -0
- package/dist/theme/FeeddoTheme.js.map +1 -0
- package/dist/ui/FeeddoFeedbackCard.d.ts +15 -0
- package/dist/ui/FeeddoFeedbackCard.d.ts.map +1 -0
- package/dist/ui/FeeddoFeedbackCard.js +188 -0
- package/dist/ui/FeeddoFeedbackCard.js.map +1 -0
- package/dist/ui/FeeddoModal.d.ts +20 -0
- package/dist/ui/FeeddoModal.d.ts.map +1 -0
- package/dist/ui/FeeddoModal.js +174 -0
- package/dist/ui/FeeddoModal.js.map +1 -0
- package/dist/ui/components/AttachmentPreview.d.ts +10 -0
- package/dist/ui/components/AttachmentPreview.d.ts.map +1 -0
- package/dist/ui/components/AttachmentPreview.js +143 -0
- package/dist/ui/components/AttachmentPreview.js.map +1 -0
- package/dist/ui/components/ChatInputArea.d.ts +16 -0
- package/dist/ui/components/ChatInputArea.d.ts.map +1 -0
- package/dist/ui/components/ChatInputArea.js +85 -0
- package/dist/ui/components/ChatInputArea.js.map +1 -0
- package/dist/ui/components/FeeddoIcon.d.ts +10 -0
- package/dist/ui/components/FeeddoIcon.d.ts.map +1 -0
- package/dist/ui/components/FeeddoIcon.js +690 -0
- package/dist/ui/components/FeeddoIcon.js.map +1 -0
- package/dist/ui/components/FeeddoNotificationBadge.d.ts +14 -0
- package/dist/ui/components/FeeddoNotificationBadge.d.ts.map +1 -0
- package/dist/ui/components/FeeddoNotificationBadge.js +171 -0
- package/dist/ui/components/FeeddoNotificationBadge.js.map +1 -0
- package/dist/ui/components/MessageBubble.d.ts +13 -0
- package/dist/ui/components/MessageBubble.d.ts.map +1 -0
- package/dist/ui/components/MessageBubble.js +163 -0
- package/dist/ui/components/MessageBubble.js.map +1 -0
- package/dist/ui/components/NotificationsSheet.d.ts +10 -0
- package/dist/ui/components/NotificationsSheet.d.ts.map +1 -0
- package/dist/ui/components/NotificationsSheet.js +252 -0
- package/dist/ui/components/NotificationsSheet.js.map +1 -0
- package/dist/ui/components/RatingWidget.d.ts +11 -0
- package/dist/ui/components/RatingWidget.d.ts.map +1 -0
- package/dist/ui/components/RatingWidget.js +34 -0
- package/dist/ui/components/RatingWidget.js.map +1 -0
- package/dist/ui/components/TaskCard.d.ts +12 -0
- package/dist/ui/components/TaskCard.d.ts.map +1 -0
- package/dist/ui/components/TaskCard.js +210 -0
- package/dist/ui/components/TaskCard.js.map +1 -0
- package/dist/ui/components/TaskDetailsSheet.d.ts +15 -0
- package/dist/ui/components/TaskDetailsSheet.d.ts.map +1 -0
- package/dist/ui/components/TaskDetailsSheet.js +577 -0
- package/dist/ui/components/TaskDetailsSheet.js.map +1 -0
- package/dist/ui/components/TicketCard.d.ts +11 -0
- package/dist/ui/components/TicketCard.d.ts.map +1 -0
- package/dist/ui/components/TicketCard.js +100 -0
- package/dist/ui/components/TicketCard.js.map +1 -0
- package/dist/ui/components/TicketDetailsSheet.d.ts +14 -0
- package/dist/ui/components/TicketDetailsSheet.d.ts.map +1 -0
- package/dist/ui/components/TicketDetailsSheet.js +254 -0
- package/dist/ui/components/TicketDetailsSheet.js.map +1 -0
- package/dist/ui/components/TypingIndicator.d.ts +10 -0
- package/dist/ui/components/TypingIndicator.d.ts.map +1 -0
- package/dist/ui/components/TypingIndicator.js +77 -0
- package/dist/ui/components/TypingIndicator.js.map +1 -0
- package/dist/ui/screens/FeeddoChatScreen.d.ts +13 -0
- package/dist/ui/screens/FeeddoChatScreen.d.ts.map +1 -0
- package/dist/ui/screens/FeeddoChatScreen.js +681 -0
- package/dist/ui/screens/FeeddoChatScreen.js.map +1 -0
- package/dist/ui/screens/FeeddoHomeScreen.d.ts +15 -0
- package/dist/ui/screens/FeeddoHomeScreen.d.ts.map +1 -0
- package/dist/ui/screens/FeeddoHomeScreen.js +653 -0
- package/dist/ui/screens/FeeddoHomeScreen.js.map +1 -0
- package/dist/ui/screens/FeeddoMessagesScreen.d.ts +12 -0
- package/dist/ui/screens/FeeddoMessagesScreen.d.ts.map +1 -0
- package/dist/ui/screens/FeeddoMessagesScreen.js +326 -0
- package/dist/ui/screens/FeeddoMessagesScreen.js.map +1 -0
- package/dist/ui/screens/FeeddoTasksScreen.d.ts +13 -0
- package/dist/ui/screens/FeeddoTasksScreen.d.ts.map +1 -0
- package/dist/ui/screens/FeeddoTasksScreen.js +517 -0
- package/dist/ui/screens/FeeddoTasksScreen.js.map +1 -0
- package/dist/ui/screens/FeeddoTicketsScreen.d.ts +10 -0
- package/dist/ui/screens/FeeddoTicketsScreen.d.ts.map +1 -0
- package/dist/ui/screens/FeeddoTicketsScreen.js +112 -0
- package/dist/ui/screens/FeeddoTicketsScreen.js.map +1 -0
- package/dist/utils/DeviceInfoHelper.d.ts +29 -0
- package/dist/utils/DeviceInfoHelper.d.ts.map +1 -0
- package/dist/utils/DeviceInfoHelper.js +190 -0
- package/dist/utils/DeviceInfoHelper.js.map +1 -0
- package/dist/utils/MediaHelper.d.ts +20 -0
- package/dist/utils/MediaHelper.d.ts.map +1 -0
- package/dist/utils/MediaHelper.js +92 -0
- package/dist/utils/MediaHelper.js.map +1 -0
- package/dist/utils/NotificationSupport.d.ts +22 -0
- package/dist/utils/NotificationSupport.d.ts.map +1 -0
- package/dist/utils/NotificationSupport.js +211 -0
- package/dist/utils/NotificationSupport.js.map +1 -0
- package/dist/utils/StorageHelper.d.ts +65 -0
- package/dist/utils/StorageHelper.d.ts.map +1 -0
- package/dist/utils/StorageHelper.js +273 -0
- package/dist/utils/StorageHelper.js.map +1 -0
- package/feeddo-react-native.podspec +26 -0
- package/ios/FeeddoReactNativeModule.h +8 -0
- package/ios/FeeddoReactNativeModule.m +831 -0
- package/package.json +56 -4
- package/src/Feeddo.ts +247 -0
- package/src/FeeddoClient.ts +895 -0
- package/src/FeeddoProvider.tsx +139 -0
- package/src/config/FeeddoConfig.ts +9 -0
- package/src/index.ts +67 -0
- package/src/models/Conversation.ts +50 -0
- package/src/models/EndUser.ts +65 -0
- package/src/models/FeeddoNotification.ts +29 -0
- package/src/models/HomeData.ts +33 -0
- package/src/models/Message.ts +36 -0
- package/src/models/PushProvider.ts +15 -0
- package/src/models/Task.ts +40 -0
- package/src/models/TaskComment.ts +36 -0
- package/src/models/Ticket.ts +25 -0
- package/src/native/FeeddoNative.ts +80 -0
- package/src/push/FeeddoPushNotificationApns.ts +362 -0
- package/src/services/ApiService.ts +456 -0
- package/src/services/ConversationService.ts +305 -0
- package/src/services/WebSocketService.ts +185 -0
- package/src/theme/FeeddoTheme.ts +85 -0
- package/src/ui/FeeddoFeedbackCard.tsx +245 -0
- package/src/ui/FeeddoModal.tsx +303 -0
- package/src/ui/components/AttachmentPreview.tsx +192 -0
- package/src/ui/components/ChatInputArea.tsx +154 -0
- package/src/ui/components/FeeddoIcon.tsx +903 -0
- package/src/ui/components/FeeddoNotificationBadge.tsx +234 -0
- package/src/ui/components/MessageBubble.tsx +223 -0
- package/src/ui/components/NotificationsSheet.tsx +324 -0
- package/src/ui/components/RatingWidget.tsx +64 -0
- package/src/ui/components/TaskCard.tsx +259 -0
- package/src/ui/components/TaskDetailsSheet.tsx +747 -0
- package/src/ui/components/TicketCard.tsx +128 -0
- package/src/ui/components/TicketDetailsSheet.tsx +324 -0
- package/src/ui/components/TypingIndicator.tsx +104 -0
- package/src/ui/screens/FeeddoChatScreen.tsx +877 -0
- package/src/ui/screens/FeeddoHomeScreen.tsx +824 -0
- package/src/ui/screens/FeeddoMessagesScreen.tsx +414 -0
- package/src/ui/screens/FeeddoTasksScreen.tsx +671 -0
- package/src/ui/screens/FeeddoTicketsScreen.tsx +164 -0
- package/src/utils/DeviceInfoHelper.ts +209 -0
- package/src/utils/MediaHelper.ts +105 -0
- package/src/utils/NotificationSupport.ts +233 -0
- package/src/utils/StorageHelper.ts +305 -0
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
import React, { createContext, useContext, useState, useEffect } from 'react';
|
|
2
|
+
import { View, StyleSheet } from 'react-native';
|
|
3
|
+
import {
|
|
4
|
+
DesktopConstraints,
|
|
5
|
+
FeeddoInternal,
|
|
6
|
+
ModalState,
|
|
7
|
+
InAppNotificationState,
|
|
8
|
+
} from './FeeddoClient';
|
|
9
|
+
import { FeeddoModal } from './ui/FeeddoModal';
|
|
10
|
+
import { FeeddoNotificationBadge } from './ui/components/FeeddoNotificationBadge';
|
|
11
|
+
import { FeeddoTheme } from './theme/FeeddoTheme';
|
|
12
|
+
import { Feeddo } from './Feeddo';
|
|
13
|
+
|
|
14
|
+
interface FeeddoContextValue {
|
|
15
|
+
unreadCount: number;
|
|
16
|
+
show: (options?: {
|
|
17
|
+
theme?: FeeddoTheme;
|
|
18
|
+
useSmallWindowOnDesktop?: boolean;
|
|
19
|
+
desktopConstraints?: DesktopConstraints;
|
|
20
|
+
}) => void;
|
|
21
|
+
showCommunityBoard: (options?: { theme?: FeeddoTheme; taskId?: string }) => void;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const FeeddoContext = createContext<FeeddoContextValue>({
|
|
25
|
+
unreadCount: 0,
|
|
26
|
+
show: () => {},
|
|
27
|
+
showCommunityBoard: () => {},
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
export const useFeeddo = () => useContext(FeeddoContext);
|
|
31
|
+
|
|
32
|
+
interface FeeddoProviderProps {
|
|
33
|
+
children: React.ReactNode;
|
|
34
|
+
theme?: FeeddoTheme;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export const FeeddoProvider: React.FC<FeeddoProviderProps> = ({
|
|
38
|
+
children,
|
|
39
|
+
theme: defaultTheme,
|
|
40
|
+
}) => {
|
|
41
|
+
const [modalState, setModalState] = useState<ModalState>({
|
|
42
|
+
visible: false,
|
|
43
|
+
initialScreen: 'home',
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
const [notificationQueue, setNotificationQueue] = useState<InAppNotificationState[]>([]);
|
|
47
|
+
const [unreadCount, setUnreadCount] = useState<number>(0);
|
|
48
|
+
|
|
49
|
+
useEffect(() => {
|
|
50
|
+
const unsubscribeModal = FeeddoInternal.onModalStateChange((st) => {
|
|
51
|
+
setModalState(st);
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
const unsubscribeNotif = FeeddoInternal.onInAppNotification((st) => {
|
|
55
|
+
if (!st.visible) return;
|
|
56
|
+
setNotificationQueue((prev) => [...prev, st]);
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
const unsubscribeClear = FeeddoInternal.onClearNotifications(() => {
|
|
60
|
+
setNotificationQueue([]);
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
const unsubscribeUnread = Feeddo.onUnreadCountChange((cnt) => {
|
|
64
|
+
setUnreadCount(cnt);
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
setUnreadCount(Feeddo.unreadMessageCount);
|
|
68
|
+
|
|
69
|
+
return () => {
|
|
70
|
+
unsubscribeModal();
|
|
71
|
+
unsubscribeNotif();
|
|
72
|
+
unsubscribeClear();
|
|
73
|
+
unsubscribeUnread();
|
|
74
|
+
};
|
|
75
|
+
}, []);
|
|
76
|
+
|
|
77
|
+
const handleCloseModal = () => {
|
|
78
|
+
FeeddoInternal.setModalState({
|
|
79
|
+
visible: false,
|
|
80
|
+
initialTaskId: undefined,
|
|
81
|
+
});
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
const handleAdvanceNotificationQueue = () => {
|
|
85
|
+
setNotificationQueue((prev) => prev.slice(1));
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
const currentNotification = notificationQueue[0];
|
|
89
|
+
|
|
90
|
+
return (
|
|
91
|
+
<FeeddoContext.Provider
|
|
92
|
+
value={{
|
|
93
|
+
unreadCount,
|
|
94
|
+
show: Feeddo.show,
|
|
95
|
+
showCommunityBoard: Feeddo.showCommunityBoard,
|
|
96
|
+
}}
|
|
97
|
+
>
|
|
98
|
+
<View style={styles.container}>
|
|
99
|
+
{children}
|
|
100
|
+
|
|
101
|
+
{/* Global In-App Notification Slide Banner (queued sequentially like Flutter) */}
|
|
102
|
+
{currentNotification && currentNotification.visible && (
|
|
103
|
+
<FeeddoNotificationBadge
|
|
104
|
+
key={`${currentNotification.title}-${currentNotification.timestamp ?? 0}-${notificationQueue.length}`}
|
|
105
|
+
title={currentNotification.title}
|
|
106
|
+
body={currentNotification.body}
|
|
107
|
+
timestamp={currentNotification.timestamp}
|
|
108
|
+
theme={currentNotification.theme ?? defaultTheme}
|
|
109
|
+
duration={currentNotification.duration}
|
|
110
|
+
onTap={() => {
|
|
111
|
+
currentNotification.onTap?.();
|
|
112
|
+
}}
|
|
113
|
+
onDismiss={handleAdvanceNotificationQueue}
|
|
114
|
+
/>
|
|
115
|
+
)}
|
|
116
|
+
|
|
117
|
+
{/* Global Feeddo Support / Community Board Modal */}
|
|
118
|
+
<FeeddoModal
|
|
119
|
+
visible={modalState.visible}
|
|
120
|
+
initialScreen={modalState.initialScreen}
|
|
121
|
+
initialConversation={modalState.initialConversation}
|
|
122
|
+
initialChatMessage={modalState.initialChatMessage}
|
|
123
|
+
initialTaskId={modalState.initialTaskId}
|
|
124
|
+
theme={modalState.theme ?? defaultTheme}
|
|
125
|
+
useSmallWindowOnDesktop={modalState.useSmallWindowOnDesktop}
|
|
126
|
+
desktopConstraints={modalState.desktopConstraints}
|
|
127
|
+
navigationId={modalState.navigationId}
|
|
128
|
+
onClose={handleCloseModal}
|
|
129
|
+
/>
|
|
130
|
+
</View>
|
|
131
|
+
</FeeddoContext.Provider>
|
|
132
|
+
);
|
|
133
|
+
};
|
|
134
|
+
|
|
135
|
+
const styles = StyleSheet.create({
|
|
136
|
+
container: {
|
|
137
|
+
flex: 1,
|
|
138
|
+
},
|
|
139
|
+
});
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
// Public Core SDK API
|
|
2
|
+
export { Feeddo } from './Feeddo';
|
|
3
|
+
export { FeeddoProvider, useFeeddo } from './FeeddoProvider';
|
|
4
|
+
|
|
5
|
+
// Direct iOS APNs Bridge (companion API matching feeddo_push_notification_apns)
|
|
6
|
+
export {
|
|
7
|
+
FeeddoPushNotificationApns,
|
|
8
|
+
ApnsInitResult,
|
|
9
|
+
ApnsNotificationSettings,
|
|
10
|
+
FeeddoApnsSubscription,
|
|
11
|
+
AttachToFeeddoOptions,
|
|
12
|
+
} from './push/FeeddoPushNotificationApns';
|
|
13
|
+
|
|
14
|
+
// Notification Utilities
|
|
15
|
+
export {
|
|
16
|
+
normalizeNotificationPayload,
|
|
17
|
+
isFeeddoNotification,
|
|
18
|
+
isTaskNotification,
|
|
19
|
+
isConversationNotification,
|
|
20
|
+
} from './utils/NotificationSupport';
|
|
21
|
+
|
|
22
|
+
// Theming
|
|
23
|
+
export { FeeddoTheme, FeeddoColors } from './theme/FeeddoTheme';
|
|
24
|
+
|
|
25
|
+
// Recommended Drop-in Card
|
|
26
|
+
export { FeeddoFeedbackCard } from './ui/FeeddoFeedbackCard';
|
|
27
|
+
|
|
28
|
+
// Exceptions
|
|
29
|
+
export { FeeddoApiException } from './services/ApiService';
|
|
30
|
+
|
|
31
|
+
// Push Provider
|
|
32
|
+
export { FeeddoPushProvider, FeeddoPushProviderType } from './models/PushProvider';
|
|
33
|
+
|
|
34
|
+
// Models
|
|
35
|
+
export { EndUser, UpsertEndUserResponse } from './models/EndUser';
|
|
36
|
+
export { Conversation, GetConversationsResponse } from './models/Conversation';
|
|
37
|
+
export { Message } from './models/Message';
|
|
38
|
+
export { Ticket } from './models/Ticket';
|
|
39
|
+
export { Task } from './models/Task';
|
|
40
|
+
export { TaskComment } from './models/TaskComment';
|
|
41
|
+
export { HomeData } from './models/HomeData';
|
|
42
|
+
export { FeeddoNotification, GetNotificationsResponse } from './models/FeeddoNotification';
|
|
43
|
+
|
|
44
|
+
// Storage, DeviceInfo, & Media Adapters
|
|
45
|
+
export { StorageAdapter, StorageHelper } from './utils/StorageHelper';
|
|
46
|
+
export { DeviceInfo, DeviceInfoHelper } from './utils/DeviceInfoHelper';
|
|
47
|
+
export { MediaHelper, PickedMediaFile } from './utils/MediaHelper';
|
|
48
|
+
|
|
49
|
+
// UI Screens and Modals (for custom embedding if needed)
|
|
50
|
+
export { FeeddoModal } from './ui/FeeddoModal';
|
|
51
|
+
export { FeeddoHomeScreen } from './ui/screens/FeeddoHomeScreen';
|
|
52
|
+
export { FeeddoChatScreen } from './ui/screens/FeeddoChatScreen';
|
|
53
|
+
export { FeeddoMessagesScreen } from './ui/screens/FeeddoMessagesScreen';
|
|
54
|
+
export { FeeddoTicketsScreen } from './ui/screens/FeeddoTicketsScreen';
|
|
55
|
+
export { FeeddoTasksScreen } from './ui/screens/FeeddoTasksScreen';
|
|
56
|
+
export { TaskCard } from './ui/components/TaskCard';
|
|
57
|
+
export { TicketCard } from './ui/components/TicketCard';
|
|
58
|
+
export { RatingWidget } from './ui/components/RatingWidget';
|
|
59
|
+
export { TypingIndicator } from './ui/components/TypingIndicator';
|
|
60
|
+
export { FeeddoNotificationBadge } from './ui/components/FeeddoNotificationBadge';
|
|
61
|
+
export { TaskDetailsSheet } from './ui/components/TaskDetailsSheet';
|
|
62
|
+
export { TicketDetailsSheet } from './ui/components/TicketDetailsSheet';
|
|
63
|
+
export { NotificationsSheet } from './ui/components/NotificationsSheet';
|
|
64
|
+
|
|
65
|
+
// Default export
|
|
66
|
+
import { Feeddo } from './Feeddo';
|
|
67
|
+
export default Feeddo;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
export interface Conversation {
|
|
2
|
+
id: string;
|
|
3
|
+
appId: string;
|
|
4
|
+
status: 'active' | 'resolved' | string;
|
|
5
|
+
title?: string;
|
|
6
|
+
displayName?: string;
|
|
7
|
+
lastMessagePreview?: string;
|
|
8
|
+
autoReply: boolean;
|
|
9
|
+
startedAt: number;
|
|
10
|
+
lastMessageAt: number;
|
|
11
|
+
resolvedAt?: number;
|
|
12
|
+
resolvedBy?: string;
|
|
13
|
+
userSatisfaction?: number;
|
|
14
|
+
tags: string[];
|
|
15
|
+
customData: Record<string, any>;
|
|
16
|
+
unreadMessages: number;
|
|
17
|
+
hasTicket: boolean;
|
|
18
|
+
ticketStatus?: string;
|
|
19
|
+
hasTask: boolean;
|
|
20
|
+
taskStatus?: string;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export interface GetConversationsResponse {
|
|
24
|
+
success: boolean;
|
|
25
|
+
conversations: Conversation[];
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export function parseConversation(json: any): Conversation {
|
|
29
|
+
return {
|
|
30
|
+
id: json.id,
|
|
31
|
+
appId: json.appId ?? json.app_id ?? '',
|
|
32
|
+
status: json.status ?? 'active',
|
|
33
|
+
title: json.title,
|
|
34
|
+
displayName: json.displayName ?? json.display_name,
|
|
35
|
+
lastMessagePreview: json.lastMessagePreview ?? json.last_message_preview,
|
|
36
|
+
autoReply: json.autoReply !== undefined ? Boolean(json.autoReply) : Boolean(json.auto_reply),
|
|
37
|
+
startedAt: json.startedAt ?? json.started_at ?? Date.now(),
|
|
38
|
+
lastMessageAt: json.lastMessageAt ?? json.last_message_at ?? Date.now(),
|
|
39
|
+
resolvedAt: json.resolvedAt ?? json.resolved_at,
|
|
40
|
+
resolvedBy: json.resolvedBy ?? json.resolved_by,
|
|
41
|
+
userSatisfaction: json.userSatisfaction ?? json.user_satisfaction,
|
|
42
|
+
tags: Array.isArray(json.tags) ? json.tags.map(String) : [],
|
|
43
|
+
customData: json.customData ?? json.custom_data ?? {},
|
|
44
|
+
unreadMessages: Number(json.unreadMessages ?? json.unread_messages ?? 0),
|
|
45
|
+
hasTicket: Boolean(json.hasTicket ?? json.has_ticket ?? false),
|
|
46
|
+
ticketStatus: json.ticketStatus ?? json.ticket_status,
|
|
47
|
+
hasTask: Boolean(json.hasTask ?? json.has_task ?? false),
|
|
48
|
+
taskStatus: json.taskStatus ?? json.task_status,
|
|
49
|
+
};
|
|
50
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { FeeddoPushProviderType } from './PushProvider';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Model representing an end user in the Feeddo system
|
|
5
|
+
*/
|
|
6
|
+
export interface EndUser {
|
|
7
|
+
/** Unique identifier for the user (auto-generated if not provided) */
|
|
8
|
+
userId?: string;
|
|
9
|
+
|
|
10
|
+
/** Your application's user ID */
|
|
11
|
+
externalUserId?: string;
|
|
12
|
+
|
|
13
|
+
/** User's display name */
|
|
14
|
+
userName?: string;
|
|
15
|
+
|
|
16
|
+
/** User's email address */
|
|
17
|
+
email?: string;
|
|
18
|
+
|
|
19
|
+
/** Country code (e.g. "US") */
|
|
20
|
+
country?: string;
|
|
21
|
+
|
|
22
|
+
/** Locale code (e.g. "en-US") */
|
|
23
|
+
locale?: string;
|
|
24
|
+
|
|
25
|
+
/** Version of your app the user is using */
|
|
26
|
+
appVersion?: string;
|
|
27
|
+
|
|
28
|
+
/** Platform: ios, android, web, desktop, other */
|
|
29
|
+
platform?: string;
|
|
30
|
+
|
|
31
|
+
/** Device model (e.g., "iPhone 15", "Pixel 8") */
|
|
32
|
+
deviceModel?: string;
|
|
33
|
+
|
|
34
|
+
/** Operating system version */
|
|
35
|
+
osVersion?: string;
|
|
36
|
+
|
|
37
|
+
/** Custom user segment/category */
|
|
38
|
+
userSegment?: string;
|
|
39
|
+
|
|
40
|
+
/** Subscription status (e.g., "premium", "free") */
|
|
41
|
+
subscriptionStatus?: string;
|
|
42
|
+
|
|
43
|
+
/** Custom key-value pairs for additional data */
|
|
44
|
+
customAttributes?: Record<string, any>;
|
|
45
|
+
|
|
46
|
+
/** Push notification token */
|
|
47
|
+
pushToken?: string;
|
|
48
|
+
|
|
49
|
+
/** Push notification provider (fcm, apns, onesignal) */
|
|
50
|
+
pushProvider?: FeeddoPushProviderType;
|
|
51
|
+
|
|
52
|
+
/** Timestamp when user opened the app for the 1st time */
|
|
53
|
+
firstSeenAt?: number;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Response from upsert end user API
|
|
58
|
+
*/
|
|
59
|
+
export interface UpsertEndUserResponse {
|
|
60
|
+
success: boolean;
|
|
61
|
+
userId: string;
|
|
62
|
+
externalUserId?: string;
|
|
63
|
+
action: 'created' | 'updated';
|
|
64
|
+
recentConversation?: Record<string, any>;
|
|
65
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
export interface FeeddoNotification {
|
|
2
|
+
id: string;
|
|
3
|
+
appId: string;
|
|
4
|
+
endUserId: string;
|
|
5
|
+
title?: string;
|
|
6
|
+
body?: string;
|
|
7
|
+
data?: Record<string, any>;
|
|
8
|
+
isRead: boolean;
|
|
9
|
+
createdAt: number;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export interface GetNotificationsResponse {
|
|
13
|
+
notifications: FeeddoNotification[];
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export function parseFeeddoNotification(json: any): FeeddoNotification {
|
|
17
|
+
return {
|
|
18
|
+
id: json.id,
|
|
19
|
+
appId: json.appId ?? json.app_id,
|
|
20
|
+
endUserId: json.endUserId ?? json.end_user_id,
|
|
21
|
+
title: json.title,
|
|
22
|
+
body: json.body,
|
|
23
|
+
data: typeof json.data === 'object' && json.data !== null ? json.data : undefined,
|
|
24
|
+
isRead: json.is_read === true || json.is_read === 1 || json.isRead === true,
|
|
25
|
+
createdAt: typeof json.created_at === 'number'
|
|
26
|
+
? json.created_at
|
|
27
|
+
: Number(json.created_at ?? json.createdAt ?? Date.now()),
|
|
28
|
+
};
|
|
29
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { Task, parseTask } from './Task';
|
|
2
|
+
import { Ticket, parseTicket } from './Ticket';
|
|
3
|
+
import { Conversation, parseConversation } from './Conversation';
|
|
4
|
+
|
|
5
|
+
export interface HomeData {
|
|
6
|
+
hasConversation: boolean;
|
|
7
|
+
hasTicket: boolean;
|
|
8
|
+
hasTasks: boolean;
|
|
9
|
+
unreadMessageCount: number;
|
|
10
|
+
unreadNotificationCount: number;
|
|
11
|
+
chatbotName?: string;
|
|
12
|
+
recentTicket?: Ticket;
|
|
13
|
+
recentTask?: Task;
|
|
14
|
+
recentConversation?: Conversation;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export function parseHomeData(json: any): HomeData {
|
|
18
|
+
return {
|
|
19
|
+
hasConversation: Boolean(json.hasConversation ?? json.has_conversation ?? false),
|
|
20
|
+
hasTicket: Boolean(json.hasTicket ?? json.has_ticket ?? false),
|
|
21
|
+
hasTasks: Boolean(json.hasTasks ?? json.has_tasks ?? false),
|
|
22
|
+
unreadMessageCount: Number(json.unreadMessageCount ?? json.unread_message_count ?? 0),
|
|
23
|
+
unreadNotificationCount: Number(
|
|
24
|
+
json.unreadNotificationCount ?? json.unread_notification_count ?? 0
|
|
25
|
+
),
|
|
26
|
+
chatbotName: json.chatbotName ?? json.chatbot_name,
|
|
27
|
+
recentTicket: json.recentTicket ? parseTicket(json.recentTicket) : undefined,
|
|
28
|
+
recentTask: json.recentTask ? parseTask(json.recentTask) : undefined,
|
|
29
|
+
recentConversation: json.recentConversation
|
|
30
|
+
? parseConversation(json.recentConversation)
|
|
31
|
+
: undefined,
|
|
32
|
+
};
|
|
33
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
export interface Message {
|
|
2
|
+
id: string;
|
|
3
|
+
conversationId: string;
|
|
4
|
+
role: 'user' | 'assistant' | 'human' | 'function' | string;
|
|
5
|
+
content?: string;
|
|
6
|
+
hasAttachments: boolean;
|
|
7
|
+
attachments?: any;
|
|
8
|
+
createdAt: number;
|
|
9
|
+
displayName?: string;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export function parseMessage(json: any): Message {
|
|
13
|
+
let attachmentsValue = json.attachments;
|
|
14
|
+
if (typeof attachmentsValue === 'string') {
|
|
15
|
+
try {
|
|
16
|
+
const parsed = JSON.parse(attachmentsValue);
|
|
17
|
+
if (Array.isArray(parsed)) {
|
|
18
|
+
attachmentsValue = parsed;
|
|
19
|
+
}
|
|
20
|
+
} catch (_) {}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
return {
|
|
24
|
+
id: json.id,
|
|
25
|
+
conversationId: json.conversationId ?? json.conversation_id,
|
|
26
|
+
role: json.role,
|
|
27
|
+
content: json.content,
|
|
28
|
+
hasAttachments:
|
|
29
|
+
json.hasAttachments === true ||
|
|
30
|
+
json.has_attachments === 1 ||
|
|
31
|
+
json.has_attachments === true,
|
|
32
|
+
attachments: attachmentsValue,
|
|
33
|
+
createdAt: json.createdAt ?? json.created_at ?? Date.now(),
|
|
34
|
+
displayName: json.displayName ?? json.display_name,
|
|
35
|
+
};
|
|
36
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Supported push notification providers
|
|
3
|
+
*/
|
|
4
|
+
export type FeeddoPushProviderType = 'fcm' | 'apns' | 'onesignal';
|
|
5
|
+
|
|
6
|
+
export const FeeddoPushProvider = {
|
|
7
|
+
FCM: 'fcm' as FeeddoPushProviderType,
|
|
8
|
+
APNS: 'apns' as FeeddoPushProviderType,
|
|
9
|
+
ONESIGNAL: 'onesignal' as FeeddoPushProviderType,
|
|
10
|
+
fcm: 'fcm' as FeeddoPushProviderType,
|
|
11
|
+
apns: 'apns' as FeeddoPushProviderType,
|
|
12
|
+
onesignal: 'onesignal' as FeeddoPushProviderType,
|
|
13
|
+
} as const;
|
|
14
|
+
|
|
15
|
+
export type FeeddoPushProvider = FeeddoPushProviderType;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { TaskComment, parseTaskComment } from './TaskComment';
|
|
2
|
+
|
|
3
|
+
export interface Task {
|
|
4
|
+
id: string;
|
|
5
|
+
title: string;
|
|
6
|
+
description: string;
|
|
7
|
+
status: string;
|
|
8
|
+
priority: string;
|
|
9
|
+
type: 'feature' | 'bug' | string;
|
|
10
|
+
upvoteCount: number;
|
|
11
|
+
commentCount: number;
|
|
12
|
+
myVote?: 'up' | 'down' | null;
|
|
13
|
+
comments: TaskComment[];
|
|
14
|
+
isOwner: boolean;
|
|
15
|
+
conversationId?: string;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export function parseTask(json: any): Task {
|
|
19
|
+
let commentsList: TaskComment[] = [];
|
|
20
|
+
if (Array.isArray(json.comments)) {
|
|
21
|
+
commentsList = json.comments.map(parseTaskComment);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
return {
|
|
25
|
+
id: json.id,
|
|
26
|
+
title: json.title,
|
|
27
|
+
description: json.description ?? '',
|
|
28
|
+
status: json.status ?? 'todo',
|
|
29
|
+
priority: json.priority ?? 'medium',
|
|
30
|
+
type: json.type ?? 'feature',
|
|
31
|
+
upvoteCount: Number(json.upvoteCount ?? json.upvote_count ?? 0),
|
|
32
|
+
commentCount: Number(
|
|
33
|
+
json.commentCount ?? json.comment_count ?? commentsList.length
|
|
34
|
+
),
|
|
35
|
+
myVote: json.myVote ?? json.my_vote,
|
|
36
|
+
comments: commentsList,
|
|
37
|
+
isOwner: Boolean(json.isOwner ?? json.is_owner ?? false),
|
|
38
|
+
conversationId: json.conversationId ?? json.conversation_id,
|
|
39
|
+
};
|
|
40
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
export interface TaskComment {
|
|
2
|
+
id: string;
|
|
3
|
+
content: string;
|
|
4
|
+
userType: 'end_user' | 'developer' | string;
|
|
5
|
+
authorName?: string;
|
|
6
|
+
createdAt: number;
|
|
7
|
+
hasAttachments: boolean;
|
|
8
|
+
attachments?: Array<Record<string, any>>;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export function parseTaskComment(json: any): TaskComment {
|
|
12
|
+
let attachmentsList: Array<Record<string, any>> | undefined;
|
|
13
|
+
if (Array.isArray(json.attachments)) {
|
|
14
|
+
attachmentsList = json.attachments;
|
|
15
|
+
} else if (typeof json.attachments === 'string') {
|
|
16
|
+
try {
|
|
17
|
+
const parsed = JSON.parse(json.attachments);
|
|
18
|
+
if (Array.isArray(parsed)) {
|
|
19
|
+
attachmentsList = parsed;
|
|
20
|
+
}
|
|
21
|
+
} catch (_) {}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
return {
|
|
25
|
+
id: json.id,
|
|
26
|
+
content: json.content ?? '',
|
|
27
|
+
userType: json.userType ?? json.user_type ?? 'end_user',
|
|
28
|
+
authorName: json.authorName ?? json.author_name,
|
|
29
|
+
createdAt: Number(json.createdAt ?? json.created_at ?? 0),
|
|
30
|
+
hasAttachments:
|
|
31
|
+
json.hasAttachments === true ||
|
|
32
|
+
json.has_attachments === 1 ||
|
|
33
|
+
json.has_attachments === true,
|
|
34
|
+
attachments: attachmentsList,
|
|
35
|
+
};
|
|
36
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export interface Ticket {
|
|
2
|
+
id: string;
|
|
3
|
+
title: string;
|
|
4
|
+
description: string;
|
|
5
|
+
priority: string;
|
|
6
|
+
isResolved: boolean;
|
|
7
|
+
createdAt: number;
|
|
8
|
+
updatedAt: number;
|
|
9
|
+
isOwner: boolean;
|
|
10
|
+
conversationId?: string;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export function parseTicket(json: any): Ticket {
|
|
14
|
+
return {
|
|
15
|
+
id: json.id,
|
|
16
|
+
title: json.title,
|
|
17
|
+
description: json.description,
|
|
18
|
+
priority: json.priority ?? 'medium',
|
|
19
|
+
isResolved: Boolean(json.isResolved ?? json.is_resolved ?? false),
|
|
20
|
+
createdAt: Number(json.createdAt ?? json.created_at ?? 0),
|
|
21
|
+
updatedAt: Number(json.updatedAt ?? json.updated_at ?? 0),
|
|
22
|
+
isOwner: Boolean(json.isOwner ?? json.is_owner ?? false),
|
|
23
|
+
conversationId: json.conversationId ?? json.conversation_id,
|
|
24
|
+
};
|
|
25
|
+
}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { NativeModules, Platform } from 'react-native';
|
|
2
|
+
|
|
3
|
+
export interface NativeDeviceInfo {
|
|
4
|
+
platform?: 'ios' | 'android' | 'web' | 'desktop' | 'other';
|
|
5
|
+
deviceModel?: string;
|
|
6
|
+
osVersion?: string;
|
|
7
|
+
appVersion?: string;
|
|
8
|
+
appBuildNumber?: string;
|
|
9
|
+
packageName?: string;
|
|
10
|
+
locale?: string;
|
|
11
|
+
countryCode?: string;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export interface PickedMediaFile {
|
|
15
|
+
uri: string;
|
|
16
|
+
name?: string;
|
|
17
|
+
type?: string;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export interface FeeddoReactNativeSpec {
|
|
21
|
+
getDeviceInfo(): Promise<NativeDeviceInfo>;
|
|
22
|
+
pickImage(): Promise<PickedMediaFile | null>;
|
|
23
|
+
openVideoPlayer(url: string, headers?: Record<string, string>): Promise<boolean>;
|
|
24
|
+
createNotificationChannel(
|
|
25
|
+
channelId: string,
|
|
26
|
+
channelName: string,
|
|
27
|
+
description: string
|
|
28
|
+
): Promise<boolean>;
|
|
29
|
+
getInitialNotification?(): Promise<Record<string, any> | null>;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export interface FeeddoReactNativeApnsSpec {
|
|
33
|
+
initialize(autoRegister: boolean): Promise<{
|
|
34
|
+
token?: string;
|
|
35
|
+
initialNotification?: Record<string, any>;
|
|
36
|
+
}>;
|
|
37
|
+
requestNotificationPermissions(options: {
|
|
38
|
+
alert?: boolean;
|
|
39
|
+
badge?: boolean;
|
|
40
|
+
sound?: boolean;
|
|
41
|
+
provisional?: boolean;
|
|
42
|
+
criticalAlert?: boolean;
|
|
43
|
+
}): Promise<{ granted: boolean; error?: string | null }>;
|
|
44
|
+
getNotificationSettings(): Promise<{
|
|
45
|
+
authorizationStatus: string;
|
|
46
|
+
soundEnabled: boolean;
|
|
47
|
+
badgeEnabled: boolean;
|
|
48
|
+
alertEnabled: boolean;
|
|
49
|
+
}>;
|
|
50
|
+
getDeviceToken(): Promise<string | null>;
|
|
51
|
+
getInitialNotification(): Promise<Record<string, any> | null>;
|
|
52
|
+
registerForRemoteNotifications(): Promise<string | null>;
|
|
53
|
+
unregisterForRemoteNotifications(): Promise<boolean>;
|
|
54
|
+
setForegroundNotificationPresentationOptions(options: {
|
|
55
|
+
alert?: boolean;
|
|
56
|
+
badge?: boolean;
|
|
57
|
+
sound?: boolean;
|
|
58
|
+
}): Promise<boolean>;
|
|
59
|
+
addListener?(eventName: string): void;
|
|
60
|
+
removeListeners?(count: number): void;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export function getFeeddoNativeModule(): FeeddoReactNativeSpec | null {
|
|
64
|
+
try {
|
|
65
|
+
const mod = NativeModules?.FeeddoReactNative;
|
|
66
|
+
return mod ?? null;
|
|
67
|
+
} catch (_) {
|
|
68
|
+
return null;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
export function getFeeddoApnsNativeModule(): FeeddoReactNativeApnsSpec | null {
|
|
73
|
+
if (Platform.OS !== 'ios') return null;
|
|
74
|
+
try {
|
|
75
|
+
const mod = NativeModules?.FeeddoReactNativeApns;
|
|
76
|
+
return mod ?? null;
|
|
77
|
+
} catch (_) {
|
|
78
|
+
return null;
|
|
79
|
+
}
|
|
80
|
+
}
|