@blocksdiy/blocks-client-sdk 1.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/README.md +1 -0
- package/dist/Action.d.ts +142 -0
- package/dist/Action.d.ts.map +1 -0
- package/dist/Action.js +143 -0
- package/dist/Action.js.map +1 -0
- package/dist/AgentChat.d.ts +42 -0
- package/dist/AgentChat.d.ts.map +1 -0
- package/dist/AgentChat.js +34 -0
- package/dist/AgentChat.js.map +1 -0
- package/dist/ClientSdk.d.ts +309 -0
- package/dist/ClientSdk.d.ts.map +1 -0
- package/dist/ClientSdk.js +396 -0
- package/dist/ClientSdk.js.map +1 -0
- package/dist/Entity.d.ts +299 -0
- package/dist/Entity.d.ts.map +1 -0
- package/dist/Entity.js +329 -0
- package/dist/Entity.js.map +1 -0
- package/dist/Page.d.ts +56 -0
- package/dist/Page.d.ts.map +1 -0
- package/dist/Page.js +52 -0
- package/dist/Page.js.map +1 -0
- package/dist/ReactClientSdk.d.ts +886 -0
- package/dist/ReactClientSdk.d.ts.map +1 -0
- package/dist/ReactClientSdk.jsx +1238 -0
- package/dist/ReactClientSdk.jsx.map +1 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +7 -0
- package/dist/index.js.map +1 -0
- package/package.json +70 -0
|
@@ -0,0 +1,886 @@
|
|
|
1
|
+
import type { ActionConfig } from "./Action.js";
|
|
2
|
+
import type { AgentChatConfig } from "./AgentChat.js";
|
|
3
|
+
import { ClientSdk, UpdateUserOptions } from "./ClientSdk.js";
|
|
4
|
+
import type { EntityConfig, EntityType, EntityTypeOnlyMutable } from "./Entity.js";
|
|
5
|
+
import type { PageConfig } from "./Page.js";
|
|
6
|
+
export declare class ReactClientSdk extends ClientSdk {
|
|
7
|
+
}
|
|
8
|
+
export declare enum AppDataEventTypes {
|
|
9
|
+
APP_DATA_INSERT = "APP_DATA_INSERT",
|
|
10
|
+
APP_DATA_UPDATE = "APP_DATA_UPDATE",
|
|
11
|
+
APP_DATA_DELETE = "APP_DATA_DELETE"
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Provides ClientSdk instance to React component tree
|
|
15
|
+
*
|
|
16
|
+
* This component sets up the necessary context providers for both the ClientSdk
|
|
17
|
+
* and React Query, enabling all the hooks in this module to work properly.
|
|
18
|
+
*
|
|
19
|
+
* @param {Object} props - Component props
|
|
20
|
+
* @param {ClientSdk} props.client - ClientSdk instance to provide
|
|
21
|
+
* @param {React.ReactNode} props.children - Child components
|
|
22
|
+
* @param {ThemeMode} [props.themeMode] - (Optional) Theme mode
|
|
23
|
+
* @param {Function} [props.setThemeMode] - (Optional) Function to set the theme mode
|
|
24
|
+
* @returns {JSX.Element} Provider component
|
|
25
|
+
* @example
|
|
26
|
+
* ```tsx
|
|
27
|
+
* const client = new ClientSdk({ appId: 'my-app-id', user: {
|
|
28
|
+
* email: 'test@test.com',
|
|
29
|
+
* firstName: 'Test',
|
|
30
|
+
* lastName: 'User',
|
|
31
|
+
* isAuthenticated: true,
|
|
32
|
+
* } });
|
|
33
|
+
*
|
|
34
|
+
* function App() {
|
|
35
|
+
* return (
|
|
36
|
+
* <ClientProvider client={client}>
|
|
37
|
+
* <YourAppComponents />
|
|
38
|
+
* </ClientProvider>
|
|
39
|
+
* );
|
|
40
|
+
* }
|
|
41
|
+
* ```
|
|
42
|
+
*/
|
|
43
|
+
export declare const ClientProvider: ({ client, children, themeMode, setThemeMode, }: {
|
|
44
|
+
client: ReactClientSdk;
|
|
45
|
+
children: React.ReactNode;
|
|
46
|
+
themeMode: "dark" | "light" | "system";
|
|
47
|
+
setThemeMode: (themeMode: "dark" | "light" | "system") => void;
|
|
48
|
+
}) => import("react").JSX.Element;
|
|
49
|
+
/**
|
|
50
|
+
* Hook to access the ClientSdk instance from context
|
|
51
|
+
*
|
|
52
|
+
* This hook provides direct access to the ClientSdk, which is the core client
|
|
53
|
+
* for interacting with entities, actions, and pages.
|
|
54
|
+
*
|
|
55
|
+
* @returns {ClientSdk} The ClientSdk instance
|
|
56
|
+
* @throws {Error} If used outside of ClientProvider
|
|
57
|
+
* @example
|
|
58
|
+
* ```tsx
|
|
59
|
+
* function MyComponent() {
|
|
60
|
+
* const client = useClient();
|
|
61
|
+
* // Use client directly for advanced use cases
|
|
62
|
+
* const userEntity = client.entity(userConfig);
|
|
63
|
+
* }
|
|
64
|
+
* ```
|
|
65
|
+
*/
|
|
66
|
+
export declare const useClient: () => ReactClientSdk;
|
|
67
|
+
/**
|
|
68
|
+
* Hook to fetch all entities of a specific type
|
|
69
|
+
*
|
|
70
|
+
* Entities represent data objects stored in tables with standard CRUD operations.
|
|
71
|
+
* This hook provides a React Query-powered way to fetch multiple entities.
|
|
72
|
+
*
|
|
73
|
+
* EntityConfig properties:
|
|
74
|
+
* - tableBlockId: Unique identifier for the table
|
|
75
|
+
* - instanceType: TypeScript type defining the entity's structure
|
|
76
|
+
*
|
|
77
|
+
* @template E - Entity configuration type
|
|
78
|
+
* @param {E} entityConfig - Configuration for the entity type
|
|
79
|
+
* @param {any} [filters] - Optional filters to apply to the query
|
|
80
|
+
* @param {Object} [queryOptions] - Optional React Query configuration options
|
|
81
|
+
* @param {boolean} [queryOptions.enabled] - Whether the query should automatically execute
|
|
82
|
+
* @param {EntityType<E>[]} [queryOptions.initialData] - Initial data to use for the query
|
|
83
|
+
* @param {EntityType<E>[]} [queryOptions.placeholderData] - Placeholder data to use while loading
|
|
84
|
+
* @returns {Object} Query result with data, loading state, and error
|
|
85
|
+
* @returns {EntityType<E>[] | undefined} returns.data - The fetched entities
|
|
86
|
+
* @returns {boolean} returns.isLoading - Whether the query is loading
|
|
87
|
+
* @returns {Error | null} returns.error - Any error that occurred
|
|
88
|
+
* @returns {Function} returns.refetch - Function to manually refetch the data
|
|
89
|
+
* @returns {boolean} returns.isError - Whether the query resulted in an error
|
|
90
|
+
* @returns {boolean} returns.isFetched - Whether the query has been fetched
|
|
91
|
+
* @returns {boolean} returns.isFetching - Whether the query is currently fetching
|
|
92
|
+
* @returns {boolean} returns.isSuccess - Whether the query was successful
|
|
93
|
+
* @returns {string} returns.status - Current status of the query: 'idle', 'loading', 'success', 'error', or 'pending'
|
|
94
|
+
* @example
|
|
95
|
+
* ```tsx
|
|
96
|
+
* // Define a Item entity configuration
|
|
97
|
+
* const itemConfig = {
|
|
98
|
+
* tableBlockId: 'items-table',
|
|
99
|
+
* instanceType: {} as {
|
|
100
|
+
* name: string;
|
|
101
|
+
* price: number;
|
|
102
|
+
* }
|
|
103
|
+
* };
|
|
104
|
+
*
|
|
105
|
+
* function ItemsList() {
|
|
106
|
+
* const { data: items, isLoading } = useEntityGetAll(itemConfig);
|
|
107
|
+
*
|
|
108
|
+
* if (isLoading) return <div>Loading...</div>;
|
|
109
|
+
* return (
|
|
110
|
+
* <ul>
|
|
111
|
+
* {items?.map(item => <li key={item.id}>{item.name}</li>)}
|
|
112
|
+
* </ul>
|
|
113
|
+
* );
|
|
114
|
+
* }
|
|
115
|
+
* ```
|
|
116
|
+
*/
|
|
117
|
+
export declare const useEntityGetAll: <E extends EntityConfig>(entityConfig: E, filters?: any, queryOptions?: {
|
|
118
|
+
enabled?: boolean;
|
|
119
|
+
initialData?: EntityType<E>[];
|
|
120
|
+
placeholderData?: EntityType<E>[];
|
|
121
|
+
}) => {
|
|
122
|
+
data: EntityType<E>[] | undefined;
|
|
123
|
+
isLoading: boolean;
|
|
124
|
+
error: Error | null;
|
|
125
|
+
refetch: () => void;
|
|
126
|
+
isError: boolean;
|
|
127
|
+
isFetched: boolean;
|
|
128
|
+
isFetching: boolean;
|
|
129
|
+
isSuccess: boolean;
|
|
130
|
+
status: "idle" | "loading" | "success" | "error" | "pending";
|
|
131
|
+
};
|
|
132
|
+
/**
|
|
133
|
+
* Hook to fetch a single entity by filters
|
|
134
|
+
*
|
|
135
|
+
* Retrieves a specific entity instance using filter criteria.
|
|
136
|
+
* EntityConfig defines the structure and mapping of the entity data.
|
|
137
|
+
*
|
|
138
|
+
* @template EC - Entity configuration type
|
|
139
|
+
* @param {EC} entityConfig - Configuration for the entity type
|
|
140
|
+
* @param {Record<string, any>} filters - Filters to identify the entity (e.g., { id: "123" } or { email: "user@example.com" })
|
|
141
|
+
* @param {Object} [queryOptions] - Optional React Query configuration options
|
|
142
|
+
* @param {boolean} [queryOptions.enabled] - Whether the query should automatically execute
|
|
143
|
+
* @param {EntityType<EC> | null} [queryOptions.initialData] - Initial data to use for the query
|
|
144
|
+
* @returns {Object} Query result with data, loading state, and error
|
|
145
|
+
* @returns {EntityType<EC> | undefined | null} returns.data - The fetched entity
|
|
146
|
+
* @returns {boolean} returns.isLoading - Whether the query is loading
|
|
147
|
+
* @returns {Error | null} returns.error - Any error that occurred
|
|
148
|
+
* @returns {Function} returns.refetch - Function to manually refetch the data
|
|
149
|
+
* @returns {boolean} returns.isError - Whether the query resulted in an error
|
|
150
|
+
* @returns {boolean} returns.isFetched - Whether the query has been fetched
|
|
151
|
+
* @returns {boolean} returns.isFetching - Whether the query is currently fetching
|
|
152
|
+
* @returns {boolean} returns.isSuccess - Whether the query was successful
|
|
153
|
+
* @returns {string} returns.status - Current status of the query: 'idle', 'loading', 'success', 'error', or 'pending'
|
|
154
|
+
* @example
|
|
155
|
+
* ```tsx
|
|
156
|
+
* // Define the entity configuration
|
|
157
|
+
* const userConfig = {
|
|
158
|
+
* tableBlockId: 'users-table',
|
|
159
|
+
* instanceType: {} as {
|
|
160
|
+
* name: string;
|
|
161
|
+
* email: string;
|
|
162
|
+
* }
|
|
163
|
+
* };
|
|
164
|
+
*
|
|
165
|
+
* function UserProfile({ userEmail }) {
|
|
166
|
+
* const { data: user, isLoading } = useEntityGetOne(UserEntity, { email: userEmail });
|
|
167
|
+
*
|
|
168
|
+
* if (isLoading) return <div>Loading...</div>;
|
|
169
|
+
* if (!user) return <div>User not found</div>;
|
|
170
|
+
*
|
|
171
|
+
* return <div>Name: {user.name}</div>;
|
|
172
|
+
* }
|
|
173
|
+
* ```
|
|
174
|
+
*/
|
|
175
|
+
export declare const useEntityGetOne: <EC extends EntityConfig = EntityConfig>(entityConfig: EC, filters: Record<string, any>, queryOptions?: {
|
|
176
|
+
enabled?: boolean;
|
|
177
|
+
initialData?: EntityType<EC> | null;
|
|
178
|
+
}) => {
|
|
179
|
+
data: EntityType<EC> | undefined | null;
|
|
180
|
+
isLoading: boolean;
|
|
181
|
+
error: Error | null;
|
|
182
|
+
refetch: () => void;
|
|
183
|
+
isError: boolean;
|
|
184
|
+
isFetched: boolean;
|
|
185
|
+
isFetching: boolean;
|
|
186
|
+
isSuccess: boolean;
|
|
187
|
+
status: "idle" | "loading" | "success" | "error" | "pending";
|
|
188
|
+
};
|
|
189
|
+
/**
|
|
190
|
+
* Hook to create a new entity
|
|
191
|
+
*
|
|
192
|
+
* Creates a new entity instance in the data store.
|
|
193
|
+
* EntityTypeOnlyMutable<EC> represents the writable properties of the entity.
|
|
194
|
+
*
|
|
195
|
+
* @template EC - Entity configuration type
|
|
196
|
+
* @param {EC} entityConfig - Configuration for the entity type
|
|
197
|
+
* @returns {Object} Mutation object with create function, loading state, and error
|
|
198
|
+
* @example
|
|
199
|
+
* ```tsx
|
|
200
|
+
* // Define the entity configuration
|
|
201
|
+
* const userConfig = {
|
|
202
|
+
* tableBlockId: 'users-table',
|
|
203
|
+
* instanceType: {} as {
|
|
204
|
+
* name: string;
|
|
205
|
+
* email: string;
|
|
206
|
+
* }
|
|
207
|
+
* };
|
|
208
|
+
*
|
|
209
|
+
* function CreateUserForm() {
|
|
210
|
+
* const { createFunction, isLoading } = useEntityCreate(userConfig);
|
|
211
|
+
* const [name, setName] = useState('');
|
|
212
|
+
* const [email, setEmail] = useState('');
|
|
213
|
+
*
|
|
214
|
+
* const handleSubmit = async (e) => {
|
|
215
|
+
* e.preventDefault();
|
|
216
|
+
* await createFunction({
|
|
217
|
+
* data: {
|
|
218
|
+
* name,
|
|
219
|
+
* email
|
|
220
|
+
* }
|
|
221
|
+
* });
|
|
222
|
+
* setName('');
|
|
223
|
+
* setEmail('');
|
|
224
|
+
* };
|
|
225
|
+
*
|
|
226
|
+
* return (
|
|
227
|
+
* <form onSubmit={handleSubmit}>
|
|
228
|
+
* <input value={name} onChange={e => setName(e.target.value)} placeholder="Name" />
|
|
229
|
+
* <input value={email} onChange={e => setEmail(e.target.value)} placeholder="Email" />
|
|
230
|
+
* <button type="submit" disabled={isLoading}>Create</button>
|
|
231
|
+
* </form>
|
|
232
|
+
* );
|
|
233
|
+
* }
|
|
234
|
+
* ```
|
|
235
|
+
*/
|
|
236
|
+
export declare const useEntityCreate: <EC extends EntityConfig = EntityConfig>(entityConfig: EC) => {
|
|
237
|
+
createFunction: ({ data }: {
|
|
238
|
+
data: EntityTypeOnlyMutable<EC>;
|
|
239
|
+
}) => Promise<EntityType<EC>>;
|
|
240
|
+
isLoading: boolean;
|
|
241
|
+
error: Error | null;
|
|
242
|
+
};
|
|
243
|
+
/**
|
|
244
|
+
* Hook to create multiple entities in a single operation
|
|
245
|
+
*
|
|
246
|
+
* Creates multiple entity instances in the data store in one batch operation.
|
|
247
|
+
* This is more efficient than calling useEntityCreate multiple times when you need
|
|
248
|
+
* to create several entities at once. EntityTypeOnlyMutable<EC> represents the
|
|
249
|
+
* writable properties of the entity.
|
|
250
|
+
*
|
|
251
|
+
* @template EC - Entity configuration type
|
|
252
|
+
* @param {EC} entityConfig - Configuration for the entity type
|
|
253
|
+
* @returns {Object} Mutation object with createMany function, loading state, and error
|
|
254
|
+
* @example
|
|
255
|
+
* ```tsx
|
|
256
|
+
* // Define the entity configuration
|
|
257
|
+
* const taskConfig = {
|
|
258
|
+
* tableBlockId: 'tasks-table',
|
|
259
|
+
* instanceType: {} as {
|
|
260
|
+
* title: string;
|
|
261
|
+
* status: 'todo' | 'in_progress' | 'done';
|
|
262
|
+
* assigneeId: string;
|
|
263
|
+
* }
|
|
264
|
+
* };
|
|
265
|
+
*
|
|
266
|
+
* function ImportTasksButton() {
|
|
267
|
+
* const { createManyFunction, isLoading } = useEntityCreateMany(taskConfig);
|
|
268
|
+
*
|
|
269
|
+
* const handleImport = async () => {
|
|
270
|
+
* const tasksToCreate = [
|
|
271
|
+
* { title: 'Review code', status: 'todo', assigneeId: 'user-1' },
|
|
272
|
+
* { title: 'Write tests', status: 'todo', assigneeId: 'user-2' },
|
|
273
|
+
* { title: 'Update docs', status: 'in_progress', assigneeId: 'user-1' }
|
|
274
|
+
* ];
|
|
275
|
+
*
|
|
276
|
+
* const createdTasks = await createManyFunction({ data: tasksToCreate });
|
|
277
|
+
* console.log(`Created ${createdTasks.length} tasks`);
|
|
278
|
+
* };
|
|
279
|
+
*
|
|
280
|
+
* return (
|
|
281
|
+
* <button onClick={handleImport} disabled={isLoading}>
|
|
282
|
+
* {isLoading ? 'Importing...' : 'Import Tasks'}
|
|
283
|
+
* </button>
|
|
284
|
+
* );
|
|
285
|
+
* }
|
|
286
|
+
* ```
|
|
287
|
+
*/
|
|
288
|
+
export declare const useEntityCreateMany: <EC extends EntityConfig = EntityConfig>(entityConfig: EC) => {
|
|
289
|
+
createManyFunction: ({ data }: {
|
|
290
|
+
data: EntityTypeOnlyMutable<EC>[];
|
|
291
|
+
}) => Promise<EntityType<EC>[]>;
|
|
292
|
+
isLoading: boolean;
|
|
293
|
+
error: Error | null;
|
|
294
|
+
};
|
|
295
|
+
/**
|
|
296
|
+
* Hook to update an existing entity
|
|
297
|
+
*
|
|
298
|
+
* Updates an existing entity with the provided partial data.
|
|
299
|
+
* Only the properties included in the data object will be updated.
|
|
300
|
+
*
|
|
301
|
+
* @template EC - Entity configuration type
|
|
302
|
+
* @param {EC} entityConfig - Configuration for the entity type
|
|
303
|
+
* @returns {Object} Mutation object with update function, loading state, and error
|
|
304
|
+
* @example
|
|
305
|
+
* ```tsx
|
|
306
|
+
* // Define the entity configuration
|
|
307
|
+
* const userConfig = {
|
|
308
|
+
* tableBlockId: 'users-table',
|
|
309
|
+
* instanceType: {} as {
|
|
310
|
+
* name: string;
|
|
311
|
+
* email: string;
|
|
312
|
+
* }
|
|
313
|
+
* };
|
|
314
|
+
*
|
|
315
|
+
* function EditUserForm({ user }) {
|
|
316
|
+
* const { updateFunction, isLoading } = useEntityUpdate(userConfig);
|
|
317
|
+
* const [name, setName] = useState(user.name);
|
|
318
|
+
*
|
|
319
|
+
* const handleSubmit = async (e) => {
|
|
320
|
+
* e.preventDefault();
|
|
321
|
+
* await updateFunction({
|
|
322
|
+
* id: user.id,
|
|
323
|
+
* data: { name }
|
|
324
|
+
* });
|
|
325
|
+
* };
|
|
326
|
+
*
|
|
327
|
+
* return (
|
|
328
|
+
* <form onSubmit={handleSubmit}>
|
|
329
|
+
* <input value={name} onChange={e => setName(e.target.value)} />
|
|
330
|
+
* <button type="submit" disabled={isLoading}>Update</button>
|
|
331
|
+
* </form>
|
|
332
|
+
* );
|
|
333
|
+
* }
|
|
334
|
+
* ```
|
|
335
|
+
*/
|
|
336
|
+
export declare const useEntityUpdate: <EC extends EntityConfig = EntityConfig>(entityConfig: EC) => {
|
|
337
|
+
updateFunction: ({ id, data }: {
|
|
338
|
+
id: string;
|
|
339
|
+
data: Partial<EntityTypeOnlyMutable<EC>>;
|
|
340
|
+
}) => Promise<EntityType<EC>>;
|
|
341
|
+
isLoading: boolean;
|
|
342
|
+
error: Error | null;
|
|
343
|
+
};
|
|
344
|
+
/**
|
|
345
|
+
* Hook to delete an entity
|
|
346
|
+
*
|
|
347
|
+
* Permanently removes an entity from the data store by its ID.
|
|
348
|
+
* Automatically invalidates relevant queries after deletion.
|
|
349
|
+
*
|
|
350
|
+
* @template EC - Entity configuration type
|
|
351
|
+
* @param {EC} entityConfig - Configuration for the entity type
|
|
352
|
+
* @returns {Object} Mutation object with delete function, loading state, and error
|
|
353
|
+
* @example
|
|
354
|
+
* ```tsx
|
|
355
|
+
* // Define the entity configuration
|
|
356
|
+
* const userConfig = {
|
|
357
|
+
* tableBlockId: 'users-table',
|
|
358
|
+
* instanceType: {} as {
|
|
359
|
+
* name: string;
|
|
360
|
+
* email: string;
|
|
361
|
+
* }
|
|
362
|
+
* };
|
|
363
|
+
*
|
|
364
|
+
* function DeleteUserButton({ userId }) {
|
|
365
|
+
* const { deleteFunction, isLoading } = useEntityDelete(userConfig);
|
|
366
|
+
*
|
|
367
|
+
* const handleDelete = async () => {
|
|
368
|
+
* if (confirm('Are you sure?')) {
|
|
369
|
+
* await deleteFunction({ id: userId });
|
|
370
|
+
* }
|
|
371
|
+
* };
|
|
372
|
+
*
|
|
373
|
+
* return (
|
|
374
|
+
* <button onClick={handleDelete} disabled={isLoading}>
|
|
375
|
+
* Delete User
|
|
376
|
+
* </button>
|
|
377
|
+
* );
|
|
378
|
+
* }
|
|
379
|
+
* ```
|
|
380
|
+
*/
|
|
381
|
+
export declare const useEntityDelete: <EC extends EntityConfig = EntityConfig>(entityConfig: EC) => {
|
|
382
|
+
deleteFunction: ({ id }: {
|
|
383
|
+
id: string;
|
|
384
|
+
}) => Promise<void>;
|
|
385
|
+
isLoading: boolean;
|
|
386
|
+
error: Error | null;
|
|
387
|
+
};
|
|
388
|
+
/**
|
|
389
|
+
* Hook to delete multiple entities at once
|
|
390
|
+
*
|
|
391
|
+
* Permanently removes multiple entities from the data store by their IDs.
|
|
392
|
+
* Automatically invalidates relevant queries after deletion.
|
|
393
|
+
*
|
|
394
|
+
* @template EC - Entity configuration type
|
|
395
|
+
* @param {EC} entityConfig - Configuration for the entity type
|
|
396
|
+
* @returns {Object} Mutation object with delete many function, loading state, and error
|
|
397
|
+
* @example
|
|
398
|
+
* ```tsx
|
|
399
|
+
* // Define the entity configuration
|
|
400
|
+
* const userConfig = {
|
|
401
|
+
* tableBlockId: 'users-table',
|
|
402
|
+
* instanceType: {} as {
|
|
403
|
+
* name: string;
|
|
404
|
+
* email: string;
|
|
405
|
+
* }
|
|
406
|
+
* };
|
|
407
|
+
*
|
|
408
|
+
* function DeleteSelectedUsersButton({ selectedUserIds }) {
|
|
409
|
+
* const { deleteManyFunction, isLoading } = useEntityDeleteMany(userConfig);
|
|
410
|
+
*
|
|
411
|
+
* const handleDeleteSelected = async () => {
|
|
412
|
+
* if (confirm(`Delete ${selectedUserIds.length} users?`)) {
|
|
413
|
+
* await deleteManyFunction({ ids: selectedUserIds });
|
|
414
|
+
* }
|
|
415
|
+
* };
|
|
416
|
+
*
|
|
417
|
+
* return (
|
|
418
|
+
* <button onClick={handleDeleteSelected} disabled={isLoading}>
|
|
419
|
+
* Delete Selected ({selectedUserIds.length})
|
|
420
|
+
* </button>
|
|
421
|
+
* );
|
|
422
|
+
* }
|
|
423
|
+
* ```
|
|
424
|
+
*/
|
|
425
|
+
export declare const useEntityDeleteMany: <EC extends EntityConfig = EntityConfig>(entityConfig: EC) => {
|
|
426
|
+
deleteManyFunction: ({ ids }: {
|
|
427
|
+
ids: string[];
|
|
428
|
+
}) => Promise<void>;
|
|
429
|
+
isLoading: boolean;
|
|
430
|
+
error: Error | null;
|
|
431
|
+
};
|
|
432
|
+
/**
|
|
433
|
+
* Hook to execute an action, with support for streaming results
|
|
434
|
+
*
|
|
435
|
+
* Actions represent executable workflows that perform any type of server-side operation,
|
|
436
|
+
* including data processing, business logic, integrations with external
|
|
437
|
+
* services, file operations, AI functionalities, and more. This hook provides a React-friendly
|
|
438
|
+
* way to execute these actions with proper state management.
|
|
439
|
+
*
|
|
440
|
+
* AI capabilities are a particularly interesting use case for actions - you can leverage
|
|
441
|
+
* various AI models and services while the SDK handles the complexity of streaming responses,
|
|
442
|
+
* state management, and UI integration.
|
|
443
|
+
*
|
|
444
|
+
* The hook provides two different result states:
|
|
445
|
+
* - `result`: Contains the final, complete output once the action execution is done
|
|
446
|
+
* - `streamResult`: Contains incrementally updating results during streaming operations,
|
|
447
|
+
* updated in real-time as chunks arrive from the server before the action is complete
|
|
448
|
+
*
|
|
449
|
+
* ActionConfig properties:
|
|
450
|
+
* - actionBlockId: Unique identifier for the action workflow
|
|
451
|
+
* - inputInstanceType: TypeScript type defining the action's input parameters
|
|
452
|
+
* - outputInstanceType: TypeScript type defining the action's output structure
|
|
453
|
+
*
|
|
454
|
+
* @template AC - Action configuration type
|
|
455
|
+
* @param {AC} actionConfig - Configuration for the action
|
|
456
|
+
* @returns {Object} Action execution object with functions, state, and results
|
|
457
|
+
* @returns {Function} returns.executeFunction - Function to execute the action with inputs
|
|
458
|
+
* @returns {AC["outputInstanceType"]} returns.result - Final result after action completes
|
|
459
|
+
* @returns {AC["outputInstanceType"]} returns.streamResult - Incrementally updated result during streaming
|
|
460
|
+
* @returns {boolean} returns.isLoading - Whether the action is currently executing
|
|
461
|
+
* @returns {boolean} returns.isDone - Whether the action has completed
|
|
462
|
+
* @returns {Error | null} returns.error - Any error that occurred during execution
|
|
463
|
+
* @returns {Function} returns.clear - Function to clear result and streamResult values
|
|
464
|
+
* @example
|
|
465
|
+
* ```tsx
|
|
466
|
+
* // Example 1: Process payment action
|
|
467
|
+
* const processPaymentConfig = {
|
|
468
|
+
* actionBlockId: 'process-payment',
|
|
469
|
+
* inputInstanceType: {} as {
|
|
470
|
+
* amount: number;
|
|
471
|
+
* paymentMethod: string;
|
|
472
|
+
* currency: string;
|
|
473
|
+
* },
|
|
474
|
+
* outputInstanceType: {} as {
|
|
475
|
+
* success: boolean;
|
|
476
|
+
* transactionId: string;
|
|
477
|
+
* receiptUrl?: string;
|
|
478
|
+
* error?: string;
|
|
479
|
+
* }
|
|
480
|
+
* };
|
|
481
|
+
*
|
|
482
|
+
* function PaymentForm() {
|
|
483
|
+
* const { executeFunction, result, isLoading, error } = useExecuteAction(processPaymentConfig);
|
|
484
|
+
* const [amount, setAmount] = useState('');
|
|
485
|
+
* const [paymentMethod, setPaymentMethod] = useState('credit_card');
|
|
486
|
+
*
|
|
487
|
+
* const handleSubmit = async (e) => {
|
|
488
|
+
* e.preventDefault();
|
|
489
|
+
* await executeFunction({
|
|
490
|
+
* amount: parseFloat(amount),
|
|
491
|
+
* paymentMethod,
|
|
492
|
+
* currency: 'USD'
|
|
493
|
+
* });
|
|
494
|
+
* };
|
|
495
|
+
*
|
|
496
|
+
* return (
|
|
497
|
+
* <div>
|
|
498
|
+
* <form onSubmit={handleSubmit}>
|
|
499
|
+
* <input
|
|
500
|
+
* type="number"
|
|
501
|
+
* value={amount}
|
|
502
|
+
* onChange={e => setAmount(e.target.value)}
|
|
503
|
+
* placeholder="Amount"
|
|
504
|
+
* />
|
|
505
|
+
* <select value={paymentMethod} onChange={e => setPaymentMethod(e.target.value)}>
|
|
506
|
+
* <option value="credit_card">Credit Card</option>
|
|
507
|
+
* <option value="paypal">PayPal</option>
|
|
508
|
+
* </select>
|
|
509
|
+
* <button type="submit" disabled={isLoading}>Process Payment</button>
|
|
510
|
+
* </form>
|
|
511
|
+
*
|
|
512
|
+
* {isLoading && <div>Processing payment...</div>}
|
|
513
|
+
* {error && <div className="error">Error: {error.message}</div>}
|
|
514
|
+
* {result?.success && <div className="success">
|
|
515
|
+
* Payment successful! Transaction ID: {result.transactionId}
|
|
516
|
+
* </div>}
|
|
517
|
+
* </div>
|
|
518
|
+
* );
|
|
519
|
+
* }
|
|
520
|
+
*
|
|
521
|
+
* // Example 2: Data export action (with streaming)
|
|
522
|
+
* const exportDataConfig = {
|
|
523
|
+
* actionBlockId: 'export-data',
|
|
524
|
+
* inputInstanceType: {} as {
|
|
525
|
+
* format: 'csv' | 'json';
|
|
526
|
+
* filters: Record<string, any>;
|
|
527
|
+
* },
|
|
528
|
+
* outputInstanceType: {} as {
|
|
529
|
+
* progress: number;
|
|
530
|
+
* downloadUrl?: string;
|
|
531
|
+
* status: string;
|
|
532
|
+
* }
|
|
533
|
+
* };
|
|
534
|
+
*
|
|
535
|
+
* function DataExportTool() {
|
|
536
|
+
* const { executeFunction, result, isLoading, isDone } = useExecuteAction(exportDataConfig);
|
|
537
|
+
* const [format, setFormat] = useState<'csv' | 'json'>('csv');
|
|
538
|
+
*
|
|
539
|
+
* const handleExport = async () => {
|
|
540
|
+
* await executeFunction({
|
|
541
|
+
* format,
|
|
542
|
+
* filters: { startDate: '2023-01-01' }
|
|
543
|
+
* });
|
|
544
|
+
* };
|
|
545
|
+
*
|
|
546
|
+
* return (
|
|
547
|
+
* <div>
|
|
548
|
+
* <div>
|
|
549
|
+
* <select value={format} onChange={e => setFormat(e.target.value as 'csv' | 'json')}>
|
|
550
|
+
* <option value="csv">CSV</option>
|
|
551
|
+
* <option value="json">JSON</option>
|
|
552
|
+
* </select>
|
|
553
|
+
* <button onClick={handleExport} disabled={isLoading}>Export Data</button>
|
|
554
|
+
* </div>
|
|
555
|
+
*
|
|
556
|
+
* {isLoading && !isDone && (
|
|
557
|
+
* <div>
|
|
558
|
+
* {result?.progress ? `Export in progress: ${result.progress}%` : 'Starting export...'}
|
|
559
|
+
* </div>
|
|
560
|
+
* )}
|
|
561
|
+
* {isDone && result?.downloadUrl && (
|
|
562
|
+
* <a href={result.downloadUrl} download>Download your data</a>
|
|
563
|
+
* )}
|
|
564
|
+
* </div>
|
|
565
|
+
* );
|
|
566
|
+
* }
|
|
567
|
+
* ```
|
|
568
|
+
*/
|
|
569
|
+
export declare const useExecuteAction: <AC extends ActionConfig = ActionConfig>(actionConfig: AC) => {
|
|
570
|
+
executeFunction: import("@tanstack/react-query").UseMutateAsyncFunction<AC["outputInstanceType"], Error, AC["inputInstanceType"], unknown>;
|
|
571
|
+
result: AC["outputInstanceType"] | undefined;
|
|
572
|
+
streamResult: AC["outputInstanceType"] | undefined;
|
|
573
|
+
isLoading: boolean;
|
|
574
|
+
isDone: boolean;
|
|
575
|
+
error: Error | null;
|
|
576
|
+
clear: () => void;
|
|
577
|
+
};
|
|
578
|
+
/**
|
|
579
|
+
* Hook to get an AgentChat instance
|
|
580
|
+
*
|
|
581
|
+
* This hook provides access to an AgentChat instance for the specified configuration.
|
|
582
|
+
*
|
|
583
|
+
* @template ACC - AgentChat configuration type
|
|
584
|
+
* @param {ACC} agentChatConfig - Configuration for the agent chat
|
|
585
|
+
* @returns {AgentChat<ACC>} An AgentChat instance for the given configuration
|
|
586
|
+
* @example
|
|
587
|
+
* ```tsx
|
|
588
|
+
* // Define the agent chat configuration
|
|
589
|
+
* const agentChatConfig = {
|
|
590
|
+
* agentChatId: 'agent-chat-id'
|
|
591
|
+
* };
|
|
592
|
+
*
|
|
593
|
+
* function AgentChatComponent() {
|
|
594
|
+
* const agentChat = useAgentChat(agentChatConfig);
|
|
595
|
+
* return <AgentChat agentChat={agentChat} />;
|
|
596
|
+
* }
|
|
597
|
+
* ```
|
|
598
|
+
*/
|
|
599
|
+
export declare const useAgentChat: <ACC extends AgentChatConfig = AgentChatConfig>(agentChatConfig: ACC) => import("./AgentChat.js").AgentChat<ACC>;
|
|
600
|
+
/**
|
|
601
|
+
* Hook to handle file uploads
|
|
602
|
+
*
|
|
603
|
+
* Provides a function to upload files with progress tracking
|
|
604
|
+
*
|
|
605
|
+
* @returns {Object} Upload object with upload functionality and status
|
|
606
|
+
* @returns {Function} returns.uploadFunction - Function that takes a File and returns a Promise with the URL
|
|
607
|
+
* @returns {boolean} returns.isLoading - Whether an upload is in progress
|
|
608
|
+
* @returns {number} returns.uploadPercentage - Current upload progress (0-100)
|
|
609
|
+
* @example
|
|
610
|
+
* ```tsx
|
|
611
|
+
* function FileUploader() {
|
|
612
|
+
* const { uploadFunction, isLoading, uploadPercentage } = useFileUpload();
|
|
613
|
+
* const [fileUrl, setFileUrl] = useState('');
|
|
614
|
+
*
|
|
615
|
+
* const handleFileChange = async (event) => {
|
|
616
|
+
* const file = event.target.files[0];
|
|
617
|
+
* if (file) {
|
|
618
|
+
* try {
|
|
619
|
+
* const url = await uploadFunction(file);
|
|
620
|
+
* setFileUrl(url);
|
|
621
|
+
* } catch (error) {
|
|
622
|
+
* console.error('Upload failed:', error);
|
|
623
|
+
* }
|
|
624
|
+
* }
|
|
625
|
+
* };
|
|
626
|
+
*
|
|
627
|
+
* return (
|
|
628
|
+
* <div>
|
|
629
|
+
* <input type="file" onChange={handleFileChange} disabled={isLoading} />
|
|
630
|
+
* {isLoading && <Progress value={uploadPercentage} />}
|
|
631
|
+
* {fileUrl && <img src={fileUrl} alt="Uploaded file" />}
|
|
632
|
+
* </div>
|
|
633
|
+
* );
|
|
634
|
+
* }
|
|
635
|
+
* ```
|
|
636
|
+
*/
|
|
637
|
+
export declare const useFileUpload: () => {
|
|
638
|
+
uploadFunction: (file: File) => Promise<string>;
|
|
639
|
+
isLoading: boolean;
|
|
640
|
+
uploadPercentage: number;
|
|
641
|
+
};
|
|
642
|
+
/**
|
|
643
|
+
* Represents a user's data
|
|
644
|
+
* @interface User
|
|
645
|
+
* @property {string} [id] - The user's ID (optional, must exist if user is authenticated)
|
|
646
|
+
* @property {string} [email] - The user's email (optional, must exist if user is authenticated)
|
|
647
|
+
* @property {string} [name] - The user's name (optional, must exist if user is authenticated)
|
|
648
|
+
* @property {string} [profileImageUrl] - The user's profile image URL (optional)
|
|
649
|
+
* @property {string} [firstName] - The user's first name (optional)
|
|
650
|
+
* @property {string} [lastName] - The user's last name (optional)
|
|
651
|
+
* @property {string} [role] - The user's role name (optional)
|
|
652
|
+
* @property {string} [permission] - The user's permission level: 'build' (can modify app) or 'use' (read-only) (optional)
|
|
653
|
+
*/
|
|
654
|
+
/**
|
|
655
|
+
* Hook to get the current user information
|
|
656
|
+
*
|
|
657
|
+
* This hook provides access to the user's data
|
|
658
|
+
* that was provided during SDK initialization, including role information for multi-role apps.
|
|
659
|
+
*
|
|
660
|
+
* @returns {User} The current user object with optional role property
|
|
661
|
+
* @example
|
|
662
|
+
* ```tsx
|
|
663
|
+
* const user = useUser();
|
|
664
|
+
* console.log(user.isAuthenticated ? `Logged in as: ${user.firstName} ${user.lastName}` : "Not logged in");
|
|
665
|
+
*
|
|
666
|
+
* // For multi-role apps, conditionally render based on role
|
|
667
|
+
* if (user.role === "Manager") {
|
|
668
|
+
* return <ManagerDashboard />;
|
|
669
|
+
* } else if (user.role === "Employee") {
|
|
670
|
+
* return <EmployeeDashboard />;
|
|
671
|
+
* }
|
|
672
|
+
* ```
|
|
673
|
+
*/
|
|
674
|
+
export declare const useUser: () => import("./ClientSdk.js").User;
|
|
675
|
+
/**
|
|
676
|
+
* Hook to manage the application theme mode
|
|
677
|
+
*
|
|
678
|
+
* This hook provides access to the current theme mode and a function to change it.
|
|
679
|
+
* It supports three theme modes: dark, light, and system (which follows the user's OS preference).
|
|
680
|
+
*
|
|
681
|
+
* @returns {Object} Object containing current theme mode and setter function
|
|
682
|
+
* @returns {("dark" | "light" | "system")} themeMode - The current theme mode
|
|
683
|
+
* @returns {Function} setThemeMode - Function to update the theme mode
|
|
684
|
+
* @example
|
|
685
|
+
* ```tsx
|
|
686
|
+
* function ThemeToggle() {
|
|
687
|
+
* const { themeMode, setThemeMode } = useThemeMode();
|
|
688
|
+
*
|
|
689
|
+
* return (
|
|
690
|
+
* <div>
|
|
691
|
+
* <p>Current theme: {themeMode}</p>
|
|
692
|
+
* <button onClick={() => setThemeMode("dark")}>Dark</button>
|
|
693
|
+
* <button onClick={() => setThemeMode("light")}>Light</button>
|
|
694
|
+
* <button onClick={() => setThemeMode("system")}>System</button>
|
|
695
|
+
* </div>
|
|
696
|
+
* );
|
|
697
|
+
* }
|
|
698
|
+
*
|
|
699
|
+
* // Example with a select dropdown
|
|
700
|
+
* function ThemeSelector() {
|
|
701
|
+
* const { themeMode, setThemeMode } = useThemeMode();
|
|
702
|
+
*
|
|
703
|
+
* return (
|
|
704
|
+
* <select
|
|
705
|
+
* value={themeMode}
|
|
706
|
+
* onChange={(e) => setThemeMode(e.target.value as "dark" | "light" | "system")}
|
|
707
|
+
* >
|
|
708
|
+
* <option value="system">System</option>
|
|
709
|
+
* <option value="light">Light</option>
|
|
710
|
+
* <option value="dark">Dark</option>
|
|
711
|
+
* </select>
|
|
712
|
+
* );
|
|
713
|
+
* }
|
|
714
|
+
* ```
|
|
715
|
+
*/
|
|
716
|
+
export declare const useThemeMode: () => {
|
|
717
|
+
themeMode: "dark" | "light" | "system";
|
|
718
|
+
setThemeMode: (themeMode: "dark" | "light" | "system") => void;
|
|
719
|
+
};
|
|
720
|
+
/**
|
|
721
|
+
* Hook to change a user's role in multi-role applications
|
|
722
|
+
*
|
|
723
|
+
* This hook provides functionality to change a user's role, but only if the current user
|
|
724
|
+
* has "build" permission. The hook automatically invalidates relevant queries after a successful
|
|
725
|
+
* role change, including the current user's data if they changed their own role.
|
|
726
|
+
*
|
|
727
|
+
* @param {Object} [params] - Hook parameters
|
|
728
|
+
* @param {UpdateUserOptions} [params.options] - Optional configuration for the user update
|
|
729
|
+
* @returns {Object} Mutation object with role change function, loading state, error, and authorization state
|
|
730
|
+
* @returns {Function} returns.changeUserRoleFunction - Function to change a user's role
|
|
731
|
+
* @returns {boolean} returns.isLoading - Whether the role change is in progress
|
|
732
|
+
* @returns {Error | null} returns.error - Any error that occurred during the role change
|
|
733
|
+
* @returns {boolean} returns.isEnabled - Whether the current user is authorized to change roles (has "build" permission)
|
|
734
|
+
* @example
|
|
735
|
+
* ```tsx
|
|
736
|
+
* function UserRoleManager({ userId, currentRole }) {
|
|
737
|
+
* const { changeUserRoleFunction, isLoading, error, isEnabled } = useChangeUserRole();
|
|
738
|
+
* const [selectedRole, setSelectedRole] = useState(currentRole);
|
|
739
|
+
*
|
|
740
|
+
* const handleRoleChange = async () => {
|
|
741
|
+
* try {
|
|
742
|
+
* await changeUserRoleFunction({
|
|
743
|
+
* userId,
|
|
744
|
+
* role: selectedRole
|
|
745
|
+
* });
|
|
746
|
+
* alert('Role changed successfully!');
|
|
747
|
+
* } catch (err) {
|
|
748
|
+
* console.error('Failed to change role:', err);
|
|
749
|
+
* }
|
|
750
|
+
* };
|
|
751
|
+
*
|
|
752
|
+
* if (!isEnabled) {
|
|
753
|
+
* return <div>You don't have permission to change user roles</div>;
|
|
754
|
+
* }
|
|
755
|
+
*
|
|
756
|
+
* return (
|
|
757
|
+
* <div>
|
|
758
|
+
* <select
|
|
759
|
+
* value={selectedRole}
|
|
760
|
+
* onChange={(e) => setSelectedRole(e.target.value)}
|
|
761
|
+
* disabled={isLoading}
|
|
762
|
+
* >
|
|
763
|
+
* <option value="Admin">Admin</option>
|
|
764
|
+
* <option value="Manager">Manager</option>
|
|
765
|
+
* <option value="Employee">Employee</option>
|
|
766
|
+
* </select>
|
|
767
|
+
* <button onClick={handleRoleChange} disabled={isLoading}>
|
|
768
|
+
* {isLoading ? 'Changing...' : 'Change Role'}
|
|
769
|
+
* </button>
|
|
770
|
+
* {error && <div className="error">Error: {error.message}</div>}
|
|
771
|
+
* </div>
|
|
772
|
+
* );
|
|
773
|
+
* }
|
|
774
|
+
* ```
|
|
775
|
+
*/
|
|
776
|
+
export declare const useChangeUserRole: ({ options }?: {
|
|
777
|
+
options?: UpdateUserOptions;
|
|
778
|
+
}) => {
|
|
779
|
+
changeUserRoleFunction: import("@tanstack/react-query").UseMutateAsyncFunction<void, Error, {
|
|
780
|
+
userId: string;
|
|
781
|
+
role: string;
|
|
782
|
+
}, unknown>;
|
|
783
|
+
isLoading: boolean;
|
|
784
|
+
error: Error | null;
|
|
785
|
+
isEnabled: boolean;
|
|
786
|
+
};
|
|
787
|
+
/**
|
|
788
|
+
* Hook to send a passwordless login link (magic link) to a user's email
|
|
789
|
+
*
|
|
790
|
+
* This hook provides functionality to send an email containing a one-time login link
|
|
791
|
+
* that allows users to authenticate without entering a password. When the user clicks
|
|
792
|
+
* the link in their email, they will be automatically logged into the application.
|
|
793
|
+
* The hook manages loading state, success state, and error handling automatically.
|
|
794
|
+
*
|
|
795
|
+
* @returns {Object} Object with send function, loading state, success state, and error
|
|
796
|
+
* @returns {Function} returns.sendLoginLink - Function to send the login link to an email address
|
|
797
|
+
* @returns {boolean} returns.isLoading - Whether the request is currently in progress
|
|
798
|
+
* @returns {boolean} returns.isSuccess - Whether the login link was sent successfully
|
|
799
|
+
* @returns {Error | null} returns.error - Any error that occurred during the request
|
|
800
|
+
* @example
|
|
801
|
+
* ```tsx
|
|
802
|
+
* function PasswordlessLoginForm() {
|
|
803
|
+
* const { sendLoginLink, isLoading, isSuccess, error } = useSendLoginLink();
|
|
804
|
+
* const [email, setEmail] = useState('');
|
|
805
|
+
*
|
|
806
|
+
* const handleSubmit = async (e: React.FormEvent) => {
|
|
807
|
+
* e.preventDefault();
|
|
808
|
+
* await sendLoginLink({ email });
|
|
809
|
+
* };
|
|
810
|
+
*
|
|
811
|
+
* if (isSuccess) {
|
|
812
|
+
* return <div>Check your email for a login link!</div>;
|
|
813
|
+
* }
|
|
814
|
+
*
|
|
815
|
+
* return (
|
|
816
|
+
* <form onSubmit={handleSubmit}>
|
|
817
|
+
* <input
|
|
818
|
+
* type="email"
|
|
819
|
+
* value={email}
|
|
820
|
+
* onChange={(e) => setEmail(e.target.value)}
|
|
821
|
+
* placeholder="Enter your email"
|
|
822
|
+
* disabled={isLoading}
|
|
823
|
+
* />
|
|
824
|
+
* <button type="submit" disabled={isLoading}>
|
|
825
|
+
* {isLoading ? 'Sending...' : 'Send Login Link'}
|
|
826
|
+
* </button>
|
|
827
|
+
* {error && <div className="error">{error.message}</div>}
|
|
828
|
+
* </form>
|
|
829
|
+
* );
|
|
830
|
+
* }
|
|
831
|
+
* ```
|
|
832
|
+
*/
|
|
833
|
+
export declare const useSendLoginLink: () => {
|
|
834
|
+
sendLoginLink: ({ email }: {
|
|
835
|
+
email: string;
|
|
836
|
+
}) => Promise<void>;
|
|
837
|
+
isLoading: boolean;
|
|
838
|
+
isSuccess: boolean;
|
|
839
|
+
error: Error | null;
|
|
840
|
+
};
|
|
841
|
+
/**
|
|
842
|
+
* Hook to get the Google OAuth login URL
|
|
843
|
+
*
|
|
844
|
+
* This hook returns the URL for initiating the Google OAuth login flow.
|
|
845
|
+
* When users navigate to this URL, they will be redirected to Google's authentication page.
|
|
846
|
+
* After successful authentication with Google, they will be redirected back to the application
|
|
847
|
+
* and automatically logged in.
|
|
848
|
+
*
|
|
849
|
+
* @returns {string} The Google OAuth login URL
|
|
850
|
+
* @example
|
|
851
|
+
* ```tsx
|
|
852
|
+
* // Example 1: Use in a Link component
|
|
853
|
+
* function GoogleLoginLink() {
|
|
854
|
+
* const googleLoginUrl = useGoogleLogin();
|
|
855
|
+
*
|
|
856
|
+
* return (
|
|
857
|
+
* <Link to={googleLoginUrl}>
|
|
858
|
+
* <Button>Sign in with Google</Button>
|
|
859
|
+
* </Link>
|
|
860
|
+
* );
|
|
861
|
+
* }
|
|
862
|
+
*
|
|
863
|
+
* // Example 2: Redirect with a button
|
|
864
|
+
* function GoogleLoginButton() {
|
|
865
|
+
* const googleLoginUrl = useGoogleLogin();
|
|
866
|
+
*
|
|
867
|
+
* const handleGoogleLogin = () => {
|
|
868
|
+
* window.location.href = googleLoginUrl;
|
|
869
|
+
* };
|
|
870
|
+
*
|
|
871
|
+
* return <Button onClick={handleGoogleLogin}>Sign in with Google</Button>;
|
|
872
|
+
* }
|
|
873
|
+
* ```
|
|
874
|
+
*/
|
|
875
|
+
export declare const useGoogleLogin: () => string;
|
|
876
|
+
/**
|
|
877
|
+
* @deprecated
|
|
878
|
+
* This hook is deprecated and should not be used.
|
|
879
|
+
*/
|
|
880
|
+
export declare const usePageParams: <PC extends PageConfig = PageConfig>(pageConfig: PC) => Record<string, string>;
|
|
881
|
+
/**
|
|
882
|
+
* @deprecated
|
|
883
|
+
* This hook is deprecated and should not be used.
|
|
884
|
+
*/
|
|
885
|
+
export declare const usePageUrl: <PC extends PageConfig = PageConfig>(pageConfig: PC) => string;
|
|
886
|
+
//# sourceMappingURL=ReactClientSdk.d.ts.map
|