ddd-node 34.1.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/decorators/model.d.ts +17 -7
- package/base/decorators/model.js +65 -47
- package/base/decorators/prop.js +1 -2
- package/base/decorators/props-validator.js +1 -3
- package/base/meta/index.d.ts +1 -0
- package/base/meta/index.js +1 -0
- package/base/meta/model-domain.d.ts +0 -1
- package/base/meta/model-domain.js +5 -5
- package/base/meta/model-id.js +1 -1
- package/base/meta/model-name.js +1 -1
- package/base/meta/model-property-accessor.js +11 -18
- package/base/meta/model-props-type.d.ts +4 -0
- package/base/meta/model-props-type.js +12 -0
- package/base/meta/model-props-validator.d.ts +9 -2
- package/base/meta/model-props-validator.js +35 -17
- package/base/meta/model-static-values.js +2 -3
- package/base/meta/model-version.js +1 -1
- package/base/model/model-descriptor.d.ts +13 -11
- package/base/model/model-descriptor.js +14 -12
- package/base/model/model.d.ts +7 -7
- package/base/model/model.js +10 -15
- package/base/model-registry.d.ts +1 -1
- package/base/model-registry.js +3 -3
- package/common/index.d.ts +1 -0
- package/common/index.js +17 -0
- package/common/props-validator/index.d.ts +1 -0
- package/common/props-validator/index.js +17 -0
- package/common/props-validator/use-class-validator.d.ts +17 -0
- package/common/props-validator/use-class-validator.js +62 -0
- 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 -18
- package/core/model/aggregate/es-aggregate.d.ts +16 -12
- 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 +10 -11
- 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 +5 -7
- 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 +9 -7
- package/core/model/message/command.js +5 -7
- package/core/model/message/event.d.ts +10 -12
- package/core/model/message/event.js +6 -8
- package/core/model/message/message.d.ts +12 -22
- package/core/model/message/message.js +23 -24
- package/core/model/value-object/value-object.d.ts +1 -1
- package/handling-event/event-dispatcher.js +3 -14
- package/handling-event/event-subscriber.js +1 -2
- package/index.d.ts +1 -1
- package/index.js +1 -0
- 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 -20
- /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
|
@@ -8,53 +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 Object.assign(Object.assign({}, super.metadata()), { timestamp: this._timestamp, correlationIds: this._correlationIds, causationId: this._causationId });
|
|
32
|
-
}
|
|
33
|
-
timestamp() {
|
|
30
|
+
get timestamp() {
|
|
34
31
|
return this._timestamp;
|
|
35
32
|
}
|
|
36
|
-
correlationIds() {
|
|
33
|
+
get correlationIds() {
|
|
37
34
|
return this._correlationIds;
|
|
38
35
|
}
|
|
39
|
-
causationId() {
|
|
36
|
+
get causationId() {
|
|
40
37
|
return this._causationId;
|
|
41
38
|
}
|
|
39
|
+
setTimestamp(timestamp) {
|
|
40
|
+
this._timestamp = timestamp;
|
|
41
|
+
}
|
|
42
42
|
setCausationId(causationId) {
|
|
43
|
-
|
|
44
|
-
this._causationId = causationId;
|
|
43
|
+
this._causationId = causationId;
|
|
45
44
|
}
|
|
46
|
-
|
|
45
|
+
setCorrelationId(type, correlationId) {
|
|
47
46
|
this._correlationIds[type] = correlationId;
|
|
48
47
|
}
|
|
49
48
|
setCorrelationIds(correlationIds) {
|
|
50
49
|
this._correlationIds = correlationIds;
|
|
51
50
|
}
|
|
51
|
+
mergeCorrelationIds(correlationIds) {
|
|
52
|
+
this.setCorrelationIds(lodash_1.default.merge(this._correlationIds, correlationIds));
|
|
53
|
+
}
|
|
52
54
|
};
|
|
53
55
|
exports.Message = Message;
|
|
54
|
-
Message.createMetadata = (metadata) => {
|
|
55
|
-
return Object.assign({ id: (0, uuid_1.v4)(), timestamp: Date.now(), correlationIds: {} }, metadata);
|
|
56
|
-
};
|
|
57
56
|
exports.Message = Message = __decorate([
|
|
58
57
|
(0, base_1.Mutable)(false),
|
|
59
|
-
__metadata("design:paramtypes", [Object, Object])
|
|
58
|
+
__metadata("design:paramtypes", [String, Number, Object, String, Object])
|
|
60
59
|
], Message);
|
|
@@ -3,7 +3,7 @@ import { DomainModel, InferredProps, Props, PropsBuilder } from "../../../base";
|
|
|
3
3
|
import { ClassStatic } from "../../../types";
|
|
4
4
|
export declare class ValueObject<P extends Props> extends DomainModel<P> {
|
|
5
5
|
constructor(props?: P | PropsBuilder<ValueObject<P>>);
|
|
6
|
-
_constructor(): ValueObjectClass<this>;
|
|
6
|
+
_constructor(): ValueObjectClass<typeof this>;
|
|
7
7
|
props(): P;
|
|
8
8
|
equals<V extends AnyValueObject>(vo: V): boolean;
|
|
9
9
|
with(props: Partial<P>): typeof this;
|
|
@@ -1,24 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
3
|
exports.EventDispatcher = void 0;
|
|
13
4
|
class EventDispatcher {
|
|
14
5
|
constructor(subscriberRegistry) {
|
|
15
6
|
this.subscriberRegistry = subscriberRegistry;
|
|
16
7
|
}
|
|
17
|
-
dispatch(event) {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
yield Promise.all(subscribers.map((subscriber) => subscriber.handleEvent(event)));
|
|
21
|
-
});
|
|
8
|
+
async dispatch(event) {
|
|
9
|
+
const subscribers = this.subscriberRegistry.getAllSubscribersForEvent(event.constructor);
|
|
10
|
+
await Promise.all(subscribers.map((subscriber) => subscriber.handleEvent(event)));
|
|
22
11
|
}
|
|
23
12
|
}
|
|
24
13
|
exports.EventDispatcher = EventDispatcher;
|
|
@@ -4,8 +4,7 @@ exports.DynamicEventSubscriber = exports.EventSubscriber = void 0;
|
|
|
4
4
|
const decorators_1 = require("./decorators");
|
|
5
5
|
class EventSubscriber {
|
|
6
6
|
subscribeToEvents() {
|
|
7
|
-
|
|
8
|
-
const subscribedEvents = (_a = Reflect.getOwnMetadata(decorators_1.SubscribedEventsMetaKey, this.constructor)) !== null && _a !== void 0 ? _a : [];
|
|
7
|
+
const subscribedEvents = Reflect.getOwnMetadata(decorators_1.SubscribedEventsMetaKey, this.constructor) ?? [];
|
|
9
8
|
return subscribedEvents;
|
|
10
9
|
}
|
|
11
10
|
}
|
package/index.d.ts
CHANGED
package/index.js
CHANGED
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,20 +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 Object.assign(Object.assign({}, super.metadata()), { id: this._id });
|
|
12
|
-
}
|
|
13
|
-
id() {
|
|
14
|
-
return this._id;
|
|
15
|
-
}
|
|
16
|
-
hasId(id) {
|
|
17
|
-
return this._id === id;
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
exports.ModelWithId = ModelWithId;
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|