@tetrascience-npm/tetrascience-react-ui 0.4.0-beta.2.1 → 0.4.0-beta.4.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 +22 -1
- package/dist/cjs/index.js +167 -166
- package/dist/cjs/index.js.map +1 -1
- package/dist/esm/index.js +87 -86
- package/dist/esm/index.js.map +1 -1
- package/dist/index.d.ts +137 -3
- package/dist/server.d.ts +12 -4
- package/package.json +2 -2
- package/src/styles/README.md +0 -56
package/README.md
CHANGED
|
@@ -127,10 +127,10 @@ import {
|
|
|
127
127
|
const userToken = await jwtManager.getTokenFromExpressRequest(req);
|
|
128
128
|
|
|
129
129
|
// Create TDPClient with the user's auth token
|
|
130
|
+
// Other fields (tdpEndpoint, connectorId, orgSlug) are read from environment variables
|
|
130
131
|
const client = new TDPClient({
|
|
131
132
|
authToken: userToken,
|
|
132
133
|
artifactType: 'data-app',
|
|
133
|
-
orgSlug: process.env.ORG_SLUG,
|
|
134
134
|
});
|
|
135
135
|
await client.init();
|
|
136
136
|
|
|
@@ -205,6 +205,27 @@ try {
|
|
|
205
205
|
|
|
206
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
207
|
|
|
208
|
+
### TDP Search (`server`)
|
|
209
|
+
|
|
210
|
+
**TdpSearchManager** - Server-side handler for the TdpSearch component. Resolves auth from request cookies (via `jwtManager`), calls TDP `searchEql`, and returns the response so the frontend hook works with minimal wiring.
|
|
211
|
+
|
|
212
|
+
```typescript
|
|
213
|
+
import { tdpSearchManager } from "@tetrascience-npm/tetrascience-react-ui/server";
|
|
214
|
+
|
|
215
|
+
// Express: mount a POST route (e.g. /api/search)
|
|
216
|
+
app.post("/api/search", express.json(), async (req, res) => {
|
|
217
|
+
try {
|
|
218
|
+
const body = req.body; // SearchEqlRequest (searchTerm, from, size, sort, order, ...)
|
|
219
|
+
const response = await tdpSearchManager.handleSearchRequest(req, body);
|
|
220
|
+
res.json(response);
|
|
221
|
+
} catch (err) {
|
|
222
|
+
res.status(401).json({ error: err instanceof Error ? err.message : "Search failed" });
|
|
223
|
+
}
|
|
224
|
+
});
|
|
225
|
+
```
|
|
226
|
+
|
|
227
|
+
Frontend: use `<TdpSearch columns={...} />` with default `apiEndpoint="/api/search"`, or pass `apiEndpoint` if you use a different path. Auth is taken from cookies (`ts-auth-token` or `ts-token-ref` via `jwtManager`).
|
|
228
|
+
|
|
208
229
|
## TypeScript Support
|
|
209
230
|
|
|
210
231
|
Full TypeScript support with exported types:
|