@lv-agent/logdb-client 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 +13 -0
- package/dist/client.d.ts +11 -0
- package/dist/client.js +20 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -62,6 +62,8 @@ sub.on('data', (rec) => {
|
|
|
62
62
|
| `listStreams(ns)` | List streams in a namespace |
|
|
63
63
|
| `status()` | Node status |
|
|
64
64
|
| `verifyChain(ns, stream)` | Verify hash chain |
|
|
65
|
+
| `createStream(ns, stream)` | Create a stream (admin) |
|
|
66
|
+
| `deleteStream(ns, stream)` | Delete all records in a stream (admin) |
|
|
65
67
|
| `commitOffset(...)` / `committedOffset(...)` | Consumer group offset management |
|
|
66
68
|
|
|
67
69
|
## TLS / mTLS
|
|
@@ -76,6 +78,17 @@ const client = new Client('logdbd.example.com:50051', {
|
|
|
76
78
|
});
|
|
77
79
|
```
|
|
78
80
|
|
|
81
|
+
## RBAC / Auth
|
|
82
|
+
|
|
83
|
+
Roles: `admin` (all), `writer` (append), `reader` (read/query), `subscriber` (subscribe).
|
|
84
|
+
|
|
85
|
+
```typescript
|
|
86
|
+
// Pass token via ClientOptions
|
|
87
|
+
const client = new Client('logdbd.example.com:50051', {
|
|
88
|
+
authToken: 'admin-secret-token',
|
|
89
|
+
});
|
|
90
|
+
```
|
|
91
|
+
|
|
79
92
|
## License
|
|
80
93
|
|
|
81
94
|
Apache-2.0
|
package/dist/client.d.ts
CHANGED
|
@@ -77,6 +77,17 @@ export declare class Client {
|
|
|
77
77
|
commitOffset(namespace: string, stream: string, consumerGroup: string, consumerId: string, seq: number): Promise<void>;
|
|
78
78
|
/** Get committed offset for a consumer. */
|
|
79
79
|
committedOffset(namespace: string, stream: string, consumerGroup: string, consumerId: string): Promise<number>;
|
|
80
|
+
/** Create a stream (and namespace if needed). Requires admin token. */
|
|
81
|
+
createStream(namespace: string, stream: string): Promise<{
|
|
82
|
+
namespaceId: number;
|
|
83
|
+
streamId: number;
|
|
84
|
+
created: boolean;
|
|
85
|
+
}>;
|
|
86
|
+
/** Mark all records in a stream as deleted. Requires admin token. */
|
|
87
|
+
deleteStream(namespace: string, stream: string): Promise<{
|
|
88
|
+
deleted: boolean;
|
|
89
|
+
deletedCount: number;
|
|
90
|
+
}>;
|
|
80
91
|
/** Close the client connection. */
|
|
81
92
|
close(): void;
|
|
82
93
|
}
|
package/dist/client.js
CHANGED
|
@@ -301,6 +301,26 @@ class Client {
|
|
|
301
301
|
});
|
|
302
302
|
});
|
|
303
303
|
}
|
|
304
|
+
/** Create a stream (and namespace if needed). Requires admin token. */
|
|
305
|
+
createStream(namespace, stream) {
|
|
306
|
+
return new Promise((resolve, reject) => {
|
|
307
|
+
this.client.CreateStream({ namespace, stream, maxRecords: 0, maxBytes: 0 }, (err, resp) => {
|
|
308
|
+
if (err)
|
|
309
|
+
return reject(err);
|
|
310
|
+
resolve({ namespaceId: resp.namespaceId, streamId: resp.streamId, created: resp.created });
|
|
311
|
+
});
|
|
312
|
+
});
|
|
313
|
+
}
|
|
314
|
+
/** Mark all records in a stream as deleted. Requires admin token. */
|
|
315
|
+
deleteStream(namespace, stream) {
|
|
316
|
+
return new Promise((resolve, reject) => {
|
|
317
|
+
this.client.DeleteStream({ namespace, stream }, (err, resp) => {
|
|
318
|
+
if (err)
|
|
319
|
+
return reject(err);
|
|
320
|
+
resolve({ deleted: resp.deleted, deletedCount: Number(resp.deletedCount) });
|
|
321
|
+
});
|
|
322
|
+
});
|
|
323
|
+
}
|
|
304
324
|
/** Close the client connection. */
|
|
305
325
|
close() {
|
|
306
326
|
if (!this.closed) {
|