ddd-node 34.2.0 → 35.1.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.
Files changed (55) hide show
  1. package/base/meta/model-id.js +1 -1
  2. package/base/meta/model-props-validator.js +1 -1
  3. package/base/model/model-descriptor.d.ts +11 -11
  4. package/base/model/model-descriptor.js +11 -11
  5. package/base/model/model.d.ts +7 -7
  6. package/base/model/model.js +9 -13
  7. package/base/model-registry.d.ts +1 -1
  8. package/base/model-registry.js +3 -3
  9. package/core/decorators/enum/is-enum.d.ts +2 -2
  10. package/core/decorators/enum/is-enum.js +4 -1
  11. package/core/decorators/es-aggregate/handle.js +1 -1
  12. package/core/decorators/es-aggregate/when.js +1 -1
  13. package/core/meta/{command.metadata.js → command.js} +5 -5
  14. package/core/meta/enum.d.ts +7 -0
  15. package/core/meta/enum.js +33 -0
  16. package/core/meta/es-aggregate/{command-handler-map.d.ts → command-handler.d.ts} +2 -3
  17. package/core/meta/es-aggregate/{command-handler-map.js → command-handler.js} +11 -10
  18. package/core/meta/es-aggregate/{event-applier-map.d.ts → event-applier.d.ts} +1 -3
  19. package/core/meta/es-aggregate/{event-applier-map.js → event-applier.js} +11 -11
  20. package/core/meta/es-aggregate/index.d.ts +2 -2
  21. package/core/meta/es-aggregate/index.js +2 -2
  22. package/core/meta/{event.metadata.js → event.js} +4 -4
  23. package/core/meta/index.d.ts +3 -2
  24. package/core/meta/index.js +3 -2
  25. package/core/model/aggregate/aggregate.d.ts +8 -14
  26. package/core/model/aggregate/aggregate.js +11 -25
  27. package/core/model/aggregate/es-aggregate.d.ts +12 -9
  28. package/core/model/aggregate/es-aggregate.js +27 -25
  29. package/core/model/aggregate/state-aggregate.d.ts +8 -10
  30. package/core/model/aggregate/state-aggregate.js +12 -11
  31. package/core/model/aggregate/types.d.ts +0 -4
  32. package/core/model/entity/entity.d.ts +4 -6
  33. package/core/model/entity/entity.js +7 -7
  34. package/core/model/enum/enum.d.ts +1 -0
  35. package/core/model/enum/enum.js +12 -10
  36. package/core/model/identified-model/identified-model.d.ts +16 -0
  37. package/core/model/identified-model/identified-model.js +21 -0
  38. package/core/model/identified-model/index.d.ts +2 -0
  39. package/core/model/{model-with-id → identified-model}/index.js +1 -1
  40. package/core/model/index.d.ts +1 -1
  41. package/core/model/index.js +1 -1
  42. package/core/model/message/command.d.ts +8 -6
  43. package/core/model/message/command.js +5 -10
  44. package/core/model/message/event.d.ts +8 -10
  45. package/core/model/message/event.js +6 -12
  46. package/core/model/message/message.d.ts +12 -22
  47. package/core/model/message/message.js +23 -34
  48. package/package.json +1 -1
  49. package/core/model/model-with-id/index.d.ts +0 -2
  50. package/core/model/model-with-id/model-with-id.d.ts +0 -13
  51. package/core/model/model-with-id/model-with-id.js +0 -23
  52. /package/core/meta/{command.metadata.d.ts → command.d.ts} +0 -0
  53. /package/core/meta/{event.metadata.d.ts → event.d.ts} +0 -0
  54. /package/core/model/{model-with-id → identified-model}/id.d.ts +0 -0
  55. /package/core/model/{model-with-id → identified-model}/id.js +0 -0
@@ -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 uuid_1 = require("uuid");
16
+ const lodash_1 = __importDefault(require("lodash"));
14
17
  const base_1 = require("../../../base");
15
- const model_with_id_1 = require("../model-with-id");
16
- let Message = class Message extends model_with_id_1.ModelWithId {
17
- static buildMessage(props, metadata) {
18
- return new this(this.createMetadata(metadata), props);
19
- }
20
- constructor(metadata, props) {
21
- super(metadata);
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
- metadata() {
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
- if (!this._causationId)
49
- this._causationId = causationId;
43
+ this._causationId = causationId;
50
44
  }
51
- addCorrelationId(type, correlationId) {
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":"34.2.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
+ {"name":"ddd-node","version":"35.1.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,2 +0,0 @@
1
- export * from "./id";
2
- export * from "./model-with-id";
@@ -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