Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ on:

permissions:
contents: write
packages: write

jobs:
release:
Expand All @@ -20,7 +19,6 @@ jobs:
uses: actions/checkout@v4
with:
fetch-depth: '0'
token: ${{ secrets.TOKEN_GITHUB_TO_GITHUB_REPOSITORIES_RW }}
- name: Use Node.js
uses: actions/setup-node@v4
with:
Expand Down
1 change: 0 additions & 1 deletion .npmignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
.github/
src/
test/
.gitignore
.npmignore
biome.json
Expand Down
12 changes: 5 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@
}
},
"types": "./dist/index.d.ts",
"dependencies": {
"testcontainers": "10.24.2"
},
"devDependencies": {
"@biomejs/biome": "1.9.4",
"@types/node": "22.14.1",
Expand All @@ -26,9 +29,7 @@
"build": "npx tsc --noEmit && npx tsup --clean --dts --format cjs,esm --minify --out-dir=./dist/ ./src/index.ts",
"format": "npx biome format --write .",
"qa": "npm run analyze && npm run test",
"test": "npm run test:unit && npm run test:integration",
"test:unit": "node --test --import tsx \"./src/**/*.test.ts\"",
"test:integration": "node --test --import tsx \"./test/**/*.test.ts\""
"test": "node --test --import tsx \"./src/**/*.test.ts\""
},
"repository": {
"type": "git",
Expand All @@ -43,8 +44,5 @@
"event sourcing",
"event store",
"cqrs"
],
"dependencies": {
"testcontainers": "10.24.2"
}
]
}
34 changes: 17 additions & 17 deletions test/observeEvents.test.ts → src/observeEvents.test.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import assert from 'node:assert/strict';
import { afterEach, beforeEach, suite, test } from 'node:test';
import type { Event } from '../src/Event.js';
import type { EventCandidate } from '../src/EventCandidate.js';
import { EventSourcingDbContainer } from '../src/EventSourcingDbContainer.js';
import type { Event } from './Event.js';
import type { EventCandidate } from './EventCandidate.js';
import { EventSourcingDbContainer } from './EventSourcingDbContainer.js';

suite('observeEvents', { timeout: 30_000 }, () => {
let container: EventSourcingDbContainer;
Expand Down Expand Up @@ -67,18 +67,18 @@ suite('observeEvents', { timeout: 30_000 }, () => {
controller.abort();
}, 100);

const eventsRead: Event[] = [];
const eventsObserved: Event[] = [];
for await (const event of client.observeEvents(
'/test',
{
recursive: false,
},
controller.signal,
)) {
eventsRead.push(event);
eventsObserved.push(event);
}

assert.equal(eventsRead.length, 2);
assert.equal(eventsObserved.length, 2);
});

test('observes recursively.', async (): Promise<void> => {
Expand Down Expand Up @@ -110,18 +110,18 @@ suite('observeEvents', { timeout: 30_000 }, () => {
controller.abort();
}, 100);

const eventsRead: Event[] = [];
const eventsObserved: Event[] = [];
for await (const event of client.observeEvents(
'/',
{
recursive: true,
},
controller.signal,
)) {
eventsRead.push(event);
eventsObserved.push(event);
}

assert.equal(eventsRead.length, 2);
assert.equal(eventsObserved.length, 2);
});

