gentiq 0.7.31 → 0.7.32

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,184 @@
1
+ import { GentiqUser } from '../types';
2
+ export declare const currentUserQueryKey: (cacheNamespace: string) => readonly [string, "currentUser"];
3
+ export interface UseGentiqUserOptions {
4
+ /** Set to false to defer loading the authenticated user profile. */
5
+ enabled?: boolean;
6
+ }
7
+ /**
8
+ * Loads the authenticated Gentiq user and exposes common display values.
9
+ */
10
+ export declare function useGentiqUser(options?: UseGentiqUserOptions): {
11
+ user: GentiqUser | null;
12
+ firstName: string | null;
13
+ data: GentiqUser;
14
+ error: Error;
15
+ isError: true;
16
+ isPending: false;
17
+ isLoading: false;
18
+ isLoadingError: false;
19
+ isRefetchError: true;
20
+ isSuccess: false;
21
+ isPlaceholderData: false;
22
+ status: "error";
23
+ dataUpdatedAt: number;
24
+ errorUpdatedAt: number;
25
+ failureCount: number;
26
+ failureReason: Error | null;
27
+ errorUpdateCount: number;
28
+ isFetched: boolean;
29
+ isFetchedAfterMount: boolean;
30
+ isFetching: boolean;
31
+ isInitialLoading: boolean;
32
+ isPaused: boolean;
33
+ isRefetching: boolean;
34
+ isStale: boolean;
35
+ isEnabled: boolean;
36
+ refetch: (options?: import('@tanstack/react-query').RefetchOptions) => Promise<import('@tanstack/react-query').QueryObserverResult<GentiqUser, Error>>;
37
+ fetchStatus: import('@tanstack/react-query').FetchStatus;
38
+ promise: Promise<GentiqUser>;
39
+ } | {
40
+ user: GentiqUser | null;
41
+ firstName: string | null;
42
+ data: GentiqUser;
43
+ error: null;
44
+ isError: false;
45
+ isPending: false;
46
+ isLoading: false;
47
+ isLoadingError: false;
48
+ isRefetchError: false;
49
+ isSuccess: true;
50
+ isPlaceholderData: false;
51
+ status: "success";
52
+ dataUpdatedAt: number;
53
+ errorUpdatedAt: number;
54
+ failureCount: number;
55
+ failureReason: Error | null;
56
+ errorUpdateCount: number;
57
+ isFetched: boolean;
58
+ isFetchedAfterMount: boolean;
59
+ isFetching: boolean;
60
+ isInitialLoading: boolean;
61
+ isPaused: boolean;
62
+ isRefetching: boolean;
63
+ isStale: boolean;
64
+ isEnabled: boolean;
65
+ refetch: (options?: import('@tanstack/react-query').RefetchOptions) => Promise<import('@tanstack/react-query').QueryObserverResult<GentiqUser, Error>>;
66
+ fetchStatus: import('@tanstack/react-query').FetchStatus;
67
+ promise: Promise<GentiqUser>;
68
+ } | {
69
+ user: GentiqUser | null;
70
+ firstName: string | null;
71
+ data: undefined;
72
+ error: Error;
73
+ isError: true;
74
+ isPending: false;
75
+ isLoading: false;
76
+ isLoadingError: true;
77
+ isRefetchError: false;
78
+ isSuccess: false;
79
+ isPlaceholderData: false;
80
+ status: "error";
81
+ dataUpdatedAt: number;
82
+ errorUpdatedAt: number;
83
+ failureCount: number;
84
+ failureReason: Error | null;
85
+ errorUpdateCount: number;
86
+ isFetched: boolean;
87
+ isFetchedAfterMount: boolean;
88
+ isFetching: boolean;
89
+ isInitialLoading: boolean;
90
+ isPaused: boolean;
91
+ isRefetching: boolean;
92
+ isStale: boolean;
93
+ isEnabled: boolean;
94
+ refetch: (options?: import('@tanstack/react-query').RefetchOptions) => Promise<import('@tanstack/react-query').QueryObserverResult<GentiqUser, Error>>;
95
+ fetchStatus: import('@tanstack/react-query').FetchStatus;
96
+ promise: Promise<GentiqUser>;
97
+ } | {
98
+ user: GentiqUser | null;
99
+ firstName: string | null;
100
+ data: undefined;
101
+ error: null;
102
+ isError: false;
103
+ isPending: true;
104
+ isLoading: true;
105
+ isLoadingError: false;
106
+ isRefetchError: false;
107
+ isSuccess: false;
108
+ isPlaceholderData: false;
109
+ status: "pending";
110
+ dataUpdatedAt: number;
111
+ errorUpdatedAt: number;
112
+ failureCount: number;
113
+ failureReason: Error | null;
114
+ errorUpdateCount: number;
115
+ isFetched: boolean;
116
+ isFetchedAfterMount: boolean;
117
+ isFetching: boolean;
118
+ isInitialLoading: boolean;
119
+ isPaused: boolean;
120
+ isRefetching: boolean;
121
+ isStale: boolean;
122
+ isEnabled: boolean;
123
+ refetch: (options?: import('@tanstack/react-query').RefetchOptions) => Promise<import('@tanstack/react-query').QueryObserverResult<GentiqUser, Error>>;
124
+ fetchStatus: import('@tanstack/react-query').FetchStatus;
125
+ promise: Promise<GentiqUser>;
126
+ } | {
127
+ user: GentiqUser | null;
128
+ firstName: string | null;
129
+ data: undefined;
130
+ error: null;
131
+ isError: false;
132
+ isPending: true;
133
+ isLoadingError: false;
134
+ isRefetchError: false;
135
+ isSuccess: false;
136
+ isPlaceholderData: false;
137
+ status: "pending";
138
+ dataUpdatedAt: number;
139
+ errorUpdatedAt: number;
140
+ failureCount: number;
141
+ failureReason: Error | null;
142
+ errorUpdateCount: number;
143
+ isFetched: boolean;
144
+ isFetchedAfterMount: boolean;
145
+ isFetching: boolean;
146
+ isLoading: boolean;
147
+ isInitialLoading: boolean;
148
+ isPaused: boolean;
149
+ isRefetching: boolean;
150
+ isStale: boolean;
151
+ isEnabled: boolean;
152
+ refetch: (options?: import('@tanstack/react-query').RefetchOptions) => Promise<import('@tanstack/react-query').QueryObserverResult<GentiqUser, Error>>;
153
+ fetchStatus: import('@tanstack/react-query').FetchStatus;
154
+ promise: Promise<GentiqUser>;
155
+ } | {
156
+ user: GentiqUser | null;
157
+ firstName: string | null;
158
+ data: GentiqUser;
159
+ isError: false;
160
+ error: null;
161
+ isPending: false;
162
+ isLoading: false;
163
+ isLoadingError: false;
164
+ isRefetchError: false;
165
+ isSuccess: true;
166
+ isPlaceholderData: true;
167
+ status: "success";
168
+ dataUpdatedAt: number;
169
+ errorUpdatedAt: number;
170
+ failureCount: number;
171
+ failureReason: Error | null;
172
+ errorUpdateCount: number;
173
+ isFetched: boolean;
174
+ isFetchedAfterMount: boolean;
175
+ isFetching: boolean;
176
+ isInitialLoading: boolean;
177
+ isPaused: boolean;
178
+ isRefetching: boolean;
179
+ isStale: boolean;
180
+ isEnabled: boolean;
181
+ refetch: (options?: import('@tanstack/react-query').RefetchOptions) => Promise<import('@tanstack/react-query').QueryObserverResult<GentiqUser, Error>>;
182
+ fetchStatus: import('@tanstack/react-query').FetchStatus;
183
+ promise: Promise<GentiqUser>;
184
+ };
@@ -19,5 +19,6 @@ export { default as RequireAuth } from './components/RequireAuth';
19
19
  export { default as UserLoginPage } from './pages/UserLoginPage';
