create-bluecopa-react-app 1.0.12 → 1.0.13

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.
@@ -73,583 +73,627 @@ export function Component({ className, children }: ComponentProps) {
73
73
  - Implement loading and error states
74
74
  - Use TanStack Query for caching
75
75
  - Handle optimistic updates
76
- # @bluecopa/react [![npm version](https://img.shields.io/npm/v/@bluecopa/react)](https://www.npmjs.com/package/@bluecopa/react) [![License](https://img.shields.io/npm/l/@bluecopa/react)](https://github.com/bluecopa/blui/blob/main/packages/react/LICENSE)
77
-
78
- ## A Comprehensive React Query Integration for Bluecopa
79
-
80
- A React library providing opinionated custom hooks for TanStack React Query integration with Bluecopa core API. This package enables efficient data fetching, caching, and synchronization with the Bluecopa platform while maintaining type safety and developer experience.
81
-
82
- ## Table of Contents
83
-
84
- - [@bluecopa/react ](#bluecopareact--)
85
- - [A Comprehensive React Query Integration for Bluecopa](#a-comprehensive-react-query-integration-for-bluecopa)
86
- - [Table of Contents](#table-of-contents)
87
- - [Features](#features)
88
- - [Installation](#installation)
89
- - [Peer Dependencies](#peer-dependencies)
90
- - [Usage](#usage)
91
- - [Query Provider Setup](#query-provider-setup)
92
- - [Boilerplate Integration](#boilerplate-integration)
93
- - [Hook Examples](#hook-examples)
94
- - [`useUser` - Fetch authenticated user](#useuser---fetch-authenticated-user)
95
- - [`useDataset` - Fetch dataset with query controls](#usedataset---fetch-dataset-with-query-controls)
96
- - [API Documentation](#api-documentation)
97
- - [`useUser(options?)`](#useuseroptions)
98
- - [`useDataset(datasetId, options?)`](#usedatasetdatasetid-options)
99
- - [`useDatasetSample(datasetId, options?)`](#usedatasetsampledatasetid-options)
100
- - [`useMetric(metricId, options?)`](#usemetricmetricid-options)
101
- - [`useInputTable(inputTableId, options?)`](#useinputtableinputtableid-options)
102
- - [`useGetFileUrlByFileId(fileId, options?)`](#usegetfileurlbyfileidfileid-options)
103
- - [`useGetPublishedWorkbookById(workbookId, options?)`](#usegetpublishedworkbookbyidworkbookid-options)
104
- - [`useGetTableById(tableId, options?)`](#usegettablebyidtableid-options)
105
- - [`useGetWorkbooksByType(workbookType, options?)`](#usegetworkbooksbytypeworkbooktype-options)
106
- - [`useGetWorkflowInstanceStatusById(instanceId, options?)`](#usegetworkflowinstancestatusbyidinstanceid-options)
107
- - [`useGetWorksheets(options?)`](#usegetworksheetsoptions)
108
- - [`useGetWorksheetsByType(worksheetType, options?)`](#usegetworksheetsbytypeworksheettype-options)
109
- - [`useRunDefinition(definitionId, options?)`](#userundefinitiondefinitionid-options)
110
- - [`useRunPublishedDefinition(publishedDefinitionId, options?)`](#userunpublisheddefinitionpublisheddefinitionid-options)
111
- - [`useRunSampleDefinition(sampleDefinitionId, options?)`](#userunsampledefinitionsampledefinitionid-options)
112
- - [`useTriggerHttpWorkflow(workflowId, payload, options?)`](#usetriggerhttpworkflowworkflowid-payload-options)
113
- - [`useTriggerWorkflow(workflowId, options?)`](#usetriggerworkflowworkflowid-options)
114
- - [`useWorkbook(workbookId, options?)`](#useworkbookworkbookid-options)
115
- - [`useWorkflow(workflowId, options?)`](#useworkflowworkflowid-options)
116
- - [`useWorksheet(worksheetId, options?)`](#useworksheetworksheetid-options)
117
- - [Configuration](#configuration)
118
- - [Default Query Configuration](#default-query-configuration)
119
- - [Customizable Parameters](#customizable-parameters)
120
- - [Advanced Usage](#advanced-usage)
121
- - [Error Handling](#error-handling)
122
- - [Manual Refetching](#manual-refetching)
123
- - [Re-exports](#re-exports)
124
- - [TypeScript Support](#typescript-support)
125
- - [Development](#development)
126
-
127
- ## Features
128
-
129
- - ✅ First-class TypeScript support with strict type definitions
130
- - 🔁 Seamless integration with TanStack React Query (v5+)
131
- - 🛡 Comprehensive error handling patterns
132
- - ⚙ Optimized default query configuration
133
- - 📦 Re-exports of core TanStack React Query utilities
134
- - 📊 Sample data preview capabilities
135
- - 🧩 Customizable query parameters (limit, caching, retries)
136
-
137
- ## Installation
138
-
139
- ```bash
140
- npm install @bluecopa/react
141
- # or with pnpm
142
- pnpm add @bluecopa/react
143
- ```
144
-
145
- ### Peer Dependencies
146
-
147
- This package requires the following in your application:
148
-
149
- ```bash
150
- npm install react@^18.0.0 react-dom@^18.0.0
151
- ```
152
-
153
- ## Usage
154
-
155
- ### Query Provider Setup
156
-
157
- Wrap your application with the React Query provider:
158
-
159
- ```tsx
160
- import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
161
-
162
- const queryClient = new QueryClient({
163
- defaultOptions: {
164
- queries: {
165
- staleTime: 60 * 1000, // 1 minute
166
- refetchOnWindowFocus: false,
167
- },
168
- },
169
- });
170
-
171
- function App() {
172
- return (
173
- <QueryClientProvider client={queryClient}>
174
- <YourApp />
175
- <ReactQueryDevtools initialIsOpen={false} />
176
- </QueryClientProvider>
177
- );
178
- }
179
- ```
180
-
181
- ### Boilerplate Integration
182
-
183
- For projects using the Bluecopa React boilerplate, use the pre-configured `QueryProvider` component that handles API configuration automatically:
184
-
185
- ```tsx
186
- // src/providers/query-provider.tsx
187
- import { ReactQueryDevtools, reactQuery, copaSetConfig } from "@bluecopa/react";
188
- import { useEffect, useState } from "react";
189
-
190
- const { QueryClient, QueryClientProvider } = reactQuery;
191
-
192
- export default function QueryProvider({ children }: { children: React.ReactNode }) {
193
- const [queryClient] = useState(() => new QueryClient({
194
- defaultOptions: {
195
- queries: {
196
- staleTime: 60 * 1000, // 1 minute
197
- refetchOnWindowFocus: false,
198
- },
199
- },
200
- }));
201
-
202
- useEffect(() => {
203
- let copaUser: any = {};
204
- try {
205
- const copaToken = import.meta.env.VITE_BLUECOPA_API_TOKEN
206
- ? atob(import.meta.env.VITE_BLUECOPA_API_TOKEN)
207
- : "{}";
208
-
209
- copaUser = JSON.parse(copaToken);
210
- } catch (error) {
211
- console.warn("Failed to parse VITE_BLUECOPA_API_TOKEN:", error);
212
- }
213
-
214
- copaSetConfig({
215
- apiBaseUrl: import.meta.env.VITE_BLUECOPA_API_URL || "https://develop.bluecopa.com/api/v1",
216
- workspaceId: import.meta.env.VITE_BLUECOPA_WORKSPACE_ID || "",
217
- accessToken: copaUser?.accessToken || "",
218
- });
219
- }, []);
220
-
221
- return (
222
- <QueryClientProvider client={queryClient}>
223
- {children}
224
- <ReactQueryDevtools initialIsOpen={false} />
225
- </QueryClientProvider>
226
- );
227
- }
228
- ```
229
-
230
- **Required Environment Variables:**
231
-
232
- | Variable | Description | Example |
233
- |----------|-------------|---------|
234
- | `VITE_BLUECOPA_API_URL` | Base URL for Bluecopa API | `https://develop.bluecopa.com` |
235
- | `VITE_BLUECOPA_WORKSPACE_ID` | Your workspace identifier | `my-workspace-123` |
236
- | `VITE_BLUECOPA_API_TOKEN` | Base64-encoded JSON string containing `accessToken` | `eyJhY2Nlc3NUb2tlbiI6IjEyMzQ1In0=` |
237
-
238
- **Example `.env` file:**
239
- ```
240
- VITE_BLUECOPA_API_URL=https://develop.bluecopa.com
241
- VITE_BLUECOPA_WORKSPACE_ID=your-workspace-id
242
- VITE_BLUECOPA_API_TOKEN=base64-encoded-json-here
243
- ```
244
-
245
- Then wrap your application with this provider:
246
-
247
- ```tsx
248
- import QueryProvider from './providers/query-provider';
249
-
250
- function App() {
251
- return (
252
- <QueryProvider>
253
- <YourApp />
254
- </QueryProvider>
255
- );
256
- }
257
- ```
258
-
259
- This setup automatically configures the API client with your environment-specific settings and applies optimal caching defaults.
260
-
261
- ### Hook Examples
262
-
263
- #### `useUser` - Fetch authenticated user
264
-
265
- ```tsx
266
- import { useUser } from '@bluecopa/react';
267
-
268
- function UserProfile() {
269
- const { data, isLoading, error } = useUser({
270
- staleTime: 5 * 60 * 1000, // 5 minutes
271
- retry: 2
272
- });
273
-
274
- if (isLoading) return <div>Loading...</div>;
275
- if (error) return <div>Error: {error.message}</div>;
276
-
277
- return <div>Welcome, {data?.name}!</div>;
278
- }
279
- ```
280
-
281
- #### `useDataset` - Fetch dataset with query controls
282
-
283
- ```tsx
284
- import { useDataset } from '@bluecopa/react';
285
-
286
- function DatasetViewer({ datasetId }) {
287
- const { data, isLoading } = useDataset(datasetId, {
288
- limit: 500,
289
- staleTime: 10 * 60 * 1000 // 10 minutes
290
- });
291
-
292
- if (isLoading) return <div>Loading dataset...</div>;
293
- return <div>{data?.name} ({data?.records?.length} records)</div>;
294
- }
295
- ```
296
-
297
- ## API Documentation
298
-
299
- ### `useUser(options?)`
300
-
301
- Fetches authenticated user details with query controls.
302
-
303
- **Parameters:**
304
- - `options` (optional): Query options extending TanStack React Query's `UseQueryOptions`
305
-
306
- **Returns:**
307
- - `data`: User object or `undefined`
308
- - `isLoading`: Boolean indicating loading state
309
- - `error`: Error object if request failed
310
- - `refetch`: Function to manually trigger refetch
311
-
312
- ### `useDataset(datasetId, options?)`
313
76
 
314
- Fetches dataset data by ID with configurable parameters.
77
+ # @bluecopa/react [![npm version](https://img.shields.io/npm/v/@bluecopa/react)](https://www.npmjs.com/package/@bluecopa/react) [![License](https://img.shields.io/npm/l/@bluecopa/react)](https://github.com/bluecopa/blui/blob/main/packages/react/LICENSE)
78
+
79
+ ## A Comprehensive React Query Integration for Bluecopa
80
+
81
+ A React library providing opinionated custom hooks for TanStack React Query integration with Bluecopa core API. This package enables efficient data fetching, caching, and synchronization with the Bluecopa platform while maintaining type safety and developer experience.
82
+
83
+ ## Table of Contents
84
+
85
+ - [AI Agent Guide for BlueCopa React shadcn/ui Template](#ai-agent-guide-for-bluecopa-react-shadcnui-template)
86
+ - [🏗️ Project Architecture Overview](#️-project-architecture-overview)
87
+ - [Core Stack](#core-stack)
88
+ - [Key Directories](#key-directories)
89
+ - [🎨 Component Patterns](#-component-patterns)
90
+ - [shadcn/ui Components](#shadcnui-components)
91
+ - [Custom Components](#custom-components)
92
+ - [Example Component Structure](#example-component-structure)
93
+ - [🔧 Development Patterns](#-development-patterns)
94
+ - [State Management](#state-management)
95
+ - [Data Fetching](#data-fetching)
96
+ - [@bluecopa/react ](#bluecopareact--)
97
+ - [A Comprehensive React Query Integration for Bluecopa](#a-comprehensive-react-query-integration-for-bluecopa)
98
+ - [Table of Contents](#table-of-contents)
99
+ - [Features](#features)
100
+ - [Installation](#installation)
101
+ - [Peer Dependencies](#peer-dependencies)
102
+ - [Usage](#usage)
103
+ - [Query Provider Setup](#query-provider-setup)
104
+ - [Boilerplate Integration](#boilerplate-integration)
105
+ - [Hook Examples](#hook-examples)
106
+ - [`useUser` - Fetch authenticated user](#useuser---fetch-authenticated-user)
107
+ - [`useDataset` - Fetch dataset with query controls](#usedataset---fetch-dataset-with-query-controls)
108
+ - [API Documentation](#api-documentation)
109
+ - [`useUser(options?)`](#useuseroptions)
110
+ - [`useDataset(datasetId, options?)`](#usedatasetdatasetid-options)
111
+ - [`useDatasetSample(datasetId, options?)`](#usedatasetsampledatasetid-options)
112
+ - [`useMetric(metricId, options?)`](#usemetricmetricid-options)
113
+ - [`useInputTable(inputTableId, options?)`](#useinputtableinputtableid-options)
114
+ - [`useGetFileUrlByFileId(fileId, options?)`](#usegetfileurlbyfileidfileid-options)
115
+ - [`useGetPublishedWorkbookById(workbookId, options?)`](#usegetpublishedworkbookbyidworkbookid-options)
116
+ - [`useGetTableById(tableId, options?)`](#usegettablebyidtableid-options)
117
+ - [`useGetWorkbooksByType(workbookType, options?)`](#usegetworkbooksbytypeworkbooktype-options)
118
+ - [`useGetWorkflowInstanceStatusById(instanceId, options?)`](#usegetworkflowinstancestatusbyidinstanceid-options)
119
+ - [`useGetWorksheets(options?)`](#usegetworksheetsoptions)
120
+ - [`useGetWorksheetsByType(worksheetType, options?)`](#usegetworksheetsbytypeworksheettype-options)
121
+ - [`useRunDefinition(definitionId, options?)`](#userundefinitiondefinitionid-options)
122
+ - [`useRunPublishedDefinition(publishedDefinitionId, options?)`](#userunpublisheddefinitionpublisheddefinitionid-options)
123
+ - [`useRunSampleDefinition(sampleDefinitionId, options?)`](#userunsampledefinitionsampledefinitionid-options)
124
+ - [`useTriggerHttpWorkflow(workflowId, payload, options?)`](#usetriggerhttpworkflowworkflowid-payload-options)
125
+ - [`useTriggerWorkflow(workflowId, options?)`](#usetriggerworkflowworkflowid-options)
126
+ - [`useWorkbook(workbookId, options?)`](#useworkbookworkbookid-options)
127
+ - [`useWorkflow(workflowId, options?)`](#useworkflowworkflowid-options)
128
+ - [`useWorksheet(worksheetId, options?)`](#useworksheetworksheetid-options)
129
+ - [Configuration](#configuration)
130
+ - [Default Query Configuration](#default-query-configuration)
131
+ - [Customizable Parameters](#customizable-parameters)
132
+ - [Advanced Usage](#advanced-usage)
133
+ - [Error Handling](#error-handling)
134
+ - [Manual Refetching](#manual-refetching)
135
+ - [Re-exports](#re-exports)
136
+ - [Styling Guidelines](#styling-guidelines)
137
+ - [📊 Data Visualization](#-data-visualization)
138
+ - [Charts (Recharts)](#charts-recharts)
139
+ - [Tables (TanStack Table)](#tables-tanstack-table)
140
+ - [🎯 Common Tasks \& Solutions](#-common-tasks--solutions)
141
+ - [Adding New Pages](#adding-new-pages)
142
+ - [Adding New Components](#adding-new-components)
143
+ - [Working with Forms](#working-with-forms)
144
+ - [API Integration](#api-integration)
145
+ - [🚀 Performance Optimization](#-performance-optimization)
146
+ - [Code Splitting](#code-splitting)
147
+ - [Bundle Optimization](#bundle-optimization)
148
+ - [Runtime Performance](#runtime-performance)
149
+ - [🧪 Testing Strategies](#-testing-strategies)
150
+ - [Component Testing](#component-testing)
151
+ - [Integration Testing](#integration-testing)
152
+ - [🔒 Security Considerations](#-security-considerations)
153
+ - [Data Handling](#data-handling)
154
+ - [📱 Responsive Design](#-responsive-design)
155
+ - [Breakpoints](#breakpoints)
156
+ - [Layout Patterns](#layout-patterns)
157
+ - [🌙 Dark Mode Implementation](#-dark-mode-implementation)
158
+ - [Theme System](#theme-system)
159
+ - [Component Theming](#component-theming)
160
+ - [🐛 Debugging Tips](#-debugging-tips)
161
+ - [Common Issues](#common-issues)
162
+ - [Development Tools](#development-tools)
163
+ - [📚 Useful Resources](#-useful-resources)
164
+ - [Documentation](#documentation)
165
+ - [BlueCopa Specific](#bluecopa-specific)
166
+ - [🎯 Best Practices Summary](#-best-practices-summary)
167
+ - [🔄 Common Workflows](#-common-workflows)
168
+ - [Adding a New Feature](#adding-a-new-feature)
169
+ - [Debugging Issues](#debugging-issues)
170
+
171
+ ## Features
172
+
173
+ - ✅ First-class TypeScript support with strict type definitions
174
+ - 🔁 Seamless integration with TanStack React Query (v5+)
175
+ - 🛡 Comprehensive error handling patterns
176
+ - ⚙ Optimized default query configuration
177
+ - 📦 Re-exports of core TanStack React Query utilities
178
+ - 📊 Sample data preview capabilities
179
+ - 🧩 Customizable query parameters (limit, caching, retries)
180
+
181
+ ## Installation
182
+
183
+ ```bash
184
+ npm install @bluecopa/react
185
+ # or with pnpm
186
+ pnpm add @bluecopa/react
187
+ ```
315
188
 
316
- **Parameters:**
317
- - `datasetId`: ID of the dataset to fetch
318
- - `options` (optional): Query options with:
319
- - `limit`: Maximum records to fetch
320
- - `staleTime`: Duration (ms) before data is considered stale
189
+ ### Peer Dependencies
321
190
 
322
- **Returns:**
323
- - `data`: Dataset object containing name and records
324
- - `isLoading`: Boolean indicating loading state
325
- - `error`: Error object if request failed
326
- - `refetch`: Function to manually trigger refetch
191
+ This package requires the following in your application:
327
192
 
328
- ### `useDatasetSample(datasetId, options?)`
193
+ ```bash
194
+ npm install react@^18.0.0 react-dom@^18.0.0
195
+ ```
329
196
 
330
- Fetches a representative sample of dataset data.
197
+ ## Usage
331
198
 
332
- **Parameters:**
333
- - `datasetId`: ID of the dataset
334
- - `options` (optional): Query options with `enabled` flag
199
+ ### Query Provider Setup
335
200
 
336
- **Returns:**
337
- - `data`: Object containing sample data
338
- - `isLoading`: Boolean indicating loading state
339
- - `refetch`: Function to manually trigger refetch
201
+ Wrap your application with the React Query provider:
340
202
 
341
- ### `useMetric(metricId, options?)`
203
+ ```tsx
204
+ import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
205
+
206
+ const queryClient = new QueryClient({
207
+ defaultOptions: {
208
+ queries: {
209
+ staleTime: 60 * 1000, // 1 minute
210
+ refetchOnWindowFocus: false,
211
+ },
212
+ },
213
+ });
214
+
215
+ function App() {
216
+ return (
217
+ <QueryClientProvider client={queryClient}>
218
+ <YourApp />
219
+ <ReactQueryDevtools initialIsOpen={false} />
220
+ </QueryClientProvider>
221
+ );
222
+ }
223
+ ```
342
224
 
343
- Fetches metric data by ID.
225
+ ### Boilerplate Integration
344
226
 
345
- **Parameters:**
346
- - `metricId`: ID of the metric
347
- - `options` (optional): Query options
227
+ For projects using the Bluecopa React boilerplate, use the pre-configured `QueryProvider` component that handles API configuration automatically:
348
228
 
349
- **Returns:**
350
- - `data`: Metric object with name and value
351
- - `isLoading`: Boolean indicating loading state
352
- - `error`: Error object if request failed
353
- - `refetch`: Function to manually trigger refetch
229
+ ```tsx
230
+ // src/providers/query-provider.tsx
231
+ import { ReactQueryDevtools, reactQuery, copaSetConfig } from "@bluecopa/react";
232
+ import { useEffect, useState } from "react";
233
+
234
+ const { QueryClient, QueryClientProvider } = reactQuery;
235
+
236
+ export default function QueryProvider({ children }: { children: React.ReactNode }) {
237
+ const [queryClient] = useState(() => new QueryClient({
238
+ defaultOptions: {
239
+ queries: {
240
+ staleTime: 60 * 1000, // 1 minute
241
+ refetchOnWindowFocus: false,
242
+ },
243
+ },
244
+ }));
245
+
246
+ useEffect(() => {
247
+ let copaUser: any = {};
248
+ try {
249
+ const copaToken = import.meta.env.VITE_BLUECOPA_API_TOKEN
250
+ ? atob(import.meta.env.VITE_BLUECOPA_API_TOKEN)
251
+ : "{}";
252
+
253
+ copaUser = JSON.parse(copaToken);
254
+ } catch (error) {
255
+ console.warn("Failed to parse VITE_BLUECOPA_API_TOKEN:", error);
256
+ }
257
+
258
+ copaSetConfig({
259
+ apiBaseUrl: import.meta.env.VITE_BLUECOPA_API_URL || "https://develop.bluecopa.com/api/v1",
260
+ workspaceId: import.meta.env.VITE_BLUECOPA_WORKSPACE_ID || "",
261
+ accessToken: copaUser?.accessToken || "",
262
+ });
263
+ }, []);
354
264
 
355
- ### `useInputTable(inputTableId, options?)`
265
+ return (
266
+ <QueryClientProvider client={queryClient}>
267
+ {children}
268
+ <ReactQueryDevtools initialIsOpen={false} />
269
+ </QueryClientProvider>
270
+ );
271
+ }
272
+ ```
356
273
 
357
- Fetches input table data with limit parameters.
274
+ **Required Environment Variables:**
358
275
 
359
- **Parameters:**
360
- - `inputTableId`: ID of the input table
361
- - `options` (optional): Query options with `limitParams`:
362
- - `limit`: Maximum rows to fetch
363
- - `limitFrom`: Direction to apply limit from ('top' or 'bottom')
276
+ | Variable | Description | Example |
277
+ |----------|-------------|---------|
278
+ | `VITE_BLUECOPA_API_URL` | Base URL for Bluecopa API | `https://develop.bluecopa.com` |
279
+ | `VITE_BLUECOPA_WORKSPACE_ID` | Your workspace identifier | `my-workspace-123` |
280
+ | `VITE_BLUECOPA_API_TOKEN` | Base64-encoded JSON string containing `accessToken` | `eyJhY2Nlc3NUb2tlbiI6IjEyMzQ1In0=` |
364
281
 
365
- **Returns:**
366
- - `data`: Input table object with rows
367
- - `isLoading`: Boolean indicating loading state
368
- - `error`: Error object if request failed
369
- - `refetch`: Function to manually trigger refetch
282
+ **Example `.env` file:**
283
+ ```
284
+ VITE_BLUECOPA_API_URL=https://develop.bluecopa.com
285
+ VITE_BLUECOPA_WORKSPACE_ID=your-workspace-id
286
+ VITE_BLUECOPA_API_TOKEN=base64-encoded-json-here
287
+ ```
370
288
 
371
- ### `useGetFileUrlByFileId(fileId, options?)`
289
+ Then wrap your application with this provider:
372
290
 
373
- Fetches the URL for a file by its ID.
291
+ ```tsx
292
+ import QueryProvider from './providers/query-provider';
374
293
 
375
- **Parameters:**
376
- - `fileId`: ID of the file to fetch URL for
377
- - `options` (optional): Query options extending TanStack React Query's `UseQueryOptions`
294
+ function App() {
295
+ return (
296
+ <QueryProvider>
297
+ <YourApp />
298
+ </QueryProvider>
299
+ );
300
+ }
301
+ ```
378
302
 
379
- **Returns:**
380
- - `data`: Object containing file URL
381
- - `isLoading`: Boolean indicating loading state
382
- - `error`: Error object if request failed
383
- - `refetch`: Function to manually trigger refetch
303
+ This setup automatically configures the API client with your environment-specific settings and applies optimal caching defaults.
384
304
 
385
- ### `useGetPublishedWorkbookById(workbookId, options?)`
305
+ ### Hook Examples
386
306
 
387
- Fetches published workbook details by ID.
307
+ #### `useUser` - Fetch authenticated user
388
308
 
389
- **Parameters:**
390
- - `workbookId`: ID of the published workbook
391
- - `options` (optional): Query options
309
+ ```tsx
310
+ import { useUser } from '@bluecopa/react';
311
+
312
+ function UserProfile() {
313
+ const { data, isLoading, error } = useUser({
314
+ staleTime: 5 * 60 * 1000, // 5 minutes
315
+ retry: 2
316
+ });
317
+
318
+ if (isLoading) return <div>Loading...</div>;
319
+ if (error) return <div>Error: {error.message}</div>;
320
+
321
+ return <div>Welcome, {data?.name}!</div>;
322
+ }
323
+ ```
392
324
 
393
- **Returns:**
394
- - `data`: Published workbook object
395
- - `isLoading`: Boolean indicating loading state
396
- - `error`: Error object if request failed
397
- - `refetch`: Function to manually trigger refetch
325
+ #### `useDataset` - Fetch dataset with query controls
398
326
 
399
- ### `useGetTableById(tableId, options?)`
327
+ ```tsx
328
+ import { useDataset } from '@bluecopa/react';
329
+
330
+ function DatasetViewer({ datasetId }) {
331
+ const { data, isLoading } = useDataset(datasetId, {
332
+ limit: 500,
333
+ staleTime: 10 * 60 * 1000 // 10 minutes
334
+ });
335
+
336
+ if (isLoading) return <div>Loading dataset...</div>;
337
+ return <div>{data?.name} ({data?.records?.length} records)</div>;
338
+ }
339
+ ```
400
340
 
401
- Fetches table metadata by ID.
341
+ ## API Documentation
402
342
 
403
- **Parameters:**
404
- - `tableId`: ID of the table
405
- - `options` (optional): Query options
343
+ ### `useUser(options?)`
406
344
 
407
- **Returns:**
408
- - `data`: Table metadata object
409
- - `isLoading`: Boolean indicating loading state
410
- - `error`: Error object if request failed
411
- - `refetch`: Function to manually trigger refetch
345
+ Fetches authenticated user details with query controls.
412
346
 
413
- ### `useGetWorkbooksByType(workbookType, options?)`
347
+ **Parameters:**
348
+ - `options` (optional): Query options extending TanStack React Query's `UseQueryOptions`
414
349
 
415
- Fetches workbooks filtered by type.
350
+ **Returns:**
351
+ - `data`: User object or `undefined`
352
+ - `isLoading`: Boolean indicating loading state
353
+ - `error`: Error object if request failed
354
+ - `refetch`: Function to manually trigger refetch
416
355
 
417
- **Parameters:**
418
- - `workbookType`: Type of workbooks to fetch
419
- - `options` (optional): Query options
356
+ ### `useDataset(datasetId, options?)`
420
357
 
421
- **Returns:**
422
- - `data`: Array of workbook objects
423
- - `isLoading`: Boolean indicating loading state
424
- - `error`: Error object if request failed
425
- - `refetch`: Function to manually trigger refetch
358
+ Fetches dataset data by ID with configurable parameters.
426
359
 
427
- ### `useGetWorkflowInstanceStatusById(instanceId, options?)`
360
+ **Parameters:**
361
+ - `datasetId`: ID of the dataset to fetch
362
+ - `options` (optional): Query options with:
363
+ - `limit`: Maximum records to fetch
364
+ - `staleTime`: Duration (ms) before data is considered stale
428
365
 
429
- Fetches workflow instance status by ID.
366
+ **Returns:**
367
+ - `data`: Dataset object containing name and records
368
+ - `isLoading`: Boolean indicating loading state
369
+ - `error`: Error object if request failed
370
+ - `refetch`: Function to manually trigger refetch
430
371
 
431
- **Parameters:**
432
- - `instanceId`: ID of the workflow instance
433
- - `options` (optional): Query options
372
+ ### `useDatasetSample(datasetId, options?)`
434
373
 
435
- **Returns:**
436
- - `data`: Workflow status object
437
- - `isLoading`: Boolean indicating loading state
438
- - `error`: Error object if request failed
439
- - `refetch`: Function to manually trigger refetch
374
+ Fetches a representative sample of dataset data.
440
375
 
441
- ### `useGetWorksheets(options?)`
376
+ **Parameters:**
377
+ - `datasetId`: ID of the dataset
378
+ - `options` (optional): Query options with `enabled` flag
442
379
 
443
- Fetches all available worksheets.
380
+ **Returns:**
381
+ - `data`: Object containing sample data
382
+ - `isLoading`: Boolean indicating loading state
383
+ - `refetch`: Function to manually trigger refetch
444
384
 
445
- **Parameters:**
446
- - `options` (optional): Query options
385
+ ### `useMetric(metricId, options?)`
447
386
 
448
- **Returns:**
449
- - `data`: Array of worksheet objects
450
- - `isLoading`: Boolean indicating loading state
451
- - `error`: Error object if request failed
452
- - `refetch`: Function to manually trigger refetch
387
+ Fetches metric data by ID.
453
388
 
454
- ### `useGetWorksheetsByType(worksheetType, options?)`
389
+ **Parameters:**
390
+ - `metricId`: ID of the metric
391
+ - `options` (optional): Query options
455
392
 
456
- Fetches worksheets filtered by type.
393
+ **Returns:**
394
+ - `data`: Metric object with name and value
395
+ - `isLoading`: Boolean indicating loading state
396
+ - `error`: Error object if request failed
397
+ - `refetch`: Function to manually trigger refetch
457
398
 
458
- **Parameters:**
459
- - `worksheetType`: Type of worksheets to fetch
460
- - `options` (optional): Query options
399
+ ### `useInputTable(inputTableId, options?)`
461
400
 
462
- **Returns:**
463
- - `data`: Array of worksheet objects
464
- - `isLoading`: Boolean indicating loading state
465
- - `error`: Error object if request failed
466
- - `refetch`: Function to manually trigger refetch
401
+ Fetches input table data with limit parameters.
467
402
 
468
- ### `useRunDefinition(definitionId, options?)`
403
+ **Parameters:**
404
+ - `inputTableId`: ID of the input table
405
+ - `options` (optional): Query options with `limitParams`:
406
+ - `limit`: Maximum rows to fetch
407
+ - `limitFrom`: Direction to apply limit from ('top' or 'bottom')
469
408
 
470
- Executes a run definition.
409
+ **Returns:**
410
+ - `data`: Input table object with rows
411
+ - `isLoading`: Boolean indicating loading state
412
+ - `error`: Error object if request failed
413
+ - `refetch`: Function to manually trigger refetch
471
414
 
472
- **Parameters:**
473
- - `definitionId`: ID of the run definition
474
- - `options` (optional): Query options
415
+ ### `useGetFileUrlByFileId(fileId, options?)`
475
416
 
476
- **Returns:**
477
- - `data`: Execution result
478
- - `isLoading`: Boolean indicating loading state
479
- - `error`: Error object if request failed
480
- - `refetch`: Function to manually trigger refetch
417
+ Fetches the URL for a file by its ID.
481
418
 
482
- ### `useRunPublishedDefinition(publishedDefinitionId, options?)`
419
+ **Parameters:**
420
+ - `fileId`: ID of the file to fetch URL for
421
+ - `options` (optional): Query options extending TanStack React Query's `UseQueryOptions`
483
422
 
484
- Executes a published run definition.
423
+ **Returns:**
424
+ - `data`: Object containing file URL
425
+ - `isLoading`: Boolean indicating loading state
426
+ - `error`: Error object if request failed
427
+ - `refetch`: Function to manually trigger refetch
485
428
 
486
- **Parameters:**
487
- - `publishedDefinitionId`: ID of the published definition
488
- - `options` (optional): Query options
429
+ ### `useGetPublishedWorkbookById(workbookId, options?)`
489
430
 
490
- **Returns:**
491
- - `data`: Execution result
492
- - `isLoading`: Boolean indicating loading state
493
- - `error`: Error object if request failed
494
- - `refetch`: Function to manually trigger refetch
431
+ Fetches published workbook details by ID.
495
432
 
496
- ### `useRunSampleDefinition(sampleDefinitionId, options?)`
433
+ **Parameters:**
434
+ - `workbookId`: ID of the published workbook
435
+ - `options` (optional): Query options
497
436
 
498
- Executes a sample run definition.
437
+ **Returns:**
438
+ - `data`: Published workbook object
439
+ - `isLoading`: Boolean indicating loading state
440
+ - `error`: Error object if request failed
441
+ - `refetch`: Function to manually trigger refetch
499
442
 
500
- **Parameters:**
501
- - `sampleDefinitionId`: ID of the sample definition
502
- - `options` (optional): Query options
443
+ ### `useGetTableById(tableId, options?)`
503
444
 
504
- **Returns:**
505
- - `data`: Sample execution result
506
- - `isLoading`: Boolean indicating loading state
507
- - `error`: Error object if request failed
508
- - `refetch`: Function to manually trigger refetch
445
+ Fetches table metadata by ID.
509
446
 
510
- ### `useTriggerHttpWorkflow(workflowId, payload, options?)`
447
+ **Parameters:**
448
+ - `tableId`: ID of the table
449
+ - `options` (optional): Query options
511
450
 
512
- Triggers an HTTP workflow execution.
451
+ **Returns:**
452
+ - `data`: Table metadata object
453
+ - `isLoading`: Boolean indicating loading state
454
+ - `error`: Error object if request failed
455
+ - `refetch`: Function to manually trigger refetch
513
456
 
514
- **Parameters:**
515
- - `workflowId`: ID of the workflow
516
- - `payload`: Request payload
517
- - `options` (optional): Query options
457
+ ### `useGetWorkbooksByType(workbookType, options?)`
518
458
 
519
- **Returns:**
520
- - `data`: Workflow execution response
521
- - `isLoading`: Boolean indicating loading state
522
- - `error`: Error object if request failed
523
- - `refetch`: Function to manually trigger refetch
459
+ Fetches workbooks filtered by type.
524
460
 
525
- ### `useTriggerWorkflow(workflowId, options?)`
461
+ **Parameters:**
462
+ - `workbookType`: Type of workbooks to fetch
463
+ - `options` (optional): Query options
526
464
 
527
- Triggers a workflow execution.
465
+ **Returns:**
466
+ - `data`: Array of workbook objects
467
+ - `isLoading`: Boolean indicating loading state
468
+ - `error`: Error object if request failed
469
+ - `refetch`: Function to manually trigger refetch
528
470
 
529
- **Parameters:**
530
- - `workflowId`: ID of the workflow
531
- - `options` (optional): Query options
471
+ ### `useGetWorkflowInstanceStatusById(instanceId, options?)`
532
472
 
533
- **Returns:**
534
- - `data`: Workflow execution response
535
- - `isLoading`: Boolean indicating loading state
536
- - `error`: Error object if request failed
537
- - `refetch`: Function to manually trigger refetch
473
+ Fetches workflow instance status by ID.
538
474
 
539
- ### `useWorkbook(workbookId, options?)`
475
+ **Parameters:**
476
+ - `instanceId`: ID of the workflow instance
477
+ - `options` (optional): Query options
540
478
 
541
- Fetches workbook details by ID.
479
+ **Returns:**
480
+ - `data`: Workflow status object
481
+ - `isLoading`: Boolean indicating loading state
482
+ - `error`: Error object if request failed
483
+ - `refetch`: Function to manually trigger refetch
542
484
 
543
- **Parameters:**
544
- - `workbookId`: ID of the workbook
545
- - `options` (optional): Query options
485
+ ### `useGetWorksheets(options?)`
546
486
 
547
- **Returns:**
548
- - `data`: Workbook object
549
- - `isLoading`: Boolean indicating loading state
550
- - `error`: Error object if request failed
551
- - `refetch`: Function to manually trigger refetch
487
+ Fetches all available worksheets.
552
488
 
553
- ### `useWorkflow(workflowId, options?)`
489
+ **Parameters:**
490
+ - `options` (optional): Query options
554
491
 
555
- Fetches workflow configuration by ID.
492
+ **Returns:**
493
+ - `data`: Array of worksheet objects
494
+ - `isLoading`: Boolean indicating loading state
495
+ - `error`: Error object if request failed
496
+ - `refetch`: Function to manually trigger refetch
556
497
 
557
- **Parameters:**
558
- - `workflowId`: ID of the workflow
559
- - `options` (optional): Query options
498
+ ### `useGetWorksheetsByType(worksheetType, options?)`
560
499
 
561
- **Returns:**
562
- - `data`: Workflow configuration object
563
- - `isLoading`: Boolean indicating loading state
564
- - `error`: Error object if request failed
565
- - `refetch`: Function to manually trigger refetch
500
+ Fetches worksheets filtered by type.
566
501
 
567
- ### `useWorksheet(worksheetId, options?)`
502
+ **Parameters:**
503
+ - `worksheetType`: Type of worksheets to fetch
504
+ - `options` (optional): Query options
568
505
 
569
- Fetches worksheet details by ID.
506
+ **Returns:**
507
+ - `data`: Array of worksheet objects
508
+ - `isLoading`: Boolean indicating loading state
509
+ - `error`: Error object if request failed
510
+ - `refetch`: Function to manually trigger refetch
570
511
 
571
- **Parameters:**
572
- - `worksheetId`: ID of the worksheet
573
- - `options` (optional): Query options
512
+ ### `useRunDefinition(definitionId, options?)`
574
513
 
575
- **Returns:**
576
- - `data`: Worksheet object
577
- - `isLoading`: Boolean indicating loading state
578
- - `error`: Error object if request failed
579
- - `refetch`: Function to manually trigger refetch
514
+ Executes a run definition.
580
515
 
581
-
582
- ## Configuration
583
-
584
- ### Default Query Configuration
585
-
586
- ```tsx
587
- const queryClient = new QueryClient({
588
- defaultOptions: {
589
- queries: {
590
- retry: 3,
591
- staleTime: 1000 * 60 * 5, // 5 minutes
592
- gcTime: 1000 * 60 * 10, // 10 minutes
593
- },
594
- },
595
- });
596
- ```
597
-
598
- ### Customizable Parameters
599
-
600
- All hooks accept standard TanStack React Query options:
601
-
602
- ```ts
603
- interface QueryOptions {
604
- enabled?: boolean; // Enable/disable query
605
- staleTime?: number; // Duration (ms) before data is stale
606
- gcTime?: number; // Duration (ms) to keep data in cache
607
- retry?: number | boolean; // Number of retries or disable retries
608
- onSuccess?: (data: any) => void; // Success callback
609
- onError?: (error: Error) => void; // Error callback
610
- }
611
- ```
612
-
613
- ## Advanced Usage
614
-
615
- ### Error Handling
616
-
617
- ```tsx
618
- useUser({
619
- onError: (error) => {
620
- console.error('User fetch failed:', error.message);
621
- // Custom error recovery logic
622
- }
623
- });
624
- ```
625
-
626
- ### Manual Refetching
627
-
628
- ```tsx
629
- function ManualRefetch() {
630
- const { data, refetch } = useUser();
631
-
632
- return (
633
- <div>
634
- <button onClick={() => refetch()}>Refresh</button>
635
- </div>
636
- );
637
- }
638
- ```
639
-
640
- ## Re-exports
641
-
642
- This package re-exports core TanStack React Query utilities:
643
-
644
- ```ts
645
- import {
646
- useQuery,
647
- useMutation,
648
- QueryClient,
649
- QueryClientProvider,
650
- ReactQueryDevtools
651
- } from '@bluecopa/react';
652
- ```
516
+ **Parameters:**
517
+ - `definitionId`: ID of the run definition
518
+ - `options` (optional): Query options
519
+
520
+ **Returns:**
521
+ - `data`: Execution result
522
+ - `isLoading`: Boolean indicating loading state
523
+ - `error`: Error object if request failed
524
+ - `refetch`: Function to manually trigger refetch
525
+
526
+ ### `useRunPublishedDefinition(publishedDefinitionId, options?)`
527
+
528
+ Executes a published run definition.
529
+
530
+ **Parameters:**
531
+ - `publishedDefinitionId`: ID of the published definition
532
+ - `options` (optional): Query options
533
+
534
+ **Returns:**
535
+ - `data`: Execution result
536
+ - `isLoading`: Boolean indicating loading state
537
+ - `error`: Error object if request failed
538
+ - `refetch`: Function to manually trigger refetch
539
+
540
+ ### `useRunSampleDefinition(sampleDefinitionId, options?)`
541
+
542
+ Executes a sample run definition.
543
+
544
+ **Parameters:**
545
+ - `sampleDefinitionId`: ID of the sample definition
546
+ - `options` (optional): Query options
547
+
548
+ **Returns:**
549
+ - `data`: Sample execution result
550
+ - `isLoading`: Boolean indicating loading state
551
+ - `error`: Error object if request failed
552
+ - `refetch`: Function to manually trigger refetch
553
+
554
+ ### `useTriggerHttpWorkflow(workflowId, payload, options?)`
555
+
556
+ Triggers an HTTP workflow execution.
557
+
558
+ **Parameters:**
559
+ - `workflowId`: ID of the workflow
560
+ - `payload`: Request payload
561
+ - `options` (optional): Query options
562
+
563
+ **Returns:**
564
+ - `data`: Workflow execution response
565
+ - `isLoading`: Boolean indicating loading state
566
+ - `error`: Error object if request failed
567
+ - `refetch`: Function to manually trigger refetch
568
+
569
+ ### `useTriggerWorkflow(workflowId, options?)`
570
+
571
+ Triggers a workflow execution.
572
+
573
+ **Parameters:**
574
+ - `workflowId`: ID of the workflow
575
+ - `options` (optional): Query options
576
+
577
+ **Returns:**
578
+ - `data`: Workflow execution response
579
+ - `isLoading`: Boolean indicating loading state
580
+ - `error`: Error object if request failed
581
+ - `refetch`: Function to manually trigger refetch
582
+
583
+ ### `useWorkbook(workbookId, options?)`
584
+
585
+ Fetches workbook details by ID.
586
+
587
+ **Parameters:**
588
+ - `workbookId`: ID of the workbook
589
+ - `options` (optional): Query options
590
+
591
+ **Returns:**
592
+ - `data`: Workbook object
593
+ - `isLoading`: Boolean indicating loading state
594
+ - `error`: Error object if request failed
595
+ - `refetch`: Function to manually trigger refetch
596
+
597
+ ### `useWorkflow(workflowId, options?)`
598
+
599
+ Fetches workflow configuration by ID.
600
+
601
+ **Parameters:**
602
+ - `workflowId`: ID of the workflow
603
+ - `options` (optional): Query options
604
+
605
+ **Returns:**
606
+ - `data`: Workflow configuration object
607
+ - `isLoading`: Boolean indicating loading state
608
+ - `error`: Error object if request failed
609
+ - `refetch`: Function to manually trigger refetch
610
+
611
+ ### `useWorksheet(worksheetId, options?)`
612
+
613
+ Fetches worksheet details by ID.
614
+
615
+ **Parameters:**
616
+ - `worksheetId`: ID of the worksheet
617
+ - `options` (optional): Query options
618
+
619
+ **Returns:**
620
+ - `data`: Worksheet object
621
+ - `isLoading`: Boolean indicating loading state
622
+ - `error`: Error object if request failed
623
+ - `refetch`: Function to manually trigger refetch
624
+
625
+
626
+ ## Configuration
627
+
628
+ ### Default Query Configuration
629
+
630
+ ```tsx
631
+ const queryClient = new QueryClient({
632
+ defaultOptions: {
633
+ queries: {
634
+ retry: 3,
635
+ staleTime: 1000 * 60 * 5, // 5 minutes
636
+ gcTime: 1000 * 60 * 10, // 10 minutes
637
+ },
638
+ },
639
+ });
640
+ ```
641
+
642
+ ### Customizable Parameters
643
+
644
+ All hooks accept standard TanStack React Query options:
645
+
646
+ ```ts
647
+ interface QueryOptions {
648
+ enabled?: boolean; // Enable/disable query
649
+ staleTime?: number; // Duration (ms) before data is stale
650
+ gcTime?: number; // Duration (ms) to keep data in cache
651
+ retry?: number | boolean; // Number of retries or disable retries
652
+ onSuccess?: (data: any) => void; // Success callback
653
+ onError?: (error: Error) => void; // Error callback
654
+ }
655
+ ```
656
+
657
+ ## Advanced Usage
658
+
659
+ ### Error Handling
660
+
661
+ ```tsx
662
+ useUser({
663
+ onError: (error) => {
664
+ console.error('User fetch failed:', error.message);
665
+ // Custom error recovery logic
666
+ }
667
+ });
668
+ ```
669
+
670
+ ### Manual Refetching
671
+
672
+ ```tsx
673
+ function ManualRefetch() {
674
+ const { data, refetch } = useUser();
675
+
676
+ return (
677
+ <div>
678
+ <button onClick={() => refetch()}>Refresh</button>
679
+ </div>
680
+ );
681
+ }
682
+ ```
683
+
684
+ ## Re-exports
685
+
686
+ This package re-exports core TanStack React Query utilities:
687
+
688
+ ```ts
689
+ import {
690
+ useQuery,
691
+ useMutation,
692
+ QueryClient,
693
+ QueryClientProvider,
694
+ ReactQueryDevtools
695
+ } from '@bluecopa/react';
696
+ ```
653
697
 
654
698
  ### Styling Guidelines
655
699
  - Use Tailwind CSS classes