seeksphere-sdk 1.1.0 → 1.2.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.
Files changed (2) hide show
  1. package/LLM.md +299 -0
  2. package/package.json +3 -2
package/LLM.md ADDED
@@ -0,0 +1,299 @@
1
+ # SeekSphere SDK - AI Assistant Guide
2
+
3
+ This document provides AI assistants (like Claude, ChatGPT, etc.) with comprehensive information to help developers implement the SeekSphere SDK effectively.
4
+
5
+ ## Quick Implementation Guide
6
+
7
+ ### Installation
8
+ ```bash
9
+ npm install seeksphere-sdk
10
+ ```
11
+
12
+ ### Basic Setup
13
+ ```typescript
14
+ import { SeekSphereClient } from 'seeksphere-sdk';
15
+
16
+ const client = new SeekSphereClient({
17
+ apiKey: 'your-org-id-here', // This is your organization ID from SeekSphere dashboard
18
+ timeout: 30000 // Optional, defaults to 30 seconds
19
+ });
20
+ ```
21
+
22
+ ### Core Search Functionality
23
+ ```typescript
24
+ // Basic search (only public method available)
25
+ const result = await client.search({
26
+ query: 'show me all users from last month'
27
+ });
28
+
29
+ // Search with explicit mode (only 'sql_only' is currently supported)
30
+ const result = await client.search({
31
+ query: 'find top 10 products by sales'
32
+ }, 'sql_only');
33
+ ```
34
+
35
+ ## Key Implementation Details
36
+
37
+ ### 1. Configuration
38
+ - **No baseUrl needed**: The SDK uses a fixed base URL (`https://api.seeksphere.com`)
39
+ - **Only apiKey required**: This is your organization ID from the SeekSphere dashboard
40
+ - **Optional timeout**: Defaults to 30 seconds if not specified
41
+
42
+ ### 2. Search Modes
43
+ - **'sql_only'**: Currently supported (default)
44
+ - **'full'**: Coming soon - will throw error if used
45
+
46
+ ### 3. Private Methods Warning
47
+ The following methods are private and should NOT be used:
48
+ - `updateTokens()` - Use SeekSphere dashboard instead
49
+ - `updateSchema()` - Use SeekSphere dashboard instead
50
+ - `getTokens()` - Use SeekSphere dashboard instead
51
+ - `getSchema()` - Use SeekSphere dashboard instead
52
+
53
+ These methods are deprecated and may be removed in future versions.
54
+
55
+ ## Common Implementation Patterns
56
+
57
+ ### Error Handling
58
+ ```typescript
59
+ try {
60
+ const result = await client.search({
61
+ query: 'your search query here'
62
+ });
63
+ console.log('Search successful:', result);
64
+ } catch (error) {
65
+ if (error instanceof Error) {
66
+ console.error('Search failed:', error.message);
67
+ }
68
+ }
69
+ ```
70
+
71
+ ### TypeScript Types
72
+ ```typescript
73
+ import {
74
+ SeekSphereClient,
75
+ SearchRequest,
76
+ SearchResponse,
77
+ SearchMode
78
+ } from 'seeksphere-sdk';
79
+
80
+ // Request type
81
+ const request: SearchRequest = {
82
+ query: 'find all active users'
83
+ };
84
+
85
+ // Response type
86
+ const response: SearchResponse = await client.search(request);
87
+ ```
88
+
89
+ ### Environment Variables Pattern
90
+ ```typescript
91
+ // Recommended: Use environment variables
92
+ const client = new SeekSphereClient({
93
+ apiKey: process.env.SEEKSPHERE_ORG_ID || 'fallback-org-id',
94
+ timeout: parseInt(process.env.SEEKSPHERE_TIMEOUT || '30000')
95
+ });
96
+ ```
97
+
98
+ ## Response Structure
99
+
100
+ ### Successful Search Response
101
+ ```typescript
102
+ {
103
+ success: boolean;
104
+ org_id: string;
105
+ mode: string;
106
+ user_id: string;
107
+ // Additional response data varies based on query
108
+ [key: string]: any;
109
+ }
110
+ ```
111
+
112
+ ### Error Handling
113
+ The SDK automatically handles and formats errors:
114
+ - **API Errors**: `API Error: {status} - {message}`
115
+ - **Network Errors**: `Network Error: No response received from server`
116
+ - **Request Errors**: `Request Error: {message}`
117
+
118
+ ## Best Practices for AI Assistants
119
+
120
+ ### When Helping Developers:
121
+
122
+ 1. **Always use the public search method only**
123
+ - Never suggest using private methods (updateTokens, updateSchema, etc.)
124
+ - Direct users to the SeekSphere dashboard for configuration
125
+
126
+ 2. **Configuration guidance**:
127
+ - Emphasize that no baseUrl is needed
128
+ - apiKey is the organization ID from their dashboard
129
+ - Suggest using environment variables for the API key
130
+
131
+ 3. **Error handling**:
132
+ - Always wrap search calls in try-catch blocks
133
+ - Show proper error message extraction
134
+
135
+ 4. **Search mode guidance**:
136
+ - Default to 'sql_only' mode
137
+ - Warn that 'full' mode will throw an error (coming soon)
138
+
139
+ ### Code Examples to Provide
140
+
141
+ #### Basic Implementation
142
+ ```typescript
143
+ import { SeekSphereClient } from 'seeksphere-sdk';
144
+
145
+ const client = new SeekSphereClient({
146
+ apiKey: process.env.SEEKSPHERE_ORG_ID!
147
+ });
148
+
149
+ async function searchData(query: string) {
150
+ try {
151
+ const result = await client.search({ query });
152
+ return result;
153
+ } catch (error) {
154
+ console.error('Search failed:', error);
155
+ throw error;
156
+ }
157
+ }
158
+ ```
159
+
160
+ #### With Custom Timeout
161
+ ```typescript
162
+ const client = new SeekSphereClient({
163
+ apiKey: 'your-org-id',
164
+ timeout: 60000 // 60 seconds for complex queries
165
+ });
166
+ ```
167
+
168
+ #### Multiple Searches
169
+ ```typescript
170
+ async function performMultipleSearches() {
171
+ const queries = [
172
+ 'show recent orders',
173
+ 'find top customers',
174
+ 'get product analytics'
175
+ ];
176
+
177
+ const results = await Promise.all(
178
+ queries.map(query => client.search({ query }))
179
+ );
180
+
181
+ return results;
182
+ }
183
+ ```
184
+
185
+ ## Common Issues and Solutions
186
+
187
+ ### Issue: "baseUrl does not exist in type SDKConfig"
188
+ **Solution**: Remove baseUrl from configuration - it's now fixed internally.
189
+
190
+ ### Issue: "SearchMode 'full' is coming soon"
191
+ **Solution**: Use 'sql_only' mode or omit the mode parameter (defaults to 'sql_only').
192
+
193
+ ### Issue: Cannot access updateTokens/updateSchema methods
194
+ **Solution**: These are now private. Direct users to the SeekSphere dashboard for token and schema management.
195
+
196
+ ### Issue: Network timeouts
197
+ **Solution**: Increase the timeout in the configuration or optimize the search query.
198
+
199
+ ## Integration Examples
200
+
201
+ ### Express.js API
202
+ ```typescript
203
+ import express from 'express';
204
+ import { SeekSphereClient } from 'seeksphere-sdk';
205
+
206
+ const app = express();
207
+ const client = new SeekSphereClient({
208
+ apiKey: process.env.SEEKSPHERE_ORG_ID!
209
+ });
210
+
211
+ app.post('/search', async (req, res) => {
212
+ try {
213
+ const { query } = req.body;
214
+ const result = await client.search({ query });
215
+ res.json(result);
216
+ } catch (error) {
217
+ res.status(500).json({
218
+ error: error instanceof Error ? error.message : 'Search failed'
219
+ });
220
+ }
221
+ });
222
+ ```
223
+
224
+ ### Next.js API Route
225
+ ```typescript
226
+ // pages/api/search.ts
227
+ import { NextApiRequest, NextApiResponse } from 'next';
228
+ import { SeekSphereClient } from 'seeksphere-sdk';
229
+
230
+ const client = new SeekSphereClient({
231
+ apiKey: process.env.SEEKSPHERE_ORG_ID!
232
+ });
233
+
234
+ export default async function handler(req: NextApiRequest, res: NextApiResponse) {
235
+ if (req.method !== 'POST') {
236
+ return res.status(405).json({ error: 'Method not allowed' });
237
+ }
238
+
239
+ try {
240
+ const { query } = req.body;
241
+ const result = await client.search({ query });
242
+ res.status(200).json(result);
243
+ } catch (error) {
244
+ res.status(500).json({
245
+ error: error instanceof Error ? error.message : 'Search failed'
246
+ });
247
+ }
248
+ }
249
+ ```
250
+
251
+ ## Testing Guidance
252
+
253
+ ### Unit Testing
254
+ ```typescript
255
+ import { SeekSphereClient } from 'seeksphere-sdk';
256
+
257
+ // Mock the client for testing
258
+ jest.mock('seeksphere-sdk');
259
+
260
+ const mockClient = {
261
+ search: jest.fn().mockResolvedValue({ success: true, data: [] })
262
+ };
263
+
264
+ (SeekSphereClient as jest.Mock).mockImplementation(() => mockClient);
265
+ ```
266
+
267
+ ### Integration Testing
268
+ ```typescript
269
+ // Use a test organization ID for integration tests
270
+ const testClient = new SeekSphereClient({
271
+ apiKey: process.env.TEST_SEEKSPHERE_ORG_ID!,
272
+ timeout: 10000
273
+ });
274
+
275
+ describe('SeekSphere Integration', () => {
276
+ it('should perform search successfully', async () => {
277
+ const result = await testClient.search({
278
+ query: 'test query'
279
+ });
280
+ expect(result.success).toBe(true);
281
+ });
282
+ });
283
+ ```
284
+
285
+ ## Version Information
286
+
287
+ - **Current Version**: 1.0.0
288
+ - **Node.js Requirement**: >= 18.0.0
289
+ - **TypeScript Support**: Full TypeScript definitions included
290
+ - **Dependencies**: axios (HTTP client)
291
+
292
+ ## Support and Resources
293
+
294
+ - **Dashboard**: Use SeekSphere dashboard for token and schema management
295
+ - **Documentation**: This SDK focuses only on search functionality
296
+ - **Issues**: Report issues on the GitHub repository
297
+ - **Updates**: Follow semantic versioning (patch/minor/major)
298
+
299
+ Remember: This SDK is designed to be simple and focused on search functionality only. All configuration and management should be done through the SeekSphere dashboard.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "seeksphere-sdk",
3
- "version": "1.1.0",
3
+ "version": "1.2.0",
4
4
  "description": "Official TypeScript Node.js SDK for SeekSphere API",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -41,7 +41,8 @@
41
41
  "files": [
42
42
  "dist/**/*",
43
43
  "README.md",
44
- "LICENSE"
44
+ "LICENSE",
45
+ "LLM.md"
45
46
  ],
46
47
  "engines": {
47
48
  "node": ">=18.0.0"