@fluid-app/rep-sdk 0.1.2 → 0.1.3

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.
Files changed (73) hide show
  1. package/dist/ContactsScreen-33AJ5XUB.js +5 -0
  2. package/dist/{ContactsScreen-BYXF74BO.js.map → ContactsScreen-33AJ5XUB.js.map} +1 -1
  3. package/dist/ContactsScreen-ATASCZO2.cjs +18 -0
  4. package/dist/{ContactsScreen-XZOQJVFE.cjs.map → ContactsScreen-ATASCZO2.cjs.map} +1 -1
  5. package/dist/CustomersScreen-E4HXBKV7.js +5 -0
  6. package/dist/{CustomersScreen-VS6LGULO.js.map → CustomersScreen-E4HXBKV7.js.map} +1 -1
  7. package/dist/CustomersScreen-XMPMKSQA.cjs +18 -0
  8. package/dist/{CustomersScreen-53SXRDDK.cjs.map → CustomersScreen-XMPMKSQA.cjs.map} +1 -1
  9. package/dist/MessagingScreen-4H7ZBO3V.js +4 -0
  10. package/dist/{MessagingScreen-O42JEJMW.js.map → MessagingScreen-4H7ZBO3V.js.map} +1 -1
  11. package/dist/MessagingScreen-UPFXQZV3.cjs +17 -0
  12. package/dist/{MessagingScreen-UCVLYWZB.cjs.map → MessagingScreen-UPFXQZV3.cjs.map} +1 -1
  13. package/dist/OrdersScreen-IPPZLEYF.js +5 -0
  14. package/dist/{OrdersScreen-QQJFTTSS.js.map → OrdersScreen-IPPZLEYF.js.map} +1 -1
  15. package/dist/OrdersScreen-X7FYUROL.cjs +18 -0
  16. package/dist/{OrdersScreen-WNT2WDLI.cjs.map → OrdersScreen-X7FYUROL.cjs.map} +1 -1
  17. package/dist/ProductsScreen-4ZIUQNUU.cjs +18 -0
  18. package/dist/{ProductsScreen-CTIAKS3Z.cjs.map → ProductsScreen-4ZIUQNUU.cjs.map} +1 -1
  19. package/dist/ProductsScreen-YTSOZW7B.js +5 -0
  20. package/dist/{ProductsScreen-TRIT2FE3.js.map → ProductsScreen-YTSOZW7B.js.map} +1 -1
  21. package/dist/chunk-424PT5DM.js +21 -0
  22. package/dist/chunk-424PT5DM.js.map +1 -0
  23. package/dist/{chunk-QUVJ3R4T.cjs → chunk-5UBEM3AX.cjs} +4 -4
  24. package/dist/{chunk-QUVJ3R4T.cjs.map → chunk-5UBEM3AX.cjs.map} +1 -1
  25. package/dist/chunk-7JMNKWPN.js +1868 -0
  26. package/dist/chunk-7JMNKWPN.js.map +1 -0
  27. package/dist/chunk-B6S6BEPL.cjs +16 -0
  28. package/dist/chunk-B6S6BEPL.cjs.map +1 -0
  29. package/dist/{chunk-WH7WZXT6.js → chunk-CMF2FYTD.js} +3 -3
  30. package/dist/{chunk-WH7WZXT6.js.map → chunk-CMF2FYTD.js.map} +1 -1
  31. package/dist/{chunk-MEOOAMH2.cjs → chunk-EOXYOOWS.cjs} +4 -4
  32. package/dist/{chunk-MEOOAMH2.cjs.map → chunk-EOXYOOWS.cjs.map} +1 -1
  33. package/dist/{chunk-YII3IXF4.cjs → chunk-FG2CI6HA.cjs} +4 -4
  34. package/dist/{chunk-YII3IXF4.cjs.map → chunk-FG2CI6HA.cjs.map} +1 -1
  35. package/dist/chunk-HDQ2JUQT.cjs +24 -0
  36. package/dist/chunk-HDQ2JUQT.cjs.map +1 -0
  37. package/dist/{chunk-MBUCXIUN.cjs → chunk-MHPK7YQ2.cjs} +4 -4
  38. package/dist/{chunk-MBUCXIUN.cjs.map → chunk-MHPK7YQ2.cjs.map} +1 -1
  39. package/dist/{chunk-2AWTZV3T.js → chunk-QZMWG7EM.js} +3 -3
  40. package/dist/{chunk-2AWTZV3T.js.map → chunk-QZMWG7EM.js.map} +1 -1
  41. package/dist/chunk-RS4OSTES.js +14 -0
  42. package/dist/chunk-RS4OSTES.js.map +1 -0
  43. package/dist/chunk-V3IMQZIG.cjs +1942 -0
  44. package/dist/chunk-V3IMQZIG.cjs.map +1 -0
  45. package/dist/{chunk-PZIHCYDD.js → chunk-WFPYEYC7.js} +3 -3
  46. package/dist/{chunk-PZIHCYDD.js.map → chunk-WFPYEYC7.js.map} +1 -1
  47. package/dist/{chunk-CXRJSGO6.js → chunk-WMBD65GH.js} +3 -3
  48. package/dist/{chunk-CXRJSGO6.js.map → chunk-WMBD65GH.js.map} +1 -1
  49. package/dist/index.cjs +1596 -1212
  50. package/dist/index.cjs.map +1 -1
  51. package/dist/index.d.cts +2596 -0
  52. package/dist/index.d.ts +2596 -0
  53. package/dist/index.js +1256 -1011
  54. package/dist/index.js.map +1 -1
  55. package/package.json +27 -8
  56. package/dist/ContactsScreen-BYXF74BO.js +0 -4
  57. package/dist/ContactsScreen-XZOQJVFE.cjs +0 -17
  58. package/dist/CustomersScreen-53SXRDDK.cjs +0 -17
  59. package/dist/CustomersScreen-VS6LGULO.js +0 -4
  60. package/dist/MessagingScreen-O42JEJMW.js +0 -4
  61. package/dist/MessagingScreen-UCVLYWZB.cjs +0 -17
  62. package/dist/OrdersScreen-QQJFTTSS.js +0 -4
  63. package/dist/OrdersScreen-WNT2WDLI.cjs +0 -17
  64. package/dist/ProductsScreen-CTIAKS3Z.cjs +0 -17
  65. package/dist/ProductsScreen-TRIT2FE3.js +0 -4
  66. package/dist/chunk-DEQ3PBVX.cjs +0 -29
  67. package/dist/chunk-DEQ3PBVX.cjs.map +0 -1
  68. package/dist/chunk-JZRNKSKT.cjs +0 -19
  69. package/dist/chunk-JZRNKSKT.cjs.map +0 -1
  70. package/dist/chunk-LO2HDG6C.js +0 -26
  71. package/dist/chunk-LO2HDG6C.js.map +0 -1
  72. package/dist/chunk-PJWPO4BJ.js +0 -16
  73. package/dist/chunk-PJWPO4BJ.js.map +0 -1
