ddd-node 7.0.0 → 8.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/core/aggregate.d.ts +2 -2
- package/dist/core/aggregate.js +2 -2
- package/dist/core/command.js +1 -1
- package/dist/core/entity.js +1 -1
- package/dist/core/event.js +1 -1
- package/dist/core/id.d.ts +7 -3
- package/dist/core/id.js +20 -11
- package/package.json +1 -1
package/dist/core/aggregate.d.ts
CHANGED
|
@@ -20,8 +20,8 @@ export declare class Aggregate<Props extends object> extends AggregateBase<Props
|
|
|
20
20
|
static newAggregate<T extends AnyAggregate>(this: AggregateClassWithTypedConstructor<T>, props: PropsOf<T>, id?: Id): T;
|
|
21
21
|
get version(): number;
|
|
22
22
|
get events(): AnyEvent[];
|
|
23
|
-
recordEvent<E extends AnyEvent>(event: E): void;
|
|
24
|
-
recordEvent<E extends AnyEvent>(eventClass: EventClass<E>, props: PropsOf<E>): void;
|
|
23
|
+
protected recordEvent<E extends AnyEvent>(event: E): void;
|
|
24
|
+
protected recordEvent<E extends AnyEvent>(eventClass: EventClass<E>, props: PropsOf<E>): void;
|
|
25
25
|
clearEvents(): void;
|
|
26
26
|
}
|
|
27
27
|
export interface SnapshotMetadata extends AggregateBaseMetadata {
|
package/dist/core/aggregate.js
CHANGED
|
@@ -27,7 +27,7 @@ class Aggregate extends AggregateBase {
|
|
|
27
27
|
}
|
|
28
28
|
static newAggregate(props, id) {
|
|
29
29
|
return new this({
|
|
30
|
-
id: id !== null && id !== void 0 ? id : id_1.
|
|
30
|
+
id: id !== null && id !== void 0 ? id : id_1.Uuid4.new(),
|
|
31
31
|
version: 0,
|
|
32
32
|
}, props);
|
|
33
33
|
}
|
|
@@ -61,7 +61,7 @@ class AggregateES extends AggregateBase {
|
|
|
61
61
|
}
|
|
62
62
|
static newStream(id) {
|
|
63
63
|
return new this({
|
|
64
|
-
id: id !== null && id !== void 0 ? id : id_1.
|
|
64
|
+
id: id !== null && id !== void 0 ? id : id_1.Uuid4.new(),
|
|
65
65
|
version: 0,
|
|
66
66
|
});
|
|
67
67
|
}
|
package/dist/core/command.js
CHANGED
package/dist/core/entity.js
CHANGED
package/dist/core/event.js
CHANGED
package/dist/core/id.d.ts
CHANGED
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
export declare class Id {
|
|
2
2
|
private _value;
|
|
3
|
-
|
|
4
|
-
static unique(): Id;
|
|
5
|
-
static from(value: string): Id;
|
|
3
|
+
constructor(value: string);
|
|
6
4
|
get value(): string;
|
|
7
5
|
equals(id: Id): boolean;
|
|
8
6
|
}
|
|
7
|
+
export declare class Uuid4 extends Id {
|
|
8
|
+
private constructor();
|
|
9
|
+
static new(): Uuid4;
|
|
10
|
+
static from(value: string): Uuid4;
|
|
11
|
+
static validate(value: string): boolean;
|
|
12
|
+
}
|
package/dist/core/id.js
CHANGED
|
@@ -1,21 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Id = void 0;
|
|
3
|
+
exports.Uuid4 = exports.Id = void 0;
|
|
4
4
|
const uuid_1 = require("uuid");
|
|
5
5
|
class Id {
|
|
6
6
|
constructor(value) {
|
|
7
7
|
this._value = value;
|
|
8
8
|
}
|
|
9
|
-
static unique() {
|
|
10
|
-
const value = (0, uuid_1.v4)();
|
|
11
|
-
return new Id(value);
|
|
12
|
-
}
|
|
13
|
-
static from(value) {
|
|
14
|
-
const isUUID4 = (0, uuid_1.validate)(value) && (0, uuid_1.version)(value) === 4;
|
|
15
|
-
if (!isUUID4)
|
|
16
|
-
throw new Error("Invalid uuid version 4 value");
|
|
17
|
-
return new Id(value);
|
|
18
|
-
}
|
|
19
9
|
get value() {
|
|
20
10
|
return this._value;
|
|
21
11
|
}
|
|
@@ -24,3 +14,22 @@ class Id {
|
|
|
24
14
|
}
|
|
25
15
|
}
|
|
26
16
|
exports.Id = Id;
|
|
17
|
+
class Uuid4 extends Id {
|
|
18
|
+
constructor(value) {
|
|
19
|
+
super(value);
|
|
20
|
+
}
|
|
21
|
+
static new() {
|
|
22
|
+
const newValue = (0, uuid_1.v4)();
|
|
23
|
+
return this.from(newValue);
|
|
24
|
+
}
|
|
25
|
+
static from(value) {
|
|
26
|
+
this.validate(value);
|
|
27
|
+
return new Uuid4(value);
|
|
28
|
+
}
|
|
29
|
+
static validate(value) {
|
|
30
|
+
const isUuid = (0, uuid_1.validate)(value);
|
|
31
|
+
const isV4 = (0, uuid_1.version)(value) === 4;
|
|
32
|
+
return isUuid && isV4;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
exports.Uuid4 = Uuid4;
|