Skip to content

Commit 0721340

Browse files
authored
fix: Rename precondition. (#246)
1 parent 7339d7c commit 0721340

File tree

5 files changed

+20
-20
lines changed

5 files changed

+20
-20
lines changed

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -94,17 +94,17 @@ const writtenEvents = await client.writeEvents([
9494

9595
*Note that according to the CloudEvents standard, event IDs must be of type string.*
9696

97-
#### Using the `isEventQlTrue` precondition
97+
#### Using the `isEventQlQueryTrue` precondition
9898

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:
99+
If you want to write events depending on an EventQL query, import the `isEventQlQueryTrue` function and pass it as an array of preconditions in the second argument:
100100

101101
```typescript
102-
import { isEventQlTrue } from 'eventsourcingdb';
102+
import { isEventQlQueryTrue } from 'eventsourcingdb';
103103

104104
const writtenEvents = await client.writeEvents([
105105
// events
106106
], [
107-
isEventQlTrue(`FROM e IN events WHERE e.type == 'io.eventsourcingdb.library.book-borrowed' PROJECT INTO COUNT() < 10`)
107+
isEventQlQueryTrue(`FROM e IN events WHERE e.type == 'io.eventsourcingdb.library.book-borrowed' PROJECT INTO COUNT() < 10`)
108108
]);
109109
```
110110

src/Precondition.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ interface IsSubjectOnEventIdPrecondition {
77
eventId: string;
88
}
99

10-
interface IsEventQlTruePrecondition {
10+
interface IsEventQlQueryTruePrecondition {
1111
query: string;
1212
}
1313

@@ -21,8 +21,8 @@ type Precondition =
2121
payload: IsSubjectOnEventIdPrecondition;
2222
}
2323
| {
24-
type: 'isEventQlTrue';
25-
payload: IsEventQlTruePrecondition;
24+
type: 'isEventQlQueryTrue';
25+
payload: IsEventQlQueryTruePrecondition;
2626
};
2727

2828
export type { Precondition };

src/isEventQlQueryTrue.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import type { Precondition } from './Precondition.js';
2+
3+
const isEventQlQueryTrue = (query: string): Precondition => {
4+
return {
5+
type: 'isEventQlQueryTrue',
6+
payload: { query },
7+
};
8+
};
9+
10+
export { isEventQlQueryTrue };

src/isEventQlTrue.ts

Lines changed: 0 additions & 10 deletions
This file was deleted.

src/writeEvents.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { afterEach, beforeEach, suite, test } from 'node:test';
33
import { Container } from './Container.js';
44
import type { EventCandidate } from './EventCandidate.js';
55
import { getImageVersionFromDockerfile } from './getImageVersionFromDockerfile.js';
6-
import { isEventQlTrue } from './isEventQlTrue.js';
6+
import { isEventQlQueryTrue } from './isEventQlQueryTrue.js';
77
import { isSubjectOnEventId } from './isSubjectOnEventId.js';
88
import { isSubjectPristine } from './isSubjectPristine.js';
99

@@ -145,7 +145,7 @@ suite('writeEvents', { timeout: 30_000 }, () => {
145145
);
146146
});
147147

148-
test('supports the isEventQlTrue precondition.', async (): Promise<void> => {
148+
test('supports the isEventQlQueryTrue precondition.', async (): Promise<void> => {
149149
const client = container.getClient();
150150

151151
const firstEvent: EventCandidate = {
@@ -172,7 +172,7 @@ suite('writeEvents', { timeout: 30_000 }, () => {
172172
async () => {
173173
await client.writeEvents(
174174
[secondEvent],
175-
[isEventQlTrue('FROM e IN events PROJECT INTO COUNT() == 0')],
175+
[isEventQlQueryTrue('FROM e IN events PROJECT INTO COUNT() == 0')],
176176
);
177177
},
178178
error => {

0 commit comments

Comments
 (0)