test('observes with lower bound.', async (): Promise<void> => {
Expand Down Expand Up @@ -153,7 +153,7 @@ suite('observeEvents', { timeout: 30_000 }, () => {
controller.abort();
}, 100);

const eventsRead: Event[] = [];
const eventsObserved: Event[] = [];
for await (const event of client.observeEvents(
'/test',
{
Expand All @@ -162,11 +162,11 @@ suite('observeEvents', { timeout: 30_000 }, () => {
},
controller.signal,
)) {
eventsRead.push(event);
eventsObserved.push(event);
}

assert.equal(eventsRead.length, 1);
assert.equal(eventsRead[0].data.value, 42);
assert.equal(eventsObserved.length, 1);
assert.equal(eventsObserved[0].data.value, 42);
});

test('observes from latest event.', async (): Promise<void> => {
Expand Down Expand Up @@ -198,7 +198,7 @@ suite('observeEvents', { timeout: 30_000 }, () => {
controller.abort();
}, 100);

const eventsRead: Event[] = [];
const eventsObserved: Event[] = [];
for await (const event of client.observeEvents(
'/test',
{
Expand All @@ -211,10 +211,10 @@ suite('observeEvents', { timeout: 30_000 }, () => {
},
controller.signal,
)) {
eventsRead.push(event);
eventsObserved.push(event);
}

assert.equal(eventsRead.length, 1);
assert.equal(eventsRead[0].data.value, 42);
assert.equal(eventsObserved.length, 1);
assert.equal(eventsObserved[0].data.value, 42);
});
});
4 changes: 2 additions & 2 deletions test/ping.test.ts → src/ping.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import assert from 'node:assert/strict';
import { afterEach, beforeEach, suite, test } from 'node:test';
import { Client } from '../src/Client.js';
import { EventSourcingDbContainer } from '../src/EventSourcingDbContainer.js';
import { Client } from './Client.js';
import { EventSourcingDbContainer } from './EventSourcingDbContainer.js';

suite('ping', { timeout: 30_000 }, () => {
let container: EventSourcingDbContainer;
Expand Down
6 changes: 3 additions & 3 deletions test/readEventTypes.test.ts → src/readEventTypes.test.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import assert from 'node:assert/strict';
import { afterEach, beforeEach, suite, test } from 'node:test';
import type { EventCandidate } from '../src/EventCandidate.js';
import { EventSourcingDbContainer } from '../src/EventSourcingDbContainer.js';
import type { EventType } from '../src/EventType.js';
import type { EventCandidate } from './EventCandidate.js';
import { EventSourcingDbContainer } from './EventSourcingDbContainer.js';
import type { EventType } from './EventType.js';

suite('readEventTypes', { timeout: 20_000 }, () => {
let container: EventSourcingDbContainer;
Expand Down
6 changes: 3 additions & 3 deletions test/readEvents.test.ts → src/readEvents.test.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import assert from 'node:assert/strict';
import { afterEach, beforeEach, suite, test } from 'node:test';
import type { Event } from '../src/Event.js';
import type { EventCandidate } from '../src/EventCandidate.js';
import { EventSourcingDbContainer } from '../src/EventSourcingDbContainer.js';
import type { Event } from './Event.js';
import type { EventCandidate } from './EventCandidate.js';
import { EventSourcingDbContainer } from './EventSourcingDbContainer.js';

suite('readEvents', { timeout: 30_000 }, () => {
let container: EventSourcingDbContainer;
Expand Down
4 changes: 2 additions & 2 deletions test/readSubjects.test.ts → src/readSubjects.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import assert from 'node:assert/strict';
import { afterEach, beforeEach, suite, test } from 'node:test';
import type { EventCandidate } from '../src/EventCandidate.js';
import { EventSourcingDbContainer } from '../src/EventSourcingDbContainer.js';
import type { EventCandidate } from './EventCandidate.js';
import { EventSourcingDbContainer } from './EventSourcingDbContainer.js';

suite('readSubjects', { timeout: 30_000 }, () => {
let container: EventSourcingDbContainer;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import assert from 'node:assert/strict';
import { afterEach, beforeEach, suite, test } from 'node:test';
import { EventSourcingDbContainer } from '../src/EventSourcingDbContainer.js';
import { EventSourcingDbContainer } from './EventSourcingDbContainer.js';

suite('registerEventSchema', { timeout: 30_000 }, () => {
let container: EventSourcingDbContainer;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import assert from 'node:assert/strict';
import { afterEach, beforeEach, suite, test } from 'node:test';
import type { EventCandidate } from '../src/EventCandidate.js';
import { EventSourcingDbContainer } from '../src/EventSourcingDbContainer.js';
import type { EventCandidate } from './EventCandidate.js';
import { EventSourcingDbContainer } from './EventSourcingDbContainer.js';

suite('runEventQlQuery', { timeout: 30_000 }, () => {
let container: EventSourcingDbContainer;
Expand Down
4 changes: 2 additions & 2 deletions test/verifyApiToken.test.ts → src/verifyApiToken.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import assert from 'node:assert/strict';
import { afterEach, beforeEach, suite, test } from 'node:test';
import { Client } from '../src/Client.js';
import { EventSourcingDbContainer } from '../src/EventSourcingDbContainer.js';
import { Client } from './Client.js';
import { EventSourcingDbContainer } from './EventSourcingDbContainer.js';

suite('verifyApiToken', { timeout: 30_000 }, () => {
let container: EventSourcingDbContainer;
Expand Down
8 changes: 4 additions & 4 deletions test/writeEvents.test.ts → src/writeEvents.test.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import assert from 'node:assert/strict';
import { afterEach, beforeEach, suite, test } from 'node:test';
import type { EventCandidate } from '../src/EventCandidate.js';
import { EventSourcingDbContainer } from '../src/EventSourcingDbContainer.js';
import { isSubjectOnEventId } from '../src/isSubjectOnEventId.js';
import { isSubjectPristine } from '../src/isSubjectPristine.js';
import type { EventCandidate } from './EventCandidate.js';
import { EventSourcingDbContainer } from './EventSourcingDbContainer.js';
import { isSubjectOnEventId } from './isSubjectOnEventId.js';
import { isSubjectPristine } from './isSubjectPristine.js';

suite('writeEvents', { timeout: 30_000 }, () => {
let container: EventSourcingDbContainer;
Expand Down