@onchaindb/sdk 2.0.0 → 2.0.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 +8 -8
- package/package.json +1 -1
- package/src/client.ts +1 -1
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
#
|
|
1
|
+
# OnDB TypeScript SDK
|
|
2
2
|
|
|
3
|
-
A TypeScript SDK for
|
|
3
|
+
A TypeScript SDK for OnDB — the decentralized database built on Celestia with x402 payment protocol integration.
|
|
4
4
|
|
|
5
5
|
## Installation
|
|
6
6
|
|
|
@@ -22,7 +22,7 @@ const db = createClient({
|
|
|
22
22
|
// Store data
|
|
23
23
|
await db.store({
|
|
24
24
|
collection: 'messages',
|
|
25
|
-
data: [{ message: 'Hello
|
|
25
|
+
data: [{ message: 'Hello OnDB!', author: 'alice' }]
|
|
26
26
|
});
|
|
27
27
|
|
|
28
28
|
// Query data
|
|
@@ -39,8 +39,8 @@ console.log(result.records);
|
|
|
39
39
|
## Configuration
|
|
40
40
|
|
|
41
41
|
```typescript
|
|
42
|
-
interface
|
|
43
|
-
endpoint: string; //
|
|
42
|
+
interface OnDBConfig {
|
|
43
|
+
endpoint: string; // OnDB server endpoint
|
|
44
44
|
appId?: string; // Application ID
|
|
45
45
|
appKey?: string; // App key for write operations (X-App-Key header)
|
|
46
46
|
userKey?: string; // User key for Auto-Pay (X-User-Key header)
|
|
@@ -568,20 +568,20 @@ const quote = await db.getPricingQuote({
|
|
|
568
568
|
## Error Handling
|
|
569
569
|
|
|
570
570
|
```typescript
|
|
571
|
-
import {
|
|
571
|
+
import { OnDBError, ValidationError, PaymentRequiredError } from '@onchaindb/sdk';
|
|
572
572
|
|
|
573
573
|
try {
|
|
574
574
|
await db.store({ collection: 'test', data: [{ value: 1 }] });
|
|
575
575
|
} catch (error) {
|
|
576
576
|
if (error instanceof ValidationError) console.log('Validation:', error.message);
|
|
577
577
|
if (error instanceof PaymentRequiredError) console.log('Quote:', error.quote);
|
|
578
|
-
if (error instanceof
|
|
578
|
+
if (error instanceof OnDBError) console.log(error.code, error.message);
|
|
579
579
|
}
|
|
580
580
|
```
|
|
581
581
|
|
|
582
582
|
## API Reference
|
|
583
583
|
|
|
584
|
-
###
|
|
584
|
+
### OnDBClient
|
|
585
585
|
|
|
586
586
|
| Method | Description |
|
|
587
587
|
|--------|-------------|
|
package/package.json
CHANGED
package/src/client.ts
CHANGED
|
@@ -955,7 +955,7 @@ export class OnDBClient extends EventEmitter<TransactionEvents> {
|
|
|
955
955
|
/**
|
|
956
956
|
* Create a fluent query builder instance
|
|
957
957
|
*
|
|
958
|
-
* @returns
|
|
958
|
+
* @returns QueryBuilder instance for building complex queries
|
|
959
959
|
*
|
|
960
960
|
* @example
|
|
961
961
|
* ```typescript
|