eventsourcingdb 1.0.2 → 1.1.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 CHANGED
@@ -94,6 +94,22 @@ const writtenEvents = await client.writeEvents([
94
94
 
95
95
  *Note that according to the CloudEvents standard, event IDs must be of type string.*
96
96
 
97
+ #### Using the `isEventQlTrue` precondition
98
+
99
+ If you want to write events depending on an EventQL query, import the `isEventQlTrue` function and pass it as an array of preconditions in the second argument:
100
+
101
+ ```typescript
102
+ import { isEventQlTrue } from 'eventsourcingdb';
103
+
104
+ const writtenEvents = await client.writeEvents([
105
+ // events
106
+ ], [
107
+ isEventQlTrue(`FROM e IN events WHERE e.type == 'io.eventsourcingdb.library.book-borrowed' PROJECT INTO COUNT() < 10`)
108
+ ]);
109
+ ```
110
+
111
+ *Note that the query must return a single row with a single value, which is interpreted as a boolean.*
112
+
97
113
  ### Reading Events
98
114
 
99
115
  To read all events of a subject, call the `readEvents` function with the subject as the first argument and an options object as the second argument. Set the `recursive` option to `false`. This ensures that only events of the given subject are returned, not events of nested subjects.
package/dist/index.d.mts CHANGED
@@ -53,12 +53,18 @@ interface IsSubjectOnEventIdPrecondition {
53
53
  subject: string;
54
54
  eventId: string;
55
55
  }
56
+ interface IsEventQlTruePrecondition {
57
+ query: string;
58
+ }
56
59
  type Precondition = {
57
60
  type: 'isSubjectPristine';
58
61
  payload: IsSubjectPristinePrecondition;
59
62
  } | {
60
63
  type: 'isSubjectOnEventId';
61
64
  payload: IsSubjectOnEventIdPrecondition;
65
+ } | {
66
+ type: 'isEventQlTrue';
67
+ payload: IsEventQlTruePrecondition;
62
68
  };
63
69
 
64
70
  type Order = 'chronological' | 'antichronological';
package/dist/index.d.ts CHANGED
@@ -53,12 +53,18 @@ interface IsSubjectOnEventIdPrecondition {
53
53
  subject: string;
54
54
  eventId: string;
55
55
  }
56
+ interface IsEventQlTruePrecondition {
57
+ query: string;
58
+ }
56
59
  type Precondition = {
57
60
  type: 'isSubjectPristine';
58
61
  payload: IsSubjectPristinePrecondition;
59
62
  } | {
60
63
  type: 'isSubjectOnEventId';
61
64
  payload: IsSubjectOnEventIdPrecondition;
65
+ } | {
66
+ type: 'isEventQlTrue';
67
+ payload: IsEventQlTruePrecondition;
62
68
  };
63
69
 
64
70
  type Order = 'chronological' | 'antichronological';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eventsourcingdb",
3
- "version": "1.0.2",
3
+ "version": "1.1.0",
4
4
  "description": "The official JavaScript client SDK for EventSourcingDB.",
5
5
  "author": {
6
6
  "name": "the native web GmbH",