diff --git a/README.md b/README.md index 5431b25..71ed3cb 100644 --- a/README.md +++ b/README.md @@ -94,17 +94,17 @@ const writtenEvents = await client.writeEvents([ *Note that according to the CloudEvents standard, event IDs must be of type string.* -#### Using the `isEventQlTrue` precondition +#### Using the `isEventQlQueryTrue` precondition -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: +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: ```typescript -import { isEventQlTrue } from 'eventsourcingdb'; +import { isEventQlQueryTrue } from 'eventsourcingdb'; const writtenEvents = await client.writeEvents([ // events ], [ - isEventQlTrue(`FROM e IN events WHERE e.type == 'io.eventsourcingdb.library.book-borrowed' PROJECT INTO COUNT() < 10`) + isEventQlQueryTrue(`FROM e IN events WHERE e.type == 'io.eventsourcingdb.library.book-borrowed' PROJECT INTO COUNT() < 10`) ]); ``` diff --git a/src/Precondition.ts b/src/Precondition.ts index cf4feaa..c8a2c04 100644 --- a/src/Precondition.ts +++ b/src/Precondition.ts @@ -7,7 +7,7 @@ interface IsSubjectOnEventIdPrecondition { eventId: string; } -interface IsEventQlTruePrecondition { +interface IsEventQlQueryTruePrecondition { query: string; } @@ -21,8 +21,8 @@ type Precondition = payload: IsSubjectOnEventIdPrecondition; } | { - type: 'isEventQlTrue'; - payload: IsEventQlTruePrecondition; + type: 'isEventQlQueryTrue'; + payload: IsEventQlQueryTruePrecondition; }; export type { Precondition }; diff --git a/src/isEventQlQueryTrue.ts b/src/isEventQlQueryTrue.ts new file mode 100644 index 0000000..5cdb5b4 --- /dev/null +++ b/src/isEventQlQueryTrue.ts @@ -0,0 +1,10 @@ +import type { Precondition } from './Precondition.js'; + +const isEventQlQueryTrue = (query: string): Precondition => { + return { + type: 'isEventQlQueryTrue', + payload: { query }, + }; +}; + +export { isEventQlQueryTrue }; diff --git a/src/isEventQlTrue.ts b/src/isEventQlTrue.ts deleted file mode 100644 index ad0bc6a..0000000 --- a/src/isEventQlTrue.ts +++ /dev/null @@ -1,10 +0,0 @@ -import type { Precondition } from './Precondition.js'; - -const isEventQlTrue = (query: string): Precondition => { - return { - type: 'isEventQlTrue', - payload: { query }, - }; -}; - -export { isEventQlTrue }; diff --git a/src/writeEvents.test.ts b/src/writeEvents.test.ts index 96e08f0..657b5c2 100644 --- a/src/writeEvents.test.ts +++ b/src/writeEvents.test.ts @@ -3,7 +3,7 @@ import { afterEach, beforeEach, suite, test } from 'node:test'; import { Container } from './Container.js'; import type { EventCandidate } from './EventCandidate.js'; import { getImageVersionFromDockerfile } from './getImageVersionFromDockerfile.js'; -import { isEventQlTrue } from './isEventQlTrue.js'; +import { isEventQlQueryTrue } from './isEventQlQueryTrue.js'; import { isSubjectOnEventId } from './isSubjectOnEventId.js'; import { isSubjectPristine } from './isSubjectPristine.js'; @@ -145,7 +145,7 @@ suite('writeEvents', { timeout: 30_000 }, () => { ); }); - test('supports the isEventQlTrue precondition.', async (): Promise => { + test('supports the isEventQlQueryTrue precondition.', async (): Promise => { const client = container.getClient(); const firstEvent: EventCandidate = { @@ -172,7 +172,7 @@ suite('writeEvents', { timeout: 30_000 }, () => { async () => { await client.writeEvents( [secondEvent], - [isEventQlTrue('FROM e IN events PROJECT INTO COUNT() == 0')], + [isEventQlQueryTrue('FROM e IN events PROJECT INTO COUNT() == 0')], ); }, error => {