@@ -0,0 +1,2596 @@
1
+ import * as react_jsx_runtime from 'react/jsx-runtime';
2
+ import * as react from 'react';
3
+ import react__default, { ReactNode, ComponentProps, ComponentType, AnchorHTMLAttributes } from 'react';
4
+ import { QueryClient, UseQueryResult } from '@tanstack/react-query';
5
+ import * as _fluid_app_api_client_core from '@fluid-app/api-client-core';
6
+ import * as _fluid_app_rep_core_types from '@fluid-app/rep-core/types';
7
+ import { WidgetSchema, ThemeDefinition, ScreenDefinition as ScreenDefinition$1, NavigationItem, RepAppData, BackgroundValue, ColorOptions, PaddingOptions, BorderRadiusOptions } from '@fluid-app/rep-core/types';
8
+ export { AlignOptions, BackgroundType, BackgroundValue, BorderRadiusOptions, ButtonSizeOptions, ColorOptions, FontSizeOptions, GapOptions, NavigationItem, PaddingOptions, RepAppData, RepAppManifest, RepAppProfile, ResolvedTheme, SectionLayoutType, ShareableItem, ThemeColorInput, ThemeDefinition, ThemePayload, TypedWidgetSchema, WIDGET_TYPE_NAMES, WidgetPath, WidgetRegistry, WidgetSchema, WidgetType, WidgetTypeName, assertDefined, assertNever, isWidgetType, isWidgetTypeName, sectionLayoutConfig } from '@fluid-app/rep-core/types';
9
+ import { RawApiTheme } from '@fluid-app/rep-core/theme';
10
+ export { DEFAULT_COLORS, DEFAULT_FONT_FAMILIES, DEFAULT_FONT_SIZES, DEFAULT_RADII, DEFAULT_SPACING, DEFAULT_THEME_ID, DEFAULT_THEME_NAME, FONT_FAMILY_KEYS, FONT_SIZE_KEYS, FontFamilyKey, FontSizeKey, GenerateThemeCSSOptions, OklchPlain, RADIUS_KEYS, RadiusKey, RawApiTheme, ResolvedColorSet, ResolvedSemanticColor, SEMANTIC_COLOR_NAMES, SHADE_STEPS, SemanticColorName, ShadeStep, ThemeColorPlain, applyTheme, buildThemeDefinition, deriveDarkVariant, deserialiseTheme, generateShades, generateThemeCSS, getActiveThemeId, getDefaultThemeDefinition, getForegroundColor, mergeDarkOverrides, parseColor, removeAllThemes, removeTheme, resolveTheme, serialiseTheme, transformThemes } from '@fluid-app/rep-core/theme';
11
+ import { MessagingAuthContext, FileUploader } from '@fluid-app/fluid-messaging-core';
12
+ export { FileUploader, MessagingAuthContext, MessagingCurrentUser, UploadCallbacks, UploadResult } from '@fluid-app/fluid-messaging-core';
13
+ import { MessagingApiConfig } from '@fluid-app/fluid-messaging-api-client';
14
+ import { AlertWidget, CalendarWidget, CarouselWidget, CatchUpWidget, ChartWidget, ContainerWidget, EmbedWidget, ImageWidget, ListWidget, MySiteWidget, NestedWidget, QuickShareWidget, RecentActivityWidget, SpacerWidget, TableWidget, TextWidget, ToDoWidget, VideoWidget } from '@fluid-app/rep-widgets/widgets';
15
+ export { AlertWidget, CalendarWidget, CarouselWidget, CatchUpWidget, ChartWidget, ContainerWidget, EmbedWidget, ImageWidget, LayoutWidget, ListWidget, MySiteWidget, NestedWidget, QuickShareWidget, RecentActivityWidget, SpacerWidget, TableWidget, TextWidget, ToDoWidget, VideoWidget, alertWidgetPropertySchema, calendarWidgetPropertySchema, carouselWidgetPropertySchema, catchUpWidgetPropertySchema, chartWidgetPropertySchema, containerWidgetPropertySchema, embedWidgetPropertySchema, imageWidgetPropertySchema, layoutWidgetPropertySchema, listWidgetPropertySchema, mySiteWidgetPropertySchema, nestedWidgetPropertySchema, quickShareWidgetPropertySchema, recentActivityWidgetPropertySchema, spacerWidgetPropertySchema, tableWidgetPropertySchema, textWidgetPropertySchema, toDoWidgetPropertySchema, videoWidgetPropertySchema, widgetPropertySchemas } from '@fluid-app/rep-widgets/widgets';
16
+ import * as _fluid_app_rep_core_registries from '@fluid-app/rep-core/registries';
17
+ import { WidgetPropertySchema } from '@fluid-app/rep-core/registries';
18
+ export { PROPERTY_FIELD_TYPES, PropertyFieldSchema, PropertyFieldType, TabConfig, WidgetPropertySchema, gapValues, isPropertyFieldType } from '@fluid-app/rep-core/registries';
19
+ export { createScreen, createWidgetFromShareable, createWidgetRegistry, groupChildrenByColumn } from '@fluid-app/rep-core/widget-utils';
20
+ export { ThemeMode, ThemeModeProvider, getThemeModeAttribute, useThemeMode } from '@fluid-app/rep-core/shell/ThemeModeContext';
21
+
22
+ /**
23
+ * Rep (sales representative) user profile
24
+ */
25
+ interface Rep {
26
+ readonly id: string;
27
+ email: string;
28
+ first_name: string;
29
+ last_name: string;
30
+ avatar_url?: string;
31
+ phone?: string;
32
+ readonly company_id: string;
33
+ readonly created_at: string;
34
+ readonly updated_at: string;
35
+ }
36
+ /**
37
+ * Data for updating a rep's profile
38
+ */
39
+ interface UpdateRepData {
40
+ first_name?: string;
41
+ last_name?: string;
42
+ avatar_url?: string;
43
+ phone?: string;
44
+ }
45
+ /**
46
+ * Current user profile from GET /api/me endpoint.
47
+ * Contains recipient_id needed for the messaging system.
48
+ * Field names match the Rails API response (snake_case).
49
+ */
50
+ interface UserMe {
51
+ readonly id: number;
52
+ readonly first_name: string | null;
53
+ readonly last_name: string | null;
54
+ readonly email: string;
55
+ readonly image_url: string | null;
56
+ readonly jwt: string;
57
+ readonly recipient_id: number | null;
58
+ readonly company_id?: number;
59
+ readonly affiliate_id: number | null;
60
+ }
61
+
62
+ /**
63
+ * Category for organizing page templates in the registry
64
+ */
65
+ interface PageCategory {
66
+ /** Unique identifier for the category */
67
+ readonly id: string;
68
+ /** Display label */
69
+ label: string;
70
+ /** Icon identifier (e.g., lucide icon name) */
71
+ icon?: string;
72
+ }
73
+ /**
74
+ * A reusable page template that can be shared across multiple navigations
75
+ */
76
+ interface PageTemplate {
77
+ /** Unique identifier for the template */
78
+ readonly id: string;
79
+ /** URL-friendly slug */
80
+ slug: string;
81
+ /** Display name */
82
+ name: string;
83
+ /** Description of the template's purpose */
84
+ description?: string;
85
+ /** Category ID for organization */
86
+ category: string;
87
+ /** Tags for filtering and search */
88
+ tags?: readonly string[];
89
+ /** The widget tree that defines the page content */
90
+ component_tree: readonly WidgetSchema[];
91
+ /** Semantic version of the template */
92
+ version: string;
93
+ /** Whether this is a core feature that cannot be removed */
94
+ isCore?: boolean;
95
+ /** Default prop values that can be customized */
96
+ defaultProps?: Readonly<Record<string, unknown>>;
97
+ /** Thumbnail image URL for UI display */
98
+ thumbnail?: string;
99
+ }
100
+ /**
101
+ * Reference to a shared page template within a navigation
102
+ */
103
+ interface PageReference {
104
+ /** ID of the page template being referenced */
105
+ page_template_id: string;
106
+ /** Screen ID to assign to this page in the navigation */
107
+ screen_id: number;
108
+ /** Optional prop overrides (only prop values, not widget structure) */
109
+ overrides?: readonly PageOverride[];
110
+ }
111
+ /**
112
+ * Override for a specific widget's props within a page template
113
+ */
114
+ interface PageOverride {
115
+ /** ID of the widget to override (must match WidgetSchema.id in the template) */
116
+ readonly widget_id: string;
117
+ /** Props to override (merged with original props) */
118
+ props: Readonly<Record<string, unknown>>;
119
+ }
120
+ /**
121
+ * Built-in page category IDs
122
+ */
123
+ declare const PAGE_CATEGORIES: {
124
+ readonly CORE: "core";
125
+ readonly COMMERCE: "commerce";
126
+ readonly COMMUNICATION: "communication";
127
+ readonly DATA: "data";
128
+ readonly CUSTOM: "custom";
129
+ };
130
+ type PageCategoryId = (typeof PAGE_CATEGORIES)[keyof typeof PAGE_CATEGORIES];
131
+
132
+ /**
133
+ * Screen definition with its component tree
134
+ */
135
+ interface ScreenDefinition {
136
+ readonly id: number;
137
+ slug: string;
138
+ name: string;
139
+ component_tree: WidgetSchema[];
140
+ }
141
+ /**
142
+ * Navigation configuration for the rep portal
143
+ */
144
+ interface Navigation {
145
+ readonly definition_id: number;
146
+ readonly id: number;
147
+ name: string;
148
+ navigation_items: _fluid_app_rep_core_types.NavigationItem[];
149
+ /** Local screen definitions (for backwards compatibility and custom screens) */
150
+ screens: ScreenDefinition[];
151
+ /** References to shared page templates from the registry */
152
+ page_refs?: PageReference[];
153
+ }
154
+
155
+ /**
156
+ * Rep portal profile containing themes and navigation configuration
157
+ */
158
+ interface Profile {
159
+ /** Profile name */
160
+ name: string;
161
+ /** Available themes for the portal */
162
+ themes: ThemeDefinition[];
163
+ /** Navigation structure and screens */
164
+ navigation: Navigation;
165
+ /** Portal definition ID */
166
+ readonly definition_id: number;
167
+ }
168
+
169
+ /**
170
+ * Standard permission action constants.
171
+ * Use these constants instead of string literals for type safety.
172
+ *
173
+ * @example
174
+ * ```ts
175
+ * if (permissions[PERMISSION_ACTIONS.view]) { ... }
176
+ * ```
177
+ */
178
+ declare const PERMISSION_ACTIONS: {
179
+ readonly view: "view";
180
+ readonly create: "create";
181
+ readonly update: "update";
182
+ readonly delete: "delete";
183
+ readonly settings: "settings";
184
+ readonly add: "add";
185
+ readonly manage: "manage";
186
+ readonly send: "send";
187
+ };
188
+ /**
189
+ * Union type of standard permission actions.
190
+ * Derived from PERMISSION_ACTIONS constant to avoid duplication.
191
+ */
192
+ type PermissionAction = (typeof PERMISSION_ACTIONS)[keyof typeof PERMISSION_ACTIONS];
193
+ /**
194
+ * Permission flags for a single resource.
195
+ * Known actions have explicit properties; index signature allows custom actions.
196
+ */
197
+ interface ResourcePermissions {
198
+ readonly view?: boolean;
199
+ readonly create?: boolean;
200
+ readonly update?: boolean;
201
+ readonly delete?: boolean;
202
+ readonly settings?: boolean;
203
+ readonly add?: boolean;
204
+ readonly manage?: boolean;
205
+ readonly send?: boolean;
206
+ /** Allow custom action keys beyond the standard set */
207
+ readonly [key: string]: boolean | undefined;
208
+ }
209
+ /**
210
+ * Map of resource names to their permissions
211
+ */
212
+ type Permissions = Record<string, ResourcePermissions>;
213
+ /**
214
+ * User's complete permission profile
215
+ */
216
+ interface UserPermissions {
217
+ /** Resource permission mappings */
218
+ permissions: Permissions;
219
+ /** User's assigned roles */
220
+ roles: readonly string[];
221
+ /** Super admin bypass flag */
222
+ is_super_admin: boolean;
223
+ }
224
+
225
+ /**
226
+ * HTTP methods supported by the API client.
227
+ * Use `as const` for literal type inference and type safety.
228
+ */
229
+ declare const HTTP_METHODS: {
230
+ readonly GET: "GET";
231
+ readonly POST: "POST";
232
+ readonly PUT: "PUT";
233
+ readonly PATCH: "PATCH";
234
+ readonly DELETE: "DELETE";
235
+ };
236
+ /**
237
+ * Union type of all supported HTTP methods.
238
+ * Derived from HTTP_METHODS constant to avoid duplication.
239
+ */
240
+ type HttpMethod = (typeof HTTP_METHODS)[keyof typeof HTTP_METHODS];
241
+ /**
242
+ * Configuration for the Fluid SDK client.
243
+ * Use Readonly<FluidSDKConfig> when the config should not be modified after creation.
244
+ */
245
+ interface FluidSDKConfig {
246
+ /**
247
+ * Base URL for API requests.
248
+ * Accepts either the domain root (e.g., "https://api.fluid.app") or
249
+ * with the /api path (e.g., "https://api.fluid.app/api").
250
+ * The SDK normalizes internally for each consumer.
251
+ */
252
+ readonly baseUrl: string;
253
+ /**
254
+ * Function to retrieve the authentication token
255
+ * Return null/undefined if no token is available
256
+ */
257
+ readonly getAuthToken?: () => string | null | Promise<string | null>;
258
+ /**
259
+ * Callback invoked when a 401 authentication error occurs
260
+ * Use this to trigger re-authentication flows
261
+ */
262
+ readonly onAuthError?: () => void;
263
+ /**
264
+ * Default headers to include in all requests
265
+ * Example: { "x-fluid-client": "rep-portal" }
266
+ */
267
+ readonly defaultHeaders?: Readonly<Record<string, string>>;
268
+ /**
269
+ * Filestack API key for messaging file uploads.
270
+ * If not provided, file attachments will be disabled in the messaging composer.
271
+ */
272
+ readonly filestackApiKey?: string;
273
+ /**
274
+ * Override WebSocket URL for real-time messaging.
275
+ * Default: derived from baseUrl by replacing trailing /api with /cable
276
+ */
277
+ readonly websocketUrl?: string;
278
+ }
279
+ /**
280
+ * Options for individual API requests.
281
+ * Uses HttpMethod type for method to ensure type safety.
282
+ */
283
+ interface RequestOptions {
284
+ readonly method?: HttpMethod;
285
+ readonly body?: unknown;
286
+ readonly params?: Readonly<Record<string, unknown>>;
287
+ readonly headers?: Readonly<Record<string, string>>;
288
+ readonly signal?: AbortSignal;
289
+ }
290
+ /**
291
+ * Pagination parameters for list endpoints
292
+ */
293
+ interface PaginationParams {
294
+ readonly page?: number;
295
+ readonly per_page?: number;
296
+ }
297
+ /**
298
+ * Sort order constant - single source of truth for sort direction values.
299
+ * Use SORT_ORDERS.asc instead of "asc" for type-safe comparisons.
300
+ */
301
+ declare const SORT_ORDERS: {
302
+ readonly asc: "asc";
303
+ readonly desc: "desc";
304
+ };
305
+ /**
306
+ * Union type of sort order values, derived from SORT_ORDERS constant.
307
+ * @see deriving-typeof-for-object-keys pattern
308
+ */
309
+ type SortOrder = (typeof SORT_ORDERS)[keyof typeof SORT_ORDERS];
310
+ /**
311
+ * Common filter parameters for list endpoints
312
+ */
313
+ interface BaseListParams extends PaginationParams {
314
+ readonly sort_by?: string;
315
+ readonly sort_order?: SortOrder;
316
+ readonly search?: string;
317
+ }
318
+
319
+ /**
320
+ * Screen Transforms
321
+ * Convert FluidOS API screen objects to ScreenDefinition format.
322
+ *
323
+ * Extracted from:
324
+ * - apps/fluid-admin/networking/app-builder/app-screens/types.ts
325
+ * - apps/fluid-admin/networking/reps/screens.api.ts
326
+ */
327
+
328
+ /** Raw screen from the FluidOS API */
329
+ interface RawApiScreen {
330
+ id: number | string;
331
+ definition_id?: number | string;
332
+ name?: string | null;
333
+ slug?: string | null;
334
+ component_tree?: unknown;
335
+ }
336
+ /**
337
+ * Normalize component_tree to always be an array.
338
+ * The API stores component_tree as a hash (object), but the frontend expects an array.
339
+ */
340
+ declare function normalizeComponentTree(componentTree: unknown): WidgetSchema[];
341
+ /**
342
+ * Convert a raw FluidOS screen to ScreenDefinition.
343
+ * Normalizes component_tree and converts string IDs to numbers.
344
+ */
345
+ declare function toScreenDefinition(screen: RawApiScreen): ScreenDefinition$1;
346
+
347
+ /**
348
+ * Navigation Transforms
349
+ * Convert FluidOS API navigation items to NavigationItem format.
350
+ *
351
+ * Extracted from:
352
+ * - apps/fluid-admin/networking/app-builder/app-navigation-items/types.ts
353
+ * - apps/fluid-admin/networking/reps/screens.api.ts
354
+ */
355
+
356
+ /** Raw navigation item from the FluidOS API */
357
+ interface RawApiNavigationItem {
358
+ id: number | string;
359
+ label?: string | null;
360
+ slug?: string | null;
361
+ icon?: string | null;
362
+ screen_id?: number | string | null;
363
+ parent_id?: number | string | null;
364
+ position?: number | null;
365
+ children?: RawApiNavigationItem[];
366
+ }
367
+ /**
368
+ * Convert a raw FluidOS navigation item to NavigationItem.
369
+ * Recursively transforms children and sorts by position.
370
+ */
371
+ declare function toNavigationItem(item: RawApiNavigationItem): NavigationItem;
372
+
373
+ /**
374
+ * Data Transforms
375
+ * Convert FluidOS API responses to RepAppData format.
376
+ *
377
+ * This is the main entry point for all transforms used by the SDK client
378
+ * and hooks when fetching from the fluidos API.
379
+ */
380
+
381
+ /** Raw manifest shape from the `/fluid_os/definitions/active` API response */
382
+ interface RawManifestResponse {
383
+ manifest: {
384
+ definition_id: number;
385
+ published_version?: number;
386
+ screens?: RawApiScreen[];
387
+ profile?: {
388
+ name?: string;
389
+ definition_id: number;
390
+ themes?: RawApiTheme[];
391
+ navigation?: {
392
+ id: number;
393
+ name?: string;
394
+ definition_id: number;
395
+ navigation_items?: RawApiNavigationItem[];
396
+ };
397
+ };
398
+ };
399
+ }
400
+ /**
401
+ * Transform a raw FluidOS manifest API response into RepAppData.
402
+ *
403
+ * This is the top-level transform used by `FluidClient.app.get()`.
404
+ * It handles:
405
+ * - Theme transformation (legacy and new formats)
406
+ * - Screen normalization (component_tree array wrapping)
407
+ * - Navigation item transformation (recursive with position sorting)
408
+ */
409
+ declare function transformManifestToRepAppData(response: RawManifestResponse): RepAppData;
410
+
411
+ /**
412
+ * API Error class for structured error handling
413
+ */
414
+ declare class ApiError extends Error {
415
+ readonly status: number;
416
+ readonly data: unknown;
417
+ constructor(message: string, status: number, data?: unknown);
418
+ toJSON(): {
419
+ name: string;
420
+ message: string;
421
+ status: number;
422
+ data: unknown;
423
+ };
424
+ }
425
+ /**
426
+ * Type guard for ApiError
427
+ */
428
+ declare function isApiError(error: unknown): error is ApiError;
429
+ /**
430
+ * Discriminated union representing the result of an API call.
431
+ * Use `isApiSuccess` and `isApiFailure` type guards to narrow.
432
+ */
433
+ type ApiResult<T> = {
434
+ readonly success: true;
435
+ readonly data: T;
436
+ } | {
437
+ readonly success: false;
438
+ readonly error: ApiError;
439
+ };
440
+ interface Product {
441
+ readonly id: number;
442
+ readonly title: string;
443
+ readonly sku?: string | null;
444
+ readonly price: string | number;
445
+ readonly description?: string | null;
446
+ readonly image_url?: string;
447
+ readonly status?: string;
448
+ readonly active?: boolean;
449
+ readonly slug?: string;
450
+ readonly in_stock?: boolean;
451
+ readonly display_price?: string;
452
+ readonly currency_code?: string;
453
+ readonly updated_at?: string;
454
+ }
455
+ interface ProductListParams extends BaseListParams {
456
+ readonly search_query?: string;
457
+ readonly status?: readonly ("active" | "draft" | "archived" | "all")[];
458
+ readonly category_id?: string;
459
+ readonly category_ids?: readonly number[];
460
+ readonly collection_id?: string;
461
+ readonly collection_ids?: readonly number[];
462
+ readonly order_by?: readonly string[];
463
+ readonly country_code?: readonly string[];
464
+ readonly published_stores?: readonly ("retail" | "rep")[];
465
+ }
466
+ interface ProductsResponse {
467
+ readonly products: readonly Product[];
468
+ readonly meta: {
469
+ readonly request_id: string;
470
+ readonly timestamp: string;
471
+ readonly pagination?: {
472
+ readonly current_page: number;
473
+ readonly per_page: number;
474
+ readonly total_pages: number;
475
+ readonly total_count: number;
476
+ };
477
+ };
478
+ }
479
+ interface Order {
480
+ readonly id: string;
481
+ readonly order_number: string;
482
+ readonly status: string;
483
+ readonly total: number;
484
+ readonly customer_id: string;
485
+ readonly rep_id?: string;
486
+ readonly created_at: string;
487
+ readonly updated_at: string;
488
+ }
489
+ interface OrderListParams extends BaseListParams {
490
+ readonly status?: string;
491
+ readonly customer_id?: string;
492
+ readonly date_from?: string;
493
+ readonly date_to?: string;
494
+ }
495
+ interface CreateOrderData {
496
+ readonly customer_id: string;
497
+ readonly line_items: readonly OrderLineItem[];
498
+ readonly notes?: string;
499
+ }
500
+ interface OrderLineItem {
501
+ readonly product_id: string;
502
+ readonly quantity: number;
503
+ readonly price?: number;
504
+ }
505
+ interface DashboardData {
506
+ readonly total_sales: number;
507
+ readonly total_orders: number;
508
+ readonly total_customers: number;
509
+ readonly recent_orders: readonly Order[];
510
+ }
511
+ interface SalesParams {
512
+ readonly date_from?: string;
513
+ readonly date_to?: string;
514
+ readonly group_by?: "day" | "week" | "month";
515
+ }
516
+ interface SalesData {
517
+ readonly total: number;
518
+ readonly data: readonly SalesDataPoint[];
519
+ }
520
+ interface SalesDataPoint {
521
+ readonly date: string;
522
+ readonly amount: number;
523
+ readonly orders: number;
524
+ }
525
+ /**
526
+ * Creates a configured Fluid API client instance
527
+ */
528
+ declare function createFluidClient(config: FluidSDKConfig): {
529
+ fetchClient: {
530
+ request: <TResponse = unknown>(endpoint: string, options?: _fluid_app_api_client_core.RequestOptions) => Promise<TResponse>;
531
+ requestWithFormData: <TResponse = unknown>(endpoint: string, formData: FormData, options?: Omit<_fluid_app_api_client_core.RequestOptions, "body" | "params"> & {
532
+ method?: "POST" | "PUT" | "PATCH";
533
+ }) => Promise<TResponse>;
534
+ get: <TResponse = unknown>(endpoint: string, params?: Record<string, unknown>, options?: Omit<_fluid_app_api_client_core.RequestOptions, "method" | "params">) => Promise<TResponse>;
535
+ post: <TResponse = unknown>(endpoint: string, body?: unknown, options?: Omit<_fluid_app_api_client_core.RequestOptions, "method" | "body">) => Promise<TResponse>;
536
+ put: <TResponse = unknown>(endpoint: string, body?: unknown, options?: Omit<_fluid_app_api_client_core.RequestOptions, "method" | "body">) => Promise<TResponse>;
537
+ patch: <TResponse = unknown>(endpoint: string, body?: unknown, options?: Omit<_fluid_app_api_client_core.RequestOptions, "method" | "body">) => Promise<TResponse>;
538
+ delete: <TResponse = unknown>(endpoint: string, options?: Omit<_fluid_app_api_client_core.RequestOptions, "method">) => Promise<TResponse>;
539
+ };
540
+ request: <TResponse = unknown>(endpoint: string, options?: RequestOptions) => Promise<TResponse>;
541
+ requestNullable: <TResponse>(endpoint: string, options?: RequestOptions) => Promise<TResponse | null>;
542
+ safeRequest: <TResponse>(endpoint: string, options?: RequestOptions) => Promise<ApiResult<TResponse>>;
543
+ get: <TResponse = unknown, TParams extends object = Record<string, unknown>>(endpoint: string, params?: TParams, options?: Omit<RequestOptions, "method" | "params">) => Promise<TResponse>;
544
+ post: <TResponse = unknown>(endpoint: string, body?: unknown, options?: Omit<RequestOptions, "method" | "body">) => Promise<TResponse>;
545
+ put: <TResponse = unknown>(endpoint: string, body?: unknown, options?: Omit<RequestOptions, "method" | "body">) => Promise<TResponse>;
546
+ patch: <TResponse = unknown>(endpoint: string, body?: unknown, options?: Omit<RequestOptions, "method" | "body">) => Promise<TResponse>;
547
+ delete: <TResponse = unknown>(endpoint: string, options?: Omit<RequestOptions, "method">) => Promise<TResponse>;
548
+ products: {
549
+ list: (params?: ProductListParams) => Promise<ProductsResponse>;
550
+ get: (id: string | number) => Promise<{
551
+ product: Product;
552
+ }>;
553
+ search: (query: string, params?: ProductListParams) => Promise<ProductsResponse>;
554
+ };
555
+ orders: {
556
+ list: (params?: OrderListParams) => Promise<Order[]>;
557
+ get: (id: string) => Promise<Order>;
558
+ create: (data: CreateOrderData) => Promise<Order>;
559
+ };
560
+ users: {
561
+ me: () => Promise<UserMe>;
562
+ };
563
+ reps: {
564
+ current: () => Promise<Rep>;
565
+ updateProfile: (data: UpdateRepData) => Promise<Rep>;
566
+ };
567
+ profile: {
568
+ get: () => Promise<Profile>;
569
+ };
570
+ app: {
571
+ /** Fetch the raw manifest (plain JSON, no Color objects). Cache-safe. */
572
+ getRaw: () => Promise<RawManifestResponse>;
573
+ /** Fetch the active app definition with full theme/screen/navigation transforms */
574
+ get: () => Promise<RepAppData>;
575
+ };
576
+ permissions: {
577
+ get: () => Promise<UserPermissions>;
578
+ };
579
+ analytics: {
580
+ dashboard: () => Promise<DashboardData>;
581
+ sales: (params?: SalesParams) => Promise<SalesData>;
582
+ };
583
+ };
584
+ type FluidClient = ReturnType<typeof createFluidClient>;
585
+
586
+ /**
587
+ * Context value for FluidProvider.
588
+ * All properties are readonly since context values should not be mutated by consumers.
589
+ */
590
+ interface FluidContextValue {
591
+ /** Configured API client instance */
592
+ readonly client: FluidClient;
593
+ /** SDK configuration */
594
+ readonly config: FluidSDKConfig;
595
+ }
596
+ interface FluidProviderProps {
597
+ /** SDK configuration (baseUrl, auth, etc.) */
598
+ config: FluidSDKConfig;
599
+ /** React children */
600
+ children: ReactNode;
601
+ /** Optional custom QueryClient instance */
602
+ queryClient?: QueryClient;
603
+ /** Optional initial theme */
604
+ initialTheme?: ThemeDefinition;
605
+ /** Optional container for scoped theme application */
606
+ themeContainer?: HTMLElement | null;
607
+ /** Optional custom widget registry (defaults to all built-in widgets) */
608
+ widgetRegistry?: Record<string, React.ComponentType<any>>;
609
+ /** Dynamic variables for data source endpoint path substitution (e.g., { rep_id: "123" }) */
610
+ variables?: Record<string, string>;
611
+ }
612
+ /**
613
+ * Main provider for the Fluid Rep SDK
614
+ *
615
+ * @example
616
+ * ```tsx
617
+ * import { FluidProvider } from "@fluid-app/rep-sdk";
618
+ *
619
+ * function App() {
620
+ * return (
621
+ * <FluidProvider
622
+ * config={{
623
+ * baseUrl: "https://api.fluid.app/api",
624
+ * getAuthToken: () => localStorage.getItem("token"),
625
+ * }}
626
+ * >
627
+ * <YourApp />
628
+ * </FluidProvider>
629
+ * );
630
+ * }
631
+ * ```
632
+ */
633
+ declare function FluidProvider({ config, children, queryClient, initialTheme, themeContainer, widgetRegistry, variables, }: FluidProviderProps): react_jsx_runtime.JSX.Element;
634
+ /**
635
+ * Hook to access the Fluid context
636
+ * Must be used within a FluidProvider
637
+ */
638
+ declare function useFluidContext(): FluidContextValue;
639
+
640
+ type ThemeMode = "light" | "dark";
641
+ /**
642
+ * Context value for theme management.
643
+ * All properties are readonly since context values should not be mutated by consumers.
644
+ */
645
+ interface ThemeContextValue {
646
+ /** Currently active theme definition */
647
+ readonly currentTheme: ThemeDefinition | null;
648
+ /** Switch to a different theme */
649
+ readonly setTheme: (theme: ThemeDefinition) => void;
650
+ /** Switch between light and dark mode for the current theme */
651
+ readonly setThemeMode: (mode: ThemeMode) => void;
652
+ /** Current theme mode */
653
+ readonly mode: ThemeMode | undefined;
654
+ }
655
+ interface FluidThemeProviderProps {
656
+ children: ReactNode;
657
+ /** Initial theme to apply */
658
+ initialTheme?: ThemeDefinition;
659
+ /** Container element for scoped theme application (defaults to document.documentElement) */
660
+ container?: HTMLElement | null;
661
+ }
662
+ declare function FluidThemeProvider({ children, initialTheme, container, }: FluidThemeProviderProps): react_jsx_runtime.JSX.Element;
663
+ /**
664
+ * Hook to access theme context
665
+ * Must be used within a FluidThemeProvider
666
+ */
667
+ declare function useThemeContext(): ThemeContextValue;
668
+
669
+ /**
670
+ * Auth Types for Fluid Rep SDK
671
+ *
672
+ * These types define the JWT payload structure and authentication
673
+ * configuration options for rep portal applications.
674
+ */
675
+ /**
676
+ * User type constant - single source of truth for user role values.
677
+ * Use USER_TYPES.admin instead of "admin" for type-safe comparisons.
678
+ */
679
+ declare const USER_TYPES: {
680
+ readonly admin: "admin";
681
+ readonly rep: "rep";
682
+ readonly root_admin: "root_admin";
683
+ readonly customer: "customer";
684
+ };
685
+ /**
686
+ * Union type of all user types, derived from USER_TYPES constant.
687
+ * @see deriving-typeof-for-object-keys pattern
688
+ */
689
+ type UserType = (typeof USER_TYPES)[keyof typeof USER_TYPES];
690
+ /**
691
+ * Runtime validation for user types.
692
+ * @param value - The value to check
693
+ * @returns true if value is a valid UserType
694
+ */
695
+ declare function isUserType(value: string): value is UserType;
696
+ /**
697
+ * JWT payload structure from Fluid Commerce authentication.
698
+ * Contains user identity and role information.
699
+ */
700
+ interface JWTPayload {
701
+ /** User ID */
702
+ id?: number | undefined;
703
+ /** User email address */
704
+ email?: string | undefined;
705
+ /** Full name of the user */
706
+ full_name?: string | undefined;
707
+ /** User role type */
708
+ user_type: UserType;
709
+ /** Original user type (for impersonation scenarios) */
710
+ og_user_type?: UserType | undefined;
711
+ /** Company ID the user belongs to */
712
+ company_id?: number | undefined;
713
+ /** Token expiration timestamp (Unix seconds) */
714
+ exp?: number | undefined;
715
+ /** Authentication type (e.g., "standard", "impersonation") */
716
+ auth_type?: string | undefined;
717
+ }
718
+ /**
719
+ * Configuration options for FluidAuthProvider.
720
+ * All options have sensible defaults.
721
+ */
722
+ interface FluidAuthConfig {
723
+ /**
724
+ * URL parameter name for the auth token.
725
+ * @default "fluidUserToken"
726
+ */
727
+ tokenKey?: string;
728
+ /**
729
+ * Cookie name for storing the auth token.
730
+ * @default "auth_token"
731
+ */
732
+ cookieKey?: string;
733
+ /**
734
+ * Cookie max age in seconds.
735
+ * @default 777600 (9 days)
736
+ */
737
+ cookieMaxAge?: number;
738
+ /**
739
+ * Grace period in milliseconds to account for clock skew
740
+ * when checking token expiration.
741
+ * @default 30000 (30 seconds)
742
+ */
743
+ gracePeriodMs?: number;
744
+ /**
745
+ * Callback invoked when authentication fails (no valid token).
746
+ * When omitted, the SDK redirects to `authUrl` with the current URL
747
+ * as a redirect parameter so users can log in and return.
748
+ */
749
+ onAuthFailure?: () => void;
750
+ /**
751
+ * Base URL for the authentication page.
752
+ * Used by the default auth failure redirect when `onAuthFailure` is not provided.
753
+ * Ignored when a custom `onAuthFailure` callback is set.
754
+ * @default "https://auth.fluid.app"
755
+ */
756
+ authUrl?: string;
757
+ /**
758
+ * Enable dev-mode auth bypass.
759
+ * When true AND running in Vite dev mode (import.meta.env.DEV),
760
+ * auth will use a synthetic mock user instead of requiring a real JWT.
761
+ * The mock user allows UI rendering but API calls will fail (token is null).
762
+ * @default false
763
+ */
764
+ devBypass?: boolean;
765
+ /**
766
+ * JWKS (JSON Web Key Set) URL for signature verification.
767
+ * When provided, JWT signatures will be verified against keys
768
+ * from this endpoint before accepting the token.
769
+ *
770
+ * This provides defense-in-depth client-side verification.
771
+ * Without this, tokens are only decoded (not verified) client-side,
772
+ * and real verification happens server-side on API calls.
773
+ *
774
+ * @example "https://api.fluid.app/.well-known/jwks.json"
775
+ */
776
+ jwksUrl?: string;
777
+ }
778
+ /**
779
+ * Value provided by the FluidAuthContext.
780
+ * All properties are readonly since context values should not be mutated by consumers.
781
+ */
782
+ interface FluidAuthContextValue {
783
+ /** Whether the user is authenticated with a valid token */
784
+ readonly isAuthenticated: boolean;
785
+ /** Whether authentication is still being initialized */
786
+ readonly isLoading: boolean;
787
+ /** Decoded JWT payload if authenticated, null otherwise */
788
+ readonly user: JWTPayload | null;
789
+ /** Raw JWT token string if authenticated, null otherwise */
790
+ readonly token: string | null;
791
+ /** Clear authentication state and stored tokens */
792
+ readonly clearAuth: () => void;
793
+ /** Authentication error if any occurred during initialization */
794
+ readonly error: Error | null;
795
+ }
796
+ /**
797
+ * Result of token validation.
798
+ * Uses a discriminated union for type-safe handling of valid/invalid states.
799
+ */
800
+ type TokenValidationResult = {
801
+ /** Token is valid */
802
+ isValid: true;
803
+ /** Decoded JWT payload */
804
+ payload: JWTPayload;
805
+ /** No error when valid */
806
+ error?: undefined;
807
+ } | {
808
+ /** Token is invalid */
809
+ isValid: false;
810
+ /** Decoded JWT payload if parseable but expired */
811
+ payload?: JWTPayload;
812
+ /** Error message explaining why validation failed */
813
+ error: string;
814
+ };
815
+
816
+ interface FluidAuthProviderProps {
817
+ /** React children to wrap with auth context */
818
+ children: ReactNode;
819
+ /** Auth configuration options */
820
+ config?: FluidAuthConfig;
821
+ }
822
+ /**
823
+ * Authentication provider for Fluid rep portal applications.
824
+ *
825
+ * On mount, this provider:
826
+ * 1. Checks for a token in the URL (passed from parent app)
827
+ * 2. Cleans token from URL immediately (security)
828
+ * 3. Falls back to stored token (cookie/localStorage)
829
+ * 4. Validates the token (checks expiration)
830
+ * 5. Stores valid tokens for future use
831
+ * 6. Calls onAuthFailure if no valid token found
832
+ *
833
+ * @example
834
+ * ```tsx
835
+ * import { FluidAuthProvider } from "@fluid-app/rep-sdk";
836
+ *
837
+ * function App() {
838
+ * return (
839
+ * <FluidAuthProvider
840
+ * config={{
841
+ * onAuthFailure: () => {
842
+ * window.location.href = "/login";
843
+ * },
844
+ * }}
845
+ * >
846
+ * <YourApp />
847
+ * </FluidAuthProvider>
848
+ * );
849
+ * }
850
+ * ```
851
+ */
852
+ declare function FluidAuthProvider({ children, config, }: FluidAuthProviderProps): react_jsx_runtime.JSX.Element;
853
+ /**
854
+ * Hook to access the auth context directly.
855
+ * Prefer using `useFluidAuth` for most use cases.
856
+ *
857
+ * @throws Error if used outside FluidAuthProvider
858
+ */
859
+ declare function useFluidAuthContext(): FluidAuthContextValue;
860
+
861
+ /**
862
+ * Screen Types - Type definitions for core feature screens
863
+ *
864
+ * All status and type unions are derived from constants for single source of truth.
865
+ * Use the constants (e.g., CONVERSATION_STATUSES.active) for type-safe comparisons.
866
+ */
867
+ /**
868
+ * Conversation status constant - single source of truth.
869
+ */
870
+ declare const CONVERSATION_STATUSES: {
871
+ readonly active: "active";
872
+ readonly archived: "archived";
873
+ readonly muted: "muted";
874
+ };
875
+ /**
876
+ * Union type derived from CONVERSATION_STATUSES constant.
877
+ */
878
+ type ConversationStatus = (typeof CONVERSATION_STATUSES)[keyof typeof CONVERSATION_STATUSES];
879
+ /**
880
+ * Message type constant - single source of truth.
881
+ */
882
+ declare const MESSAGE_TYPES: {
883
+ readonly text: "text";
884
+ readonly image: "image";
885
+ readonly file: "file";
886
+ readonly system: "system";
887
+ };
888
+ /**
889
+ * Union type derived from MESSAGE_TYPES constant.
890
+ */
891
+ type MessageType = (typeof MESSAGE_TYPES)[keyof typeof MESSAGE_TYPES];
892
+ interface Participant {
893
+ readonly id: string;
894
+ readonly name: string;
895
+ readonly email: string;
896
+ readonly avatarUrl?: string;
897
+ readonly isOnline?: boolean;
898
+ }
899
+ /**
900
+ * Message attachment type - extracted for reusability and clarity.
901
+ */
902
+ interface MessageAttachment {
903
+ readonly id: string;
904
+ readonly name: string;
905
+ readonly url: string;
906
+ readonly type: string;
907
+ readonly size?: number;
908
+ }
909
+ interface Message {
910
+ readonly id: string;
911
+ readonly conversationId: string;
912
+ readonly senderId: string;
913
+ readonly senderName: string;
914
+ readonly senderAvatarUrl?: string;
915
+ readonly type: MessageType;
916
+ readonly content: string;
917
+ readonly timestamp: string;
918
+ readonly isRead: boolean;
919
+ readonly attachments?: readonly MessageAttachment[];
920
+ }
921
+ interface Conversation {
922
+ readonly id: string;
923
+ readonly title: string;
924
+ readonly participants: readonly Participant[];
925
+ readonly lastMessage?: Message;
926
+ readonly unreadCount: number;
927
+ readonly status: ConversationStatus;
928
+ readonly createdAt: string;
929
+ readonly updatedAt: string;
930
+ }
931
+ /**
932
+ * Contact status constant - single source of truth.
933
+ */
934
+ declare const CONTACT_STATUSES: {
935
+ readonly active: "active";
936
+ readonly inactive: "inactive";
937
+ readonly lead: "lead";
938
+ readonly prospect: "prospect";
939
+ };
940
+ /**
941
+ * Union type derived from CONTACT_STATUSES constant.
942
+ */
943
+ type ContactStatus = (typeof CONTACT_STATUSES)[keyof typeof CONTACT_STATUSES];
944
+ /**
945
+ * Contact type constant - single source of truth.
946
+ */
947
+ declare const CONTACT_TYPES: {
948
+ readonly individual: "individual";
949
+ readonly company: "company";
950
+ };
951
+ /**
952
+ * Union type derived from CONTACT_TYPES constant.
953
+ */
954
+ type ContactType = (typeof CONTACT_TYPES)[keyof typeof CONTACT_TYPES];
955
+ interface ContactAddress {
956
+ readonly street?: string;
957
+ readonly city?: string;
958
+ readonly state?: string;
959
+ readonly postalCode?: string;
960
+ readonly country?: string;
961
+ }
962
+ interface Contact {
963
+ readonly id: string;
964
+ readonly firstName: string;
965
+ readonly lastName: string;
966
+ readonly email: string;
967
+ readonly phone?: string;
968
+ readonly company?: string;
969
+ readonly jobTitle?: string;
970
+ readonly avatarUrl?: string;
971
+ readonly status: ContactStatus;
972
+ readonly type: ContactType;
973
+ readonly address?: ContactAddress;
974
+ readonly tags?: readonly string[];
975
+ readonly notes?: string;
976
+ readonly createdAt: string;
977
+ readonly updatedAt: string;
978
+ }
979
+
980
+ /**
981
+ * Context value for page template resolution.
982
+ * All properties are readonly since context values should not be mutated by consumers.
983
+ */
984
+ interface PageTemplateContextValue {
985
+ /**
986
+ * Resolve a navigation's page_refs and screens into a unified screen list
987
+ */
988
+ readonly resolvePages: (navigation: Navigation) => ScreenDefinition[];
989
+ /**
990
+ * Get all available page templates
991
+ */
992
+ readonly listTemplates: () => PageTemplate[];
993
+ /**
994
+ * Get a specific template by ID
995
+ */
996
+ readonly getTemplate: (id: string) => PageTemplate | undefined;
997
+ /**
998
+ * Check if a template exists
999
+ */
1000
+ readonly hasTemplate: (id: string) => boolean;
1001
+ }
1002
+ /**
1003
+ * Props for PageTemplateProvider
1004
+ */
1005
+ interface PageTemplateProviderProps {
1006
+ children: react__default.ReactNode;
1007
+ /**
1008
+ * Additional custom page templates to register.
1009
+ * These are registered when the provider mounts and unregistered when it unmounts.
1010
+ */
1011
+ templates?: readonly PageTemplate[];
1012
+ }
1013
+ /**
1014
+ * Provider for page template resolution.
1015
+ *
1016
+ * This provider:
1017
+ * 1. Registers any custom templates passed via props
1018
+ * 2. Provides methods for resolving navigation pages
1019
+ * 3. Cleans up custom templates on unmount
1020
+ *
1021
+ * @example
1022
+ * ```tsx
1023
+ * // With custom templates
1024
+ * const customTemplates: PageTemplate[] = [
1025
+ * {
1026
+ * id: 'custom-dashboard',
1027
+ * slug: 'dashboard',
1028
+ * name: 'Dashboard',
1029
+ * category: 'custom',
1030
+ * version: '1.0.0',
1031
+ * component_tree: [{ type: 'TextWidget', props: { text: 'Custom Dashboard' } }],
1032
+ * },
1033
+ * ];
1034
+ *
1035
+ * <PageTemplateProvider templates={customTemplates}>
1036
+ * <App />
1037
+ * </PageTemplateProvider>
1038
+ *
1039
+ * // Without custom templates (uses only core templates)
1040
+ * <PageTemplateProvider>
1041
+ * <App />
1042
+ * </PageTemplateProvider>
1043
+ * ```
1044
+ */
1045
+ declare function PageTemplateProvider({ children, templates, }: PageTemplateProviderProps): react_jsx_runtime.JSX.Element;
1046
+ /**
1047
+ * Hook to access page template functionality.
1048
+ *
1049
+ * @throws Error if used outside of PageTemplateProvider
1050
+ *
1051
+ * @example
1052
+ * ```tsx
1053
+ * function NavigationRenderer({ navigation }: { navigation: Navigation }) {
1054
+ * const { resolvePages } = usePageTemplates();
1055
+ * const screens = resolvePages(navigation);
1056
+ *
1057
+ * return (
1058
+ * <div>
1059
+ * {screens.map((screen) => (
1060
+ * <Screen key={screen.id} definition={screen} />
1061
+ * ))}
1062
+ * </div>
1063
+ * );
1064
+ * }
1065
+ * ```
1066
+ */
1067
+ declare function usePageTemplates(): PageTemplateContextValue;
1068
+ /**
1069
+ * Hook to resolve navigation pages directly.
1070
+ * Convenience wrapper around usePageTemplates().resolvePages.
1071
+ *
1072
+ * @param navigation - The navigation to resolve
1073
+ * @returns Array of resolved screen definitions
1074
+ */
1075
+ declare function useResolvedPages(navigation: Navigation): ScreenDefinition[];
1076
+
1077
+ /**
1078
+ * Hook to access the Fluid API client
1079
+ *
1080
+ * @example
1081
+ * ```tsx
1082
+ * function ProductList() {
1083
+ * const api = useFluidApi();
1084
+ *
1085
+ * const { data: products } = useQuery({
1086
+ * queryKey: ["products"],
1087
+ * queryFn: () => api.products.list(),
1088
+ * });
1089
+ *
1090
+ * return <ul>{products?.map(p => <li key={p.id}>{p.name}</li>)}</ul>;
1091
+ * }
1092
+ * ```
1093
+ */
1094
+ declare function useFluidApi(): FluidClient;
1095
+
1096
+ /**
1097
+ * Query key for profile data
1098
+ */
1099
+ declare const PROFILE_QUERY_KEY: readonly ["fluid", "profile"];
1100
+ /**
1101
+ * Hook to fetch the rep portal profile (themes, navigation, screens)
1102
+ *
1103
+ * @example
1104
+ * ```tsx
1105
+ * function Navigation() {
1106
+ * const { data: profile, isLoading } = useFluidProfile();
1107
+ *
1108
+ * if (isLoading) return <Spinner />;
1109
+ *
1110
+ * return (
1111
+ * <nav>
1112
+ * {profile?.navigation.navigation_items.map(item => (
1113
+ * <NavItem key={item.id} item={item} />
1114
+ * ))}
1115
+ * </nav>
1116
+ * );
1117
+ * }
1118
+ * ```
1119
+ */
1120
+ declare function useFluidProfile(): UseQueryResult<Profile>;
1121
+
1122
+ /**
1123
+ * Query key for full app data (fluidos endpoint)
1124
+ */
1125
+ declare const APP_DATA_QUERY_KEY: readonly ["fluid", "app"];
1126
+ /**
1127
+ * Hook to fetch the full rep app data from the fluidos API.
1128
+ *
1129
+ * Returns a `RepAppData` object containing:
1130
+ * - `screens` — all screen definitions with normalized component trees
1131
+ * - `profile.themes` — fully-transformed ThemeDefinition[] (handles legacy + new formats)
1132
+ * - `profile.activeThemeId` — the currently active theme ID
1133
+ * - `profile.navigation.navigation_items` — sorted, recursive navigation tree
1134
+ *
1135
+ * Uses IndexedDB persistence so subsequent page loads hydrate instantly
1136
+ * from cache while revalidating in the background. The raw API response
1137
+ * (plain JSON) is cached; Color objects are recreated from cache via
1138
+ * `select` on every restore — this is fast (CPU only, no network).
1139
+ *
1140
+ * @example
1141
+ * ```tsx
1142
+ * function App() {
1143
+ * const { data: appData, isLoading } = useFluidApp();
1144
+ *
1145
+ * if (isLoading) return <Spinner />;
1146
+ *
1147
+ * return (
1148
+ * <AppShell
1149
+ * appData={appData}
1150
+ * navigation={appData.profile.navigation.navigation_items}
1151
+ * />
1152
+ * );
1153
+ * }
1154
+ * ```
1155
+ */
1156
+ declare function useFluidApp(options?: {
1157
+ enabled?: boolean;
1158
+ }): UseQueryResult<RepAppData>;
1159
+
1160
+ /**
1161
+ * Query key for permissions data
1162
+ */
1163
+ declare const PERMISSIONS_QUERY_KEY: readonly ["fluid", "permissions"];
1164
+ /**
1165
+ * Result of useFluidPermissions hook
1166
+ */
1167
+ interface UseFluidPermissionsResult {
1168
+ /** Raw permissions query result */
1169
+ query: UseQueryResult<UserPermissions>;
1170
+ /** Permissions data (alias for query.data) */
1171
+ permissions: UserPermissions | undefined;
1172
+ /** Check if user has a specific permission */
1173
+ can: (resource: string, action?: PermissionAction) => boolean;
1174
+ /** Check if user is a super admin */
1175
+ isSuperAdmin: boolean;
1176
+ }
1177
+ /**
1178
+ * Hook to fetch and check user permissions
1179
+ *
1180
+ * @example
1181
+ * ```tsx
1182
+ * function TeamSettings() {
1183
+ * const { can, isSuperAdmin } = useFluidPermissions();
1184
+ *
1185
+ * if (!can("team", "manage")) {
1186
+ * return <AccessDenied />;
1187
+ * }
1188
+ *
1189
+ * return <TeamSettingsForm canDelete={can("team", "delete")} />;
1190
+ * }
1191
+ * ```
1192
+ */
1193
+ declare function useFluidPermissions(): UseFluidPermissionsResult;
1194
+
1195
+ /**
1196
+ * Result of useFluidTheme hook
1197
+ */
1198
+ interface UseFluidThemeResult {
1199
+ /** Currently active theme */
1200
+ currentTheme: ThemeDefinition | null;
1201
+ /** Switch to a different theme */
1202
+ setTheme: (theme: ThemeDefinition) => void;
1203
+ /** Switch between light and dark mode */
1204
+ setThemeMode: (mode: "light" | "dark") => void;
1205
+ /** Current theme mode (convenience accessor) */
1206
+ mode: "light" | "dark" | undefined;
1207
+ }
1208
+ /**
1209
+ * Hook to access and control theme settings
1210
+ *
1211
+ * @example
1212
+ * ```tsx
1213
+ * function ThemeSwitcher({ themes }: { themes: ThemeDefinition[] }) {
1214
+ * const { currentTheme, setTheme, setThemeMode, mode } = useFluidTheme();
1215
+ *
1216
+ * return (
1217
+ * <div>
1218
+ * <select
1219
+ * value={currentTheme?.name}
1220
+ * onChange={(e) => {
1221
+ * const theme = themes.find(t => t.name === e.target.value);
1222
+ * if (theme) setTheme(theme);
1223
+ * }}
1224
+ * >
1225
+ * {themes.map(theme => (
1226
+ * <option key={theme.name} value={theme.name}>
1227
+ * {theme.name}
1228
+ * </option>
1229
+ * ))}
1230
+ * </select>
1231
+ *
1232
+ * <button onClick={() => setThemeMode(mode === "dark" ? "light" : "dark")}>
1233
+ * Toggle {mode === "dark" ? "Light" : "Dark"} Mode
1234
+ * </button>
1235
+ * </div>
1236
+ * );
1237
+ * }
1238
+ * ```
1239
+ */
1240
+ declare function useFluidTheme(): UseFluidThemeResult;
1241
+
1242
+ /**
1243
+ * Query key for current rep data
1244
+ */
1245
+ declare const CURRENT_REP_QUERY_KEY: readonly ["fluid", "currentRep"];
1246
+ /**
1247
+ * Hook to fetch the currently authenticated rep's profile
1248
+ *
1249
+ * @example
1250
+ * ```tsx
1251
+ * function RepHeader() {
1252
+ * const { data: rep, isLoading } = useCurrentRep();
1253
+ *
1254
+ * if (isLoading) return <Skeleton />;
1255
+ *
1256
+ * return (
1257
+ * <div>
1258
+ * <Avatar src={rep?.avatar_url} />
1259
+ * <span>{rep?.first_name} {rep?.last_name}</span>
1260
+ * </div>
1261
+ * );
1262
+ * }
1263
+ * ```
1264
+ */
1265
+ declare function useCurrentRep(): UseQueryResult<Rep>;
1266
+
1267
+ /**
1268
+ * useFluidAuth Hook
1269
+ *
1270
+ * Provides access to authentication state and utilities.
1271
+ * This is the primary hook for interacting with auth in components.
1272
+ */
1273
+
1274
+ /**
1275
+ * Hook to access authentication state and utilities.
1276
+ *
1277
+ * Must be used within a `FluidAuthProvider`.
1278
+ *
1279
+ * @returns Authentication context with user info, loading state, and utilities
1280
+ * @throws Error if used outside FluidAuthProvider
1281
+ *
1282
+ * @example
1283
+ * ```tsx
1284
+ * function UserProfile() {
1285
+ * const { isAuthenticated, isLoading, user, clearAuth } = useFluidAuth();
1286
+ *
1287
+ * if (isLoading) {
1288
+ * return <Spinner />;
1289
+ * }
1290
+ *
1291
+ * if (!isAuthenticated) {
1292
+ * return <p>Please log in</p>;
1293
+ * }
1294
+ *
1295
+ * return (
1296
+ * <div>
1297
+ * <p>Welcome, {user.full_name}!</p>
1298
+ * <button onClick={clearAuth}>Log out</button>
1299
+ * </div>
1300
+ * );
1301
+ * }
1302
+ * ```
1303
+ */
1304
+ declare function useFluidAuth(): FluidAuthContextValue;
1305
+
1306
+ /**
1307
+ * Hook type utilities and type predicates.
1308
+ *
1309
+ * This module provides:
1310
+ * - Generic hook result types with default type parameters
1311
+ * - Type predicates for query state narrowing
1312
+ * - Reusable patterns for type-safe property access in hooks
1313
+ *
1314
+ * Following generics best practices:
1315
+ * - generics-default-type-parameters: Default E to Error for common case
1316
+ * - generics-type-predicates: Type predicates for result state narrowing
1317
+ * - generics-constrain-type-parameters: K extends keyof T for property access
1318
+ */
1319
+ /**
1320
+ * Base result type for query hooks with default error type.
1321
+ * Uses default type parameter for E (generics-default-type-parameters rule).
1322
+ *
1323
+ * @typeParam T - The data type
1324
+ * @typeParam E - The error type (defaults to Error)
1325
+ *
1326
+ * @example
1327
+ * // Error type defaults to Error
1328
+ * type UsersResult = QueryResult<User[]>;
1329
+ *
1330
+ * // Can override when needed
1331
+ * type CustomResult = QueryResult<User[], ApiError>;
1332
+ */
1333
+ interface QueryResult<T, E = Error> {
1334
+ readonly data: T;
1335
+ readonly isLoading: boolean;
1336
+ readonly isError: boolean;
1337
+ readonly error?: E | undefined;
1338
+ }
1339
+ /**
1340
+ * Result type for hooks that may not have data yet.
1341
+ * Extends QueryResult with nullable data.
1342
+ *
1343
+ * @typeParam T - The data type
1344
+ * @typeParam E - The error type (defaults to Error)
1345
+ */
1346
+ interface QueryResultNullable<T, E = Error> {
1347
+ readonly data: T | null | undefined;
1348
+ readonly isLoading: boolean;
1349
+ readonly isError: boolean;
1350
+ readonly error?: E | undefined;
1351
+ }
1352
+ /**
1353
+ * Result type for list/collection hooks with aggregates.
1354
+ *
1355
+ * @typeParam T - The item type in the array
1356
+ * @typeParam E - The error type (defaults to Error)
1357
+ */
1358
+ interface ListQueryResult<T, E = Error> extends QueryResult<T[], E> {
1359
+ readonly totalCount: number;
1360
+ }
1361
+ /**
1362
+ * Result type for list hooks with value aggregation (e.g., deals with total value).
1363
+ *
1364
+ * @typeParam T - The item type in the array
1365
+ * @typeParam E - The error type (defaults to Error)
1366
+ */
1367
+ interface ValueListQueryResult<T, E = Error> extends ListQueryResult<T, E> {
1368
+ readonly totalValue: number;
1369
+ }
1370
+ /**
1371
+ * Type predicate to check if a query result has successfully loaded data.
1372
+ * Narrows the data type from T | null | undefined to T.
1373
+ *
1374
+ * @example
1375
+ * const result = useContact(id);
1376
+ * if (hasData(result)) {
1377
+ * // TypeScript knows result.data is Contact, not Contact | null
1378
+ * console.log(result.data.name);
1379
+ * }
1380
+ */
1381
+ declare function hasData<T, E = Error>(result: QueryResultNullable<T, E>): result is QueryResultNullable<T, E> & {
1382
+ readonly data: T;
1383
+ };
1384
+ /**
1385
+ * Type predicate to check if a query result is in loading state.
1386
+ * Useful for conditional rendering.
1387
+ *
1388
+ * @example
1389
+ * if (isLoading(result)) {
1390
+ * return <Spinner />;
1391
+ * }
1392
+ */
1393
+ declare function isLoading<T, E = Error>(result: QueryResult<T, E> | QueryResultNullable<T, E>): boolean;
1394
+ /**
1395
+ * Type predicate to check if a query result has an error.
1396
+ * Narrows to include the error property.
1397
+ *
1398
+ * @example
1399
+ * if (isErrorResult(result)) {
1400
+ * console.error(result.error); // error is E, not undefined
1401
+ * }
1402
+ */
1403
+ declare function isErrorResult<T, E = Error>(result: QueryResult<T, E> | QueryResultNullable<T, E>): result is (QueryResult<T, E> | QueryResultNullable<T, E>) & {
1404
+ readonly isError: true;
1405
+ readonly error: E;
1406
+ };
1407
+ /**
1408
+ * Type predicate to check if a query result is in idle state (not loading, no error, has data).
1409
+ *
1410
+ * @example
1411
+ * if (isIdle(result)) {
1412
+ * // Safe to access and render data
1413
+ * }
1414
+ */
1415
+ declare function isIdle<T, E = Error>(result: QueryResult<T, E> | QueryResultNullable<T, E>): boolean;
1416
+ /**
1417
+ * Type-safe property selector for hook results.
1418
+ * Uses K extends keyof T constraint (generics-function-constraints rule).
1419
+ *
1420
+ * @typeParam T - The data object type
1421
+ * @typeParam K - Key of T (constrained to actual keys)
1422
+ *
1423
+ * @example
1424
+ * const users = [{ name: "Alice", age: 30 }];
1425
+ * const names = selectProperty(users, "name"); // string[]
1426
+ * const ages = selectProperty(users, "age"); // number[]
1427
+ * selectProperty(users, "invalid"); // Error: "invalid" not in "name" | "age"
1428
+ */
1429
+ declare function selectProperty<T, K extends keyof T>(items: readonly T[], key: K): T[K][];
1430
+ /**
1431
+ * Type-safe property getter for a single item.
1432
+ * Returns undefined if item is null/undefined.
1433
+ *
1434
+ * @typeParam T - The data object type
1435
+ * @typeParam K - Key of T (constrained to actual keys)
1436
+ */
1437
+ declare function getProperty<T, K extends keyof T>(item: T | null | undefined, key: K): T[K] | undefined;
1438
+ /**
1439
+ * Generic type for hooks that fetch a single resource by ID.
1440
+ * Useful for creating consistent API across different resource types.
1441
+ *
1442
+ * @typeParam T - The resource type
1443
+ * @typeParam E - The error type (defaults to Error)
1444
+ */
1445
+ type UseSingleResourceHook<T, E = Error> = (id: string) => QueryResultNullable<T, E>;
1446
+ /**
1447
+ * Generic type for hooks that fetch a list of resources with optional params.
1448
+ * Uses generics-default-type-parameters for the params type.
1449
+ *
1450
+ * @typeParam T - The item type
1451
+ * @typeParam P - The params type (defaults to empty object)
1452
+ * @typeParam E - The error type (defaults to Error)
1453
+ */
1454
+ type UseListResourceHook<T, P extends Record<string, unknown> = Record<string, never>, E = Error> = (params?: P) => ListQueryResult<T, E>;
1455
+ /**
1456
+ * Transforms a nullable result to a non-nullable one if data exists.
1457
+ * Useful when you've already checked hasData().
1458
+ */
1459
+ type WithData<R extends QueryResultNullable<unknown>> = R extends QueryResultNullable<infer T, infer E> ? QueryResultNullable<T, E> & {
1460
+ readonly data: T;
1461
+ } : never;
1462
+ /**
1463
+ * Activity slug constants as a const object.
1464
+ * Derive the ActivitySlug type from this single source of truth.
1465
+ */
1466
+ declare const ACTIVITY_SLUGS: {
1467
+ readonly abandonedCart: "abandoned_cart";
1468
+ readonly announcements: "announcements";
1469
+ readonly cartItemsAdded: "cart_items_added";
1470
+ readonly commentReply: "comment_reply";
1471
+ readonly directMessage: "direct_message";
1472
+ readonly fantasyPoint: "fantasy_point";
1473
+ readonly newLead: "new_lead";
1474
+ readonly orderPlaced: "order_placed";
1475
+ readonly pageViews: "page_views";
1476
+ readonly pageViewsContact: "page_views_contact";
1477
+ readonly tasks: "tasks";
1478
+ readonly upcomingEvent: "upcoming_event";
1479
+ readonly video: "video";
1480
+ readonly videoComplete: "video_complete";
1481
+ readonly videoCompleteContact: "video_complete_contact";
1482
+ readonly videoContact: "video_contact";
1483
+ readonly messageReceived: "message_received";
1484
+ readonly messageSent: "message_sent";
1485
+ readonly newCartItemsAdded: "new_cart_items_added";
1486
+ readonly smartLinkClicked: "smart_link_clicked";
1487
+ readonly reviewLeft: "review_left";
1488
+ };
1489
+ /** Activity slug union type derived from ACTIVITY_SLUGS constant. */
1490
+ type ActivitySlug = (typeof ACTIVITY_SLUGS)[keyof typeof ACTIVITY_SLUGS];
1491
+ /** Type predicate to check if a string is a valid ActivitySlug. */
1492
+ declare function isActivitySlug(value: string): value is ActivitySlug;
1493
+ /** Transformed activity for display. */
1494
+ interface Activity {
1495
+ readonly id: number;
1496
+ readonly userName: string;
1497
+ readonly avatarUrl: string | null;
1498
+ readonly activityType: string;
1499
+ readonly targetName: string;
1500
+ readonly timestamp: string;
1501
+ readonly slug: ActivitySlug;
1502
+ }
1503
+ /** Description/rich text metadata for a calendar event. */
1504
+ interface CalendarEventDescription {
1505
+ readonly id?: number | null;
1506
+ readonly name?: string | null;
1507
+ readonly body?: string | null;
1508
+ readonly record_type?: string | null;
1509
+ readonly record_id?: number | null;
1510
+ readonly created_at?: string | null;
1511
+ readonly updated_at?: string | null;
1512
+ readonly locale?: string | null;
1513
+ }
1514
+ /** Calendar event data from the API. */
1515
+ interface CalendarEvent {
1516
+ readonly id: number;
1517
+ readonly title: string;
1518
+ readonly description?: CalendarEventDescription | null;
1519
+ readonly color?: string | null;
1520
+ readonly url?: string | null;
1521
+ readonly start: string;
1522
+ readonly end: string;
1523
+ readonly active?: boolean | null;
1524
+ readonly time_zone?: string | null;
1525
+ readonly status?: string | null;
1526
+ readonly image_url?: string | null;
1527
+ readonly images?: readonly unknown[] | null;
1528
+ readonly venue?: string | null;
1529
+ readonly countries?: readonly string[] | null;
1530
+ readonly hasTomorrow?: boolean | null;
1531
+ readonly hasYesterday?: boolean | null;
1532
+ readonly isAllDay?: boolean;
1533
+ }
1534
+ /** Catch up suggestion data from the API. */
1535
+ interface CatchUp {
1536
+ readonly id: number;
1537
+ readonly suggestion_title: string;
1538
+ }
1539
+ /** MySite data returned by the hook. */
1540
+ interface MySiteData {
1541
+ readonly url: string | null;
1542
+ readonly views: number;
1543
+ readonly leads: number;
1544
+ readonly userName: string;
1545
+ }
1546
+ /** Transformed todo for display. */
1547
+ interface Todo {
1548
+ readonly id: number;
1549
+ readonly body: string;
1550
+ readonly dueAt: string | null;
1551
+ readonly completedAt: string | null;
1552
+ readonly createdAt: string;
1553
+ readonly contactName: string | null;
1554
+ }
1555
+
1556
+ /**
1557
+ * Calendar events hook - stub implementation for SDK
1558
+ * In production, implement this hook to fetch from your API
1559
+ */
1560
+
1561
+ /**
1562
+ * Result type for useCalendarEvents hook.
1563
+ * Uses QueryResult<CalendarEvent[]> with default Error type.
1564
+ */
1565
+ type UseCalendarEventsResult = QueryResult<CalendarEvent[]>;
1566
+ /**
1567
+ * Hook to fetch calendar events.
1568
+ * This is a stub implementation - override with your own data fetching logic.
1569
+ */
1570
+ declare function useCalendarEvents(): UseCalendarEventsResult;
1571
+
1572
+ /**
1573
+ * Todos hook - stub implementation for SDK
1574
+ * In production, implement this hook to fetch from your API
1575
+ */
1576
+
1577
+ /**
1578
+ * Result type for useTodos hook.
1579
+ * Uses QueryResult<Todo[]> with default Error type.
1580
+ */
1581
+ type UseTodosResult = QueryResult<Todo[]>;
1582
+ /**
1583
+ * Hook to fetch todo items.
1584
+ * This is a stub implementation - override with your own data fetching logic.
1585
+ */
1586
+ declare function useTodos(): UseTodosResult;
1587
+
1588
+ /**
1589
+ * Activities hook - stub implementation for SDK
1590
+ * In production, implement this hook to fetch from your API
1591
+ */
1592
+
1593
+ /**
1594
+ * Result type for useActivities hook.
1595
+ * Uses QueryResult generic with Activity[] and default Error type.
1596
+ */
1597
+ type UseActivitiesResult = QueryResult<Activity[]>;
1598
+ /**
1599
+ * Hook to fetch recent activities.
1600
+ * This is a stub implementation - override with your own data fetching logic.
1601
+ */
1602
+ declare function useActivities(): UseActivitiesResult;
1603
+
1604
+ /**
1605
+ * Catch ups hook - stub implementation for SDK
1606
+ * In production, implement this hook to fetch from your API
1607
+ */
1608
+
1609
+ /**
1610
+ * Result type for useCatchUps hook.
1611
+ * Uses QueryResult<CatchUp[]> with default Error type.
1612
+ */
1613
+ type UseCatchUpsResult = QueryResult<CatchUp[]>;
1614
+ /**
1615
+ * Hook to fetch catch up items.
1616
+ * This is a stub implementation - override with your own data fetching logic.
1617
+ */
1618
+ declare function useCatchUps(): UseCatchUpsResult;
1619
+
1620
+ /**
1621
+ * MySite hook - stub implementation for SDK
1622
+ * In production, implement this hook to fetch from your API
1623
+ */
1624
+
1625
+ /**
1626
+ * Result type for useMySite hook.
1627
+ * Uses QueryResultNullable since MySite data may not be available.
1628
+ */
1629
+ type UseMySiteResult = QueryResultNullable<MySiteData>;
1630
+ /**
1631
+ * Hook to fetch MySite data.
1632
+ * This is a stub implementation - override with your own data fetching logic.
1633
+ */
1634
+ declare function useMySite(): UseMySiteResult;
1635
+
1636
+ /**
1637
+ * Conversations hooks - stub implementations for SDK
1638
+ * In production, implement these hooks to fetch from your API
1639
+ */
1640
+
1641
+ /**
1642
+ * Result type for useConversations hook.
1643
+ * Uses QueryResult<Conversation[]> with default Error type.
1644
+ */
1645
+ type UseConversationsResult = QueryResult<Conversation[]>;
1646
+ /**
1647
+ * Hook to fetch all conversations.
1648
+ * This is a stub implementation - override with your own data fetching logic.
1649
+ *
1650
+ * @returns UseConversationsResult with empty data array
1651
+ *
1652
+ * @example
1653
+ * ```tsx
1654
+ * const { data: conversations, isLoading, isError } = useConversations();
1655
+ *
1656
+ * if (isLoading) return <Loading />;
1657
+ * if (isError) return <Error />;
1658
+ *
1659
+ * return conversations.map(conv => <ConversationItem key={conv.id} {...conv} />);
1660
+ * ```
1661
+ */
1662
+ declare function useConversations(): UseConversationsResult;
1663
+ /**
1664
+ * Result type for useConversationMessages hook.
1665
+ * Uses QueryResult<Message[]> with default Error type.
1666
+ */
1667
+ type UseConversationMessagesResult = QueryResult<Message[]>;
1668
+ /**
1669
+ * Hook to fetch messages for a specific conversation.
1670
+ * This is a stub implementation - override with your own data fetching logic.
1671
+ *
1672
+ * @param conversationId - The ID of the conversation to fetch messages for
1673
+ * @returns UseConversationMessagesResult with empty data array
1674
+ *
1675
+ * @example
1676
+ * ```tsx
1677
+ * const { data: messages, isLoading, isError } = useConversationMessages(conversationId);
1678
+ *
1679
+ * if (isLoading) return <Loading />;
1680
+ * if (isError) return <Error />;
1681
+ *
1682
+ * return messages.map(msg => <MessageBubble key={msg.id} {...msg} />);
1683
+ * ```
1684
+ */
1685
+ declare function useConversationMessages(_conversationId: string): UseConversationMessagesResult;
1686
+
1687
+ /**
1688
+ * Contacts hooks - stub implementation for SDK
1689
+ * In production, implement these hooks to fetch from your API
1690
+ */
1691
+
1692
+ /**
1693
+ * Type predicate to check if a status string is a valid ContactStatus.
1694
+ * Enables runtime validation with type narrowing.
1695
+ */
1696
+ declare function isContactStatus(value: string): value is ContactStatus;
1697
+ /**
1698
+ * Parameters for filtering and paginating contacts.
1699
+ * Uses readonly properties and proper ContactStatus type for status.
1700
+ */
1701
+ interface UseContactsParams {
1702
+ /** Search query to filter contacts by name, email, or company */
1703
+ readonly search?: string;
1704
+ /** Filter contacts by status - uses ContactStatus union type for type safety */
1705
+ readonly status?: ContactStatus;
1706
+ /** Maximum number of contacts to return */
1707
+ readonly limit?: number;
1708
+ }
1709
+ /**
1710
+ * Result type for the useContacts hook.
1711
+ * Uses ListQueryResult<Contact> with totalCount and default Error type.
1712
+ */
1713
+ type UseContactsResult = ListQueryResult<Contact>;
1714
+ /**
1715
+ * Result type for the useContact hook.
1716
+ * Uses QueryResultNullable since a specific contact may not exist.
1717
+ */
1718
+ type UseContactResult = QueryResultNullable<Contact>;
1719
+ /**
1720
+ * Hook to fetch a list of contacts with optional filtering and pagination.
1721
+ * This is a stub implementation - override with your own data fetching logic.
1722
+ *
1723
+ * @param params - Optional parameters for filtering and pagination
1724
+ * @returns Object containing contacts data, loading state, error state, and total count
1725
+ *
1726
+ * @example
1727
+ * ```tsx
1728
+ * const { data: contacts, isLoading, totalCount } = useContacts({
1729
+ * search: 'john',
1730
+ * status: 'active',
1731
+ * limit: 20
1732
+ * });
1733
+ * ```
1734
+ */
1735
+ declare function useContacts(_params?: UseContactsParams): UseContactsResult;
1736
+ /**
1737
+ * Hook to fetch a single contact by ID.
1738
+ * This is a stub implementation - override with your own data fetching logic.
1739
+ *
1740
+ * @param contactId - The unique identifier of the contact to fetch
1741
+ * @returns Object containing contact data, loading state, and error state
1742
+ *
1743
+ * @example
1744
+ * ```tsx
1745
+ * const { data: contact, isLoading, isError } = useContact('contact-123');
1746
+ * ```
1747
+ */
1748
+ declare function useContact(_contactId: string): UseContactResult;
1749
+
1750
+ /**
1751
+ * Auth Constants for Fluid Rep SDK
1752
+ *
1753
+ * These constants define the default values for authentication
1754
+ * configuration and storage keys.
1755
+ */
1756
+ /**
1757
+ * Authentication-related constants with sensible defaults.
1758
+ */
1759
+ declare const AUTH_CONSTANTS: {
1760
+ /**
1761
+ * Grace period in milliseconds to account for clock skew
1762
+ * when checking token expiration. Tokens are considered valid
1763
+ * if they expire within this period.
1764
+ */
1765
+ readonly TOKEN_GRACE_PERIOD_MS: number;
1766
+ /**
1767
+ * Default cookie max age in seconds (9 days).
1768
+ * This matches the typical JWT token lifetime from the Fluid API.
1769
+ */
1770
+ readonly COOKIE_MAX_AGE: number;
1771
+ };
1772
+ /**
1773
+ * Storage keys for auth tokens.
1774
+ */
1775
+ declare const STORAGE_KEYS: {
1776
+ /** localStorage key for user token */
1777
+ readonly USER_TOKEN: "fluidUserToken";
1778
+ /** localStorage key for company token (legacy) */
1779
+ readonly COMPANY_TOKEN: "fluidCompanyToken";
1780
+ /** Cookie name for auth token */
1781
+ readonly AUTH_COOKIE: "auth_token";
1782
+ };
1783
+ /**
1784
+ * Default URL parameter names for token extraction.
1785
+ */
1786
+ declare const URL_PARAMS: {
1787
+ /** URL parameter name for user token */
1788
+ readonly USER_TOKEN: "fluidUserToken";
1789
+ /** URL parameter name for company token (legacy) */
1790
+ readonly COMPANY_TOKEN: "fluidCompanyToken";
1791
+ };
1792
+
1793
+ /**
1794
+ * Auth Redirect Utilities
1795
+ *
1796
+ * Provides default redirect behavior for authentication failures.
1797
+ * When no custom callback is provided, the SDK redirects to Fluid's
1798
+ * auth page with a redirect_url pointing back to the current page.
1799
+ *
1800
+ * Includes loop detection: if a redirect was attempted within the
1801
+ * cooldown window, subsequent calls are suppressed to prevent
1802
+ * infinite redirect cycles (e.g., auth returns a token the API rejects).
1803
+ */
1804
+ /**
1805
+ * Default Fluid authentication URL.
1806
+ * Users are redirected here when auth fails and no custom handler is provided.
1807
+ */
1808
+ declare const DEFAULT_AUTH_URL = "https://auth.fluid.app";
1809
+ /**
1810
+ * Creates a redirect function that navigates to the auth URL
1811
+ * with the current page URL encoded as a redirect parameter.
1812
+ *
1813
+ * Includes loop detection: if a redirect was attempted within the last
1814
+ * {@link REDIRECT_COOLDOWN_S} seconds, the redirect is suppressed and
1815
+ * the normal error UI is allowed to render instead.
1816
+ *
1817
+ * @param authUrl - Custom auth URL to redirect to. Defaults to DEFAULT_AUTH_URL.
1818
+ * @returns A function that performs the redirect when called (no-op if loop detected).
1819
+ *
1820
+ * @example
1821
+ * ```ts
1822
+ * const redirect = createDefaultAuthRedirect();
1823
+ * // Redirects to: https://auth.fluid.app/?redirect_url=https%3A%2F%2Fmy-portal.com%2Fdashboard
1824
+ * redirect();
1825
+ * ```
1826
+ */
1827
+ declare function createDefaultAuthRedirect(authUrl?: string): () => void;
1828
+
1829
+ /**
1830
+ * Token Utilities for Fluid Rep SDK
1831
+ *
1832
+ * Functions for decoding, validating, and checking JWT tokens.
1833
+ */
1834
+
1835
+ /**
1836
+ * Decode a JWT token and extract its payload.
1837
+ *
1838
+ * **Security note:** This function does NOT verify the JWT signature.
1839
+ * It only decodes the payload. Any valid JWT structure will be accepted,
1840
+ * regardless of who signed it.
1841
+ *
1842
+ * Client-side token decoding is used for UX purposes only (displaying
1843
+ * user info, role-based UI). The real security boundary is the server-side
1844
+ * API, which verifies the signature on every request.
1845
+ *
1846
+ * For signature verification, use {@link verifyToken} with a JWKS URL.
1847
+ *
1848
+ * @param token - The JWT token string
1849
+ * @returns The decoded JWT payload, or null if decoding fails
1850
+ *
1851
+ * @example
1852
+ * ```ts
1853
+ * const payload = decodeToken(token);
1854
+ * if (payload) {
1855
+ * console.log(`User: ${payload.email}`);
1856
+ * }
1857
+ * ```
1858
+ */
1859
+ declare function decodeToken(token: string): JWTPayload | null;
1860
+ /**
1861
+ * Check if a token has expired.
1862
+ * Includes a configurable grace period to account for clock skew.
1863
+ *
1864
+ * @param token - The JWT token string
1865
+ * @param gracePeriodMs - Grace period in milliseconds (default: 30 seconds)
1866
+ * @returns true if the token is expired, false otherwise
1867
+ *
1868
+ * @example
1869
+ * ```ts
1870
+ * if (isTokenExpired(token)) {
1871
+ * // Token is expired, need to re-authenticate
1872
+ * clearAuth();
1873
+ * }
1874
+ * ```
1875
+ */
1876
+ declare function isTokenExpired(token: string, gracePeriodMs?: number): boolean;
1877
+ /**
1878
+ * Validate a JWT token for format and expiration.
1879
+ *
1880
+ * **Security note:** This function checks JWT structure and expiration
1881
+ * but does NOT verify the signature. It is a UX-level check only.
1882
+ * For signature verification, use {@link verifyToken} with a JWKS URL.
1883
+ *
1884
+ * @param token - The JWT token string
1885
+ * @param gracePeriodMs - Grace period for expiration check (default: 30 seconds)
1886
+ * @returns Validation result with status and decoded payload if valid
1887
+ *
1888
+ * @example
1889
+ * ```ts
1890
+ * const result = validateToken(token);
1891
+ * if (result.isValid) {
1892
+ * console.log(`Welcome, ${result.payload?.full_name}`);
1893
+ * } else {
1894
+ * console.error(`Auth failed: ${result.error}`);
1895
+ * }
1896
+ * ```
1897
+ */
1898
+ declare function validateToken(token: string, gracePeriodMs?: number): TokenValidationResult;
1899
+ /**
1900
+ * Type guard to check if a validation result is valid.
1901
+ * Enables TypeScript narrowing of the result type.
1902
+ *
1903
+ * @param result - The validation result to check
1904
+ * @returns true if the token is valid (narrows payload to non-optional)
1905
+ *
1906
+ * @example
1907
+ * ```ts
1908
+ * const result = validateToken(token);
1909
+ * if (isValidToken(result)) {
1910
+ * // result.payload is guaranteed to be JWTPayload (not undefined)
1911
+ * console.log(result.payload.email);
1912
+ * }
1913
+ * ```
1914
+ */
1915
+ declare function isValidToken(result: TokenValidationResult): result is TokenValidationResult & {
1916
+ isValid: true;
1917
+ payload: JWTPayload;
1918
+ };
1919
+ /**
1920
+ * Get the expiration time of a token as a Date.
1921
+ *
1922
+ * @param token - The JWT token string
1923
+ * @returns The expiration Date, or null if token has no expiration or is invalid
1924
+ */
1925
+ declare function getTokenExpiration(token: string): Date | null;
1926
+ /**
1927
+ * Get the time remaining until token expiration in milliseconds.
1928
+ *
1929
+ * @param token - The JWT token string
1930
+ * @returns Milliseconds until expiration, or 0 if expired/invalid, or Infinity if no expiration
1931
+ */
1932
+ declare function getTokenTimeRemaining(token: string): number;
1933
+
1934
+ /**
1935
+ * Token Storage Utilities for Fluid Rep SDK
1936
+ *
1937
+ * Functions for storing and retrieving auth tokens from
1938
+ * cookies and localStorage.
1939
+ */
1940
+
1941
+ /**
1942
+ * Get the stored auth token.
1943
+ * Checks cookie first, then falls back to localStorage.
1944
+ *
1945
+ * @param config - Optional auth config for custom cookie key
1946
+ * @returns The stored token or null if not found
1947
+ *
1948
+ * @example
1949
+ * ```ts
1950
+ * const token = getStoredToken();
1951
+ * if (token) {
1952
+ * console.log("User is logged in");
1953
+ * }
1954
+ * ```
1955
+ */
1956
+ declare function getStoredToken(config?: FluidAuthConfig): string | null;
1957
+ /**
1958
+ * Store an auth token in both cookie and localStorage.
1959
+ * Using both provides redundancy and compatibility with different auth flows.
1960
+ *
1961
+ * @param token - The JWT token to store
1962
+ * @param config - Optional auth config for custom storage options
1963
+ *
1964
+ * @example
1965
+ * ```ts
1966
+ * storeToken(newToken);
1967
+ * // Token is now accessible via getStoredToken()
1968
+ * ```
1969
+ */
1970
+ declare function storeToken(token: string, config?: FluidAuthConfig): void;
1971
+ /**
1972
+ * Clear all stored auth tokens from cookies and localStorage.
1973
+ *
1974
+ * @param config - Optional auth config for custom cookie key
1975
+ *
1976
+ * @example
1977
+ * ```ts
1978
+ * // User logs out
1979
+ * clearTokens();
1980
+ * ```
1981
+ */
1982
+ declare function clearTokens(config?: FluidAuthConfig): void;
1983
+ /**
1984
+ * Check if any auth token is stored.
1985
+ *
1986
+ * @param config - Optional auth config
1987
+ * @returns true if a token is stored, false otherwise
1988
+ */
1989
+ declare function hasStoredToken(config?: FluidAuthConfig): boolean;
1990
+
1991
+ /**
1992
+ * URL Token Utilities for Fluid Rep SDK
1993
+ *
1994
+ * Functions for extracting and cleaning auth tokens from URL parameters.
1995
+ * This is the primary way tokens are passed from the parent Fluid Commerce
1996
+ * app to embedded rep portals.
1997
+ *
1998
+ * **Security model**: Tokens in URL parameters are a known tradeoff.
1999
+ * The token is extracted and immediately cleaned from the URL via
2000
+ * `history.replaceState()`. A `Referrer-Policy` meta tag in the
2001
+ * starter template prevents the token from leaking in referrer headers.
2002
+ * See docs/authentication.md for full security analysis.
2003
+ */
2004
+ /**
2005
+ * Extract the auth token from the URL query parameters.
2006
+ *
2007
+ * @param tokenKey - The URL parameter name (default: "fluidUserToken")
2008
+ * @returns The token value or null if not present
2009
+ *
2010
+ * @example
2011
+ * ```ts
2012
+ * // URL: https://myportal.com?fluidUserToken=eyJhbG...
2013
+ * const token = extractTokenFromUrl();
2014
+ * // token = "eyJhbG..."
2015
+ * ```
2016
+ */
2017
+ declare function extractTokenFromUrl(tokenKey?: string): string | null;
2018
+ /**
2019
+ * Extract the company token from the URL query parameters.
2020
+ * This is a legacy parameter that may still be used in some flows.
2021
+ *
2022
+ * @param tokenKey - The URL parameter name (default: "fluidCompanyToken")
2023
+ * @returns The token value or null if not present
2024
+ */
2025
+ declare function extractCompanyTokenFromUrl(tokenKey?: string): string | null;
2026
+ /**
2027
+ * Remove the auth token from the URL without reloading the page.
2028
+ * This prevents the token from being accidentally shared via URL copy/paste
2029
+ * or appearing in browser history.
2030
+ *
2031
+ * Uses history.replaceState to update the URL cleanly.
2032
+ *
2033
+ * @param tokenKey - The URL parameter name to remove (default: "fluidUserToken")
2034
+ *
2035
+ * @example
2036
+ * ```ts
2037
+ * // Before: https://myportal.com?fluidUserToken=eyJhbG...&page=1
2038
+ * cleanTokenFromUrl();
2039
+ * // After: https://myportal.com?page=1
2040
+ * ```
2041
+ */
2042
+ declare function cleanTokenFromUrl(tokenKey?: string): void;
2043
+ /**
2044
+ * Check if the URL contains an auth token parameter.
2045
+ *
2046
+ * @param tokenKey - The URL parameter name (default: "fluidUserToken")
2047
+ * @returns true if the URL contains the token parameter
2048
+ */
2049
+ declare function hasTokenInUrl(tokenKey?: string): boolean;
2050
+ /**
2051
+ * Extract all auth-related tokens from the URL at once.
2052
+ *
2053
+ * @param userTokenKey - The URL parameter name for user token
2054
+ * @param companyTokenKey - The URL parameter name for company token
2055
+ * @returns Object with both token values (or null if not present)
2056
+ */
2057
+ declare function extractAllTokensFromUrl(userTokenKey?: string, companyTokenKey?: string): {
2058
+ userToken: string | null;
2059
+ companyToken: string | null;
2060
+ };
2061
+
2062
+ interface RequireAuthProps {
2063
+ /** Content to render when authenticated */
2064
+ children: ReactNode;
2065
+ /** Component to show while checking authentication (default: AuthLoading) */
2066
+ fallback?: ReactNode;
2067
+ /** Component to show when not authenticated (default: AuthError) */
2068
+ errorComponent?: ReactNode;
2069
+ }
2070
+ /**
2071
+ * Component that protects content requiring authentication.
2072
+ *
2073
+ * **Important:** This provides UX-level protection only. It prevents
2074
+ * unauthenticated users from seeing the UI, but the real security
2075
+ * boundary is the server-side API. Client-side auth can always be
2076
+ * bypassed by modifying browser state.
2077
+ *
2078
+ * For defense-in-depth, configure `jwksUrl` in `FluidAuthConfig`
2079
+ * to enable client-side JWT signature verification.
2080
+ *
2081
+ * Shows different states based on auth status:
2082
+ * - Loading: Shows fallback (spinner by default)
2083
+ * - Not authenticated: Shows errorComponent (AuthError by default)
2084
+ * - Authenticated: Shows children
2085
+ *
2086
+ * @example
2087
+ * ```tsx
2088
+ * // Basic usage - shows default loading/error states
2089
+ * <RequireAuth>
2090
+ * <ProtectedContent />
2091
+ * </RequireAuth>
2092
+ *
2093
+ * // Custom loading state
2094
+ * <RequireAuth fallback={<CustomSpinner />}>
2095
+ * <ProtectedContent />
2096
+ * </RequireAuth>
2097
+ *
2098
+ * // Custom error component
2099
+ * <RequireAuth errorComponent={<LoginPrompt />}>
2100
+ * <ProtectedContent />
2101
+ * </RequireAuth>
2102
+ *
2103
+ * // Both custom
2104
+ * <RequireAuth
2105
+ * fallback={<SkeletonLoader />}
2106
+ * errorComponent={<RedirectToLogin />}
2107
+ * >
2108
+ * <Dashboard />
2109
+ * </RequireAuth>
2110
+ * ```
2111
+ */
2112
+ declare function RequireAuth({ children, fallback, errorComponent, }: RequireAuthProps): react_jsx_runtime.JSX.Element;
2113
+
2114
+ interface AuthErrorProps {
2115
+ /** Error message to display */
2116
+ message?: string;
2117
+ /** Optional title */
2118
+ title?: string;
2119
+ /** Optional children for custom content */
2120
+ children?: ReactNode;
2121
+ }
2122
+ /**
2123
+ * Default authentication error component.
2124
+ *
2125
+ * Displays a simple error message when authentication fails.
2126
+ * Can be customized via props or replaced entirely in RequireAuth.
2127
+ *
2128
+ * @example
2129
+ * ```tsx
2130
+ * // Use with default message
2131
+ * <AuthError />
2132
+ *
2133
+ * // Use with custom message
2134
+ * <AuthError message="Session expired. Please log in again." />
2135
+ *
2136
+ * // Use with custom content
2137
+ * <AuthError>
2138
+ * <CustomLoginButton />
2139
+ * </AuthError>
2140
+ * ```
2141
+ */
2142
+ declare function AuthError({ message, title, children, }: AuthErrorProps): react_jsx_runtime.JSX.Element;
2143
+ /**
2144
+ * Simple loading spinner component for auth loading state.
2145
+ */
2146
+ declare function AuthLoading(): react_jsx_runtime.JSX.Element;
2147
+
2148
+ /**
2149
+ * Bridge hook: maps rep SDK auth context to MessagingAuthContext.
2150
+ *
2151
+ * The messaging system identifies users by `recipient_id`, which is NOT in the
2152
+ * JWT payload or the /reps/me endpoint. It IS returned by GET /api/me.
2153
+ * This hook fetches that data and maps it into the shape MessagingApp expects.
2154
+ */
2155
+
2156
+ declare function useMessagingAuth(): MessagingAuthContext;
2157
+
2158
+ /**
2159
+ * Hook that derives MessagingApiConfig from the rep SDK's FluidProvider context.
2160
+ *
2161
+ * Maps FluidSDKConfig fields to the shape expected by MessagingApp:
2162
+ * - baseUrl -> from config.baseUrl
2163
+ * - getHeaders -> builds Authorization header from config.getAuthToken()
2164
+ * - onAuthError -> from config.onAuthError
2165
+ * - websocketUrl -> config.websocketUrl or derived from baseUrl
2166
+ * - token -> from auth context
2167
+ */
2168
+
2169
+ interface MessagingConfig {
2170
+ readonly apiConfig: MessagingApiConfig;
2171
+ readonly websocketUrl: string;
2172
+ readonly token: string | null;
2173
+ }
2174
+ declare function useMessagingConfig(): MessagingConfig;
2175
+
2176
+ /**
2177
+ * Lightweight Filestack file uploader for the rep SDK.
2178
+ *
2179
+ * Uploads files to Filestack using the REST API (no filestack-js dependency).
2180
+ * Flow: upload to `https://www.filestackapi.com/api/store/S3?key=<apiKey>`
2181
+ * Uses XMLHttpRequest for upload progress tracking.
2182
+ */
2183
+
2184
+ /**
2185
+ * Creates a FileUploader that uploads to Filestack using the REST API.
2186
+ *
2187
+ * @param apiKey - Filestack API key. If falsy, returns a noop uploader
2188
+ * that rejects uploads with a helpful error message.
2189
+ */
2190
+ declare function createFluidFileUploader(apiKey: string | undefined): FileUploader;
2191
+
2192
+ type MessagingScreenProps = ComponentProps<"div"> & {
2193
+ background?: BackgroundValue;
2194
+ textColor?: ColorOptions;
2195
+ accentColor?: ColorOptions;
2196
+ padding?: PaddingOptions;
2197
+ borderRadius?: BorderRadiusOptions;
2198
+ onToast?: (message: string, type: "success" | "error") => void;
2199
+ filestackApiKey?: string;
2200
+ websocketUrl?: string;
2201
+ };
2202
+ declare function MessagingScreen({ onToast, filestackApiKey, websocketUrl: websocketUrlOverride, background, textColor, accentColor, padding, borderRadius, ...divProps }: MessagingScreenProps): react_jsx_runtime.JSX.Element;
2203
+ declare const messagingScreenPropertySchema: WidgetPropertySchema;
2204
+
2205
+ type ContactsScreenProps = ComponentProps<"div"> & {
2206
+ background?: BackgroundValue;
2207
+ textColor?: ColorOptions;
2208
+ accentColor?: ColorOptions;
2209
+ padding?: PaddingOptions;
2210
+ borderRadius?: BorderRadiusOptions;
2211
+ defaultViewMode?: "list" | "grid";
2212
+ onContactSelect?: (contactId: string) => void;
2213
+ onCreateContact?: () => void;
2214
+ };
2215
+ declare function ContactsScreen(_props: ContactsScreenProps): react_jsx_runtime.JSX.Element;
2216
+ declare const contactsScreenPropertySchema: WidgetPropertySchema;
2217
+
2218
+ type OrdersScreenProps = ComponentProps<"div"> & {
2219
+ background?: BackgroundValue;
2220
+ textColor?: ColorOptions;
2221
+ accentColor?: ColorOptions;
2222
+ padding?: PaddingOptions;
2223
+ borderRadius?: BorderRadiusOptions;
2224
+ };
2225
+ declare function OrdersScreen(_props: OrdersScreenProps): react_jsx_runtime.JSX.Element;
2226
+ declare const ordersScreenPropertySchema: WidgetPropertySchema;
2227
+
2228
+ type CustomersScreenProps = ComponentProps<"div"> & {
2229
+ background?: BackgroundValue;
2230
+ textColor?: ColorOptions;
2231
+ accentColor?: ColorOptions;
2232
+ padding?: PaddingOptions;
2233
+ borderRadius?: BorderRadiusOptions;
2234
+ };
2235
+ declare function CustomersScreen(_props: CustomersScreenProps): react_jsx_runtime.JSX.Element;
2236
+ declare const customersScreenPropertySchema: WidgetPropertySchema;
2237
+
2238
+ type ProductsScreenProps = ComponentProps<"div"> & {
2239
+ background?: BackgroundValue;
2240
+ textColor?: ColorOptions;
2241
+ accentColor?: ColorOptions;
2242
+ padding?: PaddingOptions;
2243
+ borderRadius?: BorderRadiusOptions;
2244
+ };
2245
+ declare function ProductsScreen(_props: ProductsScreenProps): react_jsx_runtime.JSX.Element;
2246
+ declare const productsScreenPropertySchema: WidgetPropertySchema;
2247
+
2248
+ declare const screenPropertySchemas: {
2249
+ MessagingScreen: () => Promise<_fluid_app_rep_core_registries.WidgetPropertySchema>;
2250
+ ContactsScreen: () => Promise<_fluid_app_rep_core_registries.WidgetPropertySchema>;
2251
+ OrdersScreen: () => Promise<_fluid_app_rep_core_registries.WidgetPropertySchema>;
2252
+ CustomersScreen: () => Promise<_fluid_app_rep_core_registries.WidgetPropertySchema>;
2253
+ ProductsScreen: () => Promise<_fluid_app_rep_core_registries.WidgetPropertySchema>;
2254
+ };
2255
+ /**
2256
+ * Core page template IDs
2257
+ */
2258
+ declare const CORE_PAGE_IDS: {
2259
+ readonly MESSAGING: "core-messaging";
2260
+ readonly CONTACTS: "core-contacts";
2261
+ readonly ORDERS: "core-orders";
2262
+ readonly CUSTOMERS: "core-customers";
2263
+ readonly PRODUCTS: "core-products";
2264
+ };
2265
+
2266
+ declare const DEFAULT_SDK_WIDGET_REGISTRY: {
2267
+ AlertWidget: typeof AlertWidget;
2268
+ CalendarWidget: typeof CalendarWidget;
2269
+ CarouselWidget: typeof CarouselWidget;
2270
+ CatchUpWidget: typeof CatchUpWidget;
2271
+ ChartWidget: typeof ChartWidget;
2272
+ ContainerWidget: typeof ContainerWidget;
2273
+ EmbedWidget: typeof EmbedWidget;
2274
+ ImageWidget: typeof ImageWidget;
2275
+ LayoutWidget: <T extends Record<string, react.ComponentType<any>>>({ sectionLayout, gap, gapSize, background, padding, borderRadius, children, registry, className, minHeight, }: {
2276
+ sectionLayout?: _fluid_app_rep_core_types.SectionLayoutType;
2277
+ type?: "flex" | "grid";
2278
+ columns?: number;
2279
+ rows?: number;
2280
+ direction?: string;
2281
+ justify?: string;
2282
+ align?: string;
2283
+ wrap?: boolean;
2284
+ gap?: number;
2285
+ gapSize?: _fluid_app_rep_core_types.GapOptions;
2286
+ background?: _fluid_app_rep_core_types.BackgroundValue;
2287
+ padding?: _fluid_app_rep_core_types.PaddingOptions;
2288
+ borderRadius?: _fluid_app_rep_core_types.BorderRadiusOptions;
2289
+ children: (_fluid_app_rep_core_types.WidgetSchema | null)[] | (_fluid_app_rep_core_types.TypedWidgetSchema<T> | null)[];
2290
+ registry?: T | undefined;
2291
+ className?: string;
2292
+ minHeight?: number;
2293
+ }) => react_jsx_runtime.JSX.Element;
2294
+ ListWidget: typeof ListWidget;
2295
+ MySiteWidget: typeof MySiteWidget;
2296
+ NestedWidget: typeof NestedWidget;
2297
+ QuickShareWidget: typeof QuickShareWidget;
2298
+ RecentActivityWidget: typeof RecentActivityWidget;
2299
+ SpacerWidget: typeof SpacerWidget;
2300
+ TableWidget: typeof TableWidget;
2301
+ TextWidget: typeof TextWidget;
2302
+ ToDoWidget: typeof ToDoWidget;
2303
+ VideoWidget: typeof VideoWidget;
2304
+ };
2305
+
2306
+ /**
2307
+ * Resolve all page references and local screens into a unified screen list.
2308
+ *
2309
+ * This function merges:
2310
+ * 1. Screen definitions from page_refs (shared templates)
2311
+ * 2. Local screen definitions (for backwards compatibility and custom screens)
2312
+ *
2313
+ * When a screen_id appears in both page_refs and screens, the local screen
2314
+ * takes precedence (allows local overrides of template pages).
2315
+ *
2316
+ * @param navigation - The navigation configuration
2317
+ * @returns A unified array of ScreenDefinition objects
2318
+ *
2319
+ * @example
2320
+ * ```ts
2321
+ * const navigation: Navigation = {
2322
+ * definition_id: 1,
2323
+ * id: 1,
2324
+ * name: "Main Nav",
2325
+ * navigation_items: [...],
2326
+ * screens: [
2327
+ * // Local custom screen
2328
+ * { id: 1, slug: "home", name: "Home", component_tree: [...] }
2329
+ * ],
2330
+ * page_refs: [
2331
+ * // Reference to shared messaging template
2332
+ * { page_template_id: "core-messaging", screen_id: 2 }
2333
+ * ],
2334
+ * };
2335
+ *
2336
+ * const allScreens = resolveNavigationPages(navigation);
2337
+ * // Returns: [home screen, messaging screen from template]
2338
+ * ```
2339
+ */
2340
+ declare function resolveNavigationPages(navigation: Readonly<Navigation>): ScreenDefinition[];
2341
+ /**
2342
+ * Get all available page templates for use in navigation.
2343
+ *
2344
+ * @returns Array of page templates from the registry
2345
+ */
2346
+ declare function getAvailablePageTemplates(): PageTemplate[];
2347
+ /**
2348
+ * Get core page templates that are required for basic functionality.
2349
+ *
2350
+ * @returns Array of core page templates
2351
+ */
2352
+ declare function getCorePageTemplates(): PageTemplate[];
2353
+ /**
2354
+ * Get optional page templates that can be added to navigation.
2355
+ *
2356
+ * @returns Array of optional (non-core) page templates
2357
+ */
2358
+ declare function getOptionalPageTemplates(): PageTemplate[];
2359
+ /**
2360
+ * Check if a navigation has all required core pages.
2361
+ *
2362
+ * @param navigation - The navigation to check
2363
+ * @returns Object with validation result and missing page IDs
2364
+ */
2365
+ declare function validateNavigationPages(navigation: Readonly<Navigation>): {
2366
+ readonly valid: boolean;
2367
+ readonly missingCorePages: readonly string[];
2368
+ };
2369
+
2370
+ /**
2371
+ * Registry for managing reusable page templates.
2372
+ *
2373
+ * The registry provides a central store for page templates that can be
2374
+ * shared across multiple navigations. Core pages (like Messaging, Contacts)
2375
+ * are pre-registered and cannot be removed.
2376
+ *
2377
+ * @example
2378
+ * ```ts
2379
+ * // Register a custom page template
2380
+ * PageTemplateRegistry.register({
2381
+ * id: 'custom-dashboard',
2382
+ * slug: 'dashboard',
2383
+ * name: 'Custom Dashboard',
2384
+ * category: 'custom',
2385
+ * version: '1.0.0',
2386
+ * component_tree: [{ type: 'TextWidget', props: { text: 'Hello' } }],
2387
+ * });
2388
+ *
2389
+ * // Get a template by ID
2390
+ * const template = PageTemplateRegistry.get('custom-dashboard');
2391
+ *
2392
+ * // List all templates in a category
2393
+ * const corePages = PageTemplateRegistry.getByCategory('core');
2394
+ * ```
2395
+ */
2396
+ declare class PageTemplateRegistryImpl {
2397
+ private templates;
2398
+ private categories;
2399
+ constructor();
2400
+ /**
2401
+ * Register a new page template.
2402
+ * @throws Error if a template with the same ID already exists
2403
+ */
2404
+ register(template: PageTemplate): void;
2405
+ /**
2406
+ * Unregister a page template by ID.
2407
+ * Core templates cannot be unregistered.
2408
+ * @returns true if the template was removed, false if it didn't exist or is a core template
2409
+ */
2410
+ unregister(id: string): boolean;
2411
+ /**
2412
+ * Get a page template by ID.
2413
+ */
2414
+ get(id: string): PageTemplate | undefined;
2415
+ /**
2416
+ * Get all page templates in a specific category.
2417
+ */
2418
+ getByCategory(category: PageCategoryId | string): PageTemplate[];
2419
+ /**
2420
+ * List all registered page templates.
2421
+ */
2422
+ listAll(): PageTemplate[];
2423
+ /**
2424
+ * List all core page templates (isCore: true).
2425
+ */
2426
+ listCore(): PageTemplate[];
2427
+ /**
2428
+ * List all non-core page templates.
2429
+ */
2430
+ listOptional(): PageTemplate[];
2431
+ /**
2432
+ * List all registered categories.
2433
+ */
2434
+ listCategories(): PageCategory[];
2435
+ /**
2436
+ * Add a custom category.
2437
+ */
2438
+ addCategory(category: PageCategory): void;
2439
+ /**
2440
+ * Check if a template exists by ID.
2441
+ */
2442
+ has(id: string): boolean;
2443
+ /**
2444
+ * Get the count of registered templates.
2445
+ */
2446
+ get size(): number;
2447
+ /**
2448
+ * Clear all non-core templates.
2449
+ * Useful for testing or resetting the registry.
2450
+ */
2451
+ clearNonCore(): void;
2452
+ }
2453
+ /**
2454
+ * Global page template registry singleton.
2455
+ *
2456
+ * This registry is automatically populated with core page templates
2457
+ * (Messaging, Contacts) when the SDK is imported.
2458
+ */
2459
+ declare const PageTemplateRegistry: PageTemplateRegistryImpl;
2460
+
2461
+ interface AppShellProps {
2462
+ /** Pre-fetched app data (skips internal useFluidApp call if provided) */
2463
+ appData?: RepAppData;
2464
+ /** Override navigation items (otherwise derived from appData/API) */
2465
+ navigation?: NavigationItem[];
2466
+ /** Custom page components keyed by slug */
2467
+ customPages?: Record<string, ComponentType<{
2468
+ slug?: string;
2469
+ params?: string;
2470
+ }>>;
2471
+ /** Base path for subpath deployments (e.g. "/portal"). Default: "/" */
2472
+ basePath?: string;
2473
+ /** Controlled current slug */
2474
+ currentSlug?: string;
2475
+ /** Navigation callback */
2476
+ onNavigate?: (slug: string) => void;
2477
+ /** Custom sidebar header slot */
2478
+ sidebarHeader?: ReactNode;
2479
+ /** Custom sidebar footer slot */
2480
+ sidebarFooter?: ReactNode;
2481
+ /** Render prop or static children for the content area */
2482
+ children?: ReactNode | ((props: {
2483
+ currentSlug: string;
2484
+ currentNavItem: NavigationItem | undefined;
2485
+ }) => ReactNode);
2486
+ }
2487
+ declare function AppShell({ appData: appDataProp, navigation: navigationProp, customPages, basePath, currentSlug: controlledSlug, onNavigate: onNavigateProp, sidebarHeader, sidebarFooter, children, }: AppShellProps): react_jsx_runtime.JSX.Element;
2488
+
2489
+ interface BuilderScreenViewProps {
2490
+ /** The screen definition to render */
2491
+ screen: ScreenDefinition$1;
2492
+ /** Additional CSS classes for the wrapper div */
2493
+ className?: string;
2494
+ }
2495
+ /**
2496
+ * Renders a builder screen's component_tree with full data source support.
2497
+ * Widgets with `dataSource` config are automatically wrapped with `DataAwareWidget`
2498
+ * which fetches data and merges it with static props before rendering.
2499
+ */
2500
+ declare function BuilderScreenViewImpl({ screen, className }: BuilderScreenViewProps): react_jsx_runtime.JSX.Element;
2501
+ declare const BuilderScreenView: react.MemoExoticComponent<typeof BuilderScreenViewImpl>;
2502
+
2503
+ interface SdkNavigationProps {
2504
+ navItems: NavigationItem[];
2505
+ currentSlug: string;
2506
+ onNavigate: (slug: string) => void;
2507
+ navSlugs: string[];
2508
+ }
2509
+ declare function SdkNavigation({ navItems, currentSlug, onNavigate, navSlugs, }: SdkNavigationProps): react_jsx_runtime.JSX.Element;
2510
+
2511
+ interface SdkHeaderProps {
2512
+ tabs: NavigationItem[];
2513
+ currentSlug: string;
2514
+ onNavigate: (slug: string) => void;
2515
+ navSlugs: string[];
2516
+ }
2517
+ declare function SdkHeader({ tabs, currentSlug, onNavigate, navSlugs, }: SdkHeaderProps): react_jsx_runtime.JSX.Element;
2518
+
2519
+ interface PageRouterProps {
2520
+ currentSlug: string;
2521
+ currentNavItem?: NavigationItem | undefined;
2522
+ customPages?: Record<string, ComponentType<{
2523
+ slug?: string;
2524
+ params?: string;
2525
+ }>> | undefined;
2526
+ /** Builder screen definitions (from fluidos API) */
2527
+ screens?: ScreenDefinition[] | undefined;
2528
+ baseSlug: string;
2529
+ restParams: string;
2530
+ }
2531
+ declare function PageRouter({ currentSlug, currentNavItem, customPages, screens, baseSlug, restParams, }: PageRouterProps): react_jsx_runtime.JSX.Element;
2532
+
2533
+ interface QuickLinksDropdownProps {
2534
+ onNavigate: (slug: string) => void;
2535
+ }
2536
+ declare function QuickLinksDropdown({ onNavigate }: QuickLinksDropdownProps): react_jsx_runtime.JSX.Element;
2537
+
2538
+ interface AppNavigationContextValue {
2539
+ /** Current active slug (e.g. "contacts/123") */
2540
+ currentSlug: string;
2541
+ /** Base path for subpath deployments (e.g. "/portal"). Default: "/" */
2542
+ basePath: string;
2543
+ /** Navigate to a slug programmatically */
2544
+ navigate: (slug: string) => void;
2545
+ /** Build a full href for a slug (for use in <a> tags) */
2546
+ buildHref: (slug: string) => string;
2547
+ }
2548
+ interface AppNavigationProviderProps {
2549
+ currentSlug: string;
2550
+ basePath: string;
2551
+ navigate: (slug: string) => void;
2552
+ children: ReactNode;
2553
+ }
2554
+ declare function AppNavigationProvider({ currentSlug, basePath, navigate, children, }: AppNavigationProviderProps): react_jsx_runtime.JSX.Element;
2555
+ declare function useAppNavigation(): AppNavigationContextValue;
2556
+
2557
+ interface AppLinkProps extends Omit<AnchorHTMLAttributes<HTMLAnchorElement>, "href"> {
2558
+ /** Slug to navigate to (e.g. "contacts/123") */
2559
+ to: string;
2560
+ }
2561
+ /**
2562
+ * SPA-aware link that renders a real `<a href>` for accessibility
2563
+ * (right-click, ctrl+click, screen readers) but intercepts normal
2564
+ * clicks for client-side navigation.
2565
+ */
2566
+ declare const AppLink: react.ForwardRefExoticComponent<AppLinkProps & react.RefAttributes<HTMLAnchorElement>>;
2567
+
2568
+ interface SlugMatch {
2569
+ matchedSlug: string;
2570
+ rest: string;
2571
+ }
2572
+ /**
2573
+ * Extract all slugs from a navigation tree, sorted by segment count descending.
2574
+ * Longest slugs first enables greedy prefix matching (e.g. "share/playlists"
2575
+ * is checked before "share").
2576
+ */
2577
+ declare function collectNavSlugs(items: NavigationItem[]): string[];
2578
+ /**
2579
+ * Find the longest registered nav slug that is a prefix of `fullSlug`.
2580
+ * Uses segment-boundary checking to prevent "shop" from matching "shopping".
2581
+ */
2582
+ declare function matchSlugPrefix(fullSlug: string, navSlugs: string[]): SlugMatch | undefined;
2583
+ /**
2584
+ * Extract the slug portion from a full pathname by stripping the basePath prefix.
2585
+ * Returns an empty string when the pathname equals the basePath exactly.
2586
+ *
2587
+ * Examples:
2588
+ * extractSlugFromPathname("/contacts/123", "/") → "contacts/123"
2589
+ * extractSlugFromPathname("/portal/contacts", "/portal") → "contacts"
2590
+ * extractSlugFromPathname("/portal", "/portal") → ""
2591
+ * extractSlugFromPathname("/", "/") → ""
2592
+ */
2593
+ declare function extractSlugFromPathname(pathname: string, basePath: string): string;
2594
+ declare function isSlugInSection(item: NavigationItem, currentSlug: string, navSlugs: string[]): boolean;
2595
+
2596
+ export { ACTIVITY_SLUGS, APP_DATA_QUERY_KEY, AUTH_CONSTANTS, type Activity as ActivityItem, type ActivitySlug, ApiError, AppLink, type AppLinkProps, type AppNavigationContextValue, AppNavigationProvider, type AppNavigationProviderProps, AppShell, type AppShellProps, AuthError, type AuthErrorProps, AuthLoading, type BaseListParams, BuilderScreenView, type BuilderScreenViewProps, CORE_PAGE_IDS, CURRENT_REP_QUERY_KEY, type CalendarEvent, type CatchUp as CatchUpItem, type Contact, type ContactAddress, type ContactStatus, type ContactType, ContactsScreen, type Conversation, type ConversationStatus, type CreateOrderData, CustomersScreen, DEFAULT_AUTH_URL, DEFAULT_SDK_WIDGET_REGISTRY, type DashboardData, type FluidAuthConfig, type FluidAuthContextValue, FluidAuthProvider, type FluidAuthProviderProps, type FluidClient, FluidProvider, type FluidProviderProps, type FluidSDKConfig, FluidThemeProvider, type FluidThemeProviderProps, type JWTPayload, type ListQueryResult, type Message, type MessageType, type MessagingConfig, MessagingScreen, type MySiteData, type Navigation, type Order, type OrderLineItem, type OrderListParams, OrdersScreen, PAGE_CATEGORIES, PERMISSIONS_QUERY_KEY, PROFILE_QUERY_KEY, type PageCategory, type PageCategoryId, type PageOverride, type PageReference, PageRouter, type PageRouterProps, type PageTemplate, PageTemplateProvider, PageTemplateRegistry, type PaginationParams, type Participant, type PermissionAction, type Permissions, type Product, type ProductListParams, ProductsScreen, type Profile, type QueryResult, type QueryResultNullable, QuickLinksDropdown, type QuickLinksDropdownProps, type RawApiNavigationItem, type RawApiScreen, type RawManifestResponse, type Rep, type RequestOptions, RequireAuth, type RequireAuthProps, type ResourcePermissions, STORAGE_KEYS, type SalesData, type SalesDataPoint, type SalesParams, type ScreenDefinition, SdkHeader, type SdkHeaderProps, SdkNavigation, type SdkNavigationProps, type SlugMatch, type Todo as TodoItem, type TokenValidationResult, URL_PARAMS, USER_TYPES, type UpdateRepData, type UseContactResult, type UseContactsParams, type UseContactsResult, type UseConversationMessagesResult, type UseConversationsResult, type UseFluidPermissionsResult, type UseFluidThemeResult, type UseListResourceHook, type UseSingleResourceHook, type UserMe, type UserPermissions, type UserType, type ValueListQueryResult, type WithData, cleanTokenFromUrl, clearTokens, collectNavSlugs, contactsScreenPropertySchema, createDefaultAuthRedirect, createFluidClient, createFluidFileUploader, customersScreenPropertySchema, decodeToken, extractAllTokensFromUrl, extractCompanyTokenFromUrl, extractSlugFromPathname, extractTokenFromUrl, getAvailablePageTemplates, getCorePageTemplates, getOptionalPageTemplates, getProperty, getStoredToken, getTokenExpiration, getTokenTimeRemaining, hasData, hasStoredToken, hasTokenInUrl, isActivitySlug, isApiError, isContactStatus, isErrorResult, isIdle, isLoading, isSlugInSection, isTokenExpired, isUserType, isValidToken, matchSlugPrefix, messagingScreenPropertySchema, normalizeComponentTree, ordersScreenPropertySchema, productsScreenPropertySchema, resolveNavigationPages, screenPropertySchemas, selectProperty, storeToken, toNavigationItem, toScreenDefinition, transformManifestToRepAppData, useActivities, useAppNavigation, useCalendarEvents, useCatchUps, useContact, useContacts, useConversationMessages, useConversations, useCurrentRep, useFluidApi, useFluidApp, useFluidAuth, useFluidAuthContext, useFluidContext, useFluidPermissions, useFluidProfile, useFluidTheme, useMessagingAuth, useMessagingConfig, useMySite, usePageTemplates, useResolvedPages, useThemeContext, useTodos, validateNavigationPages, validateToken };