@nestjslatam/ddd-lib 1.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/LICENSE +21 -0
- package/README.md +13 -0
- package/command.base.d.ts +7 -0
- package/command.base.js +21 -0
- package/command.base.js.map +1 -0
- package/core/broken-rules/broken-rule-collection.d.ts +11 -0
- package/core/broken-rules/broken-rule-collection.js +44 -0
- package/core/broken-rules/broken-rule-collection.js.map +1 -0
- package/core/broken-rules/broken-rule.d.ts +6 -0
- package/core/broken-rules/broken-rule.js +21 -0
- package/core/broken-rules/broken-rule.js.map +1 -0
- package/core/broken-rules/index.d.ts +2 -0
- package/core/broken-rules/index.js +19 -0
- package/core/broken-rules/index.js.map +1 -0
- package/core/index.d.ts +3 -0
- package/core/index.js +20 -0
- package/core/index.js.map +1 -0
- package/core/interfaces/command-bus.interface.d.ts +4 -0
- package/core/interfaces/command-bus.interface.js +3 -0
- package/core/interfaces/command-bus.interface.js.map +1 -0
- package/core/interfaces/command-handler.interface.d.ts +4 -0
- package/core/interfaces/command-handler.interface.js +3 -0
- package/core/interfaces/command-handler.interface.js.map +1 -0
- package/core/interfaces/command-metadata.interface.d.ts +5 -0
- package/core/interfaces/command-metadata.interface.js +3 -0
- package/core/interfaces/command-metadata.interface.js.map +1 -0
- package/core/interfaces/command-publisher.interface.d.ts +4 -0
- package/core/interfaces/command-publisher.interface.js +3 -0
- package/core/interfaces/command-publisher.interface.js.map +1 -0
- package/core/interfaces/command.interface.d.ts +5 -0
- package/core/interfaces/command.interface.js +3 -0
- package/core/interfaces/command.interface.js.map +1 -0
- package/core/interfaces/domain-event-bus.interface.d.ts +5 -0
- package/core/interfaces/domain-event-bus.interface.js +3 -0
- package/core/interfaces/domain-event-bus.interface.js.map +1 -0
- package/core/interfaces/domain-event-handler.interface.d.ts +4 -0
- package/core/interfaces/domain-event-handler.interface.js +3 -0
- package/core/interfaces/domain-event-handler.interface.js.map +1 -0
- package/core/interfaces/domain-event-metadata.interface.d.ts +6 -0
- package/core/interfaces/domain-event-metadata.interface.js +3 -0
- package/core/interfaces/domain-event-metadata.interface.js.map +1 -0
- package/core/interfaces/domain-event-publisher.interface.d.ts +5 -0
- package/core/interfaces/domain-event-publisher.interface.js +3 -0
- package/core/interfaces/domain-event-publisher.interface.js.map +1 -0
- package/core/interfaces/domain-event.interface.d.ts +2 -0
- package/core/interfaces/domain-event.interface.js +3 -0
- package/core/interfaces/domain-event.interface.js.map +1 -0
- package/core/interfaces/domain-repository-read.interface.d.ts +4 -0
- package/core/interfaces/domain-repository-read.interface.js +3 -0
- package/core/interfaces/domain-repository-read.interface.js.map +1 -0
- package/core/interfaces/domain-repository-transaction.interface.d.ts +4 -0
- package/core/interfaces/domain-repository-transaction.interface.js +3 -0
- package/core/interfaces/domain-repository-transaction.interface.js.map +1 -0
- package/core/interfaces/domain-repository-write.interface.d.ts +4 -0
- package/core/interfaces/domain-repository-write.interface.js +3 -0
- package/core/interfaces/domain-repository-write.interface.js.map +1 -0
- package/core/interfaces/index.d.ts +19 -0
- package/core/interfaces/index.js +36 -0
- package/core/interfaces/index.js.map +1 -0
- package/core/interfaces/message-source.interface.d.ts +5 -0
- package/core/interfaces/message-source.interface.js +3 -0
- package/core/interfaces/message-source.interface.js.map +1 -0
- package/core/interfaces/observable-bus.d.ts +6 -0
- package/core/interfaces/observable-bus.js +16 -0
- package/core/interfaces/observable-bus.js.map +1 -0
- package/core/interfaces/saga.interface.d.ts +4 -0
- package/core/interfaces/saga.interface.js +3 -0
- package/core/interfaces/saga.interface.js.map +1 -0
- package/core/interfaces/tracking.interface.d.ts +5 -0
- package/core/interfaces/tracking.interface.js +3 -0
- package/core/interfaces/tracking.interface.js.map +1 -0
- package/core/interfaces/unhandled-exception-info.interface.d.ts +5 -0
- package/core/interfaces/unhandled-exception-info.interface.js +3 -0
- package/core/interfaces/unhandled-exception-info.interface.js.map +1 -0
- package/core/interfaces/unhandled-exception-publisher.interface.d.ts +5 -0
- package/core/interfaces/unhandled-exception-publisher.interface.js +3 -0
- package/core/interfaces/unhandled-exception-publisher.interface.js.map +1 -0
- package/core/pagination.base.d.ts +25 -0
- package/core/pagination.base.js +22 -0
- package/core/pagination.base.js.map +1 -0
- package/ddd.module.d.ts +12 -0
- package/ddd.module.js +48 -0
- package/ddd.module.js.map +1 -0
- package/ddd.options.d.ts +7 -0
- package/ddd.options.js +3 -0
- package/ddd.options.js.map +1 -0
- package/ddd.service.d.ts +14 -0
- package/ddd.service.js +53 -0
- package/ddd.service.js.map +1 -0
- package/decorators/command-handler.decorator.d.ts +3 -0
- package/decorators/command-handler.decorator.js +16 -0
- package/decorators/command-handler.decorator.js.map +1 -0
- package/decorators/constants.d.ts +5 -0
- package/decorators/constants.js +9 -0
- package/decorators/constants.js.map +1 -0
- package/decorators/events-handler.decorator.d.ts +3 -0
- package/decorators/events-handler.decorator.js +18 -0
- package/decorators/events-handler.decorator.js.map +1 -0
- package/decorators/index.d.ts +4 -0
- package/decorators/index.js +21 -0
- package/decorators/index.js.map +1 -0
- package/decorators/saga.decorator.d.ts +2 -0
- package/decorators/saga.decorator.js +13 -0
- package/decorators/saga.decorator.js.map +1 -0
- package/domain-aggregate-root.d.ts +13 -0
- package/domain-aggregate-root.js +39 -0
- package/domain-aggregate-root.js.map +1 -0
- package/domain-command-bus.d.ts +21 -0
- package/domain-command-bus.js +81 -0
- package/domain-command-bus.js.map +1 -0
- package/domain-entity.d.ts +33 -0
- package/domain-entity.js +104 -0
- package/domain-entity.js.map +1 -0
- package/domain-event-bus.d.ts +34 -0
- package/domain-event-bus.js +141 -0
- package/domain-event-bus.js.map +1 -0
- package/domain-event-collection.d.ts +11 -0
- package/domain-event-collection.js +33 -0
- package/domain-event-collection.js.map +1 -0
- package/domain-event-publisher.d.ts +12 -0
- package/domain-event-publisher.js +48 -0
- package/domain-event-publisher.js.map +1 -0
- package/domain-event.d.ts +15 -0
- package/domain-event.js +28 -0
- package/domain-event.js.map +1 -0
- package/exceptions/constants.d.ts +6 -0
- package/exceptions/constants.js +10 -0
- package/exceptions/constants.js.map +1 -0
- package/exceptions/exception.base.d.ts +17 -0
- package/exceptions/exception.base.js +23 -0
- package/exceptions/exception.base.js.map +1 -0
- package/exceptions/exceptions.d.ts +32 -0
- package/exceptions/exceptions.js +71 -0
- package/exceptions/exceptions.js.map +1 -0
- package/exceptions/index.d.ts +3 -0
- package/exceptions/index.js +20 -0
- package/exceptions/index.js.map +1 -0
- package/helpers/datetime.helper.d.ts +3 -0
- package/helpers/datetime.helper.js +13 -0
- package/helpers/datetime.helper.js.map +1 -0
- package/helpers/default-command-pubsub.helper.d.ts +7 -0
- package/helpers/default-command-pubsub.helper.js +13 -0
- package/helpers/default-command-pubsub.helper.js.map +1 -0
- package/helpers/default-get-event-id.helper.d.ts +4 -0
- package/helpers/default-get-event-id.helper.js +14 -0
- package/helpers/default-get-event-id.helper.js.map +1 -0
- package/helpers/default-pubsub.helper.d.ts +8 -0
- package/helpers/default-pubsub.helper.js +16 -0
- package/helpers/default-pubsub.helper.js.map +1 -0
- package/helpers/default-unhandled-exception-pubsub.helper.d.ts +8 -0
- package/helpers/default-unhandled-exception-pubsub.helper.js +13 -0
- package/helpers/default-unhandled-exception-pubsub.helper.js.map +1 -0
- package/helpers/domain-guard.helper.d.ts +13 -0
- package/helpers/domain-guard.helper.js +60 -0
- package/helpers/domain-guard.helper.js.map +1 -0
- package/helpers/domain-object.helper.d.ts +1 -0
- package/helpers/domain-object.helper.js +37 -0
- package/helpers/domain-object.helper.js.map +1 -0
- package/helpers/index.d.ts +7 -0
- package/helpers/index.js +24 -0
- package/helpers/index.js.map +1 -0
- package/index.d.ts +15 -0
- package/index.js +32 -0
- package/index.js.map +1 -0
- package/package.json +23 -0
- package/tsconfig.lib.tsbuildinfo +1 -0
- package/unhandled-exeption-bus.d.ts +15 -0
- package/unhandled-exeption-bus.js +45 -0
- package/unhandled-exeption-bus.js.map +1 -0
- package/valueobjects/domain-audit.valueobject.d.ts +23 -0
- package/valueobjects/domain-audit.valueobject.js +59 -0
- package/valueobjects/domain-audit.valueobject.js.map +1 -0
- package/valueobjects/domain-date.valueobject.d.ts +6 -0
- package/valueobjects/domain-date.valueobject.js +20 -0
- package/valueobjects/domain-date.valueobject.js.map +1 -0
- package/valueobjects/domain-number.valueobject.d.ts +6 -0
- package/valueobjects/domain-number.valueobject.js +21 -0
- package/valueobjects/domain-number.valueobject.js.map +1 -0
- package/valueobjects/domain-string.valueobject.d.ts +6 -0
- package/valueobjects/domain-string.valueobject.js +21 -0
- package/valueobjects/domain-string.valueobject.js.map +1 -0
- package/valueobjects/domain-uid.valueobject.d.ts +6 -0
- package/valueobjects/domain-uid.valueobject.js +20 -0
- package/valueobjects/domain-uid.valueobject.js.map +1 -0
- package/valueobjects/domain-valueobject.d.ts +23 -0
- package/valueobjects/domain-valueobject.js +55 -0
- package/valueobjects/domain-valueobject.js.map +1 -0
- package/valueobjects/index.d.ts +6 -0
- package/valueobjects/index.js +23 -0
- package/valueobjects/index.js.map +1 -0
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./constants"), exports);
|
|
18
|
+
__exportStar(require("./exceptions"), exports);
|
|
19
|
+
__exportStar(require("./exception.base"), exports);
|
|
20
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../libs/ddd/src/exceptions/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,8CAA4B;AAC5B,+CAA6B;AAC7B,mDAAiC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DateTimeHelper = void 0;
|
|
4
|
+
class DateTimeHelper {
|
|
5
|
+
static getUtcDate() {
|
|
6
|
+
const year = new Date().getUTCFullYear();
|
|
7
|
+
const month = new Date().getUTCMonth();
|
|
8
|
+
const day = new Date().getUTCDate();
|
|
9
|
+
return new Date(Date.UTC(year, month, day));
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
exports.DateTimeHelper = DateTimeHelper;
|
|
13
|
+
//# sourceMappingURL=datetime.helper.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"datetime.helper.js","sourceRoot":"","sources":["../../../../libs/ddd/src/helpers/datetime.helper.ts"],"names":[],"mappings":";;;AAAA,MAAa,cAAc;IACzB,MAAM,CAAC,UAAU;QACf,MAAM,IAAI,GAAG,IAAI,IAAI,EAAE,CAAC,cAAc,EAAE,CAAC;QACzC,MAAM,KAAK,GAAG,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;QACvC,MAAM,GAAG,GAAG,IAAI,IAAI,EAAE,CAAC,UAAU,EAAE,CAAC;QAEpC,OAAO,IAAI,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,EAAE,KAAK,EAAE,GAAG,CAAC,CAAC,CAAC;IAC9C,CAAC;CACF;AARD,wCAQC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { Subject } from 'rxjs';
|
|
2
|
+
import { ICommand, ICommandPublisher } from '../core/interfaces';
|
|
3
|
+
export declare class DefaultCommandPubSubHelper<CommandBase extends ICommand> implements ICommandPublisher<CommandBase> {
|
|
4
|
+
private subject$;
|
|
5
|
+
constructor(subject$: Subject<CommandBase>);
|
|
6
|
+
publish<T extends CommandBase>(command: T): void;
|
|
7
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DefaultCommandPubSubHelper = void 0;
|
|
4
|
+
class DefaultCommandPubSubHelper {
|
|
5
|
+
constructor(subject$) {
|
|
6
|
+
this.subject$ = subject$;
|
|
7
|
+
}
|
|
8
|
+
publish(command) {
|
|
9
|
+
this.subject$.next(command);
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
exports.DefaultCommandPubSubHelper = DefaultCommandPubSubHelper;
|
|
13
|
+
//# sourceMappingURL=default-command-pubsub.helper.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"default-command-pubsub.helper.js","sourceRoot":"","sources":["../../../../libs/ddd/src/helpers/default-command-pubsub.helper.ts"],"names":[],"mappings":";;;AAGA,MAAa,0BAA0B;IAGrC,YAAoB,QAA8B;QAA9B,aAAQ,GAAR,QAAQ,CAAsB;IAAG,CAAC;IAEtD,OAAO,CAAwB,OAAU;QACvC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IAC9B,CAAC;CACF;AARD,gEAQC"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { Type } from '@nestjs/common';
|
|
2
|
+
import { IDomainEvent } from '../core';
|
|
3
|
+
export declare const defaultGetDomainEventIdHelper: <DomainEventBase extends IDomainEvent = IDomainEvent>(event: DomainEventBase) => string;
|
|
4
|
+
export declare const defaultReflectEventId: <DomainEventBase extends Type<IDomainEvent> = Type<IDomainEvent>>(event: DomainEventBase) => string;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.defaultReflectEventId = exports.defaultGetDomainEventIdHelper = void 0;
|
|
4
|
+
const decorators_1 = require("../decorators");
|
|
5
|
+
const defaultGetDomainEventIdHelper = (event) => {
|
|
6
|
+
const { constructor } = Object.getPrototypeOf(event);
|
|
7
|
+
return Reflect.getMetadata(decorators_1.DOMAIN_EVENT_METADATA, constructor)?.id ?? null;
|
|
8
|
+
};
|
|
9
|
+
exports.defaultGetDomainEventIdHelper = defaultGetDomainEventIdHelper;
|
|
10
|
+
const defaultReflectEventId = (event) => {
|
|
11
|
+
return Reflect.getMetadata(decorators_1.DOMAIN_EVENT_METADATA, event).id;
|
|
12
|
+
};
|
|
13
|
+
exports.defaultReflectEventId = defaultReflectEventId;
|
|
14
|
+
//# sourceMappingURL=default-get-event-id.helper.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"default-get-event-id.helper.js","sourceRoot":"","sources":["../../../../libs/ddd/src/helpers/default-get-event-id.helper.ts"],"names":[],"mappings":";;;AAGA,8CAAsD;AAE/C,MAAM,6BAA6B,GAAG,CAG3C,KAAsB,EACd,EAAE;IACV,MAAM,EAAE,WAAW,EAAE,GAAG,MAAM,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC;IACrD,OAAO,OAAO,CAAC,WAAW,CAAC,kCAAqB,EAAE,WAAW,CAAC,EAAE,EAAE,IAAI,IAAI,CAAC;AAC7E,CAAC,CAAC;AAPW,QAAA,6BAA6B,iCAOxC;AAEK,MAAM,qBAAqB,GAAG,CAGnC,KAAsB,EACd,EAAE;IACV,OAAO,OAAO,CAAC,WAAW,CAAC,kCAAqB,EAAE,KAAK,CAAC,CAAC,EAAE,CAAC;AAC9D,CAAC,CAAC;AANW,QAAA,qBAAqB,yBAMhC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Subject } from 'rxjs';
|
|
2
|
+
import { IDomainEvent, IDomainEventPublisher, IMessageSource } from '../core/interfaces';
|
|
3
|
+
export declare class DefaultPubSubHelper<DomainEventBase extends IDomainEvent> implements IDomainEventPublisher<DomainEventBase>, IMessageSource<DomainEventBase> {
|
|
4
|
+
private subject$;
|
|
5
|
+
constructor(subject$: Subject<DomainEventBase>);
|
|
6
|
+
publish<T extends DomainEventBase>(event: T): void;
|
|
7
|
+
bridgeEventsTo<T extends DomainEventBase>(subject: Subject<T>): void;
|
|
8
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DefaultPubSubHelper = void 0;
|
|
4
|
+
class DefaultPubSubHelper {
|
|
5
|
+
constructor(subject$) {
|
|
6
|
+
this.subject$ = subject$;
|
|
7
|
+
}
|
|
8
|
+
publish(event) {
|
|
9
|
+
this.subject$.next(event);
|
|
10
|
+
}
|
|
11
|
+
bridgeEventsTo(subject) {
|
|
12
|
+
this.subject$ = subject;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
exports.DefaultPubSubHelper = DefaultPubSubHelper;
|
|
16
|
+
//# sourceMappingURL=default-pubsub.helper.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"default-pubsub.helper.js","sourceRoot":"","sources":["../../../../libs/ddd/src/helpers/default-pubsub.helper.ts"],"names":[],"mappings":";;;AAOA,MAAa,mBAAmB;IAK9B,YAAoB,QAAkC;QAAlC,aAAQ,GAAR,QAAQ,CAA0B;IAAG,CAAC;IAE1D,OAAO,CAA4B,KAAQ;QACzC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAC5B,CAAC;IAED,cAAc,CAA4B,OAAmB;QAC3D,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC;IAC1B,CAAC;CACF;AAdD,kDAcC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Subject } from 'rxjs';
|
|
2
|
+
import { ICommand, IUnhandledExceptionPublisher, UnhandledExceptionInfo } from '../core/interfaces';
|
|
3
|
+
import { IDomainEvent } from '@nestjslatam/ddd';
|
|
4
|
+
export declare class DefaultUnhandledExceptionPubSub<Cause = IDomainEvent | ICommand> implements IUnhandledExceptionPublisher<Cause> {
|
|
5
|
+
private subject$;
|
|
6
|
+
constructor(subject$: Subject<UnhandledExceptionInfo<Cause>>);
|
|
7
|
+
publish(info: UnhandledExceptionInfo<Cause>): void;
|
|
8
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DefaultUnhandledExceptionPubSub = void 0;
|
|
4
|
+
class DefaultUnhandledExceptionPubSub {
|
|
5
|
+
constructor(subject$) {
|
|
6
|
+
this.subject$ = subject$;
|
|
7
|
+
}
|
|
8
|
+
publish(info) {
|
|
9
|
+
this.subject$.next(info);
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
exports.DefaultUnhandledExceptionPubSub = DefaultUnhandledExceptionPubSub;
|
|
13
|
+
//# sourceMappingURL=default-unhandled-exception-pubsub.helper.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"default-unhandled-exception-pubsub.helper.js","sourceRoot":"","sources":["../../../../libs/ddd/src/helpers/default-unhandled-exception-pubsub.helper.ts"],"names":[],"mappings":";;;AAQA,MAAa,+BAA+B;IAG1C,YAAoB,QAAgD;QAAhD,aAAQ,GAAR,QAAQ,CAAwC;IAAG,CAAC;IAExE,OAAO,CAAC,IAAmC;QACzC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC3B,CAAC;CACF;AARD,0EAQC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { DomainValueObject } from '../valueobjects';
|
|
2
|
+
export declare class DomainGuard {
|
|
3
|
+
static isValueObject(obj: unknown): obj is DomainValueObject<unknown>;
|
|
4
|
+
static isEmpty(value: unknown): boolean;
|
|
5
|
+
static lengthIsBetween(value: number | string | Array<unknown>, min: number, max: number): boolean;
|
|
6
|
+
static lenghtIsEqual(value: number | string | Array<unknown>, length: number): boolean;
|
|
7
|
+
static isEmail(value: string): boolean;
|
|
8
|
+
static isString(value: unknown): boolean;
|
|
9
|
+
static isNumber(value: unknown): boolean;
|
|
10
|
+
static isNumberBetween(value: number, min: number, max: number): boolean;
|
|
11
|
+
static isDate(value: unknown): boolean;
|
|
12
|
+
private static getValueLength;
|
|
13
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DomainGuard = void 0;
|
|
4
|
+
const valueobjects_1 = require("../valueobjects");
|
|
5
|
+
const ERROR_MESSAGE_LENGTH = 'Cannot check length of a value. Provided value is empty';
|
|
6
|
+
class DomainGuard {
|
|
7
|
+
static isValueObject(obj) {
|
|
8
|
+
return obj instanceof valueobjects_1.DomainValueObject;
|
|
9
|
+
}
|
|
10
|
+
static isEmpty(value) {
|
|
11
|
+
if (typeof value === 'number' ||
|
|
12
|
+
typeof value === 'boolean' ||
|
|
13
|
+
value instanceof Date)
|
|
14
|
+
return false;
|
|
15
|
+
if (typeof value === 'undefined' ||
|
|
16
|
+
value === null ||
|
|
17
|
+
(value instanceof Object && !Object.keys(value).length) ||
|
|
18
|
+
value === '')
|
|
19
|
+
return true;
|
|
20
|
+
if (Array.isArray(value)) {
|
|
21
|
+
if (value.length === 0)
|
|
22
|
+
return true;
|
|
23
|
+
if (value.every((item) => DomainGuard.isEmpty(item))) {
|
|
24
|
+
return true;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
return false;
|
|
28
|
+
}
|
|
29
|
+
static lengthIsBetween(value, min, max) {
|
|
30
|
+
if (DomainGuard.isEmpty(value))
|
|
31
|
+
throw new Error(ERROR_MESSAGE_LENGTH);
|
|
32
|
+
const valueLength = this.getValueLength(value);
|
|
33
|
+
return valueLength >= min && valueLength <= max ? true : false;
|
|
34
|
+
}
|
|
35
|
+
static lenghtIsEqual(value, length) {
|
|
36
|
+
if (DomainGuard.isEmpty(value))
|
|
37
|
+
throw new Error(ERROR_MESSAGE_LENGTH);
|
|
38
|
+
return this.getValueLength(value) === length ? true : false;
|
|
39
|
+
}
|
|
40
|
+
static isEmail(value) {
|
|
41
|
+
return /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(value);
|
|
42
|
+
}
|
|
43
|
+
static isString(value) {
|
|
44
|
+
return typeof value === 'string';
|
|
45
|
+
}
|
|
46
|
+
static isNumber(value) {
|
|
47
|
+
return typeof value === 'number';
|
|
48
|
+
}
|
|
49
|
+
static isNumberBetween(value, min, max) {
|
|
50
|
+
if (DomainGuard.isEmpty(value))
|
|
51
|
+
throw new Error(ERROR_MESSAGE_LENGTH);
|
|
52
|
+
return value >= min && value <= max ? true : false;
|
|
53
|
+
}
|
|
54
|
+
static isDate(value) {
|
|
55
|
+
return value instanceof Date;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
exports.DomainGuard = DomainGuard;
|
|
59
|
+
DomainGuard.getValueLength = (value) => typeof value === 'number' ? Number(value).toString().length : value.length;
|
|
60
|
+
//# sourceMappingURL=domain-guard.helper.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"domain-guard.helper.js","sourceRoot":"","sources":["../../../../libs/ddd/src/helpers/domain-guard.helper.ts"],"names":[],"mappings":";;;AAAA,kDAAoD;AAEpD,MAAM,oBAAoB,GACxB,yDAAyD,CAAC;AAE5D,MAAa,WAAW;IACtB,MAAM,CAAC,aAAa,CAAC,GAAY;QAC/B,OAAO,GAAG,YAAY,gCAAiB,CAAC;IAC1C,CAAC;IAED,MAAM,CAAC,OAAO,CAAC,KAAc;QAC3B,IACE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CAAC;IAED,MAAM,CAAC,OAAO,CAAC,KAAa;QAC1B,OAAO,4BAA4B,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAClD,CAAC;IAED,MAAM,CAAC,QAAQ,CAAC,KAAc;QAC5B,OAAO,OAAO,KAAK,KAAK,QAAQ,CAAC;IACnC,CAAC;IAED,MAAM,CAAC,QAAQ,CAAC,KAAc;QAC5B,OAAO,OAAO,KAAK,KAAK,QAAQ,CAAC;IACnC,CAAC;IAED,MAAM,CAAC,eAAe,CAAC,KAAa,EAAE,GAAW,EAAE,GAAW;QAC5D,IAAI,WAAW,CAAC,OAAO,CAAC,KAAK,CAAC;YAAE,MAAM,IAAI,KAAK,CAAC,oBAAoB,CAAC,CAAC;QAEtE,OAAO,KAAK,IAAI,GAAG,IAAI,KAAK,IAAI,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC;IACrD,CAAC;IAED,MAAM,CAAC,MAAM,CAAC,KAAc;QAC1B,OAAO,KAAK,YAAY,IAAI,CAAC;IAC/B,CAAC;;AAzEH,kCA6EC;AAFgB,0BAAc,GAAG,CAAC,KAAuC,EAAE,EAAE,CAC1E,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,QAAQ,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const convertPropsToObject: (props: any) => any;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.convertPropsToObject = void 0;
|
|
4
|
+
const domain_guard_helper_1 = require("./domain-guard.helper");
|
|
5
|
+
const isEntity = (obj) => {
|
|
6
|
+
return (Object.prototype.hasOwnProperty.call(obj, 'toObject') &&
|
|
7
|
+
Object.prototype.hasOwnProperty.call(obj, 'id') &&
|
|
8
|
+
Object.prototype.hasOwnProperty.call(obj, '_id') &&
|
|
9
|
+
Object.prototype.hasOwnProperty.call(obj, '_trackingProps'));
|
|
10
|
+
};
|
|
11
|
+
const convertToPlainObject = (item) => {
|
|
12
|
+
if (!item)
|
|
13
|
+
throw new Error('Item is required');
|
|
14
|
+
if (domain_guard_helper_1.DomainGuard.isValueObject(item)) {
|
|
15
|
+
return item.unpack();
|
|
16
|
+
}
|
|
17
|
+
if (isEntity(item)) {
|
|
18
|
+
return item.toObject();
|
|
19
|
+
}
|
|
20
|
+
return item;
|
|
21
|
+
};
|
|
22
|
+
const convertPropsToObject = (props) => {
|
|
23
|
+
if (!props)
|
|
24
|
+
throw new Error('Props is required');
|
|
25
|
+
const propsCopy = { ...props };
|
|
26
|
+
for (const prop in propsCopy) {
|
|
27
|
+
if (Array.isArray(propsCopy[prop])) {
|
|
28
|
+
propsCopy[prop] = propsCopy[prop].map((item) => {
|
|
29
|
+
return convertToPlainObject(item);
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
propsCopy[prop] = convertToPlainObject(propsCopy[prop]);
|
|
33
|
+
}
|
|
34
|
+
return propsCopy;
|
|
35
|
+
};
|
|
36
|
+
exports.convertPropsToObject = convertPropsToObject;
|
|
37
|
+
//# sourceMappingURL=domain-object.helper.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"domain-object.helper.js","sourceRoot":"","sources":["../../../../libs/ddd/src/helpers/domain-object.helper.ts"],"names":[],"mappings":";;;AACA,+DAAoD;AAEpD,MAAM,QAAQ,GAAG,CAAC,GAAY,EAAgC,EAAE;IAC9D,OAAO,CACL,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,GAAG,EAAE,UAAU,CAAC;QACrD,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,GAAG,EAAE,IAAI,CAAC;QAC/C,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,GAAG,EAAE,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per';
|
|
4
|
+
export * from './default-command-pubsub.helper';
|
|
5
|
+
export * from './default-get-event-id.helper';
|
|
6
|
+
export * from './default-pubsub.helper';
|
|
7
|
+
export * from './default-unhandled-exception-pubsub.helper';
|
package/helpers/index.js
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./domain-guard.helper"), exports);
|
|
18
|
+
__exportStar(require("./domain-object.helper"), exports);
|
|
19
|
+
__exportStar(require("./datetime.helper"), exports);
|
|
20
|
+
__exportStar(require("./default-command-pubsub.helper"), exports);
|
|
21
|
+
__exportStar(require("./default-get-event-id.helper"), exports);
|
|
22
|
+
__exportStar(require("./default-pubsub.helper"), exports);
|
|
23
|
+
__exportStar(require("./default-unhandled-exception-pubsub.helper"), exports);
|
|
24
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../libs/ddd/src/helpers/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,wDAAsC;AACtC,yDAAuC;AACvC,oDAAkC;AAClC,kEAAgD;AAChD,gEAA8C;AAC9C,0DAAwC;AACxC,8EAA4D"}
|
package/index.d.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export * from './core';
|
|
2
|
+
export * from './exceptions';
|
|
3
|
+
export * from './helpers';
|
|
4
|
+
export * from './valueobjects';
|
|
5
|
+
export * from './domain-aggregate-root';
|
|
6
|
+
export * from './domain-entity';
|
|
7
|
+
export * from './domain-event-collection';
|
|
8
|
+
export * from './domain-event';
|
|
9
|
+
export * from './ddd.module';
|
|
10
|
+
export * from './ddd.service';
|
|
11
|
+
export * from './command.base';
|
|
12
|
+
export * from './domain-command-bus';
|
|
13
|
+
export * from './domain-event-bus';
|
|
14
|
+
export * from './domain-event-publisher';
|
|
15
|
+
export * from './unhandled-exeption-bus';
|
package/index.js
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./core"), exports);
|
|
18
|
+
__exportStar(require("./exceptions"), exports);
|
|
19
|
+
__exportStar(require("./helpers"), exports);
|
|
20
|
+
__exportStar(require("./valueobjects"), exports);
|
|
21
|
+
__exportStar(require("./domain-aggregate-root"), exports);
|
|
22
|
+
__exportStar(require("./domain-entity"), exports);
|
|
23
|
+
__exportStar(require("./domain-event-collection"), exports);
|
|
24
|
+
__exportStar(require("./domain-event"), exports);
|
|
25
|
+
__exportStar(require("./ddd.module"), exports);
|
|
26
|
+
__exportStar(require("./ddd.service"), exports);
|
|
27
|
+
__exportStar(require("./command.base"), exports);
|
|
28
|
+
__exportStar(require("./domain-command-bus"), exports);
|
|
29
|
+
__exportStar(require("./domain-event-bus"), exports);
|
|
30
|
+
__exportStar(require("./domain-event-publisher"), exports);
|
|
31
|
+
__exportStar(require("./unhandled-exeption-bus"), exports);
|
|
32
|
+
//# sourceMappingURL=index.js.map
|
package/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../libs/ddd/src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,yCAAuB;AACvB,+CAA6B;AAC7B,4CAA0B;AAC1B,iDAA+B;AAC/B,0DAAwC;AACxC,kDAAgC;AAChC,4DAA0C;AAC1C,iDAA+B;AAC/B,+CAA6B;AAC7B,gDAA8B;AAC9B,iDAA+B;AAC/B,uDAAqC;AACrC,qDAAmC;AACnC,2DAAyC;AACzC,2DAAyC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@nestjslatam/ddd-lib",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "A simple Domain-Driven Library for NESTJS",
|
|
5
|
+
"main": "index.js",
|
|
6
|
+
"private": false,
|
|
7
|
+
"keywords": [
|
|
8
|
+
"nestjs",
|
|
9
|
+
"ddd"
|
|
10
|
+
],
|
|
11
|
+
"author": {
|
|
12
|
+
"name": "Alberto Arroyo Raygada",
|
|
13
|
+
"email": "beyondnet.peru@gmail.com",
|
|
14
|
+
"url": "http://nestjslatam.org/"
|
|
15
|
+
},
|
|
16
|
+
"license": "MIT",
|
|
17
|
+
"dependencies": {
|
|
18
|
+
"@nestjs/common": "^10.2.7",
|
|
19
|
+
"@nestjs/core": "^10.2.7",
|
|
20
|
+
"rxjs": "^7.8.1",
|
|
21
|
+
"uuid": "^9.0.0"
|
|
22
|
+
}
|
|
23
|
+
}
|