ddd-node 5.0.0 → 5.0.1
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/dist/base/aggregate.d.ts
CHANGED
|
@@ -9,12 +9,13 @@ export interface IAggregateMetadata extends IEntityMetadata {
|
|
|
9
9
|
readonly aggregateType: string;
|
|
10
10
|
readonly version: number;
|
|
11
11
|
}
|
|
12
|
+
export type AggregateMetadataWithoutEntityType = Omit<IAggregateMetadata, "entityType">;
|
|
12
13
|
export type NewAggregateMetadata = Partial<Omit<IAggregateMetadata, "aggregateType">>;
|
|
13
14
|
export declare class Aggregate<P extends object> extends Entity<P> implements IAggregateMetadata {
|
|
14
15
|
private readonly _aggregateType;
|
|
15
16
|
protected readonly _version: number;
|
|
16
17
|
protected events: AnyEvent[];
|
|
17
|
-
constructor(metadata:
|
|
18
|
+
constructor(metadata: AggregateMetadataWithoutEntityType, props?: P);
|
|
18
19
|
static aggregateType(): string;
|
|
19
20
|
static newAggregate<T extends AnyAggregate>(this: AggregateClass<T>, props?: PropsOf<T>, metadata?: NewAggregateMetadata): T;
|
|
20
21
|
get version(): number;
|
|
@@ -26,8 +27,9 @@ export declare class Aggregate<P extends object> extends Entity<P> implements IA
|
|
|
26
27
|
protected addEvent<E extends AnyEvent>(event: E): void;
|
|
27
28
|
protected addNewEvent<E extends AnyEvent>(eventClass: EventClass<E>, props: PropsOf<E>, metadata?: NewEventMetadataOptions): void;
|
|
28
29
|
}
|
|
30
|
+
export type SnapshotAggregateMetadata = AggregateMetadataWithoutEntityType;
|
|
29
31
|
export interface SnapshotWithProps<P extends object> {
|
|
30
|
-
metadata:
|
|
32
|
+
metadata: SnapshotAggregateMetadata;
|
|
31
33
|
props: P;
|
|
32
34
|
}
|
|
33
35
|
export interface Snapshot<T extends AnyAggregateES> extends SnapshotWithProps<PropsOf<T>> {
|
package/dist/base/aggregate.js
CHANGED
|
@@ -8,7 +8,7 @@ const aggregate_error_1 = require("./errors/aggregate.error");
|
|
|
8
8
|
const id_1 = require("./id");
|
|
9
9
|
class Aggregate extends entity_1.Entity {
|
|
10
10
|
constructor(metadata, props) {
|
|
11
|
-
super({ id: metadata.id }, props);
|
|
11
|
+
super({ id: metadata.id, entityType: "" }, props);
|
|
12
12
|
this.events = [];
|
|
13
13
|
this._aggregateType = metadata.aggregateType;
|
|
14
14
|
this._version = metadata.version;
|
package/dist/base/entity.d.ts
CHANGED
|
@@ -3,16 +3,18 @@ import { ClassStatic } from "../types/class-static";
|
|
|
3
3
|
import { Id } from "./id";
|
|
4
4
|
import { PropsEnvelope, PropsOf } from "./props-envelope";
|
|
5
5
|
export interface IEntityMetadata {
|
|
6
|
+
readonly entityType: string;
|
|
6
7
|
readonly id: Id;
|
|
7
8
|
}
|
|
8
9
|
export type NewEntityMetadataOptions = Partial<IEntityMetadata>;
|
|
9
10
|
export declare class Entity<P extends object> extends PropsEnvelope<P> implements IEntityMetadata {
|
|
11
|
+
private readonly _entityType;
|
|
10
12
|
private readonly _id;
|
|
11
13
|
constructor(metadata: IEntityMetadata, props?: P);
|
|
12
14
|
static entityType(): string;
|
|
13
15
|
static newEntity<T extends AnyEntity>(this: EntityClass<T>, props?: PropsOf<T>, metadata?: NewEntityMetadataOptions): T;
|
|
14
16
|
get id(): Id;
|
|
15
|
-
entityType(): string;
|
|
17
|
+
get entityType(): string;
|
|
16
18
|
equals<E extends AnyEntity>(entity: E): boolean;
|
|
17
19
|
}
|
|
18
20
|
export type AnyEntity = Entity<any>;
|
package/dist/base/entity.js
CHANGED
|
@@ -7,20 +7,20 @@ const props_envelope_1 = require("./props-envelope");
|
|
|
7
7
|
class Entity extends props_envelope_1.PropsEnvelope {
|
|
8
8
|
constructor(metadata, props) {
|
|
9
9
|
super(props);
|
|
10
|
+
this._entityType = metadata.entityType;
|
|
10
11
|
this._id = metadata.id;
|
|
11
12
|
}
|
|
12
13
|
static entityType() {
|
|
13
14
|
return (0, entity_1.getEntityType)(this.prototype);
|
|
14
15
|
}
|
|
15
16
|
static newEntity(props, metadata) {
|
|
16
|
-
return new this(Object.assign({ id: id_1.Id.unique() }, metadata), props);
|
|
17
|
+
return new this(Object.assign({ entityType: this.entityType(), id: id_1.Id.unique() }, metadata), props);
|
|
17
18
|
}
|
|
18
19
|
get id() {
|
|
19
20
|
return this._id;
|
|
20
21
|
}
|
|
21
|
-
entityType() {
|
|
22
|
-
|
|
23
|
-
return (0, entity_1.getEntityType)(prototype);
|
|
22
|
+
get entityType() {
|
|
23
|
+
return this._entityType;
|
|
24
24
|
}
|
|
25
25
|
equals(entity) {
|
|
26
26
|
const equalsType = entity instanceof this.constructor;
|