@fluid-app/rep-sdk 0.1.9 → 0.1.11

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 (85) hide show
  1. package/dist/ContactsScreen-CB6l0Lf1.mjs +24 -0
  2. package/dist/ContactsScreen-CB6l0Lf1.mjs.map +1 -0
  3. package/dist/ContactsScreen-UfrdOORn.cjs +41 -0
  4. package/dist/ContactsScreen-UfrdOORn.cjs.map +1 -0
  5. package/dist/CoreScreenPlaceholder-D93ZYKt2.mjs +32 -0
  6. package/dist/CoreScreenPlaceholder-D93ZYKt2.mjs.map +1 -0
  7. package/dist/CoreScreenPlaceholder-DBZqxDsK.cjs +38 -0
  8. package/dist/CoreScreenPlaceholder-DBZqxDsK.cjs.map +1 -0
  9. package/dist/CustomersScreen-BEar6Leg.mjs +24 -0
  10. package/dist/CustomersScreen-BEar6Leg.mjs.map +1 -0
  11. package/dist/CustomersScreen-DXXPpWZW.cjs +41 -0
  12. package/dist/CustomersScreen-DXXPpWZW.cjs.map +1 -0
  13. package/dist/MessagingScreen-CsDvKkLC.cjs +1458 -0
  14. package/dist/MessagingScreen-CsDvKkLC.cjs.map +1 -0
  15. package/dist/MessagingScreen-xO9YudMx.mjs +1285 -0
  16. package/dist/MessagingScreen-xO9YudMx.mjs.map +1 -0
  17. package/dist/OrdersScreen-DB1v051q.mjs +24 -0
  18. package/dist/OrdersScreen-DB1v051q.mjs.map +1 -0
  19. package/dist/OrdersScreen-fcxcnpNU.cjs +41 -0
  20. package/dist/OrdersScreen-fcxcnpNU.cjs.map +1 -0
  21. package/dist/ProductsScreen-BaEng3LB.cjs +41 -0
  22. package/dist/ProductsScreen-BaEng3LB.cjs.map +1 -0
  23. package/dist/ProductsScreen-nVDsY6kf.mjs +24 -0
  24. package/dist/ProductsScreen-nVDsY6kf.mjs.map +1 -0
  25. package/dist/chunk-D1SwGrFN.mjs +27 -0
  26. package/dist/index.cjs +3397 -2850
  27. package/dist/index.cjs.map +1 -1
  28. package/dist/index.d.cts +1026 -955
  29. package/dist/index.d.cts.map +1 -0
  30. package/dist/index.d.mts +2207 -0
  31. package/dist/index.d.mts.map +1 -0
  32. package/dist/index.mjs +2921 -0
  33. package/dist/index.mjs.map +1 -0
  34. package/package.json +8 -8
  35. package/dist/ContactsScreen-7RGAMMGN.cjs +0 -18
  36. package/dist/ContactsScreen-7RGAMMGN.cjs.map +0 -1
  37. package/dist/ContactsScreen-XKZE5HTP.js +0 -5
  38. package/dist/ContactsScreen-XKZE5HTP.js.map +0 -1
  39. package/dist/CustomersScreen-BBQ3YHI4.js +0 -5
  40. package/dist/CustomersScreen-BBQ3YHI4.js.map +0 -1
  41. package/dist/CustomersScreen-EMGCQ2PV.cjs +0 -18
  42. package/dist/CustomersScreen-EMGCQ2PV.cjs.map +0 -1
  43. package/dist/MessagingScreen-I3GVOGKY.js +0 -4
  44. package/dist/MessagingScreen-I3GVOGKY.js.map +0 -1
  45. package/dist/MessagingScreen-ZRD4WEOE.cjs +0 -17
  46. package/dist/MessagingScreen-ZRD4WEOE.cjs.map +0 -1
  47. package/dist/OrdersScreen-ANDGND6F.js +0 -5
  48. package/dist/OrdersScreen-ANDGND6F.js.map +0 -1
  49. package/dist/OrdersScreen-NNE6OSRS.cjs +0 -18
  50. package/dist/OrdersScreen-NNE6OSRS.cjs.map +0 -1
  51. package/dist/ProductsScreen-5PMFLPWS.js +0 -5
  52. package/dist/ProductsScreen-5PMFLPWS.js.map +0 -1
  53. package/dist/ProductsScreen-ALQYD7ID.cjs +0 -18
  54. package/dist/ProductsScreen-ALQYD7ID.cjs.map +0 -1
  55. package/dist/chunk-2RIDFKS3.cjs +0 -19
  56. package/dist/chunk-2RIDFKS3.cjs.map +0 -1
  57. package/dist/chunk-424PT5DM.js +0 -21
  58. package/dist/chunk-424PT5DM.js.map +0 -1
  59. package/dist/chunk-4LTH3NNT.js +0 -16
  60. package/dist/chunk-4LTH3NNT.js.map +0 -1
  61. package/dist/chunk-4PHR2M6A.js +0 -14
  62. package/dist/chunk-4PHR2M6A.js.map +0 -1
  63. package/dist/chunk-EKMZ4NIA.cjs +0 -19
  64. package/dist/chunk-EKMZ4NIA.cjs.map +0 -1
  65. package/dist/chunk-HDQ2JUQT.cjs +0 -24
  66. package/dist/chunk-HDQ2JUQT.cjs.map +0 -1
  67. package/dist/chunk-HFPPHLOO.cjs +0 -19
  68. package/dist/chunk-HFPPHLOO.cjs.map +0 -1
  69. package/dist/chunk-HMOWQQDX.cjs +0 -19
  70. package/dist/chunk-HMOWQQDX.cjs.map +0 -1
  71. package/dist/chunk-JXEED3FK.js +0 -16
  72. package/dist/chunk-JXEED3FK.js.map +0 -1
  73. package/dist/chunk-LU42Y4H3.cjs +0 -1597
  74. package/dist/chunk-LU42Y4H3.cjs.map +0 -1
  75. package/dist/chunk-NGOEPTWZ.js +0 -16
  76. package/dist/chunk-NGOEPTWZ.js.map +0 -1
  77. package/dist/chunk-NNZKBXNB.cjs +0 -16
  78. package/dist/chunk-NNZKBXNB.cjs.map +0 -1
  79. package/dist/chunk-SYZUEL6B.js +0 -1538
  80. package/dist/chunk-SYZUEL6B.js.map +0 -1
  81. package/dist/chunk-TB6OK3WH.js +0 -16
  82. package/dist/chunk-TB6OK3WH.js.map +0 -1
  83. package/dist/index.d.ts +0 -2138
  84. package/dist/index.js +0 -2536
  85. package/dist/index.js.map +0 -1
