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