ddd-node 34.2.0 → 35.0.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/base/meta/model-id.js +1 -1
- package/base/meta/model-props-validator.js +1 -1
- package/base/model/model-descriptor.d.ts +11 -11
- package/base/model/model-descriptor.js +11 -11
- package/base/model/model.d.ts +7 -7
- package/base/model/model.js +9 -13
- package/base/model-registry.d.ts +1 -1
- package/base/model-registry.js +3 -3
- package/core/decorators/enum/is-enum.d.ts +2 -2
- package/core/decorators/enum/is-enum.js +4 -1
- package/core/decorators/es-aggregate/handle.js +1 -1
- package/core/decorators/es-aggregate/when.js +1 -1
- package/core/meta/{command.metadata.js → command.js} +5 -5
- package/core/meta/enum.d.ts +7 -0
- package/core/meta/enum.js +33 -0
- package/core/meta/es-aggregate/{command-handler-map.d.ts → command-handler.d.ts} +2 -3
- package/core/meta/es-aggregate/{command-handler-map.js → command-handler.js} +11 -10
- package/core/meta/es-aggregate/{event-applier-map.d.ts → event-applier.d.ts} +1 -3
- package/core/meta/es-aggregate/{event-applier-map.js → event-applier.js} +11 -11
- package/core/meta/es-aggregate/index.d.ts +2 -2
- package/core/meta/es-aggregate/index.js +2 -2
- package/core/meta/{event.metadata.js → event.js} +4 -4
- package/core/meta/index.d.ts +3 -2
- package/core/meta/index.js +3 -2
- package/core/model/aggregate/aggregate.d.ts +9 -14
- package/core/model/aggregate/aggregate.js +11 -25
- package/core/model/aggregate/es-aggregate.d.ts +13 -9
- package/core/model/aggregate/es-aggregate.js +27 -25
- package/core/model/aggregate/event-releaser.d.ts +4 -0
- package/core/model/aggregate/index.d.ts +1 -0
- package/core/model/aggregate/index.js +1 -0
- package/core/model/aggregate/state-aggregate.d.ts +9 -10
- package/core/model/aggregate/state-aggregate.js +12 -11
- package/core/model/aggregate/types.d.ts +0 -4
- package/core/model/entity/entity.d.ts +4 -6
- package/core/model/entity/entity.js +7 -7
- package/core/model/enum/enum.d.ts +1 -0
- package/core/model/enum/enum.js +12 -10
- package/core/model/identified-model/id.js +2 -0
- package/core/model/identified-model/identified-model.d.ts +16 -0
- package/core/model/identified-model/identified-model.js +21 -0
- package/core/model/identified-model/index.d.ts +2 -0
- package/core/model/{model-with-id → identified-model}/index.js +1 -1
- package/core/model/index.d.ts +1 -1
- package/core/model/index.js +1 -1
- package/core/model/message/command.d.ts +8 -6
- package/core/model/message/command.js +5 -10
- package/core/model/message/event.d.ts +8 -10
- package/core/model/message/event.js +6 -12
- package/core/model/message/message.d.ts +12 -22
- package/core/model/message/message.js +23 -34
- package/package.json +1 -1
- package/core/model/model-with-id/index.d.ts +0 -2
- package/core/model/model-with-id/model-with-id.d.ts +0 -13
- package/core/model/model-with-id/model-with-id.js +0 -23
- /package/core/meta/{command.metadata.d.ts → command.d.ts} +0 -0
- /package/core/meta/{event.metadata.d.ts → event.d.ts} +0 -0
- /package/core/model/{model-with-id/id.js → aggregate/event-releaser.js} +0 -0
- /package/core/model/{model-with-id → identified-model}/id.d.ts +0 -0
|
@@ -1,36 +1,26 @@
|
|
|
1
1
|
import { Class } from "type-fest";
|
|
2
2
|
import { DomainModelClass, InferredProps, Props } from "../../../base";
|
|
3
3
|
import { ClassStatic } from "../../../types";
|
|
4
|
-
import {
|
|
4
|
+
import { Id, IdentifiedModel } from "../identified-model";
|
|
5
|
+
export type Timestamp = number;
|
|
6
|
+
export type CausationId = string;
|
|
5
7
|
export interface CorrelationIds {
|
|
6
8
|
[type: string]: string | undefined;
|
|
7
9
|
}
|
|
8
|
-
export
|
|
9
|
-
|
|
10
|
-
causationId?: string;
|
|
11
|
-
correlationIds: CorrelationIds;
|
|
12
|
-
}
|
|
13
|
-
export type MessageMetadataInput = Partial<MessageMetadata>;
|
|
14
|
-
export declare class Message<P extends Props> extends ModelWithId<P> {
|
|
15
|
-
static createMetadata: (metadata?: MessageMetadataInput) => {
|
|
16
|
-
timestamp: number;
|
|
17
|
-
causationId?: string;
|
|
18
|
-
correlationIds: CorrelationIds;
|
|
19
|
-
id: import("../model-with-id").Id;
|
|
20
|
-
};
|
|
21
|
-
static buildMessage<T extends AnyMessage>(this: MessageClassWithTypedConstructor<T>, props: InferredProps<T>, metadata?: MessageMetadataInput): T;
|
|
22
|
-
private readonly _timestamp;
|
|
10
|
+
export declare class Message<P extends Props> extends IdentifiedModel<P> {
|
|
11
|
+
private _timestamp;
|
|
23
12
|
private _causationId?;
|
|
24
13
|
private _correlationIds;
|
|
25
|
-
constructor(
|
|
14
|
+
constructor(id: Id, timestamp: Timestamp, props: P, causationId?: CausationId, correlationIds?: CorrelationIds);
|
|
26
15
|
props(): P;
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
16
|
+
get timestamp(): number;
|
|
17
|
+
get correlationIds(): CorrelationIds;
|
|
18
|
+
get causationId(): string | undefined;
|
|
19
|
+
setTimestamp(timestamp: number): void;
|
|
31
20
|
setCausationId(causationId: string): void;
|
|
32
|
-
|
|
21
|
+
setCorrelationId(type: string, correlationId: string): void;
|
|
33
22
|
setCorrelationIds(correlationIds: CorrelationIds): void;
|
|
23
|
+
mergeCorrelationIds(correlationIds: CorrelationIds): void;
|
|
34
24
|
}
|
|
35
25
|
export type AnyMessage = Message<Props>;
|
|
36
26
|
export type MessageClass<T extends AnyMessage = AnyMessage, Arguments extends unknown[] = any[]> = DomainModelClass<T> & Class<T, Arguments> & ClassStatic<typeof Message<InferredProps<T>>>;
|
|
@@ -8,63 +8,52 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
8
8
|
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
9
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
10
|
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
11
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
15
|
exports.Message = void 0;
|
|
13
|
-
const
|
|
16
|
+
const lodash_1 = __importDefault(require("lodash"));
|
|
14
17
|
const base_1 = require("../../../base");
|
|
15
|
-
const
|
|
16
|
-
let Message = class Message extends
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
this._timestamp = metadata.timestamp;
|
|
23
|
-
this._causationId = metadata.causationId;
|
|
24
|
-
this._correlationIds = metadata.correlationIds;
|
|
18
|
+
const identified_model_1 = require("../identified-model");
|
|
19
|
+
let Message = class Message extends identified_model_1.IdentifiedModel {
|
|
20
|
+
constructor(id, timestamp, props, causationId, correlationIds) {
|
|
21
|
+
super(id);
|
|
22
|
+
this._timestamp = timestamp;
|
|
23
|
+
this._causationId = causationId;
|
|
24
|
+
this._correlationIds = correlationIds ?? {};
|
|
25
25
|
this.initializeProps(props);
|
|
26
26
|
}
|
|
27
27
|
props() {
|
|
28
28
|
return super.props();
|
|
29
29
|
}
|
|
30
|
-
|
|
31
|
-
return {
|
|
32
|
-
...super.metadata(),
|
|
33
|
-
timestamp: this._timestamp,
|
|
34
|
-
correlationIds: this._correlationIds,
|
|
35
|
-
causationId: this._causationId,
|
|
36
|
-
};
|
|
37
|
-
}
|
|
38
|
-
timestamp() {
|
|
30
|
+
get timestamp() {
|
|
39
31
|
return this._timestamp;
|
|
40
32
|
}
|
|
41
|
-
correlationIds() {
|
|
33
|
+
get correlationIds() {
|
|
42
34
|
return this._correlationIds;
|
|
43
35
|
}
|
|
44
|
-
causationId() {
|
|
36
|
+
get causationId() {
|
|
45
37
|
return this._causationId;
|
|
46
38
|
}
|
|
39
|
+
setTimestamp(timestamp) {
|
|
40
|
+
this._timestamp = timestamp;
|
|
41
|
+
}
|
|
47
42
|
setCausationId(causationId) {
|
|
48
|
-
|
|
49
|
-
this._causationId = causationId;
|
|
43
|
+
this._causationId = causationId;
|
|
50
44
|
}
|
|
51
|
-
|
|
45
|
+
setCorrelationId(type, correlationId) {
|
|
52
46
|
this._correlationIds[type] = correlationId;
|
|
53
47
|
}
|
|
54
48
|
setCorrelationIds(correlationIds) {
|
|
55
49
|
this._correlationIds = correlationIds;
|
|
56
50
|
}
|
|
51
|
+
mergeCorrelationIds(correlationIds) {
|
|
52
|
+
this.setCorrelationIds(lodash_1.default.merge(this._correlationIds, correlationIds));
|
|
53
|
+
}
|
|
57
54
|
};
|
|
58
55
|
exports.Message = Message;
|
|
59
|
-
Message.createMetadata = (metadata) => {
|
|
60
|
-
return {
|
|
61
|
-
id: (0, uuid_1.v4)(),
|
|
62
|
-
timestamp: Date.now(),
|
|
63
|
-
correlationIds: {},
|
|
64
|
-
...metadata,
|
|
65
|
-
};
|
|
66
|
-
};
|
|
67
56
|
exports.Message = Message = __decorate([
|
|
68
57
|
(0, base_1.Mutable)(false),
|
|
69
|
-
__metadata("design:paramtypes", [Object, Object])
|
|
58
|
+
__metadata("design:paramtypes", [String, Number, Object, String, Object])
|
|
70
59
|
], Message);
|
package/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"name":"ddd-node","version":"
|
|
1
|
+
{"name":"ddd-node","version":"35.0.0","description":"Domain Driven Design base for NodeJs","type":"commonjs","main":"index.js","types":"index.d.ts","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","tsconfig-paths":"^4.2.0","typescript":"^5.9.3"},"dependencies":{"class-transformer":"^0.5.1","is-class":"^0.0.9","lodash":"^4.17.21","reflect-metadata":"^0.1.13","ts-node":"^10.9.2","tsc-alias":"^1.8.8","type-fest":"^4.20.1","uuid":"^9.0.1"},"peerDependencies":{"class-validator":"^0.14.2"}}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { Id } from "./id";
|
|
2
|
-
import { DomainModel, Props } from "../../../base";
|
|
3
|
-
export interface ModelWithIdMetadata {
|
|
4
|
-
id: Id;
|
|
5
|
-
}
|
|
6
|
-
export declare class ModelWithId<P extends Props> extends DomainModel<P> {
|
|
7
|
-
protected readonly _id: Id;
|
|
8
|
-
constructor(metadata: ModelWithIdMetadata);
|
|
9
|
-
metadata(): ModelWithIdMetadata;
|
|
10
|
-
id(): string;
|
|
11
|
-
hasId(id: Id): boolean;
|
|
12
|
-
}
|
|
13
|
-
export type AnyModelWithId = ModelWithId<Props>;
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ModelWithId = void 0;
|
|
4
|
-
const base_1 = require("../../../base");
|
|
5
|
-
class ModelWithId extends base_1.DomainModel {
|
|
6
|
-
constructor(metadata) {
|
|
7
|
-
super();
|
|
8
|
-
this._id = metadata.id;
|
|
9
|
-
}
|
|
10
|
-
metadata() {
|
|
11
|
-
return {
|
|
12
|
-
...super.metadata(),
|
|
13
|
-
id: this._id,
|
|
14
|
-
};
|
|
15
|
-
}
|
|
16
|
-
id() {
|
|
17
|
-
return this._id;
|
|
18
|
-
}
|
|
19
|
-
hasId(id) {
|
|
20
|
-
return this._id === id;
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
exports.ModelWithId = ModelWithId;
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|