@seaverse/dataservice 1.6.1 → 1.6.2
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 +43 -4
- package/dist/index.d.mts +31 -2
- package/dist/index.d.ts +31 -2
- package/dist/index.js +1 -1
- package/dist/index.mjs +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -17,19 +17,58 @@ A TypeScript/JavaScript SDK for universal data storage with PostgREST backend. S
|
|
|
17
17
|
npm install @seaverse/dataservice
|
|
18
18
|
```
|
|
19
19
|
|
|
20
|
-
##
|
|
20
|
+
## Package Exports
|
|
21
|
+
|
|
22
|
+
This package uses a **factory pattern** for client creation. Here's what it exports:
|
|
23
|
+
|
|
24
|
+
**Functions:**
|
|
25
|
+
- `createClient(config)` - Factory function to create a client instance (async)
|
|
26
|
+
- `debugSetToken(token)` - Set debug token for testing (call before createClient)
|
|
27
|
+
|
|
28
|
+
**Types (TypeScript):**
|
|
29
|
+
- `DataServiceClient` - Type of the client instance (**not a constructor**)
|
|
30
|
+
- `DataRecord<T>` - Type of stored records
|
|
31
|
+
- `Collection<T>` - Type of collection instances
|
|
32
|
+
- `QueryBuilder<T>` - Type of query builder instances
|
|
33
|
+
- `DataTable` - Type of data table instances
|
|
34
|
+
- `ClientConfig` - Configuration options for createClient
|
|
35
|
+
- `DataServiceError` - Error class for API errors
|
|
36
|
+
|
|
37
|
+
**Constants:**
|
|
38
|
+
- `VERSION` - SDK version string
|
|
39
|
+
|
|
40
|
+
**Important:** Always use `createClient()` to create clients. `DataServiceClient` is a TypeScript type, not a class constructor.
|
|
21
41
|
|
|
22
42
|
```typescript
|
|
43
|
+
// ✓ CORRECT
|
|
23
44
|
import { createClient } from '@seaverse/dataservice';
|
|
45
|
+
const client = await createClient({});
|
|
46
|
+
|
|
47
|
+
// ✗ WRONG - DataServiceClient is not a constructor
|
|
48
|
+
import { DataServiceClient } from '@seaverse/dataservice';
|
|
49
|
+
const client = new DataServiceClient(); // This will fail!
|
|
50
|
+
```
|
|
24
51
|
|
|
25
|
-
|
|
52
|
+
## Quick Start
|
|
53
|
+
|
|
54
|
+
### Creating a Client
|
|
55
|
+
|
|
56
|
+
The SDK uses a **factory function pattern**. Always use `createClient()`:
|
|
57
|
+
|
|
58
|
+
```typescript
|
|
59
|
+
import { createClient, debugSetToken } from '@seaverse/dataservice';
|
|
60
|
+
|
|
61
|
+
// Production: Auto-fetch token from parent page (when running in iframe)
|
|
26
62
|
const client = await createClient({});
|
|
27
63
|
|
|
28
|
-
//
|
|
29
|
-
import { debugSetToken } from '@seaverse/dataservice';
|
|
64
|
+
// Development/Testing: Use debug token
|
|
30
65
|
debugSetToken('your-test-token');
|
|
31
66
|
const client = await createClient({});
|
|
67
|
+
```
|
|
32
68
|
|
|
69
|
+
### Basic Operations
|
|
70
|
+
|
|
71
|
+
```typescript
|
|
33
72
|
// Store user preferences (single record)
|
|
34
73
|
const userPrefs = client.userData.collection('user_preferences');
|
|
35
74
|
await userPrefs.insert({
|
package/dist/index.d.mts
CHANGED
|
@@ -214,7 +214,27 @@ interface DataTable {
|
|
|
214
214
|
/**
|
|
215
215
|
* Main client interface
|
|
216
216
|
*
|
|
217
|
+
* **IMPORTANT:** This is a TypeScript type definition, NOT a class constructor.
|
|
218
|
+
* Use the `createClient()` factory function to create client instances.
|
|
219
|
+
*
|
|
217
220
|
* AI-friendly: Entry point with clear hierarchy
|
|
221
|
+
*
|
|
222
|
+
* @example Correct Usage
|
|
223
|
+
* ```typescript
|
|
224
|
+
* import { createClient } from '@seaverse/dataservice';
|
|
225
|
+
*
|
|
226
|
+
* // ✓ CORRECT - Use factory function
|
|
227
|
+
* const client = await createClient({});
|
|
228
|
+
* console.log(client.appId);
|
|
229
|
+
* ```
|
|
230
|
+
*
|
|
231
|
+
* @example INCORRECT Usage
|
|
232
|
+
* ```typescript
|
|
233
|
+
* import { DataServiceClient } from '@seaverse/dataservice';
|
|
234
|
+
*
|
|
235
|
+
* // ✗ WRONG - DataServiceClient is NOT a constructor
|
|
236
|
+
* const client = new DataServiceClient(); // This will throw an error!
|
|
237
|
+
* ```
|
|
218
238
|
*/
|
|
219
239
|
interface DataServiceClient {
|
|
220
240
|
/** Automatically extracted application ID from current URL */
|
|
@@ -293,13 +313,15 @@ declare function createClient(config?: ClientConfig): Promise<DataServiceClient>
|
|
|
293
313
|
*
|
|
294
314
|
* AI-Friendly Universal Data Storage for TypeScript/JavaScript
|
|
295
315
|
*
|
|
316
|
+
* **IMPORTANT:** This SDK uses a factory pattern. Use `createClient()` to create instances.
|
|
317
|
+
*
|
|
296
318
|
* @packageDocumentation
|
|
297
319
|
*
|
|
298
320
|
* @example Basic Usage with Auto Token Fetch
|
|
299
321
|
* ```typescript
|
|
300
322
|
* import { createClient, debugSetToken } from '@seaverse/dataservice';
|
|
301
323
|
*
|
|
302
|
-
* //
|
|
324
|
+
* // ✓ CORRECT - Use factory function
|
|
303
325
|
* const client = await createClient({});
|
|
304
326
|
*
|
|
305
327
|
* // For development/testing, use debugSetToken
|
|
@@ -323,8 +345,15 @@ declare function createClient(config?: ClientConfig): Promise<DataServiceClient>
|
|
|
323
345
|
* .limit(10)
|
|
324
346
|
* .execute();
|
|
325
347
|
* ```
|
|
348
|
+
*
|
|
349
|
+
* @example INCORRECT Usage - Do NOT do this
|
|
350
|
+
* ```typescript
|
|
351
|
+
* // ✗ WRONG - DataServiceClient is a type, not a constructor
|
|
352
|
+
* import { DataServiceClient } from '@seaverse/dataservice';
|
|
353
|
+
* const client = new DataServiceClient(); // This will fail!
|
|
354
|
+
* ```
|
|
326
355
|
*/
|
|
327
356
|
|
|
328
|
-
declare const VERSION = "1.
|
|
357
|
+
declare const VERSION = "1.6.2";
|
|
329
358
|
|
|
330
359
|
export { type APIError, type ClientConfig, type Collection, type DataRecord, type DataServiceClient, DataServiceError, type DataTable, type OrderOptions, type QueryBuilder, type QueryFilter, type UserDataStats, VERSION, createClient, debugSetToken };
|
package/dist/index.d.ts
CHANGED
|
@@ -214,7 +214,27 @@ interface DataTable {
|
|
|
214
214
|
/**
|
|
215
215
|
* Main client interface
|
|
216
216
|
*
|
|
217
|
+
* **IMPORTANT:** This is a TypeScript type definition, NOT a class constructor.
|
|
218
|
+
* Use the `createClient()` factory function to create client instances.
|
|
219
|
+
*
|
|
217
220
|
* AI-friendly: Entry point with clear hierarchy
|
|
221
|
+
*
|
|
222
|
+
* @example Correct Usage
|
|
223
|
+
* ```typescript
|
|
224
|
+
* import { createClient } from '@seaverse/dataservice';
|
|
225
|
+
*
|
|
226
|
+
* // ✓ CORRECT - Use factory function
|
|
227
|
+
* const client = await createClient({});
|
|
228
|
+
* console.log(client.appId);
|
|
229
|
+
* ```
|
|
230
|
+
*
|
|
231
|
+
* @example INCORRECT Usage
|
|
232
|
+
* ```typescript
|
|
233
|
+
* import { DataServiceClient } from '@seaverse/dataservice';
|
|
234
|
+
*
|
|
235
|
+
* // ✗ WRONG - DataServiceClient is NOT a constructor
|
|
236
|
+
* const client = new DataServiceClient(); // This will throw an error!
|
|
237
|
+
* ```
|
|
218
238
|
*/
|
|
219
239
|
interface DataServiceClient {
|
|
220
240
|
/** Automatically extracted application ID from current URL */
|
|
@@ -293,13 +313,15 @@ declare function createClient(config?: ClientConfig): Promise<DataServiceClient>
|
|
|
293
313
|
*
|
|
294
314
|
* AI-Friendly Universal Data Storage for TypeScript/JavaScript
|
|
295
315
|
*
|
|
316
|
+
* **IMPORTANT:** This SDK uses a factory pattern. Use `createClient()` to create instances.
|
|
317
|
+
*
|
|
296
318
|
* @packageDocumentation
|
|
297
319
|
*
|
|
298
320
|
* @example Basic Usage with Auto Token Fetch
|
|
299
321
|
* ```typescript
|
|
300
322
|
* import { createClient, debugSetToken } from '@seaverse/dataservice';
|
|
301
323
|
*
|
|
302
|
-
* //
|
|
324
|
+
* // ✓ CORRECT - Use factory function
|
|
303
325
|
* const client = await createClient({});
|
|
304
326
|
*
|
|
305
327
|
* // For development/testing, use debugSetToken
|
|
@@ -323,8 +345,15 @@ declare function createClient(config?: ClientConfig): Promise<DataServiceClient>
|
|
|
323
345
|
* .limit(10)
|
|
324
346
|
* .execute();
|
|
325
347
|
* ```
|
|
348
|
+
*
|
|
349
|
+
* @example INCORRECT Usage - Do NOT do this
|
|
350
|
+
* ```typescript
|
|
351
|
+
* // ✗ WRONG - DataServiceClient is a type, not a constructor
|
|
352
|
+
* import { DataServiceClient } from '@seaverse/dataservice';
|
|
353
|
+
* const client = new DataServiceClient(); // This will fail!
|
|
354
|
+
* ```
|
|
326
355
|
*/
|
|
327
356
|
|
|
328
|
-
declare const VERSION = "1.
|
|
357
|
+
declare const VERSION = "1.6.2";
|
|
329
358
|
|
|
330
359
|
export { type APIError, type ClientConfig, type Collection, type DataRecord, type DataServiceClient, DataServiceError, type DataTable, type OrderOptions, type QueryBuilder, type QueryFilter, type UserDataStats, VERSION, createClient, debugSetToken };
|
package/dist/index.js
CHANGED
package/dist/index.mjs
CHANGED