@meticoeus/ddd-es 0.2.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/LICENSE +21 -0
- package/README.md +43 -0
- package/dist/package.json +81 -0
- package/dist/src/AbstractEventProcessManager.d.ts +32 -0
- package/dist/src/AbstractEventProcessManager.d.ts.map +1 -0
- package/dist/src/AbstractEventProcessManager.js +142 -0
- package/dist/src/AbstractEventProcessManager.js.map +1 -0
- package/dist/src/AbstractEventProcessManager.mocks.d.ts +27 -0
- package/dist/src/AbstractEventProcessManager.mocks.d.ts.map +1 -0
- package/dist/src/AbstractEventProcessManager.mocks.js +86 -0
- package/dist/src/AbstractEventProcessManager.mocks.js.map +1 -0
- package/dist/src/AbstractEventProcessManager.test.d.ts +2 -0
- package/dist/src/AbstractEventProcessManager.test.d.ts.map +1 -0
- package/dist/src/AbstractEventProcessManager.test.js +109 -0
- package/dist/src/AbstractEventProcessManager.test.js.map +1 -0
- package/dist/src/AggregateRoot.d.ts +52 -0
- package/dist/src/AggregateRoot.d.ts.map +1 -0
- package/dist/src/AggregateRoot.fixtures.d.ts +4 -0
- package/dist/src/AggregateRoot.fixtures.d.ts.map +1 -0
- package/dist/src/AggregateRoot.fixtures.js +45 -0
- package/dist/src/AggregateRoot.fixtures.js.map +1 -0
- package/dist/src/AggregateRoot.js +136 -0
- package/dist/src/AggregateRoot.js.map +1 -0
- package/dist/src/AggregateRoot.mocks.d.ts +26 -0
- package/dist/src/AggregateRoot.mocks.d.ts.map +1 -0
- package/dist/src/AggregateRoot.mocks.js +82 -0
- package/dist/src/AggregateRoot.mocks.js.map +1 -0
- package/dist/src/EventProcessor.d.ts +40 -0
- package/dist/src/EventProcessor.d.ts.map +1 -0
- package/dist/src/EventProcessor.js +112 -0
- package/dist/src/EventProcessor.js.map +1 -0
- package/dist/src/EventProcessor.mocks.d.ts +11 -0
- package/dist/src/EventProcessor.mocks.d.ts.map +1 -0
- package/dist/src/EventProcessor.mocks.js +50 -0
- package/dist/src/EventProcessor.mocks.js.map +1 -0
- package/dist/src/EventProcessor.test.d.ts +2 -0
- package/dist/src/EventProcessor.test.d.ts.map +1 -0
- package/dist/src/EventProcessor.test.js +37 -0
- package/dist/src/EventProcessor.test.js.map +1 -0
- package/dist/src/IRepository.d.ts +14 -0
- package/dist/src/IRepository.d.ts.map +1 -0
- package/dist/src/IRepository.js +25 -0
- package/dist/src/IRepository.js.map +1 -0
- package/dist/src/Repository.d.ts +20 -0
- package/dist/src/Repository.d.ts.map +1 -0
- package/dist/src/Repository.js +127 -0
- package/dist/src/Repository.js.map +1 -0
- package/dist/src/Repository.mocks.d.ts +13 -0
- package/dist/src/Repository.mocks.d.ts.map +1 -0
- package/dist/src/Repository.mocks.js +55 -0
- package/dist/src/Repository.mocks.js.map +1 -0
- package/dist/src/Repository.test.d.ts +2 -0
- package/dist/src/Repository.test.d.ts.map +1 -0
- package/dist/src/Repository.test.js +108 -0
- package/dist/src/Repository.test.js.map +1 -0
- package/dist/src/entities.d.ts +37 -0
- package/dist/src/entities.d.ts.map +1 -0
- package/dist/src/entities.js +25 -0
- package/dist/src/entities.js.map +1 -0
- package/dist/src/index.d.ts +11 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/index.js +34 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/logger.d.ts +23 -0
- package/dist/src/logger.d.ts.map +1 -0
- package/dist/src/logger.js +37 -0
- package/dist/src/logger.js.map +1 -0
- package/dist/src/mocks.d.ts +4 -0
- package/dist/src/mocks.d.ts.map +1 -0
- package/dist/src/mocks.js +27 -0
- package/dist/src/mocks.js.map +1 -0
- package/dist/src/otel/AbstractEventProcessManager.d.ts +6 -0
- package/dist/src/otel/AbstractEventProcessManager.d.ts.map +1 -0
- package/dist/src/otel/AbstractEventProcessManager.js +63 -0
- package/dist/src/otel/AbstractEventProcessManager.js.map +1 -0
- package/dist/src/otel/EventProcessor.d.ts +13 -0
- package/dist/src/otel/EventProcessor.d.ts.map +1 -0
- package/dist/src/otel/EventProcessor.js +59 -0
- package/dist/src/otel/EventProcessor.js.map +1 -0
- package/dist/src/otel/Repository.d.ts +12 -0
- package/dist/src/otel/Repository.d.ts.map +1 -0
- package/dist/src/otel/Repository.js +80 -0
- package/dist/src/otel/Repository.js.map +1 -0
- package/dist/src/otel/index.d.ts +6 -0
- package/dist/src/otel/index.d.ts.map +1 -0
- package/dist/src/otel/index.js +29 -0
- package/dist/src/otel/index.js.map +1 -0
- package/dist/src/otel/tracer.d.ts +2 -0
- package/dist/src/otel/tracer.d.ts.map +1 -0
- package/dist/src/otel/tracer.js +27 -0
- package/dist/src/otel/tracer.js.map +1 -0
- package/dist/src/otel/utils.d.ts +8 -0
- package/dist/src/otel/utils.d.ts.map +1 -0
- package/dist/src/otel/utils.js +70 -0
- package/dist/src/otel/utils.js.map +1 -0
- package/dist/src/schemas.d.ts +83 -0
- package/dist/src/schemas.d.ts.map +1 -0
- package/dist/src/schemas.js +77 -0
- package/dist/src/schemas.js.map +1 -0
- package/dist/src/schemas.test.d.ts +2 -0
- package/dist/src/schemas.test.d.ts.map +1 -0
- package/dist/src/schemas.test.js +110 -0
- package/dist/src/schemas.test.js.map +1 -0
- package/dist/src/types.d.ts +124 -0
- package/dist/src/types.d.ts.map +1 -0
- package/dist/src/types.fixtures.d.ts +3 -0
- package/dist/src/types.fixtures.d.ts.map +1 -0
- package/dist/src/types.fixtures.js +28 -0
- package/dist/src/types.fixtures.js.map +1 -0
- package/dist/src/types.js +130 -0
- package/dist/src/types.js.map +1 -0
- package/dist/src/types.mocks.d.ts +14 -0
- package/dist/src/types.mocks.d.ts.map +1 -0
- package/dist/src/types.mocks.js +239 -0
- package/dist/src/types.mocks.js.map +1 -0
- package/dist/src/utils.d.ts +11 -0
- package/dist/src/utils.d.ts.map +1 -0
- package/dist/src/utils.js +64 -0
- package/dist/src/utils.js.map +1 -0
- package/package.json +81 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IRepository.js","sourceRoot":"","sources":["../../src/IRepository.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;EAsBE"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { AggregateConfig, AggregateRoot, AggregateRootClass, PersistedAggregate } from './AggregateRoot.js';
|
|
2
|
+
import { IRepository } from './IRepository.js';
|
|
3
|
+
import { VersionedFixedLink } from './entities.js';
|
|
4
|
+
import { ConcurrencyException, EventConflictException, EventRevision, Exception, IEvent, IEventStore, Result, SaveEventSuccess } from './types.js';
|
|
5
|
+
export declare abstract class Repository<DomainEvent extends IEvent, T extends AggregateRoot<DomainEvent>> implements IRepository<DomainEvent, T> {
|
|
6
|
+
protected readonly _class: AggregateRootClass<DomainEvent, T>;
|
|
7
|
+
protected readonly _storage: IEventStore;
|
|
8
|
+
protected readonly _config?: AggregateConfig | undefined;
|
|
9
|
+
protected constructor(_class: AggregateRootClass<DomainEvent, T>, _storage: IEventStore, _config?: AggregateConfig | undefined);
|
|
10
|
+
save(aggregate: T, expectedRevision: EventRevision): Promise<Result<SaveEventSuccess, ConcurrencyException | EventConflictException | Exception>>;
|
|
11
|
+
/**
|
|
12
|
+
* Automatically retry to save the events if none of the new events conflict with the change set
|
|
13
|
+
*/
|
|
14
|
+
protected retrySave(aggregate: T, nextExpectedRevision: bigint, retries?: number, newAggregate?: T): Promise<Result<SaveEventSuccess, ConcurrencyException | EventConflictException | Exception>>;
|
|
15
|
+
getById(id: string, includeDeleted?: boolean): Promise<PersistedAggregate<DomainEvent, T> | undefined>;
|
|
16
|
+
getRevisionById(id: string, revision: bigint, includeDeleted?: boolean): Promise<PersistedAggregate<DomainEvent, T> | undefined>;
|
|
17
|
+
getByLink<ID extends string>(link: VersionedFixedLink<ID>, includeDeleted?: boolean): Promise<PersistedAggregate<DomainEvent, T> | undefined>;
|
|
18
|
+
protected loadAggregate(id: string, revision: bigint | undefined, includeDeleted: boolean | undefined): Promise<PersistedAggregate<DomainEvent, T> | undefined>;
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AAgB,EAAE,oBAAoB,GAAG,sBAAsB,GAAG,SAAS,CAAC,CAAC;IAoDlF,OAAO,CAClB,EAAE,EAAE,MAAM,EACV,cAAc,GAAE,OAAe,GAC9B,OAAO,CAAC,kBAAkB,CAAC,WAAW,EAAE,CAAC,CAAC,GAAG,SAAS,CAAC;IAI7C,eAAe,CAC1B,EAAE,EAAE,MAAM,EACV,QAAQ,EAAE,MAAM,EAChB,cAAc,GAAE,OAAe,GAC9B,OAAO,CAAC,kBAAkB,CAAC,WAAW,EAAE,CAAC,CAAC,GAAG,SAAS,CAAC;IAI7C,SAAS,CAAC,EAAE,SAAS,MAAM,EACtC,IAAI,EAAE,kBAAkB,CAAC,EAAE,CAAC,EAC5B,cAAc,CAAC,EAAE,OAAO,GACvB,OAAO,CAAC,kBAAkB,CAAC,WAAW,EAAE,CAAC,CAAC,GAAG,SAAS,CAAC;cAQ1C,aAAa,CAC3B,EAAE,EAAE,MAAM,EACV,QAAQ,EAAE,MAAM,GAAG,SAAS,EAC5B,cAAc,EAAE,OAAO,GAAG,SAAS,GAClC,OAAO,CAAC,kBAAkB,CAAC,WAAW,EAAE,CAAC,CAAC,GAAG,SAAS,CAAC;CAU3D"}
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
/*
|
|
2
|
+
MIT License
|
|
3
|
+
|
|
4
|
+
Copyright (c) 2024 Justin Bailey
|
|
5
|
+
|
|
6
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
8
|
+
in the Software without restriction, including without limitation the rights
|
|
9
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
11
|
+
furnished to do so, subject to the following conditions:
|
|
12
|
+
|
|
13
|
+
The above copyright notice and this permission notice shall be included in all
|
|
14
|
+
copies or substantial portions of the Software.
|
|
15
|
+
|
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
+
SOFTWARE.
|
|
23
|
+
*/
|
|
24
|
+
import { logProvider } from './logger.js';
|
|
25
|
+
import { Err, EventConflictException, EventExistenceRevision, Ok, } from './types.js';
|
|
26
|
+
export class Repository {
|
|
27
|
+
_class;
|
|
28
|
+
_storage;
|
|
29
|
+
_config;
|
|
30
|
+
constructor(_class, _storage, _config) {
|
|
31
|
+
this._class = _class;
|
|
32
|
+
this._storage = _storage;
|
|
33
|
+
this._config = _config;
|
|
34
|
+
}
|
|
35
|
+
async save(aggregate, expectedRevision) {
|
|
36
|
+
// don't bother trying to save the first time if the expectedRevision is already out of date
|
|
37
|
+
const hasRevision = aggregate.revision;
|
|
38
|
+
const hasExpectedRevision = typeof expectedRevision === 'bigint';
|
|
39
|
+
if (hasRevision && hasExpectedRevision && aggregate.revision > expectedRevision) {
|
|
40
|
+
return this.retrySave(aggregate, expectedRevision);
|
|
41
|
+
}
|
|
42
|
+
const stream = this._class.getStreamName(aggregate.id);
|
|
43
|
+
const res = await this._storage.saveEvents(stream, aggregate.getUncommittedChanges(), expectedRevision);
|
|
44
|
+
if (res.ok) {
|
|
45
|
+
aggregate.markChangesAsCommitted();
|
|
46
|
+
return Ok({ nextExpectedRevision: res.value.nextExpectedRevision });
|
|
47
|
+
}
|
|
48
|
+
else if (res.error) {
|
|
49
|
+
switch (expectedRevision) {
|
|
50
|
+
case EventExistenceRevision.Any:
|
|
51
|
+
// this shouldn't be possible, log it
|
|
52
|
+
logProvider.log.warn(`Repository.save unexpected ConcurrencyException for EventRevision.ANY`, res.error);
|
|
53
|
+
// fall-through
|
|
54
|
+
case EventExistenceRevision.StreamExists:
|
|
55
|
+
case EventExistenceRevision.NoStream:
|
|
56
|
+
// The stream existence state didn't match; operation failed.
|
|
57
|
+
return Err(res.error);
|
|
58
|
+
default:
|
|
59
|
+
// @ts-ignore - TODO: what can we do if the DB doesn't return the next revision here?
|
|
60
|
+
return this.retrySave(aggregate, res.error.nextExpectedRevision);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
return Err(res.error);
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Automatically retry to save the events if none of the new events conflict with the change set
|
|
67
|
+
*/
|
|
68
|
+
async retrySave(aggregate, nextExpectedRevision, retries = 5, newAggregate) {
|
|
69
|
+
if (!newAggregate) {
|
|
70
|
+
// force TS to recognize the type is no longer possibly undefined
|
|
71
|
+
newAggregate = new this._class(this._config);
|
|
72
|
+
newAggregate.loadFromHistory(aggregate.history);
|
|
73
|
+
}
|
|
74
|
+
// load the new events since the revision the command was based on.
|
|
75
|
+
const streamName = this._class.getStreamName(aggregate.id);
|
|
76
|
+
const newEvents = await this._storage.getEventsForAggregateFromRevision(streamName, nextExpectedRevision);
|
|
77
|
+
newAggregate.loadFromHistory(newEvents);
|
|
78
|
+
// Check each event for any conflicts with the latest state of the aggregate or with new events that have been processed.
|
|
79
|
+
for (const pendingEvent of aggregate.getUncommittedChanges()) {
|
|
80
|
+
const conflictRes = newAggregate.hasConflict(pendingEvent);
|
|
81
|
+
if (!conflictRes.ok) {
|
|
82
|
+
return Err(conflictRes.error);
|
|
83
|
+
}
|
|
84
|
+
for (const committedEvent of newEvents) {
|
|
85
|
+
if (this._class.eventsConflict(pendingEvent, committedEvent)) {
|
|
86
|
+
return Err(new EventConflictException(this._class.name, aggregate.id, committedEvent.type, pendingEvent.type));
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
const res = await this._storage.saveEvents(streamName, aggregate.getUncommittedChanges(), nextExpectedRevision);
|
|
91
|
+
if (res.ok) {
|
|
92
|
+
aggregate.markChangesAsCommitted();
|
|
93
|
+
return Ok({ nextExpectedRevision: res.value.nextExpectedRevision });
|
|
94
|
+
}
|
|
95
|
+
else if (res.error && retries > 0) {
|
|
96
|
+
// @ts-ignore - TODO: what can we do if the DB doesn't return the next revision here?
|
|
97
|
+
return this.retrySave(aggregate, res.error.nextExpectedRevision, retries - 1);
|
|
98
|
+
}
|
|
99
|
+
return Err(res.error);
|
|
100
|
+
}
|
|
101
|
+
async getById(id, includeDeleted = false) {
|
|
102
|
+
return this.loadAggregate(id, undefined, includeDeleted);
|
|
103
|
+
}
|
|
104
|
+
async getRevisionById(id, revision, includeDeleted = false) {
|
|
105
|
+
return this.loadAggregate(id, revision, includeDeleted);
|
|
106
|
+
}
|
|
107
|
+
async getByLink(link, includeDeleted) {
|
|
108
|
+
if (link.revision === 'latest') {
|
|
109
|
+
return this.loadAggregate(link.id, undefined, includeDeleted);
|
|
110
|
+
}
|
|
111
|
+
else {
|
|
112
|
+
return this.loadAggregate(link.id, link.revision, includeDeleted);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
async loadAggregate(id, revision, includeDeleted) {
|
|
116
|
+
const streamName = this._class.getStreamName(id);
|
|
117
|
+
const e = await this._storage.getEventsForAggregate(streamName, revision);
|
|
118
|
+
if (!e?.length)
|
|
119
|
+
return undefined;
|
|
120
|
+
const obj = new this._class(this._config);
|
|
121
|
+
obj.loadFromHistory(e);
|
|
122
|
+
if (!includeDeleted && obj.deleted)
|
|
123
|
+
return undefined;
|
|
124
|
+
return obj;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
//# sourceMappingURL=Repository.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Repository.js","sourceRoot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AE/B,OAAO,IAAI,CAAC,aAAa,CAAC,EAAE,EAAE,QAAQ,EAAE,cAAc,CAAC,CAAA;IACzD,CAAC;IAEM,KAAK,CAAC,SAAS,CACpB,IAA4B,EAC5B,cAAwB;QAExB,IAAI,IAAI,CAAC,QAAQ,KAAK,QAAQ,EAAE,CAAC;YAC/B,OAAO,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,EAAE,EAAE,SAAS,EAAE,cAAc,CAAC,CAAA;QAC/D,CAAC;aAAM,CAAC;YACN,OAAO,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,EAAE,EAAE,IAAI,CAAC,QAAQ,EAAE,cAAc,CAAC,CAAA;QACnE,CAAC;IACH,CAAC;IAES,KAAK,CAAC,aAAa,CAC3B,EAAU,EACV,QAA4B,EAC5B,cAAmC;QAEnC,MAAM,UAAU,GAAG,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,EAAE,CAAC,CAAA;QAChD,MAAM,CAAC,GAAG,MAAM,IAAI,CAAC,QAAQ,CAAC,qBAAqB,CAAc,UAAU,EAAE,QAAQ,CAAC,CAAA;QACtF,IAAI,CAAC,CAAC,EAAE,MAAM;YAAE,OAAO,SAAS,CAAA;QAEhC,MAAM,GAAG,GAAG,IAAI,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,CAAuC,CAAA;QAC/E,GAAG,CAAC,eAAe,CAAC,CAAC,CAAC,CAAA;QACtB,IAAI,CAAC,cAAc,IAAI,GAAG,CAAC,OAAO;YAAE,OAAO,SAAS,CAAA;QACpD,OAAO,GAAG,CAAA;IACZ,CAAC;CACF"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { AggregateRoot, AggregateRootClass } from './AggregateRoot.js';
|
|
2
|
+
import { Test, TestEvent } from './AggregateRoot.mocks.js';
|
|
3
|
+
import { Repository } from './Repository.js';
|
|
4
|
+
import { IEvent, IEventStore } from './types.js';
|
|
5
|
+
export declare class MockRepository<DomainEvent extends IEvent, T extends AggregateRoot<DomainEvent>> extends Repository<DomainEvent, T> {
|
|
6
|
+
private readonly prefixLength;
|
|
7
|
+
constructor(classConstructor: AggregateRootClass<DomainEvent, T>, seedEvents?: Array<IEvent>);
|
|
8
|
+
getAllIds(): string[];
|
|
9
|
+
}
|
|
10
|
+
export declare class TestRepository extends Repository<TestEvent, Test> {
|
|
11
|
+
constructor(storage: IEventStore);
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=Repository.mocks.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Repository.mocks.d.ts","sourceRoot":"","sources":["../../src/Repository.mocks.ts"],"names":[],"mappings":"AAwBA,OAAO,EAAE,aAAa,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAA;AACtE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAA;AAC1D,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAC5C,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,YAAY,CAAA;AAGhD,qBAAa,cAAc,CACzB,WAAW,SAAS,MAAM,EAC1B,CAAC,SAAS,aAAa,CAAC,WAAW,CAAC,CACpC,SAAQ,UAAU,CAAC,WAAW,EAAE,CAAC,CAAC;IAClC,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAQ;gBAGnC,gBAAgB,EAAE,kBAAkB,CAAC,WAAW,EAAE,CAAC,CAAC,EACpD,UAAU,GAAE,KAAK,CAAC,MAAM,CAAM;IAkBhC,SAAS,IAAI,MAAM,EAAE;CAItB;AAED,qBAAa,cAAe,SAAQ,UAAU,CAAC,SAAS,EAAE,IAAI,CAAC;gBACjD,OAAO,EAAE,WAAW;CAGjC"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/*
|
|
2
|
+
MIT License
|
|
3
|
+
|
|
4
|
+
Copyright (c) 2024 Justin Bailey
|
|
5
|
+
|
|
6
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
8
|
+
in the Software without restriction, including without limitation the rights
|
|
9
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
11
|
+
furnished to do so, subject to the following conditions:
|
|
12
|
+
|
|
13
|
+
The above copyright notice and this permission notice shall be included in all
|
|
14
|
+
copies or substantial portions of the Software.
|
|
15
|
+
|
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
+
SOFTWARE.
|
|
23
|
+
*/
|
|
24
|
+
import { Test } from './AggregateRoot.mocks.js';
|
|
25
|
+
import { Repository } from './Repository.js';
|
|
26
|
+
import { MockEventStore } from './types.mocks.js';
|
|
27
|
+
export class MockRepository extends Repository {
|
|
28
|
+
prefixLength;
|
|
29
|
+
constructor(classConstructor, seedEvents = []) {
|
|
30
|
+
const events = new Map();
|
|
31
|
+
for (const event of seedEvents) {
|
|
32
|
+
const streamName = classConstructor.getStreamName(event.data.id);
|
|
33
|
+
if (!events.has(streamName)) {
|
|
34
|
+
events.set(streamName, [event]);
|
|
35
|
+
}
|
|
36
|
+
else {
|
|
37
|
+
events.get(streamName).push(event);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
super(classConstructor, new MockEventStore(events));
|
|
41
|
+
// Assumes StreamName prefixes the ID. Does not work with a postfix or other changes.
|
|
42
|
+
this.prefixLength = this._class.getStreamName('').length;
|
|
43
|
+
}
|
|
44
|
+
// We need a way to get all data in memory in tests
|
|
45
|
+
getAllIds() {
|
|
46
|
+
const streamNames = this._storage.getAllIds();
|
|
47
|
+
return streamNames.map((streamName) => streamName.substring(this.prefixLength));
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
export class TestRepository extends Repository {
|
|
51
|
+
constructor(storage) {
|
|
52
|
+
super(Test, storage);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
//# sourceMappingURL=Repository.mocks.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Repository.mocks.js","sourceRoot":"","sources":["../../src/Repository.mocks.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;EAsBE;AAGF,OAAO,EAAE,IAAI,EAAa,MAAM,0BAA0B,CAAA;AAC1D,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAE5C,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAA;AAEjD,MAAM,OAAO,cAGX,SAAQ,UAA0B;IACjB,YAAY,CAAQ;IAErC,YACE,gBAAoD,EACpD,aAA4B,EAAE;QAE9B,MAAM,MAAM,GAAG,IAAI,GAAG,EAAoB,CAAA;QAC1C,KAAK,MAAM,KAAK,IAAI,UAAU,EAAE,CAAC;YAC/B,MAAM,UAAU,GAAG,gBAAgB,CAAC,aAAa,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;YAChE,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,UAAU,CAAC,EAAE,CAAC;gBAC5B,MAAM,CAAC,GAAG,CAAC,UAAU,EAAE,CAAC,KAAK,CAAC,CAAC,CAAA;YACjC,CAAC;iBAAM,CAAC;gBACN,MAAM,CAAC,GAAG,CAAC,UAAU,CAAE,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;YACrC,CAAC;QACH,CAAC;QACD,KAAK,CAAC,gBAAgB,EAAE,IAAI,cAAc,CAAC,MAAM,CAAC,CAAC,CAAA;QAEnD,qFAAqF;QACrF,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,EAAE,CAAC,CAAC,MAAM,CAAA;IAC1D,CAAC;IAED,mDAAmD;IACnD,SAAS;QACP,MAAM,WAAW,GAAI,IAAI,CAAC,QAA2B,CAAC,SAAS,EAAE,CAAA;QACjE,OAAO,WAAW,CAAC,GAAG,CAAC,CAAC,UAAU,EAAE,EAAE,CAAC,UAAU,CAAC,SAAS,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC,CAAA;IACjF,CAAC;CACF;AAED,MAAM,OAAO,cAAe,SAAQ,UAA2B;IAC7D,YAAY,OAAoB;QAC9B,KAAK,CAAC,IAAI,EAAE,OAAO,CAAC,CAAA;IACtB,CAAC;CACF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Repository.test.d.ts","sourceRoot":"","sources":["../../src/Repository.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
/*
|
|
2
|
+
MIT License
|
|
3
|
+
|
|
4
|
+
Copyright (c) 2024 Justin Bailey
|
|
5
|
+
|
|
6
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
8
|
+
in the Software without restriction, including without limitation the rights
|
|
9
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
11
|
+
furnished to do so, subject to the following conditions:
|
|
12
|
+
|
|
13
|
+
The above copyright notice and this permission notice shall be included in all
|
|
14
|
+
copies or substantial portions of the Software.
|
|
15
|
+
|
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
+
SOFTWARE.
|
|
23
|
+
*/
|
|
24
|
+
import { describe, expect, test } from 'vitest';
|
|
25
|
+
import { Test, } from './AggregateRoot.mocks.js';
|
|
26
|
+
import { TestRepository } from './Repository.mocks.js';
|
|
27
|
+
import { mockMetadata } from './types.fixtures.js';
|
|
28
|
+
import { EventConflictException, EventExistenceRevision, createEvent } from './types.js';
|
|
29
|
+
import { MockEventStore } from './types.mocks.js';
|
|
30
|
+
describe('Repository', () => {
|
|
31
|
+
const testCreated = createEvent({
|
|
32
|
+
type: 'TestCreated',
|
|
33
|
+
data: { id: '1', name: 'Test' },
|
|
34
|
+
metadata: mockMetadata,
|
|
35
|
+
});
|
|
36
|
+
const testRenamed = createEvent({
|
|
37
|
+
type: 'TestRenamed',
|
|
38
|
+
data: { id: '1', name: 'A Test' },
|
|
39
|
+
metadata: mockMetadata,
|
|
40
|
+
});
|
|
41
|
+
const testRenamedAgain = createEvent({
|
|
42
|
+
type: 'TestRenamed',
|
|
43
|
+
data: { id: '1', name: 'The Test' },
|
|
44
|
+
metadata: mockMetadata,
|
|
45
|
+
});
|
|
46
|
+
const testRenamedMore = createEvent({
|
|
47
|
+
type: 'TestRenamed',
|
|
48
|
+
data: { id: '1', name: 'Some Test' },
|
|
49
|
+
metadata: mockMetadata,
|
|
50
|
+
});
|
|
51
|
+
const testDeleted = createEvent({
|
|
52
|
+
type: 'TestDeleted',
|
|
53
|
+
data: { id: '1' },
|
|
54
|
+
metadata: mockMetadata,
|
|
55
|
+
});
|
|
56
|
+
const streamName = Test.getStreamName('1');
|
|
57
|
+
test('should save an event successfully', async () => {
|
|
58
|
+
const store = new MockEventStore();
|
|
59
|
+
const testRepo = new TestRepository(store);
|
|
60
|
+
const res = await Test.create('Test:1', 'foo');
|
|
61
|
+
expect(res.error?.message).not.toBeDefined();
|
|
62
|
+
expect(res.ok, 'Should not return an error').toBe(true);
|
|
63
|
+
if (!res.ok)
|
|
64
|
+
return;
|
|
65
|
+
const save = await testRepo.save(res.value, EventExistenceRevision.NoStream);
|
|
66
|
+
expect(save.error?.message).not.toBeDefined();
|
|
67
|
+
expect(save.ok, 'Should not return an error').toBe(true);
|
|
68
|
+
});
|
|
69
|
+
test('should fail when events conflict', async () => {
|
|
70
|
+
const store = new MockEventStore();
|
|
71
|
+
const save = await store.saveEvents(streamName, [testCreated, testRenamed, testRenamedAgain], EventExistenceRevision.NoStream);
|
|
72
|
+
expect(save.error?.message).not.toBeDefined();
|
|
73
|
+
expect(save.ok, 'Should not return an error').toBe(true);
|
|
74
|
+
expect(save.value, 'Should not return an error').toEqual({ nextExpectedRevision: 2n });
|
|
75
|
+
const testRepo = new TestRepository(store);
|
|
76
|
+
const instance = await testRepo.getById('1');
|
|
77
|
+
if (!instance)
|
|
78
|
+
throw new Error('Test 1 should exist');
|
|
79
|
+
// add a staged change
|
|
80
|
+
const rename = await instance.rename('foo');
|
|
81
|
+
expect(rename.error?.message).not.toBeDefined();
|
|
82
|
+
expect(rename.ok, 'Should not return an error').toBe(true);
|
|
83
|
+
const res = await testRepo.save(instance, 0n);
|
|
84
|
+
expect(res.ok, 'Should return an error').toBe(false);
|
|
85
|
+
if (res.ok)
|
|
86
|
+
return;
|
|
87
|
+
expect(res.error).toEqual(new EventConflictException('Test', instance.id, 'TestRenamed', 'TestRenamed'));
|
|
88
|
+
});
|
|
89
|
+
test(`should succeed when events don't conflict`, async () => {
|
|
90
|
+
const store = new MockEventStore();
|
|
91
|
+
const save = await store.saveEvents(streamName, [testCreated, testRenamed, testRenamedAgain], EventExistenceRevision.NoStream);
|
|
92
|
+
expect(save.error?.message).not.toBeDefined();
|
|
93
|
+
expect(save.ok, 'Should not return an error').toBe(true);
|
|
94
|
+
expect(save.value, 'Should not return an error').toEqual({ nextExpectedRevision: 2n });
|
|
95
|
+
const testRepo = new TestRepository(store);
|
|
96
|
+
const instance = await testRepo.getById('1');
|
|
97
|
+
if (!instance)
|
|
98
|
+
throw new Error('Test 1 should exist');
|
|
99
|
+
// add a staged change
|
|
100
|
+
const change = await instance.delete();
|
|
101
|
+
expect(change.error?.message).not.toBeDefined();
|
|
102
|
+
expect(change.ok, 'Should not return an error').toBe(true);
|
|
103
|
+
const res = await testRepo.save(instance, 0n);
|
|
104
|
+
expect(change.error?.message).not.toBeDefined();
|
|
105
|
+
expect(res.ok, 'Should return an error').toBe(true);
|
|
106
|
+
});
|
|
107
|
+
});
|
|
108
|
+
//# sourceMappingURL=Repository.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Repository.test.js","sourceRoot":"","sources":["../../src/Repository.test.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;EAsBE;AAEF,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAA;AAC/C,OAAO,EACL,IAAI,GAIL,MAAM,0BAA0B,CAAA;AACjC,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAA;AACtD,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAA;AAClD,OAAO,EAAE,sBAAsB,EAAE,sBAAsB,EAAE,WAAW,EAAE,MAAM,YAAY,CAAA;AACxF,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAA;AAEjD,QAAQ,CAAC,YAAY,EAAE,GAAG,EAAE;IAC1B,MAAM,WAAW,GAAG,WAAW,CAAmB;QAChD,IAAI,EAAE,aAAa;QACnB,I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AAK,CAAC,CAAA;QAC1C,MAAM,QAAQ,GAAG,MAAM,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,CAAA;QAC5C,IAAI,CAAC,QAAQ;YAAE,MAAM,IAAI,KAAK,CAAC,qBAAqB,CAAC,CAAA;QAErD,sBAAsB;QACtB,MAAM,MAAM,GAAG,MAAM,QAAQ,CAAC,MAAM,EAAE,CAAA;QACtC,MAAM,CAAE,MAAc,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC,GAAG,CAAC,WAAW,EAAE,CAAA;QACxD,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,4BAA4B,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;QAE1D,MAAM,GAAG,GAAG,MAAM,QAAQ,CAAC,IAAI,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAA;QAC7C,MAAM,CAAE,MAAc,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC,GAAG,CAAC,WAAW,EAAE,CAAA;QACxD,MAAM,CAAC,GAAG,CAAC,EAAE,EAAE,wBAAwB,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;IACrD,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Versioned Link to multiple types.
|
|
3
|
+
* Usage can be defined with a union.
|
|
4
|
+
*/
|
|
5
|
+
export interface Link<Type extends string = string, ID extends string = string> {
|
|
6
|
+
readonly type: Type;
|
|
7
|
+
readonly id: ID;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Versioned Link to multiple types.
|
|
11
|
+
* Usage can be defined with a union.
|
|
12
|
+
*/
|
|
13
|
+
export interface VersionedLink<Type extends string = string, ID extends string = string> extends Link<Type, ID> {
|
|
14
|
+
readonly revision: bigint | 'latest';
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Versioned Link to multiple types that must reference a specific revision.
|
|
18
|
+
* Usage can be defined with a union.
|
|
19
|
+
*/
|
|
20
|
+
export interface HardVersionedLink<Type extends string = string, ID extends string = string> extends Link<Type, ID> {
|
|
21
|
+
readonly revision: bigint;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Versioned Link to a single, known type.
|
|
25
|
+
*/
|
|
26
|
+
export interface VersionedFixedLink<ID extends string = string> {
|
|
27
|
+
readonly id: ID;
|
|
28
|
+
readonly revision: bigint | 'latest';
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Versioned Link to a single, known type that must reference a specific revision.
|
|
32
|
+
*/
|
|
33
|
+
export interface HardVersionedFixedLink<ID extends string = string> {
|
|
34
|
+
readonly id: ID;
|
|
35
|
+
readonly revision: bigint;
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=entities.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"entities.d.ts","sourceRoot":"","sources":["../../src/entities.ts"],"names":[],"mappings":"AAwBA;;;GAGG;AACH,MAAM,WAAW,IAAI,CAAC,IAAI,SAAS,MAAM,GAAG,MAAM,EAAE,EAAE,SAAS,MAAM,GAAG,MAAM;IAC5E,QAAQ,CAAC,IAAI,EAAE,IAAI,CAAA;IACnB,QAAQ,CAAC,EAAE,EAAE,EAAE,CAAA;CAChB;AAED;;;GAGG;AACH,MAAM,WAAW,aAAa,CAAC,IAAI,SAAS,MAAM,GAAG,MAAM,EAAE,EAAE,SAAS,MAAM,GAAG,MAAM,CACrF,SAAQ,IAAI,CAAC,IAAI,EAAE,EAAE,CAAC;IACtB,QAAQ,CAAC,QAAQ,EAAE,MAAM,GAAG,QAAQ,CAAA;CACrC;AAED;;;GAGG;AACH,MAAM,WAAW,iBAAiB,CAAC,IAAI,SAAS,MAAM,GAAG,MAAM,EAAE,EAAE,SAAS,MAAM,GAAG,MAAM,CACzF,SAAQ,IAAI,CAAC,IAAI,EAAE,EAAE,CAAC;IACtB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAA;CAC1B;AAED;;GAEG;AACH,MAAM,WAAW,kBAAkB,CAAC,EAAE,SAAS,MAAM,GAAG,MAAM;IAC5D,QAAQ,CAAC,EAAE,EAAE,EAAE,CAAA;IACf,QAAQ,CAAC,QAAQ,EAAE,MAAM,GAAG,QAAQ,CAAA;CACrC;AAED;;GAEG;AACH,MAAM,WAAW,sBAAsB,CAAC,EAAE,SAAS,MAAM,GAAG,MAAM;IAChE,QAAQ,CAAC,EAAE,EAAE,EAAE,CAAA;IACf,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAA;CAC1B"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/*
|
|
2
|
+
MIT License
|
|
3
|
+
|
|
4
|
+
Copyright (c) 2024 Justin Bailey
|
|
5
|
+
|
|
6
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
8
|
+
in the Software without restriction, including without limitation the rights
|
|
9
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
11
|
+
furnished to do so, subject to the following conditions:
|
|
12
|
+
|
|
13
|
+
The above copyright notice and this permission notice shall be included in all
|
|
14
|
+
copies or substantial portions of the Software.
|
|
15
|
+
|
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
+
SOFTWARE.
|
|
23
|
+
*/
|
|
24
|
+
export {};
|
|
25
|
+
//# sourceMappingURL=entities.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"entities.js","sourceRoot":"","sources":["../../src/entities.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;EAsBE"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export * from './AbstractEventProcessManager.js';
|
|
2
|
+
export * from './AggregateRoot.js';
|
|
3
|
+
export * from './EventProcessor.js';
|
|
4
|
+
export * from './IRepository.js';
|
|
5
|
+
export * from './Repository.js';
|
|
6
|
+
export * from './entities.js';
|
|
7
|
+
export * from './logger.js';
|
|
8
|
+
export * from './schemas.js';
|
|
9
|
+
export * from './types.js';
|
|
10
|
+
export * from './utils.js';
|
|
11
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAwBA,cAAc,kCAAkC,CAAA;AAChD,cAAc,oBAAoB,CAAA;AAClC,cAAc,qBAAqB,CAAA;AACnC,cAAc,kBAAkB,CAAA;AAChC,cAAc,iBAAiB,CAAA;AAC/B,cAAc,eAAe,CAAA;AAC7B,cAAc,aAAa,CAAA;AAC3B,cAAc,cAAc,CAAA;AAC5B,cAAc,YAAY,CAAA;AAC1B,cAAc,YAAY,CAAA"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/*
|
|
2
|
+
MIT License
|
|
3
|
+
|
|
4
|
+
Copyright (c) 2024 Justin Bailey
|
|
5
|
+
|
|
6
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
8
|
+
in the Software without restriction, including without limitation the rights
|
|
9
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
11
|
+
furnished to do so, subject to the following conditions:
|
|
12
|
+
|
|
13
|
+
The above copyright notice and this permission notice shall be included in all
|
|
14
|
+
copies or substantial portions of the Software.
|
|
15
|
+
|
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
+
SOFTWARE.
|
|
23
|
+
*/
|
|
24
|
+
export * from './AbstractEventProcessManager.js';
|
|
25
|
+
export * from './AggregateRoot.js';
|
|
26
|
+
export * from './EventProcessor.js';
|
|
27
|
+
export * from './IRepository.js';
|
|
28
|
+
export * from './Repository.js';
|
|
29
|
+
export * from './entities.js';
|
|
30
|
+
export * from './logger.js';
|
|
31
|
+
export * from './schemas.js';
|
|
32
|
+
export * from './types.js';
|
|
33
|
+
export * from './utils.js';
|
|
34
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;EAsBE;AAEF,cAAc,kCAAkC,CAAA;AAChD,cAAc,oBAAoB,CAAA;AAClC,cAAc,qBAAqB,CAAA;AACnC,cAAc,kBAAkB,CAAA;AAChC,cAAc,iBAAiB,CAAA;AAC/B,cAAc,eAAe,CAAA;AAC7B,cAAc,aAAa,CAAA;AAC3B,cAAc,cAAc,CAAA;AAC5B,cAAc,YAAY,CAAA;AAC1B,cAAc,YAAY,CAAA"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/** Based off of Pino's API */
|
|
2
|
+
export interface ILogger {
|
|
3
|
+
fatal: LogFn;
|
|
4
|
+
error: LogFn;
|
|
5
|
+
warn: LogFn;
|
|
6
|
+
info: LogFn;
|
|
7
|
+
debug: LogFn;
|
|
8
|
+
trace: LogFn;
|
|
9
|
+
silent: LogFn;
|
|
10
|
+
}
|
|
11
|
+
interface LogFn {
|
|
12
|
+
<T extends object>(obj: T, msg?: string, ...args: any[]): void;
|
|
13
|
+
(obj: unknown, msg?: string, ...args: any[]): void;
|
|
14
|
+
(msg: string, ...args: any[]): void;
|
|
15
|
+
}
|
|
16
|
+
declare class LogProvider {
|
|
17
|
+
protected _log: ILogger | undefined;
|
|
18
|
+
setLogger(logger: ILogger): void;
|
|
19
|
+
get log(): ILogger;
|
|
20
|
+
}
|
|
21
|
+
export declare const logProvider: LogProvider;
|
|
22
|
+
export {};
|
|
23
|
+
//# sourceMappingURL=logger.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../src/logger.ts"],"names":[],"mappings":"AAwBA,8BAA8B;AAC9B,MAAM,WAAW,OAAO;IACtB,KAAK,EAAE,KAAK,CAAA;IACZ,KAAK,EAAE,KAAK,CAAA;IACZ,IAAI,EAAE,KAAK,CAAA;IACX,IAAI,EAAE,KAAK,CAAA;IACX,KAAK,EAAE,KAAK,CAAA;IACZ,KAAK,EAAE,KAAK,CAAA;IACZ,MAAM,EAAE,KAAK,CAAA;CACd;AAED,UAAU,KAAK;IAEb,CAAC,CAAC,SAAS,MAAM,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,CAAC,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,IAAI,CAAA;IAC9D,CAAC,GAAG,EAAE,OAAO,EAAE,GAAG,CAAC,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,IAAI,CAAA;IAClD,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,IAAI,CAAA;CACpC;AAED,cAAM,WAAW;IACf,SAAS,CAAC,IAAI,EAAE,OAAO,GAAG,SAAS,CAAA;IAEnC,SAAS,CAAC,MAAM,EAAE,OAAO,GAAG,IAAI;IAIhC,IAAI,GAAG,IAAI,OAAO,CAKjB;CACF;AAED,eAAO,MAAM,WAAW,aAAoB,CAAA"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/*
|
|
2
|
+
MIT License
|
|
3
|
+
|
|
4
|
+
Copyright (c) 2024 Justin Bailey
|
|
5
|
+
|
|
6
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
8
|
+
in the Software without restriction, including without limitation the rights
|
|
9
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
11
|
+
furnished to do so, subject to the following conditions:
|
|
12
|
+
|
|
13
|
+
The above copyright notice and this permission notice shall be included in all
|
|
14
|
+
copies or substantial portions of the Software.
|
|
15
|
+
|
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
+
SOFTWARE.
|
|
23
|
+
*/
|
|
24
|
+
class LogProvider {
|
|
25
|
+
_log;
|
|
26
|
+
setLogger(logger) {
|
|
27
|
+
this._log = logger;
|
|
28
|
+
}
|
|
29
|
+
get log() {
|
|
30
|
+
if (!this._log) {
|
|
31
|
+
throw new Error(`No logger has been configured!`);
|
|
32
|
+
}
|
|
33
|
+
return this._log;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
export const logProvider = new LogProvider();
|
|
37
|
+
//# sourceMappingURL=logger.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logger.js","sourceRoot":"","sources":["../../src/logger.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;EAsBE;AAoBF,MAAM,WAAW;IACL,IAAI,CAAqB;IAEnC,SAAS,CAAC,MAAe;QACvB,IAAI,CAAC,IAAI,GAAG,MAAM,CAAA;IACpB,CAAC;IAED,IAAI,GAAG;QACL,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC;YACf,MAAM,IAAI,KAAK,CAAC,gCAAgC,CAAC,CAAA;QACnD,CAAC;QACD,OAAO,IAAI,CAAC,IAAI,CAAA;IAClB,CAAC;CACF;AAED,MAAM,CAAC,MAAM,WAAW,GAAG,IAAI,WAAW,EAAE,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mocks.d.ts","sourceRoot":"","sources":["../../src/mocks.ts"],"names":[],"mappings":"AAwBA,cAAc,0BAA0B,CAAA;AACxC,cAAc,uBAAuB,CAAA;AACrC,cAAc,kBAAkB,CAAA"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/*
|
|
2
|
+
MIT License
|
|
3
|
+
|
|
4
|
+
Copyright (c) 2024 Justin Bailey
|
|
5
|
+
|
|
6
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
8
|
+
in the Software without restriction, including without limitation the rights
|
|
9
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
11
|
+
furnished to do so, subject to the following conditions:
|
|
12
|
+
|
|
13
|
+
The above copyright notice and this permission notice shall be included in all
|
|
14
|
+
copies or substantial portions of the Software.
|
|
15
|
+
|
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
+
SOFTWARE.
|
|
23
|
+
*/
|
|
24
|
+
export * from './AggregateRoot.mocks.js';
|
|
25
|
+
export * from './Repository.mocks.js';
|
|
26
|
+
export * from './types.mocks.js';
|
|
27
|
+
//# sourceMappingURL=mocks.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mocks.js","sourceRoot":"","sources":["../../src/mocks.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;EAsBE;AAEF,cAAc,0BAA0B,CAAA;AACxC,cAAc,uBAAuB,CAAA;AACrC,cAAc,kBAAkB,CAAA"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { AbstractEventProcessManager, Subscribable } from '../AbstractEventProcessManager.js';
|
|
2
|
+
import { IPersistedEvent } from '../types.js';
|
|
3
|
+
export declare abstract class OtelAbstractEventProcessManager<DBEvent, ReadPosition, Subscription extends Subscribable<DBEvent>> extends AbstractEventProcessManager<DBEvent, ReadPosition, Subscription> {
|
|
4
|
+
protected handleDataEvent(event: IPersistedEvent, position?: ReadPosition): Promise<void>;
|
|
5
|
+
}
|
|
6
|
+
//# sourceMappingURL=AbstractEventProcessManager.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AbstractEventProcessManager.d.ts","sourceRoot":"","sources":["../../../src/otel/AbstractEventProcessManager.ts"],"names":[],"mappings":"AAyBA,OAAO,EAAE,2BAA2B,EAAE,YAAY,EAAE,MAAM,mCAAmC,CAAA;AAC7F,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AAI7C,8BAAsB,+BAA+B,CACnD,OAAO,EACP,YAAY,EACZ,YAAY,SAAS,YAAY,CAAC,OAAO,CAAC,CAC1C,SAAQ,2BAA2B,CAAC,OAAO,EAAE,YAAY,EAAE,YAAY,CAAC;cAC/C,eAAe,CACtC,KAAK,EAAE,eAAe,EACtB,QAAQ,CAAC,EAAE,YAAY,GACtB,OAAO,CAAC,IAAI,CAAC;CAoCjB"}
|