ddd-node 22.0.1 → 22.0.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.
- package/dist/core/message/command/command.d.ts +7 -2
- package/dist/core/message/command/command.js +10 -0
- package/dist/core/message/event/event.d.ts +4 -1
- package/dist/core/message/event/event.js +5 -0
- package/dist/model/meta/model-static-values.d.ts +1 -1
- package/dist/package.json +1 -1
- package/package.json +1 -1
|
@@ -1,14 +1,19 @@
|
|
|
1
1
|
import { Class } from "type-fest";
|
|
2
|
+
import { CommandType } from "../../../meta";
|
|
2
3
|
import { Props, PropsOf } from "../../../model";
|
|
3
4
|
import { ClassStatic } from "../../../types";
|
|
4
5
|
import { MessageBase, MessageMetadata } from "../message-base";
|
|
5
6
|
import { ICommandModelMetadata } from "./command-model.metadata";
|
|
6
7
|
export interface CommandMetadata extends MessageMetadata {
|
|
8
|
+
commandType: CommandType;
|
|
7
9
|
}
|
|
8
|
-
export declare class CommandBase<P extends Props> extends MessageBase<P> {
|
|
10
|
+
export declare abstract class CommandBase<P extends Props> extends MessageBase<P> {
|
|
11
|
+
protected readonly _commandType: CommandType;
|
|
9
12
|
static commandType(): string;
|
|
10
|
-
constructor(metadata: CommandMetadata, props: P);
|
|
13
|
+
constructor(metadata: Omit<CommandMetadata, "commandType">, props: P);
|
|
11
14
|
modelMetadata(): ICommandModelMetadata<typeof this>;
|
|
15
|
+
metadata(): CommandMetadata;
|
|
16
|
+
commandType(): string;
|
|
12
17
|
}
|
|
13
18
|
export type AnyCommand = CommandBase<Props>;
|
|
14
19
|
export interface CommandClass<T extends AnyCommand = AnyCommand, Arguments extends unknown[] = any[]> extends Class<T, Arguments>, ClassStatic<typeof CommandBase<PropsOf<T>>> {
|
|
@@ -9,6 +9,7 @@ class CommandBase extends message_base_1.MessageBase {
|
|
|
9
9
|
}
|
|
10
10
|
constructor(metadata, props) {
|
|
11
11
|
super(metadata, props);
|
|
12
|
+
this._commandType = (0, meta_1.getCommandType)(this.constructor);
|
|
12
13
|
}
|
|
13
14
|
modelMetadata() {
|
|
14
15
|
const commandClass = this.constructor;
|
|
@@ -17,5 +18,14 @@ class CommandBase extends message_base_1.MessageBase {
|
|
|
17
18
|
commandType: commandClass.commandType(),
|
|
18
19
|
};
|
|
19
20
|
}
|
|
21
|
+
metadata() {
|
|
22
|
+
return {
|
|
23
|
+
...super.metadata(),
|
|
24
|
+
commandType: this._commandType,
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
commandType() {
|
|
28
|
+
return this._commandType;
|
|
29
|
+
}
|
|
20
30
|
}
|
|
21
31
|
exports.CommandBase = CommandBase;
|
|
@@ -10,14 +10,17 @@ export type EventSource = Readonly<{
|
|
|
10
10
|
aggregateVersion: number;
|
|
11
11
|
}>;
|
|
12
12
|
export interface EventMetadata extends MessageMetadata {
|
|
13
|
+
eventType: EventType;
|
|
13
14
|
source: EventSource;
|
|
14
15
|
}
|
|
15
16
|
export declare class EventBase<P extends Props> extends MessageBase<P> {
|
|
17
|
+
private readonly _eventType;
|
|
16
18
|
private readonly _source;
|
|
17
|
-
constructor(metadata: EventMetadata, props: P);
|
|
19
|
+
constructor(metadata: Omit<EventMetadata, "eventType">, props: P);
|
|
18
20
|
static eventType(): EventType;
|
|
19
21
|
modelMetadata(): IEventModelMetadata<typeof this>;
|
|
20
22
|
metadata(): EventMetadata;
|
|
23
|
+
eventType(): string;
|
|
21
24
|
source(): Readonly<{
|
|
22
25
|
aggregateId: Id;
|
|
23
26
|
aggregateVersion: number;
|
|
@@ -6,6 +6,7 @@ const message_base_1 = require("../message-base");
|
|
|
6
6
|
class EventBase extends message_base_1.MessageBase {
|
|
7
7
|
constructor(metadata, props) {
|
|
8
8
|
super(metadata, props);
|
|
9
|
+
this._eventType = (0, meta_1.getEventType)(this.constructor);
|
|
9
10
|
this._source = metadata.source;
|
|
10
11
|
}
|
|
11
12
|
static eventType() {
|
|
@@ -21,9 +22,13 @@ class EventBase extends message_base_1.MessageBase {
|
|
|
21
22
|
metadata() {
|
|
22
23
|
return {
|
|
23
24
|
...super.metadata(),
|
|
25
|
+
eventType: this._eventType,
|
|
24
26
|
source: this._source,
|
|
25
27
|
};
|
|
26
28
|
}
|
|
29
|
+
eventType() {
|
|
30
|
+
return this._eventType;
|
|
31
|
+
}
|
|
27
32
|
source() {
|
|
28
33
|
return this._source;
|
|
29
34
|
}
|
|
@@ -5,7 +5,7 @@ export declare class StaticValue<T extends AnyModel = AnyModel> {
|
|
|
5
5
|
constructor(value: T | StaticValueBuilder<T>);
|
|
6
6
|
get value(): T;
|
|
7
7
|
}
|
|
8
|
-
export declare class StaticValuesMap<T extends AnyModel> extends Map<PropertyKey, StaticValue<T>> {
|
|
8
|
+
export declare class StaticValuesMap<T extends AnyModel = AnyModel> extends Map<PropertyKey, StaticValue<T>> {
|
|
9
9
|
}
|
|
10
10
|
export declare const getOwnStaticValues: <T extends AnyModel>(target: object) => StaticValuesMap<T>;
|
|
11
11
|
export declare const setStaticValue: <T extends AnyModel>(target: object, key: PropertyKey, value: T | StaticValueBuilder<T>) => void;
|
package/dist/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"name":"ddd-node","version":"22.0.
|
|
1
|
+
{"name":"ddd-node","version":"22.0.2","description":"Domain Driven Design base for NodeJs","type":"commonjs","main":"index.js","types":"index.d.ts","files":["dist"],"repository":{"type":"git","url":"https://github.com/nqd881/ddd-node"},"keywords":["ddd","ddd-node","ddd-base","ddd-ts","ddd-js"],"author":"Quoc Dai","license":"ISC","devDependencies":{"@types/chai":"^4.3.16","@types/lodash":"^4.14.200","@types/mocha":"^10.0.6","@types/uuid":"^9.0.6","chai":"^5.1.1","chai-deep-match":"^1.2.1","ddd-node":"file:dist","mocha":"^10.4.0","ts-node":"^10.9.1","tsconfig-paths":"^4.2.0","typescript":"^5.2.2"},"dependencies":{"lodash":"^4.17.21","reflect-metadata":"^0.1.13","tsc-alias":"^1.8.8","type-fest":"^4.20.1","uuid":"^9.0.1"}}
|