@tetrascience-npm/tetrascience-react-ui 0.3.0 → 0.4.0-beta.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -9,6 +9,12 @@ This library provides:
9
9
  - **Theming**: Customisable design system with ThemeProvider
10
10
  - **TypeScript**: Full type support with exported prop types
11
11
 
12
+ ## Requirements
13
+
14
+ - **React 19+**
15
+ - **Node.js 18+**
16
+ - **TypeScript 5.5+** (optional, but recommended)
17
+
12
18
  ## Installation
13
19
 
14
20
  ```bash
@@ -103,6 +109,102 @@ const token = await jwtManager.getUserToken(req.cookies);
103
109
 
104
110
  > **Note:** The singleton `jwtManager` reads environment variables when the module is imported. Ensure these are set before importing the module.
105
111
 
112
+ ### Data App Providers (`server/providers`)
113
+
114
+ TypeScript equivalents of the Python helpers from `ts-lib-ui-kit-streamlit` for connecting to database providers (Snowflake, Databricks, Athena).
115
+
116
+ **Getting Provider Configurations:**
117
+
118
+ ```typescript
119
+ import { TDPClient } from '@tetrascience-npm/ts-connectors-sdk';
120
+ import {
121
+ getProviderConfigurations,
122
+ buildProvider,
123
+ jwtManager,
124
+ } from '@tetrascience-npm/tetrascience-react-ui/server';
125
+
126
+ // Get user's auth token from request (e.g., in Express middleware)
127
+ const userToken = await jwtManager.getTokenFromExpressRequest(req);
128
+
129
+ // Create TDPClient with the user's auth token
130
+ const client = new TDPClient({
131
+ authToken: userToken,
132
+ artifactType: 'data-app',
133
+ orgSlug: process.env.ORG_SLUG,
134
+ });
135
+ await client.init();
136
+
137
+ // Get all configured providers for this data app
138
+ const providers = await getProviderConfigurations(client);
139
+
140
+ for (const config of providers) {
141
+ console.log(`Provider: ${config.name} (${config.type})`);
142
+
143
+ // Build a database connection from the config
144
+ const provider = await buildProvider(config);
145
+ const results = await provider.query('SELECT * FROM my_table LIMIT 10');
146
+ await provider.close();
147
+ }
148
+ ```
149
+
150
+ **Using Specific Providers:**
151
+
152
+ ```typescript
153
+ import {
154
+ buildSnowflakeProvider,
155
+ buildDatabricksProvider,
156
+ getTdpAthenaProvider,
157
+ type ProviderConfiguration,
158
+ } from '@tetrascience-npm/tetrascience-react-ui/server';
159
+
160
+ // Snowflake
161
+ const snowflakeProvider = await buildSnowflakeProvider(config);
162
+ const data = await snowflakeProvider.query('SELECT * FROM users');
163
+ await snowflakeProvider.close();
164
+
165
+ // Databricks
166
+ const databricksProvider = await buildDatabricksProvider(config);
167
+ const data = await databricksProvider.query('SELECT * FROM events');
168
+ await databricksProvider.close();
169
+
170
+ // TDP Athena (uses environment configuration)
171
+ const athenaProvider = await getTdpAthenaProvider();
172
+ const data = await athenaProvider.query('SELECT * FROM files');
173
+ await athenaProvider.close();
174
+ ```
175
+
176
+ **Exception Handling:**
177
+
178
+ ```typescript
179
+ import {
180
+ QueryError,
181
+ MissingTableError,
182
+ ProviderConnectionError,
183
+ InvalidProviderConfigurationError,
184
+ } from '@tetrascience-npm/tetrascience-react-ui/server';
185
+
186
+ try {
187
+ const results = await provider.query('SELECT * FROM missing_table');
188
+ } catch (error) {
189
+ if (error instanceof MissingTableError) {
190
+ console.error('Table not found:', error.message);
191
+ } else if (error instanceof QueryError) {
192
+ console.error('Query failed:', error.message);
193
+ }
194
+ }
195
+ ```
196
+
197
+ **Environment Variables:**
198
+
199
+ - `DATA_APP_PROVIDER_CONFIG` - JSON override for local development only
200
+ - `CONNECTOR_ID` - Connector ID for fetching providers from TDP
201
+ - `TDP_ENDPOINT` - TDP API base URL
202
+ - `ORG_SLUG` - Organization slug
203
+ - `ATHENA_S3_OUTPUT_LOCATION` - S3 bucket for Athena query results
204
+ - `AWS_REGION` - AWS region for Athena
205
+
206
+ > **Note:** Authentication tokens are obtained from the user's JWT via `jwtManager`. The `TS_AUTH_TOKEN` environment variable is only for local development fallback.
207
+
106
208
  ## TypeScript Support
107
209
 
108
210
  Full TypeScript support with exported types:
@@ -118,8 +220,8 @@ The repository includes example applications in the `examples/` directory:
118
220
 
119
221
  ```bash
120
222
  # Clone the repository
121
- git clone https://github.com/tetrascience/ts-lib-ui-kit-react.git
122
- cd ts-lib-ui-kit-react
223
+ git clone https://github.com/tetrascience/ts-lib-ui-kit.git
224
+ cd ts-lib-ui-kit
123
225
 
124
226
  # Install dependencies
125
227
  yarn
@@ -128,13 +230,13 @@ yarn
128
230
  yarn workspace vite-themed-app dev
129
231
  ```
130
232
 
131
- Visit http://localhost:5173 to see the example app with custom theming.
233
+ Visit <http://localhost:5173> to see the example app with custom theming.
132
234
 
133
235
  ## Documentation
134
236
 
135
- - [Getting Started Guide](https://github.com/tetrascience/ts-lib-ui-kit-react/blob/main/get_started_1.md) - Step-by-step tutorial
136
- - [Theming Guide](https://github.com/tetrascience/ts-lib-ui-kit-react/blob/main/THEMING.md) - Customise the design system
137
- - [Storybook](https://github.com/tetrascience/ts-lib-ui-kit-react/blob/main/DEVELOPERS.md#development-setup) - Clone the repo and run `yarn storybook`
237
+ - [Getting Started Guide](./get_started_1.md) - Step-by-step tutorial
238
+ - [Theming Guide](./THEMING.md) - Customise the design system
239
+ - [Contributing](./CONTRIBUTING.md#development-setup) - Clone the repo and run `yarn storybook`
138
240
 
139
241
  ## Tech Stack
140
242