@tetrascience-npm/tetrascience-react-ui 0.2.0 → 0.3.0

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
@@ -12,17 +12,17 @@ This library provides:
12
12
  ## Installation
13
13
 
14
14
  ```bash
15
- yarn add tetrascience-react-ui
15
+ yarn add @tetrascience-npm/tetrascience-react-ui
16
16
  ```
17
17
 
18
18
  ## Quick Start
19
19
 
20
20
  ```tsx
21
21
  // 1. Import the CSS (required)
22
- import 'tetrascience-react-ui/index.css';
22
+ import '@tetrascience-npm/tetrascience-react-ui/index.css';
23
23
 
24
24
  // 2. Import components
25
- import { Button, Card, BarGraph } from 'tetrascience-react-ui';
25
+ import { Button, Card, BarGraph } from '@tetrascience-npm/tetrascience-react-ui';
26
26
 
27
27
  function App() {
28
28
  return (
@@ -53,7 +53,7 @@ AppLayout, AreaGraph, BarGraph, Boxplot, Chromatogram, DotPlot, Heatmap, Histogr
53
53
  Customise colours, border radius, and spacing:
54
54
 
55
55
  ```tsx
56
- import { ThemeProvider } from 'tetrascience-react-ui';
56
+ import { ThemeProvider } from '@tetrascience-npm/tetrascience-react-ui';
57
57
 
58
58
  const customTheme = {
59
59
  colors: {
@@ -72,13 +72,44 @@ const customTheme = {
72
72
 
73
73
  See [THEMING.md](./THEMING.md) for the complete theming guide.
74
74
 
75
+ ## Server Utilities
76
+
77
+ Beyond UI components, this library includes server-side helper functions for building TetraScience applications. These are available via the `/server` subpath to avoid pulling Node.js dependencies into browser bundles.
78
+
79
+ ### Authentication (`server/auth`)
80
+
81
+ **JWT Token Manager** - Manages JWT token retrieval for data apps:
82
+
83
+ ```typescript
84
+ import { jwtManager } from '@tetrascience-npm/tetrascience-react-ui/server';
85
+
86
+ // In Express middleware
87
+ app.use(async (req, res, next) => {
88
+ const token = await jwtManager.getTokenFromExpressRequest(req);
89
+ req.tdpAuth = { token, orgSlug: process.env.ORG_SLUG };
90
+ next();
91
+ });
92
+
93
+ // Or with raw cookies
94
+ const token = await jwtManager.getUserToken(req.cookies);
95
+ ```
96
+
97
+ **Environment Variables:**
98
+
99
+ - `ORG_SLUG` - Organization slug (required)
100
+ - `CONNECTOR_ID` - Connector ID for ts-token-ref flow
101
+ - `TDP_ENDPOINT` - API base URL
102
+ - `TS_AUTH_TOKEN` - Service account token (fallback for local dev)
103
+
104
+ > **Note:** The singleton `jwtManager` reads environment variables when the module is imported. Ensure these are set before importing the module.
105
+
75
106
  ## TypeScript Support
76
107
 
77
108
  Full TypeScript support with exported types:
78
109
 
79
110
  ```tsx
80
- import { Button } from 'tetrascience-react-ui';
81
- import type { ButtonProps, BarGraphProps, BarDataSeries } from 'tetrascience-react-ui';
111
+ import { Button } from '@tetrascience-npm/tetrascience-react-ui';
112
+ import type { ButtonProps, BarGraphProps, BarDataSeries } from '@tetrascience-npm/tetrascience-react-ui';
82
113
  ```
83
114
 
84
115
  ## Examples