event-store-adapter-js 2.0.15 → 2.0.16-snapshot.2

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.
@@ -12,7 +12,7 @@ class JsonEventSerializer {
12
12
  }
13
13
  serialize(event) {
14
14
  const jsonString = JSON.stringify({
15
- type: event.constructor.name,
15
+ type: event.typeName,
16
16
  data: event,
17
17
  });
18
18
  return this.encoder.encode(jsonString);
@@ -30,7 +30,7 @@ class JsonSnapshotSerializer {
30
30
  }
31
31
  serialize(aggregate) {
32
32
  const jsonString = JSON.stringify({
33
- type: aggregate.constructor.name,
33
+ type: aggregate.typeName,
34
34
  data: aggregate,
35
35
  });
36
36
  return this.encoder.encode(jsonString);
package/dist/types.d.ts CHANGED
@@ -4,6 +4,7 @@ interface AggregateId {
4
4
  asString: string;
5
5
  }
6
6
  interface Aggregate<This extends Aggregate<This, AID>, AID extends AggregateId> {
7
+ typeName: string;
7
8
  id: AID;
8
9
  sequenceNumber: number;
9
10
  version: number;
@@ -11,6 +12,7 @@ interface Aggregate<This extends Aggregate<This, AID>, AID extends AggregateId>
11
12
  updateVersion(version: (value: number) => number): This;
12
13
  }
13
14
  interface Event<AID extends AggregateId> {
15
+ typeName: string;
14
16
  id: string;
15
17
  aggregateId: AID;
16
18
  sequenceNumber: number;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "event-store-adapter-js",
3
- "version": "2.0.15",
3
+ "version": "2.0.16-snapshot.2",
4
4
  "description": "This library is designed to turn DynamoDB into an Event Store for Event Sourcing.",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -73,7 +73,6 @@ class EventStoreFactory {
73
73
  snapshotSerializer,
74
74
  );
75
75
  }
76
-
77
76
  static ofMemory<
78
77
  AID extends AggregateId,
79
78
  A extends Aggregate<A, AID>,
@@ -19,7 +19,7 @@ class JsonEventSerializer<AID extends AggregateId, E extends Event<AID>>
19
19
 
20
20
  serialize(event: E): Uint8Array {
21
21
  const jsonString = JSON.stringify({
22
- type: event.constructor.name,
22
+ type: event.typeName,
23
23
  data: event,
24
24
  });
25
25
  return this.encoder.encode(jsonString);
@@ -40,7 +40,7 @@ class JsonSnapshotSerializer<
40
40
 
41
41
  serialize(aggregate: A): Uint8Array {
42
42
  const jsonString = JSON.stringify({
43
- type: aggregate.constructor.name,
43
+ type: aggregate.typeName,
44
44
  data: aggregate,
45
45
  });
46
46
  return this.encoder.encode(jsonString);
@@ -4,6 +4,7 @@ import { convertJSONToUserAccountId, UserAccountId } from "./user-account-id";
4
4
  interface UserAccountEvent extends Event<UserAccountId> {}
5
5
 
6
6
  class UserAccountCreated implements UserAccountEvent {
7
+ public readonly typeName: string = "UserAccountCreated";
7
8
  public readonly isCreated: boolean = true;
8
9
 
9
10
  constructor(
@@ -16,6 +17,7 @@ class UserAccountCreated implements UserAccountEvent {
16
17
  }
17
18
 
18
19
  class UserAccountRenamed implements UserAccountEvent {
20
+ public readonly typeName: string = "UserAccountRenamed";
19
21
  public readonly isCreated: boolean = false;
20
22
  constructor(
21
23
  public readonly id: string,
@@ -8,6 +8,7 @@ import {
8
8
  } from "./user-account-event";
9
9
 
10
10
  class UserAccount implements Aggregate<UserAccount, UserAccountId> {
11
+ public readonly typeName: string = "UserAccount";
11
12
  constructor(
12
13
  public readonly id: UserAccountId,
13
14
  public readonly name: string,
package/src/types.ts CHANGED
@@ -8,6 +8,7 @@ interface Aggregate<
8
8
  This extends Aggregate<This, AID>,
9
9
  AID extends AggregateId,
10
10
  > {
11
+ typeName: string;
11
12
  id: AID;
12
13
  sequenceNumber: number;
13
14
  version: number;
@@ -16,6 +17,7 @@ interface Aggregate<
16
17
  }
17
18
 
18
19
  interface Event<AID extends AggregateId> {
20
+ typeName: string;
19
21
  id: string;
20
22
  aggregateId: AID;
21
23
  sequenceNumber: number;