package/dist/index.d.ts DELETED
@@ -1,2138 +0,0 @@
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 { components } from '@fluid-app/fluidos-api-client';
12
- import { FluidAuthConfig, FluidAuthContextValue } from '@fluid-app/auth';
13
- export { AUTH_CONSTANTS, DEFAULT_AUTH_URL, FluidAuthConfig, FluidAuthContextValue, JWTPayload, STORAGE_KEYS, TokenValidationResult, URL_PARAMS, USER_TYPES, UserType, cleanTokenFromUrl, clearTokens, createDefaultAuthRedirect, decodeToken, extractAllTokensFromUrl, extractCompanyTokenFromUrl, extractTokenFromUrl, getStoredToken, getTokenExpiration, getTokenTimeRemaining, hasStoredToken, hasTokenInUrl, isTokenExpired, isUserType, isValidToken, storeToken, validateToken } from '@fluid-app/auth';
14
- import { MessagingAuthContext, FileUploader } from '@fluid-app/messaging-core';
15
- export { FileUploader, MessagingAuthContext, MessagingCurrentUser, UploadCallbacks, UploadResult } from '@fluid-app/messaging-core';
16
- import { MessagingApiConfig } from '@fluid-app/messaging-api-client';
17
- 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';
18
- 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';
19
- import * as _fluid_app_rep_core_registries from '@fluid-app/rep-core/registries';
20
- import { WidgetPropertySchema } from '@fluid-app/rep-core/registries';
21
- export { PROPERTY_FIELD_TYPES, PropertyFieldSchema, PropertyFieldType, TabConfig, WidgetPropertySchema, gapValues, isPropertyFieldType } from '@fluid-app/rep-core/registries';
22
- export { createScreen, createWidgetFromShareable, createWidgetRegistry, groupChildrenByColumn } from '@fluid-app/rep-core/widget-utils';
23
- export { ThemeMode, ThemeModeProvider, getThemeModeAttribute, useThemeMode } from '@fluid-app/rep-core/shell/ThemeModeContext';
24
-
25
- /**
26
- * Rep (sales representative) user profile
27
- */
28
- interface Rep {
29
- readonly id: string;
30
- email: string;
31
- first_name: string;
32
- last_name: string;
33
- avatar_url?: string;
34
- phone?: string;
35
- readonly company_id: string;
36
- readonly created_at: string;
37
- readonly updated_at: string;
38
- }
39
- /**
40
- * Data for updating a rep's profile
41
- */
42
- interface UpdateRepData {
43
- first_name?: string;
44
- last_name?: string;
45
- avatar_url?: string;
46
- phone?: string;
47
- }
48
- /**
49
- * Current user profile from GET /api/me endpoint.
50
- * Contains recipient_id needed for the messaging system.
51
- * Field names match the Rails API response (snake_case).
52
- */
53
- interface UserMe {
54
- readonly id: number;
55
- readonly first_name: string | null;
56
- readonly last_name: string | null;
57
- readonly email: string;
58
- readonly image_url: string | null;
59
- readonly jwt: string;
60
- readonly recipient_id: number | null;
61
- readonly company_id?: number;
62
- readonly affiliate_id: number | null;
63
- }
64
-
65
- /**
66
- * Category for organizing page templates in the registry
67
- */
68
- interface PageCategory {
69
- /** Unique identifier for the category */
70
- readonly id: string;
71
- /** Display label */
72
- label: string;
73
- /** Icon identifier (e.g., lucide icon name) */
74
- icon?: string;
75
- }
76
- /**
77
- * A reusable page template that can be shared across multiple navigations
78
- */
79
- interface PageTemplate {
80
- /** Unique identifier for the template */
81
- readonly id: string;
82
- /** URL-friendly slug */
83
- slug: string;
84
- /** Display name */
85
- name: string;
86
- /** Description of the template's purpose */
87
- description?: string;
88
- /** Category ID for organization */
89
- category: string;
90
- /** Tags for filtering and search */
91
- tags?: readonly string[];
92
- /** The widget tree that defines the page content */
93
- component_tree: readonly WidgetSchema[];
94
- /** Semantic version of the template */
95
- version: string;
96
- /** Whether this is a core feature that cannot be removed */
97
- isCore?: boolean;
98
- /** Default prop values that can be customized */
99
- defaultProps?: Readonly<Record<string, unknown>>;
100
- /** Thumbnail image URL for UI display */
101
- thumbnail?: string;
102
- }
103
- /**
104
- * Reference to a shared page template within a navigation
105
- */
106
- interface PageReference {
107
- /** ID of the page template being referenced */
108
- page_template_id: string;
109
- /** Screen ID to assign to this page in the navigation */
110
- screen_id: number;
111
- /** Optional prop overrides (only prop values, not widget structure) */
112
- overrides?: readonly PageOverride[];
113
- }
114
- /**
115
- * Override for a specific widget's props within a page template
116
- */
117
- interface PageOverride {
118
- /** ID of the widget to override (must match WidgetSchema.id in the template) */
119
- readonly widget_id: string;
120
- /** Props to override (merged with original props) */
121
- props: Readonly<Record<string, unknown>>;
122
- }
123
- /**
124
- * Built-in page category IDs
125
- */
126
- declare const PAGE_CATEGORIES: {
127
- readonly CORE: "core";
128
- readonly COMMERCE: "commerce";
129
- readonly COMMUNICATION: "communication";
130
- readonly DATA: "data";
131
- readonly CUSTOM: "custom";
132
- };
133
- type PageCategoryId = (typeof PAGE_CATEGORIES)[keyof typeof PAGE_CATEGORIES];
134
-
135
- /**
136
- * Screen definition with its component tree
137
- */
138
- interface ScreenDefinition {
139
- readonly id: number;
140
- slug: string;
141
- name: string;
142
- component_tree: WidgetSchema[];
143
- }
144
- /**
145
- * Navigation configuration for the rep portal
146
- */
147
- interface Navigation {
148
- readonly definition_id: number;
149
- readonly id: number;
150
- name: string;
151
- navigation_items: _fluid_app_rep_core_types.NavigationItem[];
152
- /** Local screen definitions (for backwards compatibility and custom screens) */
153
- screens: ScreenDefinition[];
154
- /** References to shared page templates from the registry */
155
- page_refs?: PageReference[];
156
- }
157
-
158
- /**
159
- * Rep portal profile containing themes and navigation configuration
160
- */
161
- interface Profile {
162
- /** Profile name */
163
- name: string;
164
- /** Available themes for the portal */
165
- themes: ThemeDefinition[];
166
- /** Navigation structure and screens */
167
- navigation: Navigation;
168
- /** Portal definition ID */
169
- readonly definition_id: number;
170
- }
171
-
172
- /**
173
- * Standard permission action constants.
174
- * Use these constants instead of string literals for type safety.
175
- *
176
- * @example
177
- * ```ts
178
- * if (permissions[PERMISSION_ACTIONS.view]) { ... }
179
- * ```
180
- */
181
- declare const PERMISSION_ACTIONS: {
182
- readonly view: "view";
183
- readonly create: "create";
184
- readonly update: "update";
185
- readonly delete: "delete";
186
- readonly settings: "settings";
187
- readonly add: "add";
188
- readonly manage: "manage";
189
- readonly send: "send";
190
- };
191
- /**
192
- * Union type of standard permission actions.
193
- * Derived from PERMISSION_ACTIONS constant to avoid duplication.
194
- */
195
- type PermissionAction = (typeof PERMISSION_ACTIONS)[keyof typeof PERMISSION_ACTIONS];
196
- /**
197
- * Permission flags for a single resource.
198
- * Known actions have explicit properties; index signature allows custom actions.
199
- */
200
- interface ResourcePermissions {
201
- readonly view?: boolean;
202
- readonly create?: boolean;
203
- readonly update?: boolean;
204
- readonly delete?: boolean;
205
- readonly settings?: boolean;
206
- readonly add?: boolean;
207
- readonly manage?: boolean;
208
- readonly send?: boolean;
209
- /** Allow custom action keys beyond the standard set */
210
- readonly [key: string]: boolean | undefined;
211
- }
212
- /**
213
- * Map of resource names to their permissions
214
- */
215
- type Permissions = Record<string, ResourcePermissions>;
216
- /**
217
- * User's complete permission profile
218
- */
219
- interface UserPermissions {
220
- /** Resource permission mappings */
221
- permissions: Permissions;
222
- /** User's assigned roles */
223
- roles: readonly string[];
224
- /** Super admin bypass flag */
225
- is_super_admin: boolean;
226
- }
227
-
228
- /**
229
- * HTTP methods supported by the API client.
230
- * Use `as const` for literal type inference and type safety.
231
- */
232
- declare const HTTP_METHODS: {
233
- readonly GET: "GET";
234
- readonly POST: "POST";
235
- readonly PUT: "PUT";
236
- readonly PATCH: "PATCH";
237
- readonly DELETE: "DELETE";
238
- };
239
- /**
240
- * Union type of all supported HTTP methods.
241
- * Derived from HTTP_METHODS constant to avoid duplication.
242
- */
243
- type HttpMethod = (typeof HTTP_METHODS)[keyof typeof HTTP_METHODS];
244
- /**
245
- * Configuration for the Fluid SDK client.
246
- * Use Readonly<FluidSDKConfig> when the config should not be modified after creation.
247
- */
248
- interface FluidSDKConfig {
249
- /**
250
- * Base URL for API requests.
251
- * Accepts either the domain root (e.g., "https://api.fluid.app") or
252
- * with the /api path (e.g., "https://api.fluid.app/api").
253
- * The SDK normalizes internally for each consumer.
254
- */
255
- readonly baseUrl: string;
256
- /**
257
- * Function to retrieve the authentication token
258
- * Return null/undefined if no token is available
259
- */
260
- readonly getAuthToken?: () => string | null | Promise<string | null>;
261
- /**
262
- * Callback invoked when a 401 authentication error occurs
263
- * Use this to trigger re-authentication flows
264
- */
265
- readonly onAuthError?: () => void;
266
- /**
267
- * Default headers to include in all requests
268
- * Example: { "x-fluid-client": "rep-portal" }
269
- */
270
- readonly defaultHeaders?: Readonly<Record<string, string>>;
271
- /**
272
- * Filestack API key for messaging file uploads.
273
- * If not provided, file attachments will be disabled in the messaging composer.
274
- */
275
- readonly filestackApiKey?: string;
276
- /**
277
- * Override WebSocket URL for real-time messaging.
278
- * Default: derived from baseUrl by replacing trailing /api with /cable
279
- */
280
- readonly websocketUrl?: string;
281
- }
282
- /**
283
- * Options for individual API requests.
284
- * Uses HttpMethod type for method to ensure type safety.
285
- */
286
- interface RequestOptions {
287
- readonly method?: HttpMethod;
288
- readonly body?: unknown;
289
- readonly params?: Readonly<Record<string, unknown>>;
290
- readonly headers?: Readonly<Record<string, string>>;
291
- readonly signal?: AbortSignal;
292
- }
293
- /**
294
- * Pagination parameters for list endpoints
295
- */
296
- interface PaginationParams {
297
- readonly page?: number;
298
- readonly per_page?: number;
299
- }
300
- /**
301
- * Sort order constant - single source of truth for sort direction values.
302
- * Use SORT_ORDERS.asc instead of "asc" for type-safe comparisons.
303
- */
304
- declare const SORT_ORDERS: {
305
- readonly asc: "asc";
306
- readonly desc: "desc";
307
- };
308
- /**
309
- * Union type of sort order values, derived from SORT_ORDERS constant.
310
- * @see deriving-typeof-for-object-keys pattern
311
- */
312
- type SortOrder = (typeof SORT_ORDERS)[keyof typeof SORT_ORDERS];
313
- /**
314
- * Common filter parameters for list endpoints
315
- */
316
- interface BaseListParams extends PaginationParams {
317
- readonly sort_by?: string;
318
- readonly sort_order?: SortOrder;
319
- readonly search?: string;
320
- }
321
-
322
- /**
323
- * Screen Transforms
324
- * Convert FluidOS API screen objects to ScreenDefinition format.
325
- *
326
- * Extracted from:
327
- * - apps/fluid-admin/networking/app-builder/app-screens/types.ts
328
- * - apps/fluid-admin/networking/reps/screens.api.ts
329
- */
330
-
331
- /** Raw screen from the FluidOS API */
332
- interface RawApiScreen {
333
- id: number | string;
334
- definition_id?: number | string;
335
- name?: string | null;
336
- slug?: string | null;
337
- component_tree?: unknown;
338
- }
339
- /**
340
- * Normalize component_tree to always be an array.
341
- * The API stores component_tree as a hash (object), but the frontend expects an array.
342
- */
343
- declare function normalizeComponentTree(componentTree: unknown): WidgetSchema[];
344
- /**
345
- * Convert a raw FluidOS screen to ScreenDefinition.
346
- * Normalizes component_tree and converts string IDs to numbers.
347
- */
348
- declare function toScreenDefinition(screen: RawApiScreen): ScreenDefinition$1;
349
-
350
- /**
351
- * Navigation Transforms
352
- * Convert FluidOS API navigation items to NavigationItem format.
353
- *
354
- * Extracted from:
355
- * - apps/fluid-admin/networking/app-builder/app-navigation-items/types.ts
356
- * - apps/fluid-admin/networking/reps/screens.api.ts
357
- */
358
-
359
- /** Raw navigation item from the FluidOS API (derived from generated types) */
360
- type RawApiNavigationItem = components["schemas"]["FluidOSNavigationItem"];
361
- /**
362
- * Convert a raw FluidOS navigation item to NavigationItem.
363
- * Recursively transforms children and sorts by position.
364
- */
365
- declare function toNavigationItem(item: RawApiNavigationItem): NavigationItem;
366
-
367
- /**
368
- * Data Transforms
369
- * Convert FluidOS API responses to RepAppData format.
370
- *
371
- * This is the main entry point for all transforms used by the SDK client
372
- * and hooks when fetching from the fluidos API.
373
- */
374
-
375
- /** Raw manifest shape from the `/fluid_os/definitions/active` API response */
376
- interface RawManifestResponse {
377
- manifest: {
378
- definition_id: number;
379
- published_version?: number;
380
- screens?: RawApiScreen[];
381
- profile?: {
382
- name?: string;
383
- definition_id: number;
384
- themes?: RawApiTheme[];
385
- navigation?: {
386
- id: number;
387
- name?: string;
388
- definition_id: number;
389
- navigation_items?: RawApiNavigationItem[];
390
- };
391
- mobile_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
- interface FluidAuthProviderProps {
670
- /** React children to wrap with auth context */
671
- children: ReactNode;
672
- /** Auth configuration options */
673
- config?: FluidAuthConfig;
674
- }
675
- /**
676
- * Authentication provider for Fluid rep portal applications.
677
- *
678
- * On mount, this provider:
679
- * 1. Checks for a token in the URL (passed from parent app)
680
- * 2. Cleans token from URL immediately (security)
681
- * 3. Falls back to stored token (cookie/localStorage)
682
- * 4. Validates the token (checks expiration)
683
- * 5. Stores valid tokens for future use
684
- * 6. Calls onAuthFailure if no valid token found
685
- *
686
- * @example
687
- * ```tsx
688
- * import { FluidAuthProvider } from "@fluid-app/rep-sdk";
689
- *
690
- * function App() {
691
- * return (
692
- * <FluidAuthProvider
693
- * config={{
694
- * onAuthFailure: () => {
695
- * window.location.href = "/login";
696
- * },
697
- * }}
698
- * >
699
- * <YourApp />
700
- * </FluidAuthProvider>
701
- * );
702
- * }
703
- * ```
704
- */
705
- declare function FluidAuthProvider({ children, config, }: FluidAuthProviderProps): react_jsx_runtime.JSX.Element;
706
- /**
707
- * Hook to access the auth context directly.
708
- * Prefer using `useFluidAuth` for most use cases.
709
- *
710
- * @throws Error if used outside FluidAuthProvider
711
- */
712
- declare function useFluidAuthContext(): FluidAuthContextValue;
713
-
714
- /**
715
- * Screen Types - Type definitions for core feature screens
716
- *
717
- * All status and type unions are derived from constants for single source of truth.
718
- * Use the constants (e.g., CONVERSATION_STATUSES.active) for type-safe comparisons.
719
- */
720
- /**
721
- * Conversation status constant - single source of truth.
722
- */
723
- declare const CONVERSATION_STATUSES: {
724
- readonly active: "active";
725
- readonly archived: "archived";
726
- readonly muted: "muted";
727
- };
728
- /**
729
- * Union type derived from CONVERSATION_STATUSES constant.
730
- */
731
- type ConversationStatus = (typeof CONVERSATION_STATUSES)[keyof typeof CONVERSATION_STATUSES];
732
- /**
733
- * Message type constant - single source of truth.
734
- */
735
- declare const MESSAGE_TYPES: {
736
- readonly text: "text";
737
- readonly image: "image";
738
- readonly file: "file";
739
- readonly system: "system";
740
- };
741
- /**
742
- * Union type derived from MESSAGE_TYPES constant.
743
- */
744
- type MessageType = (typeof MESSAGE_TYPES)[keyof typeof MESSAGE_TYPES];
745
- interface Participant {
746
- readonly id: string;
747
- readonly name: string;
748
- readonly email: string;
749
- readonly avatarUrl?: string;
750
- readonly isOnline?: boolean;
751
- }
752
- /**
753
- * Message attachment type - extracted for reusability and clarity.
754
- */
755
- interface MessageAttachment {
756
- readonly id: string;
757
- readonly name: string;
758
- readonly url: string;
759
- readonly type: string;
760
- readonly size?: number;
761
- }
762
- interface Message {
763
- readonly id: string;
764
- readonly conversationId: string;
765
- readonly senderId: string;
766
- readonly senderName: string;
767
- readonly senderAvatarUrl?: string;
768
- readonly type: MessageType;
769
- readonly content: string;
770
- readonly timestamp: string;
771
- readonly isRead: boolean;
772
- readonly attachments?: readonly MessageAttachment[];
773
- }
774
- interface Conversation {
775
- readonly id: string;
776
- readonly title: string;
777
- readonly participants: readonly Participant[];
778
- readonly lastMessage?: Message;
779
- readonly unreadCount: number;
780
- readonly status: ConversationStatus;
781
- readonly createdAt: string;
782
- readonly updatedAt: string;
783
- }
784
- /**
785
- * Contact status constant - single source of truth.
786
- */
787
- declare const CONTACT_STATUSES: {
788
- readonly active: "active";
789
- readonly inactive: "inactive";
790
- readonly lead: "lead";
791
- readonly prospect: "prospect";
792
- };
793
- /**
794
- * Union type derived from CONTACT_STATUSES constant.
795
- */
796
- type ContactStatus = (typeof CONTACT_STATUSES)[keyof typeof CONTACT_STATUSES];
797
- /**
798
- * Contact type constant - single source of truth.
799
- */
800
- declare const CONTACT_TYPES: {
801
- readonly individual: "individual";
802
- readonly company: "company";
803
- };
804
- /**
805
- * Union type derived from CONTACT_TYPES constant.
806
- */
807
- type ContactType = (typeof CONTACT_TYPES)[keyof typeof CONTACT_TYPES];
808
- interface ContactAddress {
809
- readonly street?: string;
810
- readonly city?: string;
811
- readonly state?: string;
812
- readonly postalCode?: string;
813
- readonly country?: string;
814
- }
815
- interface Contact {
816
- readonly id: string;
817
- readonly firstName: string;
818
- readonly lastName: string;
819
- readonly email: string;
820
- readonly phone?: string;
821
- readonly company?: string;
822
- readonly jobTitle?: string;
823
- readonly avatarUrl?: string;
824
- readonly status: ContactStatus;
825
- readonly type: ContactType;
826
- readonly address?: ContactAddress;
827
- readonly tags?: readonly string[];
828
- readonly notes?: string;
829
- readonly createdAt: string;
830
- readonly updatedAt: string;
831
- }
832
-
833
- /**
834
- * Context value for page template resolution.
835
- * All properties are readonly since context values should not be mutated by consumers.
836
- */
837
- interface PageTemplateContextValue {
838
- /**
839
- * Resolve a navigation's page_refs and screens into a unified screen list
840
- */
841
- readonly resolvePages: (navigation: Navigation) => ScreenDefinition[];
842
- /**
843
- * Get all available page templates
844
- */
845
- readonly listTemplates: () => PageTemplate[];
846
- /**
847
- * Get a specific template by ID
848
- */
849
- readonly getTemplate: (id: string) => PageTemplate | undefined;
850
- /**
851
- * Check if a template exists
852
- */
853
- readonly hasTemplate: (id: string) => boolean;
854
- }
855
- /**
856
- * Props for PageTemplateProvider
857
- */
858
- interface PageTemplateProviderProps {
859
- children: react__default.ReactNode;
860
- /**
861
- * Additional custom page templates to register.
862
- * These are registered when the provider mounts and unregistered when it unmounts.
863
- */
864
- templates?: readonly PageTemplate[];
865
- }
866
- /**
867
- * Provider for page template resolution.
868
- *
869
- * This provider:
870
- * 1. Registers any custom templates passed via props
871
- * 2. Provides methods for resolving navigation pages
872
- * 3. Cleans up custom templates on unmount
873
- *
874
- * @example
875
- * ```tsx
876
- * // With custom templates
877
- * const customTemplates: PageTemplate[] = [
878
- * {
879
- * id: 'custom-dashboard',
880
- * slug: 'dashboard',
881
- * name: 'Dashboard',
882
- * category: 'custom',
883
- * version: '1.0.0',
884
- * component_tree: [{ type: 'TextWidget', props: { text: 'Custom Dashboard' } }],
885
- * },
886
- * ];
887
- *
888
- * <PageTemplateProvider templates={customTemplates}>
889
- * <App />
890
- * </PageTemplateProvider>
891
- *
892
- * // Without custom templates (uses only core templates)
893
- * <PageTemplateProvider>
894
- * <App />
895
- * </PageTemplateProvider>
896
- * ```
897
- */
898
- declare function PageTemplateProvider({ children, templates, }: PageTemplateProviderProps): react_jsx_runtime.JSX.Element;
899
- /**
900
- * Hook to access page template functionality.
901
- *
902
- * @throws Error if used outside of PageTemplateProvider
903
- *
904
- * @example
905
- * ```tsx
906
- * function NavigationRenderer({ navigation }: { navigation: Navigation }) {
907
- * const { resolvePages } = usePageTemplates();
908
- * const screens = resolvePages(navigation);
909
- *
910
- * return (
911
- * <div>
912
- * {screens.map((screen) => (
913
- * <Screen key={screen.id} definition={screen} />
914
- * ))}
915
- * </div>
916
- * );
917
- * }
918
- * ```
919
- */
920
- declare function usePageTemplates(): PageTemplateContextValue;
921
- /**
922
- * Hook to resolve navigation pages directly.
923
- * Convenience wrapper around usePageTemplates().resolvePages.
924
- *
925
- * @param navigation - The navigation to resolve
926
- * @returns Array of resolved screen definitions
927
- */
928
- declare function useResolvedPages(navigation: Navigation): ScreenDefinition[];
929
-
930
- /**
931
- * Hook to access the Fluid API client
932
- *
933
- * @example
934
- * ```tsx
935
- * function ProductList() {
936
- * const api = useFluidApi();
937
- *
938
- * const { data: products } = useQuery({
939
- * queryKey: ["products"],
940
- * queryFn: () => api.products.list(),
941
- * });
942
- *
943
- * return <ul>{products?.map(p => <li key={p.id}>{p.name}</li>)}</ul>;
944
- * }
945
- * ```
946
- */
947
- declare function useFluidApi(): FluidClient;
948
-
949
- /**
950
- * Query key for profile data
951
- */
952
- declare const PROFILE_QUERY_KEY: readonly ["fluid", "profile"];
953
- /**
954
- * Hook to fetch the rep portal profile (themes, navigation, screens)
955
- *
956
- * @example
957
- * ```tsx
958
- * function Navigation() {
959
- * const { data: profile, isLoading } = useFluidProfile();
960
- *
961
- * if (isLoading) return <Spinner />;
962
- *
963
- * return (
964
- * <nav>
965
- * {profile?.navigation.navigation_items.map(item => (
966
- * <NavItem key={item.id} item={item} />
967
- * ))}
968
- * </nav>
969
- * );
970
- * }
971
- * ```
972
- */
973
- declare function useFluidProfile(): UseQueryResult<Profile>;
974
-
975
- /**
976
- * Query key for full app data (fluidos endpoint)
977
- */
978
- declare const APP_DATA_QUERY_KEY: readonly ["fluid", "app"];
979
- /**
980
- * Hook to fetch the full rep app data from the fluidos API.
981
- *
982
- * Returns a `RepAppData` object containing:
983
- * - `screens` — all screen definitions with normalized component trees
984
- * - `profile.themes` — fully-transformed ThemeDefinition[] (handles legacy + new formats)
985
- * - `profile.activeThemeId` — the currently active theme ID
986
- * - `profile.navigation.navigation_items` — sorted, recursive navigation tree
987
- *
988
- * Uses IndexedDB persistence so subsequent page loads hydrate instantly
989
- * from cache while revalidating in the background. The raw API response
990
- * (plain JSON) is cached; Color objects are recreated from cache via
991
- * `select` on every restore — this is fast (CPU only, no network).
992
- *
993
- * @example
994
- * ```tsx
995
- * function App() {
996
- * const { data: appData, isLoading } = useFluidApp();
997
- *
998
- * if (isLoading) return <Spinner />;
999
- *
1000
- * return (
1001
- * <AppShell
1002
- * appData={appData}
1003
- * navigation={appData.profile.navigation.navigation_items}
1004
- * />
1005
- * );
1006
- * }
1007
- * ```
1008
- */
1009
- declare function useFluidApp(options?: {
1010
- enabled?: boolean;
1011
- }): UseQueryResult<RepAppData>;
1012
-
1013
- /**
1014
- * Query key for permissions data
1015
- */
1016
- declare const PERMISSIONS_QUERY_KEY: readonly ["fluid", "permissions"];
1017
- /**
1018
- * Result of useFluidPermissions hook
1019
- */
1020
- interface UseFluidPermissionsResult {
1021
- /** Raw permissions query result */
1022
- query: UseQueryResult<UserPermissions>;
1023
- /** Permissions data (alias for query.data) */
1024
- permissions: UserPermissions | undefined;
1025
- /** Check if user has a specific permission */
1026
- can: (resource: string, action?: PermissionAction) => boolean;
1027
- /** Check if user is a super admin */
1028
- isSuperAdmin: boolean;
1029
- }
1030
- /**
1031
- * Hook to fetch and check user permissions
1032
- *
1033
- * @example
1034
- * ```tsx
1035
- * function TeamSettings() {
1036
- * const { can, isSuperAdmin } = useFluidPermissions();
1037
- *
1038
- * if (!can("team", "manage")) {
1039
- * return <AccessDenied />;
1040
- * }
1041
- *
1042
- * return <TeamSettingsForm canDelete={can("team", "delete")} />;
1043
- * }
1044
- * ```
1045
- */
1046
- declare function useFluidPermissions(): UseFluidPermissionsResult;
1047
-
1048
- /**
1049
- * Result of useFluidTheme hook
1050
- */
1051
- interface UseFluidThemeResult {
1052
- /** Currently active theme */
1053
- currentTheme: ThemeDefinition | null;
1054
- /** Switch to a different theme */
1055
- setTheme: (theme: ThemeDefinition) => void;
1056
- /** Switch between light and dark mode */
1057
- setThemeMode: (mode: "light" | "dark") => void;
1058
- /** Current theme mode (convenience accessor) */
1059
- mode: "light" | "dark" | undefined;
1060
- }
1061
- /**
1062
- * Hook to access and control theme settings
1063
- *
1064
- * @example
1065
- * ```tsx
1066
- * function ThemeSwitcher({ themes }: { themes: ThemeDefinition[] }) {
1067
- * const { currentTheme, setTheme, setThemeMode, mode } = useFluidTheme();
1068
- *
1069
- * return (
1070
- * <div>
1071
- * <select
1072
- * value={currentTheme?.name}
1073
- * onChange={(e) => {
1074
- * const theme = themes.find(t => t.name === e.target.value);
1075
- * if (theme) setTheme(theme);
1076
- * }}
1077
- * >
1078
- * {themes.map(theme => (
1079
- * <option key={theme.name} value={theme.name}>
1080
- * {theme.name}
1081
- * </option>
1082
- * ))}
1083
- * </select>
1084
- *
1085
- * <button onClick={() => setThemeMode(mode === "dark" ? "light" : "dark")}>
1086
- * Toggle {mode === "dark" ? "Light" : "Dark"} Mode
1087
- * </button>
1088
- * </div>
1089
- * );
1090
- * }
1091
- * ```
1092
- */
1093
- declare function useFluidTheme(): UseFluidThemeResult;
1094
-
1095
- /**
1096
- * Query key for current rep data
1097
- */
1098
- declare const CURRENT_REP_QUERY_KEY: readonly ["fluid", "currentRep"];
1099
- /**
1100
- * Hook to fetch the currently authenticated rep's profile
1101
- *
1102
- * @example
1103
- * ```tsx
1104
- * function RepHeader() {
1105
- * const { data: rep, isLoading } = useCurrentRep();
1106
- *
1107
- * if (isLoading) return <Skeleton />;
1108
- *
1109
- * return (
1110
- * <div>
1111
- * <Avatar src={rep?.avatar_url} />
1112
- * <span>{rep?.first_name} {rep?.last_name}</span>
1113
- * </div>
1114
- * );
1115
- * }
1116
- * ```
1117
- */
1118
- declare function useCurrentRep(): UseQueryResult<Rep>;
1119
-
1120
- /**
1121
- * useFluidAuth Hook
1122
- *
1123
- * Provides access to authentication state and utilities.
1124
- * This is the primary hook for interacting with auth in components.
1125
- */
1126
-
1127
- /**
1128
- * Hook to access authentication state and utilities.
1129
- *
1130
- * Must be used within a `FluidAuthProvider`.
1131
- *
1132
- * @returns Authentication context with user info, loading state, and utilities
1133
- * @throws Error if used outside FluidAuthProvider
1134
- *
1135
- * @example
1136
- * ```tsx
1137
- * function UserProfile() {
1138
- * const { isAuthenticated, isLoading, user, clearAuth } = useFluidAuth();
1139
- *
1140
- * if (isLoading) {
1141
- * return <Spinner />;
1142
- * }
1143
- *
1144
- * if (!isAuthenticated) {
1145
- * return <p>Please log in</p>;
1146
- * }
1147
- *
1148
- * return (
1149
- * <div>
1150
- * <p>Welcome, {user.full_name}!</p>
1151
- * <button onClick={clearAuth}>Log out</button>
1152
- * </div>
1153
- * );
1154
- * }
1155
- * ```
1156
- */
1157
- declare function useFluidAuth(): FluidAuthContextValue;
1158
-
1159
- /**
1160
- * Hook type utilities and type predicates.
1161
- *
1162
- * This module provides:
1163
- * - Generic hook result types with default type parameters
1164
- * - Type predicates for query state narrowing
1165
- * - Reusable patterns for type-safe property access in hooks
1166
- *
1167
- * Following generics best practices:
1168
- * - generics-default-type-parameters: Default E to Error for common case
1169
- * - generics-type-predicates: Type predicates for result state narrowing
1170
- * - generics-constrain-type-parameters: K extends keyof T for property access
1171
- */
1172
- /**
1173
- * Base result type for query hooks with default error type.
1174
- * Uses default type parameter for E (generics-default-type-parameters rule).
1175
- *
1176
- * @typeParam T - The data type
1177
- * @typeParam E - The error type (defaults to Error)
1178
- *
1179
- * @example
1180
- * // Error type defaults to Error
1181
- * type UsersResult = QueryResult<User[]>;
1182
- *
1183
- * // Can override when needed
1184
- * type CustomResult = QueryResult<User[], ApiError>;
1185
- */
1186
- interface QueryResult<T, E = Error> {
1187
- readonly data: T;
1188
- readonly isLoading: boolean;
1189
- readonly isError: boolean;
1190
- readonly error?: E | undefined;
1191
- }
1192
- /**
1193
- * Result type for hooks that may not have data yet.
1194
- * Extends QueryResult with nullable data.
1195
- *
1196
- * @typeParam T - The data type
1197
- * @typeParam E - The error type (defaults to Error)
1198
- */
1199
- interface QueryResultNullable<T, E = Error> {
1200
- readonly data: T | null | undefined;
1201
- readonly isLoading: boolean;
1202
- readonly isError: boolean;
1203
- readonly error?: E | undefined;
1204
- }
1205
- /**
1206
- * Result type for list/collection hooks with aggregates.
1207
- *
1208
- * @typeParam T - The item type in the array
1209
- * @typeParam E - The error type (defaults to Error)
1210
- */
1211
- interface ListQueryResult<T, E = Error> extends QueryResult<T[], E> {
1212
- readonly totalCount: number;
1213
- }
1214
- /**
1215
- * Result type for list hooks with value aggregation (e.g., deals with total value).
1216
- *
1217
- * @typeParam T - The item type in the array
1218
- * @typeParam E - The error type (defaults to Error)
1219
- */
1220
- interface ValueListQueryResult<T, E = Error> extends ListQueryResult<T, E> {
1221
- readonly totalValue: number;
1222
- }
1223
- /**
1224
- * Type predicate to check if a query result has successfully loaded data.
1225
- * Narrows the data type from T | null | undefined to T.
1226
- *
1227
- * @example
1228
- * const result = useContact(id);
1229
- * if (hasData(result)) {
1230
- * // TypeScript knows result.data is Contact, not Contact | null
1231
- * console.log(result.data.name);
1232
- * }
1233
- */
1234
- declare function hasData<T, E = Error>(result: QueryResultNullable<T, E>): result is QueryResultNullable<T, E> & {
1235
- readonly data: T;
1236
- };
1237
- /**
1238
- * Type predicate to check if a query result is in loading state.
1239
- * Useful for conditional rendering.
1240
- *
1241
- * @example
1242
- * if (isLoading(result)) {
1243
- * return <Spinner />;
1244
- * }
1245
- */
1246
- declare function isLoading<T, E = Error>(result: QueryResult<T, E> | QueryResultNullable<T, E>): boolean;
1247
- /**
1248
- * Type predicate to check if a query result has an error.
1249
- * Narrows to include the error property.
1250
- *
1251
- * @example
1252
- * if (isErrorResult(result)) {
1253
- * console.error(result.error); // error is E, not undefined
1254
- * }
1255
- */
1256
- declare function isErrorResult<T, E = Error>(result: QueryResult<T, E> | QueryResultNullable<T, E>): result is (QueryResult<T, E> | QueryResultNullable<T, E>) & {
1257
- readonly isError: true;
1258
- readonly error: E;
1259
- };
1260
- /**
1261
- * Type predicate to check if a query result is in idle state (not loading, no error, has data).
1262
- *
1263
- * @example
1264
- * if (isIdle(result)) {
1265
- * // Safe to access and render data
1266
- * }
1267
- */
1268
- declare function isIdle<T, E = Error>(result: QueryResult<T, E> | QueryResultNullable<T, E>): boolean;
1269
- /**
1270
- * Type-safe property selector for hook results.
1271
- * Uses K extends keyof T constraint (generics-function-constraints rule).
1272
- *
1273
- * @typeParam T - The data object type
1274
- * @typeParam K - Key of T (constrained to actual keys)
1275
- *
1276
- * @example
1277
- * const users = [{ name: "Alice", age: 30 }];
1278
- * const names = selectProperty(users, "name"); // string[]
1279
- * const ages = selectProperty(users, "age"); // number[]
1280
- * selectProperty(users, "invalid"); // Error: "invalid" not in "name" | "age"
1281
- */
1282
- declare function selectProperty<T, K extends keyof T>(items: readonly T[], key: K): T[K][];
1283
- /**
1284
- * Type-safe property getter for a single item.
1285
- * Returns undefined if item is null/undefined.
1286
- *
1287
- * @typeParam T - The data object type
1288
- * @typeParam K - Key of T (constrained to actual keys)
1289
- */
1290
- declare function getProperty<T, K extends keyof T>(item: T | null | undefined, key: K): T[K] | undefined;
1291
- /**
1292
- * Generic type for hooks that fetch a single resource by ID.
1293
- * Useful for creating consistent API across different resource types.
1294
- *
1295
- * @typeParam T - The resource type
1296
- * @typeParam E - The error type (defaults to Error)
1297
- */
1298
- type UseSingleResourceHook<T, E = Error> = (id: string) => QueryResultNullable<T, E>;
1299
- /**
1300
- * Generic type for hooks that fetch a list of resources with optional params.
1301
- * Uses generics-default-type-parameters for the params type.
1302
- *
1303
- * @typeParam T - The item type
1304
- * @typeParam P - The params type (defaults to empty object)
1305
- * @typeParam E - The error type (defaults to Error)
1306
- */
1307
- type UseListResourceHook<T, P extends Record<string, unknown> = Record<string, never>, E = Error> = (params?: P) => ListQueryResult<T, E>;
1308
- /**
1309
- * Transforms a nullable result to a non-nullable one if data exists.
1310
- * Useful when you've already checked hasData().
1311
- */
1312
- type WithData<R extends QueryResultNullable<unknown>> = R extends QueryResultNullable<infer T, infer E> ? QueryResultNullable<T, E> & {
1313
- readonly data: T;
1314
- } : never;
1315
- /**
1316
- * Activity slug constants as a const object.
1317
- * Derive the ActivitySlug type from this single source of truth.
1318
- */
1319
- declare const ACTIVITY_SLUGS: {
1320
- readonly abandonedCart: "abandoned_cart";
1321
- readonly announcements: "announcements";
1322
- readonly cartItemsAdded: "cart_items_added";
1323
- readonly commentReply: "comment_reply";
1324
- readonly directMessage: "direct_message";
1325
- readonly fantasyPoint: "fantasy_point";
1326
- readonly newLead: "new_lead";
1327
- readonly orderPlaced: "order_placed";
1328
- readonly pageViews: "page_views";
1329
- readonly pageViewsContact: "page_views_contact";
1330
- readonly tasks: "tasks";
1331
- readonly upcomingEvent: "upcoming_event";
1332
- readonly video: "video";
1333
- readonly videoComplete: "video_complete";
1334
- readonly videoCompleteContact: "video_complete_contact";
1335
- readonly videoContact: "video_contact";
1336
- readonly messageReceived: "message_received";
1337
- readonly messageSent: "message_sent";
1338
- readonly newCartItemsAdded: "new_cart_items_added";
1339
- readonly smartLinkClicked: "smart_link_clicked";
1340
- readonly reviewLeft: "review_left";
1341
- };
1342
- /** Activity slug union type derived from ACTIVITY_SLUGS constant. */
1343
- type ActivitySlug = (typeof ACTIVITY_SLUGS)[keyof typeof ACTIVITY_SLUGS];
1344
- /** Type predicate to check if a string is a valid ActivitySlug. */
1345
- declare function isActivitySlug(value: string): value is ActivitySlug;
1346
- /** Transformed activity for display. */
1347
- interface Activity {
1348
- readonly id: number;
1349
- readonly userName: string;
1350
- readonly avatarUrl: string | null;
1351
- readonly activityType: string;
1352
- readonly targetName: string;
1353
- readonly timestamp: string;
1354
- readonly slug: ActivitySlug;
1355
- }
1356
- /** Description/rich text metadata for a calendar event. */
1357
- interface CalendarEventDescription {
1358
- readonly id?: number | null;
1359
- readonly name?: string | null;
1360
- readonly body?: string | null;
1361
- readonly record_type?: string | null;
1362
- readonly record_id?: number | null;
1363
- readonly created_at?: string | null;
1364
- readonly updated_at?: string | null;
1365
- readonly locale?: string | null;
1366
- }
1367
- /** Calendar event data from the API. */
1368
- interface CalendarEvent {
1369
- readonly id: number;
1370
- readonly title: string;
1371
- readonly description?: CalendarEventDescription | null;
1372
- readonly color?: string | null;
1373
- readonly url?: string | null;
1374
- readonly start: string;
1375
- readonly end: string;
1376
- readonly active?: boolean | null;
1377
- readonly time_zone?: string | null;
1378
- readonly status?: string | null;
1379
- readonly image_url?: string | null;
1380
- readonly images?: readonly unknown[] | null;
1381
- readonly venue?: string | null;
1382
- readonly countries?: readonly string[] | null;
1383
- readonly hasTomorrow?: boolean | null;
1384
- readonly hasYesterday?: boolean | null;
1385
- readonly isAllDay?: boolean;
1386
- }
1387
- /** Catch up suggestion data from the API. */
1388
- interface CatchUp {
1389
- readonly id: number;
1390
- readonly suggestion_title: string;
1391
- }
1392
- /** MySite data returned by the hook. */
1393
- interface MySiteData {
1394
- readonly url: string | null;
1395
- readonly views: number;
1396
- readonly leads: number;
1397
- readonly userName: string;
1398
- }
1399
- /** Transformed todo for display. */
1400
- interface Todo {
1401
- readonly id: number;
1402
- readonly body: string;
1403
- readonly dueAt: string | null;
1404
- readonly completedAt: string | null;
1405
- readonly createdAt: string;
1406
- readonly contactName: string | null;
1407
- }
1408
-
1409
- /**
1410
- * Calendar events hook - stub implementation for SDK
1411
- * In production, implement this hook to fetch from your API
1412
- */
1413
-
1414
- /**
1415
- * Result type for useCalendarEvents hook.
1416
- * Uses QueryResult<CalendarEvent[]> with default Error type.
1417
- */
1418
- type UseCalendarEventsResult = QueryResult<CalendarEvent[]>;
1419
- /**
1420
- * Hook to fetch calendar events.
1421
- * This is a stub implementation - override with your own data fetching logic.
1422
- */
1423
- declare function useCalendarEvents(): UseCalendarEventsResult;
1424
-
1425
- /**
1426
- * Todos hook - stub implementation for SDK
1427
- * In production, implement this hook to fetch from your API
1428
- */
1429
-
1430
- /**
1431
- * Result type for useTodos hook.
1432
- * Uses QueryResult<Todo[]> with default Error type.
1433
- */
1434
- type UseTodosResult = QueryResult<Todo[]>;
1435
- /**
1436
- * Hook to fetch todo items.
1437
- * This is a stub implementation - override with your own data fetching logic.
1438
- */
1439
- declare function useTodos(): UseTodosResult;
1440
-
1441
- /**
1442
- * Activities hook - stub implementation for SDK
1443
- * In production, implement this hook to fetch from your API
1444
- */
1445
-
1446
- /**
1447
- * Result type for useActivities hook.
1448
- * Uses QueryResult generic with Activity[] and default Error type.
1449
- */
1450
- type UseActivitiesResult = QueryResult<Activity[]>;
1451
- /**
1452
- * Hook to fetch recent activities.
1453
- * This is a stub implementation - override with your own data fetching logic.
1454
- */
1455
- declare function useActivities(): UseActivitiesResult;
1456
-
1457
- /**
1458
- * Catch ups hook - stub implementation for SDK
1459
- * In production, implement this hook to fetch from your API
1460
- */
1461
-
1462
- /**
1463
- * Result type for useCatchUps hook.
1464
- * Uses QueryResult<CatchUp[]> with default Error type.
1465
- */
1466
- type UseCatchUpsResult = QueryResult<CatchUp[]>;
1467
- /**
1468
- * Hook to fetch catch up items.
1469
- * This is a stub implementation - override with your own data fetching logic.
1470
- */
1471
- declare function useCatchUps(): UseCatchUpsResult;
1472
-
1473
- /**
1474
- * MySite hook - stub implementation for SDK
1475
- * In production, implement this hook to fetch from your API
1476
- */
1477
-
1478
- /**
1479
- * Result type for useMySite hook.
1480
- * Uses QueryResultNullable since MySite data may not be available.
1481
- */
1482
- type UseMySiteResult = QueryResultNullable<MySiteData>;
1483
- /**
1484
- * Hook to fetch MySite data.
1485
- * This is a stub implementation - override with your own data fetching logic.
1486
- */
1487
- declare function useMySite(): UseMySiteResult;
1488
-
1489
- /**
1490
- * Conversations hooks - stub implementations for SDK
1491
- * In production, implement these hooks to fetch from your API
1492
- */
1493
-
1494
- /**
1495
- * Result type for useConversations hook.
1496
- * Uses QueryResult<Conversation[]> with default Error type.
1497
- */
1498
- type UseConversationsResult = QueryResult<Conversation[]>;
1499
- /**
1500
- * Hook to fetch all conversations.
1501
- * This is a stub implementation - override with your own data fetching logic.
1502
- *
1503
- * @returns UseConversationsResult with empty data array
1504
- *
1505
- * @example
1506
- * ```tsx
1507
- * const { data: conversations, isLoading, isError } = useConversations();
1508
- *
1509
- * if (isLoading) return <Loading />;
1510
- * if (isError) return <Error />;
1511
- *
1512
- * return conversations.map(conv => <ConversationItem key={conv.id} {...conv} />);
1513
- * ```
1514
- */
1515
- declare function useConversations(): UseConversationsResult;
1516
- /**
1517
- * Result type for useConversationMessages hook.
1518
- * Uses QueryResult<Message[]> with default Error type.
1519
- */
1520
- type UseConversationMessagesResult = QueryResult<Message[]>;
1521
- /**
1522
- * Hook to fetch messages for a specific conversation.
1523
- * This is a stub implementation - override with your own data fetching logic.
1524
- *
1525
- * @param conversationId - The ID of the conversation to fetch messages for
1526
- * @returns UseConversationMessagesResult with empty data array
1527
- *
1528
- * @example
1529
- * ```tsx
1530
- * const { data: messages, isLoading, isError } = useConversationMessages(conversationId);
1531
- *
1532
- * if (isLoading) return <Loading />;
1533
- * if (isError) return <Error />;
1534
- *
1535
- * return messages.map(msg => <MessageBubble key={msg.id} {...msg} />);
1536
- * ```
1537
- */
1538
- declare function useConversationMessages(_conversationId: string): UseConversationMessagesResult;
1539
-
1540
- /**
1541
- * Contacts hooks - stub implementation for SDK
1542
- * In production, implement these hooks to fetch from your API
1543
- */
1544
-
1545
- /**
1546
- * Type predicate to check if a status string is a valid ContactStatus.
1547
- * Enables runtime validation with type narrowing.
1548
- */
1549
- declare function isContactStatus(value: string): value is ContactStatus;
1550
- /**
1551
- * Parameters for filtering and paginating contacts.
1552
- * Uses readonly properties and proper ContactStatus type for status.
1553
- */
1554
- interface UseContactsParams {
1555
- /** Search query to filter contacts by name, email, or company */
1556
- readonly search?: string;
1557
- /** Filter contacts by status - uses ContactStatus union type for type safety */
1558
- readonly status?: ContactStatus;
1559
- /** Maximum number of contacts to return */
1560
- readonly limit?: number;
1561
- }
1562
- /**
1563
- * Result type for the useContacts hook.
1564
- * Uses ListQueryResult<Contact> with totalCount and default Error type.
1565
- */
1566
- type UseContactsResult = ListQueryResult<Contact>;
1567
- /**
1568
- * Result type for the useContact hook.
1569
- * Uses QueryResultNullable since a specific contact may not exist.
1570
- */
1571
- type UseContactResult = QueryResultNullable<Contact>;
1572
- /**
1573
- * Hook to fetch a list of contacts with optional filtering and pagination.
1574
- * This is a stub implementation - override with your own data fetching logic.
1575
- *
1576
- * @param params - Optional parameters for filtering and pagination
1577
- * @returns Object containing contacts data, loading state, error state, and total count
1578
- *
1579
- * @example
1580
- * ```tsx
1581
- * const { data: contacts, isLoading, totalCount } = useContacts({
1582
- * search: 'john',
1583
- * status: 'active',
1584
- * limit: 20
1585
- * });
1586
- * ```
1587
- */
1588
- declare function useContacts(_params?: UseContactsParams): UseContactsResult;
1589
- /**
1590
- * Hook to fetch a single contact by ID.
1591
- * This is a stub implementation - override with your own data fetching logic.
1592
- *
1593
- * @param contactId - The unique identifier of the contact to fetch
1594
- * @returns Object containing contact data, loading state, and error state
1595
- *
1596
- * @example
1597
- * ```tsx
1598
- * const { data: contact, isLoading, isError } = useContact('contact-123');
1599
- * ```
1600
- */
1601
- declare function useContact(_contactId: string): UseContactResult;
1602
-
1603
- interface RequireAuthProps {
1604
- /** Content to render when authenticated */
1605
- children: ReactNode;
1606
- /** Component to show while checking authentication (default: AuthLoading) */
1607
- fallback?: ReactNode;
1608
- /** Component to show when not authenticated (default: AuthError) */
1609
- errorComponent?: ReactNode;
1610
- }
1611
- /**
1612
- * Component that protects content requiring authentication.
1613
- *
1614
- * **Important:** This provides UX-level protection only. It prevents
1615
- * unauthenticated users from seeing the UI, but the real security
1616
- * boundary is the server-side API. Client-side auth can always be
1617
- * bypassed by modifying browser state.
1618
- *
1619
- * For defense-in-depth, configure `jwksUrl` in `FluidAuthConfig`
1620
- * to enable client-side JWT signature verification.
1621
- *
1622
- * Shows different states based on auth status:
1623
- * - Loading: Shows fallback (spinner by default)
1624
- * - Not authenticated: Shows errorComponent (AuthError by default)
1625
- * - Authenticated: Shows children
1626
- *
1627
- * @example
1628
- * ```tsx
1629
- * // Basic usage - shows default loading/error states
1630
- * <RequireAuth>
1631
- * <ProtectedContent />
1632
- * </RequireAuth>
1633
- *
1634
- * // Custom loading state
1635
- * <RequireAuth fallback={<CustomSpinner />}>
1636
- * <ProtectedContent />
1637
- * </RequireAuth>
1638
- *
1639
- * // Custom error component
1640
- * <RequireAuth errorComponent={<LoginPrompt />}>
1641
- * <ProtectedContent />
1642
- * </RequireAuth>
1643
- *
1644
- * // Both custom
1645
- * <RequireAuth
1646
- * fallback={<SkeletonLoader />}
1647
- * errorComponent={<RedirectToLogin />}
1648
- * >
1649
- * <Dashboard />
1650
- * </RequireAuth>
1651
- * ```
1652
- */
1653
- declare function RequireAuth({ children, fallback, errorComponent, }: RequireAuthProps): react_jsx_runtime.JSX.Element;
1654
-
1655
- interface AuthErrorProps {
1656
- /** Error message to display */
1657
- message?: string;
1658
- /** Optional title */
1659
- title?: string;
1660
- /** Optional children for custom content */
1661
- children?: ReactNode;
1662
- }
1663
- /**
1664
- * Default authentication error component.
1665
- *
1666
- * Displays a simple error message when authentication fails.
1667
- * Can be customized via props or replaced entirely in RequireAuth.
1668
- *
1669
- * @example
1670
- * ```tsx
1671
- * // Use with default message
1672
- * <AuthError />
1673
- *
1674
- * // Use with custom message
1675
- * <AuthError message="Session expired. Please log in again." />
1676
- *
1677
- * // Use with custom content
1678
- * <AuthError>
1679
- * <CustomLoginButton />
1680
- * </AuthError>
1681
- * ```
1682
- */
1683
- declare function AuthError({ message, title, children, }: AuthErrorProps): react_jsx_runtime.JSX.Element;
1684
- /**
1685
- * Simple loading spinner component for auth loading state.
1686
- */
1687
- declare function AuthLoading(): react_jsx_runtime.JSX.Element;
1688
-
1689
- /**
1690
- * Bridge hook: maps rep SDK auth context to MessagingAuthContext.
1691
- *
1692
- * The messaging system identifies users by `recipient_id`, which is NOT in the
1693
- * JWT payload or the /reps/me endpoint. It IS returned by GET /api/me.
1694
- * This hook fetches that data and maps it into the shape MessagingApp expects.
1695
- */
1696
-
1697
- declare function useMessagingAuth(): MessagingAuthContext;
1698
-
1699
- /**
1700
- * Hook that derives MessagingApiConfig from the rep SDK's FluidProvider context.
1701
- *
1702
- * Maps FluidSDKConfig fields to the shape expected by MessagingApp:
1703
- * - baseUrl -> from config.baseUrl
1704
- * - getHeaders -> builds Authorization header from config.getAuthToken()
1705
- * - onAuthError -> from config.onAuthError
1706
- * - websocketUrl -> config.websocketUrl or derived from baseUrl
1707
- * - token -> from auth context
1708
- */
1709
-
1710
- interface MessagingConfig {
1711
- readonly apiConfig: MessagingApiConfig;
1712
- readonly websocketUrl: string;
1713
- readonly token: string | null;
1714
- }
1715
- declare function useMessagingConfig(): MessagingConfig;
1716
-
1717
- /**
1718
- * Lightweight Filestack file uploader for the rep SDK.
1719
- *
1720
- * Uploads files to Filestack using the REST API (no filestack-js dependency).
1721
- * Flow: upload to `https://www.filestackapi.com/api/store/S3?key=<apiKey>`
1722
- * Uses XMLHttpRequest for upload progress tracking.
1723
- */
1724
-
1725
- /**
1726
- * Creates a FileUploader that uploads to Filestack using the REST API.
1727
- *
1728
- * @param apiKey - Filestack API key. If falsy, returns a noop uploader
1729
- * that rejects uploads with a helpful error message.
1730
- */
1731
- declare function createFluidFileUploader(apiKey: string | undefined): FileUploader;
1732
-
1733
- type MessagingScreenProps = ComponentProps<"div"> & {
1734
- background?: BackgroundValue;
1735
- textColor?: ColorOptions;
1736
- accentColor?: ColorOptions;
1737
- padding?: PaddingOptions;
1738
- borderRadius?: BorderRadiusOptions;
1739
- onToast?: (message: string, type: "success" | "error") => void;
1740
- filestackApiKey?: string;
1741
- websocketUrl?: string;
1742
- };
1743
- declare function MessagingScreen({ onToast, filestackApiKey, websocketUrl: websocketUrlOverride, background, textColor, accentColor, padding, borderRadius, ...divProps }: MessagingScreenProps): react_jsx_runtime.JSX.Element;
1744
- declare const messagingScreenPropertySchema: WidgetPropertySchema;
1745
-
1746
- type ContactsScreenProps = ComponentProps<"div"> & {
1747
- background?: BackgroundValue;
1748
- textColor?: ColorOptions;
1749
- accentColor?: ColorOptions;
1750
- padding?: PaddingOptions;
1751
- borderRadius?: BorderRadiusOptions;
1752
- defaultViewMode?: "list" | "grid";
1753
- onContactSelect?: (contactId: string) => void;
1754
- onCreateContact?: () => void;
1755
- };
1756
- declare function ContactsScreen(_props: ContactsScreenProps): react_jsx_runtime.JSX.Element;
1757
- declare const contactsScreenPropertySchema: WidgetPropertySchema;
1758
-
1759
- type OrdersScreenProps = ComponentProps<"div"> & {
1760
- background?: BackgroundValue;
1761
- textColor?: ColorOptions;
1762
- accentColor?: ColorOptions;
1763
- padding?: PaddingOptions;
1764
- borderRadius?: BorderRadiusOptions;
1765
- };
1766
- declare function OrdersScreen(_props: OrdersScreenProps): react_jsx_runtime.JSX.Element;
1767
- declare const ordersScreenPropertySchema: WidgetPropertySchema;
1768
-
1769
- type CustomersScreenProps = ComponentProps<"div"> & {
1770
- background?: BackgroundValue;
1771
- textColor?: ColorOptions;
1772
- accentColor?: ColorOptions;
1773
- padding?: PaddingOptions;
1774
- borderRadius?: BorderRadiusOptions;
1775
- };
1776
- declare function CustomersScreen(_props: CustomersScreenProps): react_jsx_runtime.JSX.Element;
1777
- declare const customersScreenPropertySchema: WidgetPropertySchema;
1778
-
1779
- type ProductsScreenProps = ComponentProps<"div"> & {
1780
- background?: BackgroundValue;
1781
- textColor?: ColorOptions;
1782
- accentColor?: ColorOptions;
1783
- padding?: PaddingOptions;
1784
- borderRadius?: BorderRadiusOptions;
1785
- };
1786
- declare function ProductsScreen(_props: ProductsScreenProps): react_jsx_runtime.JSX.Element;
1787
- declare const productsScreenPropertySchema: WidgetPropertySchema;
1788
-
1789
- declare const screenPropertySchemas: {
1790
- MessagingScreen: () => Promise<_fluid_app_rep_core_registries.WidgetPropertySchema>;
1791
- ContactsScreen: () => Promise<_fluid_app_rep_core_registries.WidgetPropertySchema>;
1792
- OrdersScreen: () => Promise<_fluid_app_rep_core_registries.WidgetPropertySchema>;
1793
- CustomersScreen: () => Promise<_fluid_app_rep_core_registries.WidgetPropertySchema>;
1794
- ProductsScreen: () => Promise<_fluid_app_rep_core_registries.WidgetPropertySchema>;
1795
- };
1796
- /**
1797
- * Core page template IDs
1798
- */
1799
- declare const CORE_PAGE_IDS: {
1800
- readonly MESSAGING: "core-messaging";
1801
- readonly CONTACTS: "core-contacts";
1802
- readonly ORDERS: "core-orders";
1803
- readonly CUSTOMERS: "core-customers";
1804
- readonly PRODUCTS: "core-products";
1805
- };
1806
-
1807
- declare const DEFAULT_SDK_WIDGET_REGISTRY: {
1808
- AlertWidget: typeof AlertWidget;
1809
- CalendarWidget: typeof CalendarWidget;
1810
- CarouselWidget: typeof CarouselWidget;
1811
- CatchUpWidget: typeof CatchUpWidget;
1812
- ChartWidget: typeof ChartWidget;
1813
- ContainerWidget: typeof ContainerWidget;
1814
- EmbedWidget: typeof EmbedWidget;
1815
- ImageWidget: typeof ImageWidget;
1816
- LayoutWidget: <T extends Record<string, react.ComponentType<any>>>({ sectionLayout, gap, gapSize, background, padding, borderRadius, children, registry, className, minHeight, }: {
1817
- sectionLayout?: _fluid_app_rep_core_types.SectionLayoutType;
1818
- type?: "flex" | "grid";
1819
- columns?: number;
1820
- rows?: number;
1821
- direction?: string;
1822
- justify?: string;
1823
- align?: string;
1824
- wrap?: boolean;
1825
- gap?: number;
1826
- gapSize?: _fluid_app_rep_core_types.GapOptions;
1827
- background?: _fluid_app_rep_core_types.BackgroundValue;
1828
- padding?: _fluid_app_rep_core_types.PaddingOptions;
1829
- borderRadius?: _fluid_app_rep_core_types.BorderRadiusOptions;
1830
- children: (_fluid_app_rep_core_types.WidgetSchema | null)[] | (_fluid_app_rep_core_types.TypedWidgetSchema<T> | null)[];
1831
- registry?: T | undefined;
1832
- className?: string;
1833
- minHeight?: number;
1834
- }) => react_jsx_runtime.JSX.Element;
1835
- ListWidget: typeof ListWidget;
1836
- MySiteWidget: typeof MySiteWidget;
1837
- NestedWidget: typeof NestedWidget;
1838
- QuickShareWidget: typeof QuickShareWidget;
1839
- RecentActivityWidget: typeof RecentActivityWidget;
1840
- SpacerWidget: typeof SpacerWidget;
1841
- TableWidget: typeof TableWidget;
1842
- TextWidget: typeof TextWidget;
1843
- ToDoWidget: typeof ToDoWidget;
1844
- VideoWidget: typeof VideoWidget;
1845
- };
1846
-
1847
- /**
1848
- * Resolve all page references and local screens into a unified screen list.
1849
- *
1850
- * This function merges:
1851
- * 1. Screen definitions from page_refs (shared templates)
1852
- * 2. Local screen definitions (for backwards compatibility and custom screens)
1853
- *
1854
- * When a screen_id appears in both page_refs and screens, the local screen
1855
- * takes precedence (allows local overrides of template pages).
1856
- *
1857
- * @param navigation - The navigation configuration
1858
- * @returns A unified array of ScreenDefinition objects
1859
- *
1860
- * @example
1861
- * ```ts
1862
- * const navigation: Navigation = {
1863
- * definition_id: 1,
1864
- * id: 1,
1865
- * name: "Main Nav",
1866
- * navigation_items: [...],
1867
- * screens: [
1868
- * // Local custom screen
1869
- * { id: 1, slug: "home", name: "Home", component_tree: [...] }
1870
- * ],
1871
- * page_refs: [
1872
- * // Reference to shared messaging template
1873
- * { page_template_id: "core-messaging", screen_id: 2 }
1874
- * ],
1875
- * };
1876
- *
1877
- * const allScreens = resolveNavigationPages(navigation);
1878
- * // Returns: [home screen, messaging screen from template]
1879
- * ```
1880
- */
1881
- declare function resolveNavigationPages(navigation: Readonly<Navigation>): ScreenDefinition[];
1882
- /**
1883
- * Get all available page templates for use in navigation.
1884
- *
1885
- * @returns Array of page templates from the registry
1886
- */
1887
- declare function getAvailablePageTemplates(): PageTemplate[];
1888
- /**
1889
- * Get core page templates that are required for basic functionality.
1890
- *
1891
- * @returns Array of core page templates
1892
- */
1893
- declare function getCorePageTemplates(): PageTemplate[];
1894
- /**
1895
- * Get optional page templates that can be added to navigation.
1896
- *
1897
- * @returns Array of optional (non-core) page templates
1898
- */
1899
- declare function getOptionalPageTemplates(): PageTemplate[];
1900
- /**
1901
- * Check if a navigation has all required core pages.
1902
- *
1903
- * @param navigation - The navigation to check
1904
- * @returns Object with validation result and missing page IDs
1905
- */
1906
- declare function validateNavigationPages(navigation: Readonly<Navigation>): {
1907
- readonly valid: boolean;
1908
- readonly missingCorePages: readonly string[];
1909
- };
1910
-
1911
- /**
1912
- * Registry for managing reusable page templates.
1913
- *
1914
- * The registry provides a central store for page templates that can be
1915
- * shared across multiple navigations. Core pages (like Messaging, Contacts)
1916
- * are pre-registered and cannot be removed.
1917
- *
1918
- * @example
1919
- * ```ts
1920
- * // Register a custom page template
1921
- * PageTemplateRegistry.register({
1922
- * id: 'custom-dashboard',
1923
- * slug: 'dashboard',
1924
- * name: 'Custom Dashboard',
1925
- * category: 'custom',
1926
- * version: '1.0.0',
1927
- * component_tree: [{ type: 'TextWidget', props: { text: 'Hello' } }],
1928
- * });
1929
- *
1930
- * // Get a template by ID
1931
- * const template = PageTemplateRegistry.get('custom-dashboard');
1932
- *
1933
- * // List all templates in a category
1934
- * const corePages = PageTemplateRegistry.getByCategory('core');
1935
- * ```
1936
- */
1937
- declare class PageTemplateRegistryImpl {
1938
- private templates;
1939
- private categories;
1940
- constructor();
1941
- /**
1942
- * Register a new page template.
1943
- * @throws Error if a template with the same ID already exists
1944
- */
1945
- register(template: PageTemplate): void;
1946
- /**
1947
- * Unregister a page template by ID.
1948
- * Core templates cannot be unregistered.
1949
- * @returns true if the template was removed, false if it didn't exist or is a core template
1950
- */
1951
- unregister(id: string): boolean;
1952
- /**
1953
- * Get a page template by ID.
1954
- */
1955
- get(id: string): PageTemplate | undefined;
1956
- /**
1957
- * Get all page templates in a specific category.
1958
- */
1959
- getByCategory(category: PageCategoryId | string): PageTemplate[];
1960
- /**
1961
- * List all registered page templates.
1962
- */
1963
- listAll(): PageTemplate[];
1964
- /**
1965
- * List all core page templates (isCore: true).
1966
- */
1967
- listCore(): PageTemplate[];
1968
- /**
1969
- * List all non-core page templates.
1970
- */
1971
- listOptional(): PageTemplate[];
1972
- /**
1973
- * List all registered categories.
1974
- */
1975
- listCategories(): PageCategory[];
1976
- /**
1977
- * Add a custom category.
1978
- */
1979
- addCategory(category: PageCategory): void;
1980
- /**
1981
- * Check if a template exists by ID.
1982
- */
1983
- has(id: string): boolean;
1984
- /**
1985
- * Get the count of registered templates.
1986
- */
1987
- get size(): number;
1988
- /**
1989
- * Clear all non-core templates.
1990
- * Useful for testing or resetting the registry.
1991
- */
1992
- clearNonCore(): void;
1993
- }
1994
- /**
1995
- * Global page template registry singleton.
1996
- *
1997
- * This registry is automatically populated with core page templates
1998
- * (Messaging, Contacts) when the SDK is imported.
1999
- */
2000
- declare const PageTemplateRegistry: PageTemplateRegistryImpl;
2001
-
2002
- interface AppShellProps {
2003
- /** Pre-fetched app data (skips internal useFluidApp call if provided) */
2004
- appData?: RepAppData;
2005
- /** Override navigation items (otherwise derived from appData/API) */
2006
- navigation?: NavigationItem[];
2007
- /** Custom page components keyed by slug */
2008
- customPages?: Record<string, ComponentType<{
2009
- slug?: string;
2010
- params?: string;
2011
- }>>;
2012
- /** Base path for subpath deployments (e.g. "/portal"). Default: "/" */
2013
- basePath?: string;
2014
- /** Controlled current slug */
2015
- currentSlug?: string;
2016
- /** Navigation callback */
2017
- onNavigate?: (slug: string) => void;
2018
- /** Custom sidebar header slot */
2019
- sidebarHeader?: ReactNode;
2020
- /** Custom sidebar footer slot */
2021
- sidebarFooter?: ReactNode;
2022
- /** Render prop or static children for the content area */
2023
- children?: ReactNode | ((props: {
2024
- currentSlug: string;
2025
- currentNavItem: NavigationItem | undefined;
2026
- }) => ReactNode);
2027
- }
2028
- declare function AppShell({ appData: appDataProp, navigation: navigationProp, customPages, basePath, currentSlug: controlledSlug, onNavigate: onNavigateProp, sidebarHeader, sidebarFooter, children, }: AppShellProps): react_jsx_runtime.JSX.Element;
2029
-
2030
- interface BuilderScreenViewProps {
2031
- /** The screen definition to render */
2032
- screen: ScreenDefinition$1;
2033
- /** Additional CSS classes for the wrapper div */
2034
- className?: string;
2035
- }
2036
- /**
2037
- * Renders a builder screen's component_tree with full data source support.
2038
- * Widgets with `dataSource` config are automatically wrapped with `DataAwareWidget`
2039
- * which fetches data and merges it with static props before rendering.
2040
- */
2041
- declare function BuilderScreenViewImpl({ screen, className }: BuilderScreenViewProps): react_jsx_runtime.JSX.Element;
2042
- declare const BuilderScreenView: react.MemoExoticComponent<typeof BuilderScreenViewImpl>;
2043
-
2044
- interface SdkNavigationProps {
2045
- navItems: NavigationItem[];
2046
- currentSlug: string;
2047
- onNavigate: (slug: string) => void;
2048
- navSlugs: string[];
2049
- }
2050
- declare function SdkNavigation({ navItems, currentSlug, onNavigate, navSlugs, }: SdkNavigationProps): react_jsx_runtime.JSX.Element;
2051
-
2052
- interface SdkHeaderProps {
2053
- tabs: NavigationItem[];
2054
- mobileTabs?: NavigationItem[];
2055
- currentSlug: string;
2056
- onNavigate: (slug: string) => void;
2057
- navSlugs: string[];
2058
- }
2059
- declare function SdkHeader({ tabs, mobileTabs, currentSlug, onNavigate, navSlugs, }: SdkHeaderProps): react_jsx_runtime.JSX.Element;
2060
-
2061
- interface PageRouterProps {
2062
- currentSlug: string;
2063
- currentNavItem?: NavigationItem | undefined;
2064
- customPages?: Record<string, ComponentType<{
2065
- slug?: string;
2066
- params?: string;
2067
- }>> | undefined;
2068
- /** Builder screen definitions (from fluidos API) */
2069
- screens?: ScreenDefinition[] | undefined;
2070
- baseSlug: string;
2071
- restParams: string;
2072
- }
2073
- declare function PageRouter({ currentSlug, currentNavItem, customPages, screens, baseSlug, restParams, }: PageRouterProps): react_jsx_runtime.JSX.Element;
2074
-
2075
- interface QuickLinksDropdownProps {
2076
- onNavigate: (slug: string) => void;
2077
- }
2078
- declare function QuickLinksDropdown({ onNavigate }: QuickLinksDropdownProps): react_jsx_runtime.JSX.Element;
2079
-
2080
- interface AppNavigationContextValue {
2081
- /** Current active slug (e.g. "contacts/123") */
2082
- currentSlug: string;
2083
- /** Base path for subpath deployments (e.g. "/portal"). Default: "/" */
2084
- basePath: string;
2085
- /** Navigate to a slug programmatically */
2086
- navigate: (slug: string) => void;
2087
- /** Build a full href for a slug (for use in <a> tags) */
2088
- buildHref: (slug: string) => string;
2089
- }
2090
- interface AppNavigationProviderProps {
2091
- currentSlug: string;
2092
- basePath: string;
2093
- navigate: (slug: string) => void;
2094
- children: ReactNode;
2095
- }
2096
- declare function AppNavigationProvider({ currentSlug, basePath, navigate, children, }: AppNavigationProviderProps): react_jsx_runtime.JSX.Element;
2097
- declare function useAppNavigation(): AppNavigationContextValue;
2098
-
2099
- interface AppLinkProps extends Omit<AnchorHTMLAttributes<HTMLAnchorElement>, "href"> {
2100
- /** Slug to navigate to (e.g. "contacts/123") */
2101
- to: string;
2102
- }
2103
- /**
2104
- * SPA-aware link that renders a real `<a href>` for accessibility
2105
- * (right-click, ctrl+click, screen readers) but intercepts normal
2106
- * clicks for client-side navigation.
2107
- */
2108
- declare const AppLink: react.ForwardRefExoticComponent<AppLinkProps & react.RefAttributes<HTMLAnchorElement>>;
2109
-
2110
- interface SlugMatch {
2111
- matchedSlug: string;
2112
- rest: string;
2113
- }
2114
- /**
2115
- * Extract all slugs from a navigation tree, sorted by segment count descending.
2116
- * Longest slugs first enables greedy prefix matching (e.g. "share/playlists"
2117
- * is checked before "share").
2118
- */
2119
- declare function collectNavSlugs(items: NavigationItem[]): string[];
2120
- /**
2121
- * Find the longest registered nav slug that is a prefix of `fullSlug`.
2122
- * Uses segment-boundary checking to prevent "shop" from matching "shopping".
2123
- */
2124
- declare function matchSlugPrefix(fullSlug: string, navSlugs: string[]): SlugMatch | undefined;
2125
- /**
2126
- * Extract the slug portion from a full pathname by stripping the basePath prefix.
2127
- * Returns an empty string when the pathname equals the basePath exactly.
2128
- *
2129
- * Examples:
2130
- * extractSlugFromPathname("/contacts/123", "/") → "contacts/123"
2131
- * extractSlugFromPathname("/portal/contacts", "/portal") → "contacts"
2132
- * extractSlugFromPathname("/portal", "/portal") → ""
2133
- * extractSlugFromPathname("/", "/") → ""
2134
- */
2135
- declare function extractSlugFromPathname(pathname: string, basePath: string): string;
2136
- declare function isSlugInSection(item: NavigationItem, currentSlug: string, navSlugs: string[]): boolean;
2137
-
2138
- export { ACTIVITY_SLUGS, APP_DATA_QUERY_KEY, 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_SDK_WIDGET_REGISTRY, type DashboardData, FluidAuthProvider, type FluidAuthProviderProps, type FluidClient, FluidProvider, type FluidProviderProps, type FluidSDKConfig, FluidThemeProvider, type FluidThemeProviderProps, 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, type SalesData, type SalesDataPoint, type SalesParams, type ScreenDefinition, SdkHeader, type SdkHeaderProps, SdkNavigation, type SdkNavigationProps, type SlugMatch, type Todo as TodoItem, 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 ValueListQueryResult, type WithData, collectNavSlugs, contactsScreenPropertySchema, createFluidClient, createFluidFileUploader, customersScreenPropertySchema, extractSlugFromPathname, getAvailablePageTemplates, getCorePageTemplates, getOptionalPageTemplates, getProperty, hasData, isActivitySlug, isApiError, isContactStatus, isErrorResult, isIdle, isLoading, isSlugInSection, matchSlugPrefix, messagingScreenPropertySchema, normalizeComponentTree, ordersScreenPropertySchema, productsScreenPropertySchema, resolveNavigationPages, screenPropertySchemas, selectProperty, 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 };