@qafka/react-native 2.0.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/CHANGELOG.md +12 -0
- package/CONTRIBUTING.md +92 -0
- package/LICENSE +22 -0
- package/README.md +109 -0
- package/SECURITY.md +67 -0
- package/android/build.gradle +35 -0
- package/android/src/main/AndroidManifest.xml +2 -0
- package/android/src/main/java/com/qafka/attestation/QafkaAttestationModule.kt +92 -0
- package/android/src/main/java/com/qafka/attestation/QafkaAttestationPackage.kt +22 -0
- package/android/src/main/java/com/qafka/audio/QafkaAudioModule.kt +290 -0
- package/android/src/main/java/com/qafka/clipboard/QafkaClipboardModule.kt +28 -0
- package/android/src/main/java/com/qafka/storage/QafkaStorageModule.kt +80 -0
- package/app.plugin.js +1 -0
- package/dist/QafkaSDK.d.ts +174 -0
- package/dist/QafkaSDK.js +461 -0
- package/dist/cards/bindings/resolveFieldName.d.ts +25 -0
- package/dist/cards/bindings/resolveFieldName.js +82 -0
- package/dist/cards/cta/CardContext.d.ts +16 -0
- package/dist/cards/cta/CardContext.js +58 -0
- package/dist/cards/cta/dispatcher.d.ts +7 -0
- package/dist/cards/cta/dispatcher.js +90 -0
- package/dist/cards/cta/types.d.ts +66 -0
- package/dist/cards/cta/types.js +2 -0
- package/dist/cards/index.d.ts +20 -0
- package/dist/cards/index.js +34 -0
- package/dist/cards/primitives/QButton.d.ts +10 -0
- package/dist/cards/primitives/QButton.js +115 -0
- package/dist/cards/primitives/QDivider.d.ts +7 -0
- package/dist/cards/primitives/QDivider.js +17 -0
- package/dist/cards/primitives/QIcon.d.ts +13 -0
- package/dist/cards/primitives/QIcon.js +26 -0
- package/dist/cards/primitives/QImage.d.ts +9 -0
- package/dist/cards/primitives/QImage.js +22 -0
- package/dist/cards/primitives/QText.d.ts +9 -0
- package/dist/cards/primitives/QText.js +30 -0
- package/dist/cards/primitives/QView.d.ts +8 -0
- package/dist/cards/primitives/QView.js +19 -0
- package/dist/cards/renderer/CardRenderer.d.ts +19 -0
- package/dist/cards/renderer/CardRenderer.js +64 -0
- package/dist/cards/renderer/renderNode.d.ts +13 -0
- package/dist/cards/renderer/renderNode.js +42 -0
- package/dist/cards/types.d.ts +110 -0
- package/dist/cards/types.js +6 -0
- package/dist/components/ActionResultBadge.d.ts +12 -0
- package/dist/components/ActionResultBadge.js +58 -0
- package/dist/components/ChatPage.d.ts +44 -0
- package/dist/components/ChatPage.js +84 -0
- package/dist/components/DataChip.d.ts +8 -0
- package/dist/components/DataChip.js +80 -0
- package/dist/components/DataChipList.d.ts +13 -0
- package/dist/components/DataChipList.js +21 -0
- package/dist/components/FloatingButton.d.ts +11 -0
- package/dist/components/FloatingButton.js +162 -0
- package/dist/components/InputArea.d.ts +57 -0
- package/dist/components/InputArea.js +142 -0
- package/dist/components/MarkdownText.d.ts +15 -0
- package/dist/components/MarkdownText.js +283 -0
- package/dist/components/MessageBubble.d.ts +134 -0
- package/dist/components/MessageBubble.js +384 -0
- package/dist/components/NavigationSuggestion.d.ts +11 -0
- package/dist/components/NavigationSuggestion.js +109 -0
- package/dist/components/Qafka.d.ts +39 -0
- package/dist/components/Qafka.handlers.d.ts +21 -0
- package/dist/components/Qafka.handlers.js +54 -0
- package/dist/components/Qafka.js +493 -0
- package/dist/components/Qafka.styles.d.ts +19 -0
- package/dist/components/Qafka.styles.js +101 -0
- package/dist/components/Qafka.types.d.ts +744 -0
- package/dist/components/Qafka.types.js +2 -0
- package/dist/components/Qafka.utils.d.ts +7 -0
- package/dist/components/Qafka.utils.js +34 -0
- package/dist/components/QafkaProvider.d.ts +12 -0
- package/dist/components/QafkaProvider.js +87 -0
- package/dist/components/QuickReplies.d.ts +14 -0
- package/dist/components/QuickReplies.js +48 -0
- package/dist/components/StepProgressIndicator.d.ts +12 -0
- package/dist/components/StepProgressIndicator.js +48 -0
- package/dist/components/SuggestionButton.d.ts +42 -0
- package/dist/components/SuggestionButton.js +67 -0
- package/dist/components/ToolStatusPill.d.ts +20 -0
- package/dist/components/ToolStatusPill.js +43 -0
- package/dist/components/TypingIndicator.d.ts +28 -0
- package/dist/components/TypingIndicator.js +109 -0
- package/dist/components/VoicePage.d.ts +48 -0
- package/dist/components/VoicePage.js +683 -0
- package/dist/components/defaults/DefaultCard.d.ts +14 -0
- package/dist/components/defaults/DefaultCard.js +156 -0
- package/dist/components/defaults/DefaultDetail.d.ts +14 -0
- package/dist/components/defaults/DefaultDetail.js +138 -0
- package/dist/components/defaults/DefaultList.d.ts +12 -0
- package/dist/components/defaults/DefaultList.js +98 -0
- package/dist/components/defaults/DefaultTable.d.ts +14 -0
- package/dist/components/defaults/DefaultTable.js +204 -0
- package/dist/components/defaults/index.d.ts +14 -0
- package/dist/components/defaults/index.js +25 -0
- package/dist/components/index.d.ts +22 -0
- package/dist/components/index.js +36 -0
- package/dist/constants.d.ts +10 -0
- package/dist/constants.js +13 -0
- package/dist/hooks/useChatMessages.d.ts +72 -0
- package/dist/hooks/useChatMessages.js +505 -0
- package/dist/hooks/useContextManager.d.ts +12 -0
- package/dist/hooks/useContextManager.js +46 -0
- package/dist/hooks/useProjectTheme.d.ts +19 -0
- package/dist/hooks/useProjectTheme.js +163 -0
- package/dist/hooks/useSDK.d.ts +31 -0
- package/dist/hooks/useSDK.js +103 -0
- package/dist/hooks/useVoiceChat.d.ts +110 -0
- package/dist/hooks/useVoiceChat.js +436 -0
- package/dist/index.d.ts +13 -0
- package/dist/index.js +59 -0
- package/dist/native/QafkaAttestation.d.ts +23 -0
- package/dist/native/QafkaAttestation.js +70 -0
- package/dist/native/QafkaAudio.d.ts +14 -0
- package/dist/native/QafkaAudio.js +31 -0
- package/dist/native/QafkaClipboard.d.ts +11 -0
- package/dist/native/QafkaClipboard.js +14 -0
- package/dist/native/QafkaStorage.d.ts +15 -0
- package/dist/native/QafkaStorage.js +12 -0
- package/dist/resolve-project-config.d.ts +35 -0
- package/dist/resolve-project-config.js +41 -0
- package/dist/runtime-config-loader.d.ts +37 -0
- package/dist/runtime-config-loader.js +53 -0
- package/dist/services/AttestationManager.d.ts +38 -0
- package/dist/services/AttestationManager.js +296 -0
- package/dist/services/BackendService.d.ts +156 -0
- package/dist/services/BackendService.js +755 -0
- package/dist/services/ConversationManager.d.ts +43 -0
- package/dist/services/ConversationManager.js +96 -0
- package/dist/services/NavigationHandler.d.ts +29 -0
- package/dist/services/NavigationHandler.js +70 -0
- package/dist/services/RealtimeService.d.ts +83 -0
- package/dist/services/RealtimeService.js +203 -0
- package/dist/services/storage.d.ts +11 -0
- package/dist/services/storage.js +15 -0
- package/dist/services/storageCore.d.ts +17 -0
- package/dist/services/storageCore.js +46 -0
- package/dist/themes/dark.d.ts +5 -0
- package/dist/themes/dark.js +129 -0
- package/dist/themes/index.d.ts +12 -0
- package/dist/themes/index.js +33 -0
- package/dist/themes/light.d.ts +5 -0
- package/dist/themes/light.js +129 -0
- package/dist/themes/types.d.ts +155 -0
- package/dist/themes/types.js +5 -0
- package/dist/types/chat.d.ts +126 -0
- package/dist/types/chat.js +5 -0
- package/dist/types/components.d.ts +56 -0
- package/dist/types/components.js +16 -0
- package/dist/types/external-navigation.d.ts +19 -0
- package/dist/types/external-navigation.js +8 -0
- package/dist/types/index.d.ts +9 -0
- package/dist/types/index.js +25 -0
- package/dist/types/navigation.d.ts +86 -0
- package/dist/types/navigation.js +5 -0
- package/dist/types/sdk.d.ts +36 -0
- package/dist/types/sdk.js +5 -0
- package/dist/utils/deepMerge.d.ts +46 -0
- package/dist/utils/deepMerge.js +70 -0
- package/dist/utils/fontUtils.d.ts +8 -0
- package/dist/utils/fontUtils.js +16 -0
- package/dist/validate-end-user.d.ts +18 -0
- package/dist/validate-end-user.js +74 -0
- package/expo-plugin/withQafkaAttestation.js +57 -0
- package/ios/QafkaAttestation.m +25 -0
- package/ios/QafkaAttestation.swift +128 -0
- package/ios/QafkaAudio.m +23 -0
- package/ios/QafkaAudio.swift +519 -0
- package/ios/QafkaClipboard.m +10 -0
- package/ios/QafkaClipboard.swift +21 -0
- package/ios/QafkaReactImports.h +2 -0
- package/ios/QafkaStorage.m +26 -0
- package/ios/QafkaStorage.swift +118 -0
- package/package.json +82 -0
- package/qafka.config.d.ts +9 -0
- package/qafka.config.js +9 -0
- package/react-native-qafka.podspec +28 -0
- package/react-native.config.js +14 -0
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
import { ChatResponse } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* Backend API Service using native fetch
|
|
4
|
+
*/
|
|
5
|
+
export declare class BackendService {
|
|
6
|
+
private baseURL;
|
|
7
|
+
private apiKey;
|
|
8
|
+
private subProjectId;
|
|
9
|
+
private endUserId;
|
|
10
|
+
private endUserData;
|
|
11
|
+
private timeout;
|
|
12
|
+
private bundleId;
|
|
13
|
+
private appVersion;
|
|
14
|
+
private deviceModel;
|
|
15
|
+
private sessionTokenGetter;
|
|
16
|
+
private attestationManager;
|
|
17
|
+
private refreshing;
|
|
18
|
+
private locale;
|
|
19
|
+
private onToolDataRequested;
|
|
20
|
+
private readonly toolDataResolvedFor;
|
|
21
|
+
private static readonly RESOLVER_TIMEOUT_MS;
|
|
22
|
+
constructor(apiKey: string | null, apiUrl?: string, subProjectId?: string);
|
|
23
|
+
setSessionTokenGetter(getter: () => Promise<string | null>): void;
|
|
24
|
+
/**
|
|
25
|
+
* Store the validated end-user identity for subsequent chat requests.
|
|
26
|
+
* Called by the React component on mount and whenever the `endUserId` /
|
|
27
|
+
* `endUserData` props change. Validation happens upstream
|
|
28
|
+
* (`validate-end-user.ts`) so this method only persists the result.
|
|
29
|
+
*/
|
|
30
|
+
setEndUser(endUserId: string, endUserData?: Record<string, unknown>): void;
|
|
31
|
+
setAttestationManager(am: {
|
|
32
|
+
refresh(): Promise<string | null>;
|
|
33
|
+
}): void;
|
|
34
|
+
/**
|
|
35
|
+
* Single-flight refresh: concurrent callers share the same in-flight promise.
|
|
36
|
+
* Prevents multiple parallel re-attests when several requests fail simultaneously.
|
|
37
|
+
*/
|
|
38
|
+
private refreshSession;
|
|
39
|
+
/**
|
|
40
|
+
* fetch() with automatic session refresh when the backend signals it —
|
|
41
|
+
* reactively on a 429 refresh hint, proactively when the budget header is
|
|
42
|
+
* low. Caller passes an init that already has Authorization/x-api-key set;
|
|
43
|
+
* on retry, only the Bearer header is swapped.
|
|
44
|
+
*/
|
|
45
|
+
private fetchWithRefresh;
|
|
46
|
+
/**
|
|
47
|
+
* Tool Data Channel: register the partner-provided resolver that
|
|
48
|
+
* supplies transient PII (`{{tooldata.X}}` substitution) bags. Called from
|
|
49
|
+
* QafkaSDK with the `onToolDataRequested` prop. Pass `null` to clear.
|
|
50
|
+
*/
|
|
51
|
+
setOnToolDataRequested(resolver: ((tool: {
|
|
52
|
+
key: string;
|
|
53
|
+
name: string;
|
|
54
|
+
}) => Record<string, unknown> | Promise<Record<string, unknown>>) | null): void;
|
|
55
|
+
/**
|
|
56
|
+
* explicit-intent locale. Only included in sdkContext when set —
|
|
57
|
+
* Qafka.tsx wires this from the `locale` prop. Developer can also call
|
|
58
|
+
* directly via QafkaSDK.setLocale().
|
|
59
|
+
*/
|
|
60
|
+
setLocale(locale: string | null): void;
|
|
61
|
+
/**
|
|
62
|
+
* Build the SDK context attached to every request: universal temporal
|
|
63
|
+
* fields plus locale when the developer has set it.
|
|
64
|
+
*/
|
|
65
|
+
private buildSdkContext;
|
|
66
|
+
/**
|
|
67
|
+
* Get security headers for API requests
|
|
68
|
+
*/
|
|
69
|
+
private getSecurityHeaders;
|
|
70
|
+
/**
|
|
71
|
+
* Tool Data Channel: invokes the partner resolver, POSTs the
|
|
72
|
+
* opaque bag to /chat/tool-data. Per-execId dedupe, soft timeout, fail-soft.
|
|
73
|
+
* Called by the tool_suggestions SSE handler when `needData=true`.
|
|
74
|
+
*/
|
|
75
|
+
private resolveAndPostToolData;
|
|
76
|
+
/**
|
|
77
|
+
* POST tooldata bag to backend. Uses the standard SDK auth headers (API key
|
|
78
|
+
* + device attestation session token) — same chain as sendMessageStream.
|
|
79
|
+
* No retry, no body persistence; 64KB cap enforced server-side.
|
|
80
|
+
*/
|
|
81
|
+
private postToolData;
|
|
82
|
+
/**
|
|
83
|
+
* Make HTTP request with timeout
|
|
84
|
+
*/
|
|
85
|
+
private fetchWithTimeout;
|
|
86
|
+
/**
|
|
87
|
+
* Handle response errors with detailed messages
|
|
88
|
+
*/
|
|
89
|
+
private handleResponse;
|
|
90
|
+
/**
|
|
91
|
+
* Send chat message to backend
|
|
92
|
+
*/
|
|
93
|
+
sendMessage(message: string, sessionId: string, context?: Record<string, any>, contextDescription?: string, isInitialMessage?: boolean): Promise<ChatResponse>;
|
|
94
|
+
/**
|
|
95
|
+
* Get conversation history
|
|
96
|
+
*/
|
|
97
|
+
getHistory(sessionId: string, limit?: number): Promise<any>;
|
|
98
|
+
/**
|
|
99
|
+
* Delete conversation
|
|
100
|
+
*/
|
|
101
|
+
deleteConversation(sessionId: string): Promise<void>;
|
|
102
|
+
/**
|
|
103
|
+
* Get project theme
|
|
104
|
+
*/
|
|
105
|
+
getTheme(): Promise<any>;
|
|
106
|
+
/**
|
|
107
|
+
* Send message with streaming response
|
|
108
|
+
* React Native compatible version using XMLHttpRequest
|
|
109
|
+
*/
|
|
110
|
+
sendMessageStream(message: string, sessionId: string, onChunk: (chunk: string) => void, onComplete: (response: ChatResponse) => void, onError: (error: Error) => void, context?: Record<string, any>, contextDescription?: string, onToolSuggestions?: (tools: any[], conversationId?: string, messageId?: string) => void, // Tool suggestions callback
|
|
111
|
+
isInitialMessage?: boolean, onActionResult?: (results: Array<{
|
|
112
|
+
actionType: string;
|
|
113
|
+
success: boolean;
|
|
114
|
+
message: string;
|
|
115
|
+
}>) => void, // Action result callback
|
|
116
|
+
onStepCompleted?: (result: {
|
|
117
|
+
tool: string;
|
|
118
|
+
step: string;
|
|
119
|
+
data: Record<string, any>;
|
|
120
|
+
actionResults?: Array<{
|
|
121
|
+
actionType: string;
|
|
122
|
+
success: boolean;
|
|
123
|
+
message: string;
|
|
124
|
+
}>;
|
|
125
|
+
}) => void, // Step completed callback
|
|
126
|
+
onFileUploadRequest?: (request: any) => void, onExtractionResult?: (result: any) => void, onToolStatus?: (event: {
|
|
127
|
+
toolKey: string;
|
|
128
|
+
message: string;
|
|
129
|
+
stage: string;
|
|
130
|
+
}) => void, onToolResultPayload?: (event: {
|
|
131
|
+
toolKey: string;
|
|
132
|
+
data: unknown;
|
|
133
|
+
uiConfig?: any;
|
|
134
|
+
}) => void, onFinalChunk?: (content: string) => void): Promise<void>;
|
|
135
|
+
/**
|
|
136
|
+
* Post a tool result back to the backend so the AI can continue its turn.
|
|
137
|
+
* Streams back `final_chunk` and `done` events.
|
|
138
|
+
*/
|
|
139
|
+
postToolResult(payload: {
|
|
140
|
+
conversationId: string;
|
|
141
|
+
messageId: string;
|
|
142
|
+
toolKey: string;
|
|
143
|
+
data: unknown;
|
|
144
|
+
sdkContext?: Record<string, unknown>;
|
|
145
|
+
}, onFinalChunk: (content: string) => void, onDone: () => void, onError: (err: Error) => void, onCard?: (card: {
|
|
146
|
+
templateId: string;
|
|
147
|
+
templateSlug: string;
|
|
148
|
+
definition: any;
|
|
149
|
+
data: any;
|
|
150
|
+
}) => void): Promise<void>;
|
|
151
|
+
uploadFile(toolId: string, file: {
|
|
152
|
+
uri: string;
|
|
153
|
+
name: string;
|
|
154
|
+
type: string;
|
|
155
|
+
}, conversationId?: string): Promise<any>;
|
|
156
|
+
}
|