20
20
  export { default as SharedChatView } from './pages/SharedChatView';
21
21
  export { useGentiqChat } from './hooks/useGentiqChat';
22
+ export { useGentiqUser, type UseGentiqUserOptions, } from './hooks/useGentiqUser';
22
23
  export { useComponents } from './ComponentsContext';
23
24
  export { useTranslation, withTranslation, Translation, Trans } from 'react-i18next';
@@ -1,4 +1,4 @@
1
- import { GentiqConfig, GentiqEndpoints } from '../types';
1
+ import { GentiqConfig, GentiqEndpoints, GentiqUser } from '../types';
2
2
  export declare const userAPI: {
3
3
  init: (config: GentiqConfig) => void;
4
4
  getConfig: () => GentiqConfig;
@@ -27,14 +27,14 @@ export declare const userAPI: {
27
27
  */
28
28
  getPublicAttachmentBlobUrl(object_name: string): Promise<string>;
29
29
  saveFeedback: (threadId: string, messageId: string, sentiment: "like" | "dislike" | null) => Promise<any>;
30
- getMe: () => Promise<any>;
30
+ getMe: () => Promise<GentiqUser>;
31
31
  updateMe: (data: {
32
32
  name?: string;
33
33
  surname?: string;
34
34
  phone?: string;
35
35
  password?: string;
36
36
  metadata?: Record<string, any>;
37
- }) => Promise<any>;
37
+ }) => Promise<GentiqUser>;
38
38
  pinThread: (threadId: string, pinned: boolean) => Promise<any>;
