eventsourcingdb 0.10.0 → 0.10.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.
Files changed (2) hide show
  1. package/README.md +55 -1
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -1,3 +1,57 @@
1
1
  # eventsourcingdb
2
2
 
3
- The official JavaScript client SDK for EventSourcingDB.
3
+ The official JavaScript client SDK for [EventSourcingDB](https://www.eventsourcingdb.io) – a purpose-built database for event sourcing.
4
+
5
+ EventSourcingDB enables you to build and operate event-driven applications with native support for writing, reading, and observing events. This client SDK provides convenient access to its capabilities in JavaScript and TypeScript.
6
+
7
+ For more information on EventSourcingDB, see its [official documentation](https://docs.eventsourcingdb.io/).
8
+
9
+ ## Getting Started
10
+
11
+ Import the `Client` class and create an instance by providing the URL of your EventSourcingDB instance and the API token to use:
12
+
13
+ ```typescript
14
+ import { Client } from 'eventsourcingdb';
15
+
16
+ const url = new URL('http://localhost:3000');
17
+ const apiToken = 'secret';
18
+
19
+ const client = new Client(url, apiToken);
20
+ ```
21
+
22
+ Then call the `ping` function to check whether the instance is reachable. If it is not, the function will throw an error:
23
+
24
+ ```typescript
25
+ await client.ping();
26
+ ```
27
+
28
+ *Note that `ping` does not require authentication, so the call may succeed even if the API token is invalid.*
29
+
30
+ If you want to verify the API token, call `verifyApiToken`. If the token is invalid, the function will throw an error:
31
+
32
+ ```typescript
33
+ await client.verifyApiToken();
34
+ ```
35
+
36
+ ### Writing Events
37
+
38
+ Call the `writeEvents` function and hand over an array with one or more events. You do not have to provide all event fields – some are automatically added by the server.
39
+
40
+ Specify `source`, `subject`, `type`, and `data` according to the [CloudEvents](https://docs.eventsourcingdb.io/fundamentals/cloud-events/) format.
41
+
42
+ The function returns the written events, including the fields added by the server:
43
+
44
+ ```typescript
45
+ const writtenEvents = await client.writeEvents([
46
+ {
47
+ source: 'https://library.eventsourcingdb.io',
48
+ subject: '/books/42',
49
+ type: 'io.eventsourcingdb.library.book-acquired',
50
+ data: {
51
+ title: '2001 – A Space Odyssey',
52
+ author: 'Arthur C. Clarke',
53
+ isbn: '978-0756906788'
54
+ }
55
+ }
56
+ ]);
57
+ ```
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eventsourcingdb",
3
- "version": "0.10.0",
3
+ "version": "0.10.2",
4
4
  "description": "The official JavaScript client SDK for EventSourcingDB.",
5
5
  "author": {
6
6
  "name": "the native web GmbH",