39
39
  shareThread: (threadId: string) => Promise<any>;
40
40
  getSharedThread: (shareId: string) => Promise<any>;
@@ -1,5 +1,6 @@
1
1
  import { ComponentType } from 'react';
2
2
  import { UIMessage, UIMessagePart } from 'ai';
3
+ import { TFunction } from 'i18next';
3
4
  /**
4
5
  * Represents a single conversation thread in the history.
5
6
  */
@@ -13,6 +14,35 @@ export interface ConversationEntry {
13
14
  /** Whether the thread is pinned to the top of the list. */
14
15
  pinned?: boolean;
15
16
  }
17
+ /**
18
+ * The authenticated user's profile returned by Gentiq.
19
+ */
20
+ export interface GentiqUser {
21
+ id: string;
22
+ phone: string;
23
+ /** The user's first name. */
24
+ name: string;
25
+ surname: string;
26
+ metadata: Record<string, any>;
27
+ balance?: {
28
+ tokens: number;
29
+ requests: number;
30
+ token_limit: number;
31
+ request_limit: number;
32
+ updated_at?: string | null;
33
+ } | null;
34
+ created_at?: string;
35
+ }
36
+ /**
37
+ * User data available when building a personalized welcome greeting.
38
+ */
39
+ export interface WelcomeGreetingContext {
40
+ user: GentiqUser | null;
41
+ firstName: string | null;
42
+ isLoading: boolean;
43
+ /** Translate the greeting using Gentiq's active language and resources. */
44
+ t: TFunction;
45
+ }
16
46
  /**
17
47
  * Adapter for managing authentication tokens and headers.
18
48
  */
@@ -132,8 +162,11 @@ export interface WelcomeSuggestion {
132
162
  * Configuration for the welcome/empty-state screen.
133
163
  */
134
164
  export interface WelcomeScreenConfig {
135
- /** Optional override for the welcome message title. */
136
- greeting?: string;
165
+ /**
166
+ * Optional override for the welcome message title. A function can be used
167
+ * to personalize the greeting with the authenticated user's first name.
168
+ */
169
+ greeting?: string | ((context: WelcomeGreetingContext) => string);
137
170
  /** Optional override for the welcome message subtitle. */
138
171
  subtitle?: string;
139
172
  /** Optional override for the starter prompt suggestions. */
package/package.json CHANGED
@@ -10,7 +10,7 @@
10
10
  "provenance": true
11
11
  },
12
12
  "description": "React UI library for the Gentiq AI framework.",
13
- "version": "0.7.31",
13
+ "version": "0.7.32",
14
14
  "type": "module",
15
15
  "files": [
16
16
  "dist"