@inovys/domain-driven-design 0.1.0-RC.1

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/README.md ADDED
@@ -0,0 +1,20 @@
1
+ <div align="center">
2
+ <h1>Inovys - Domain Driven Design</h1>
3
+
4
+ <p>
5
+ <a href="./README.md" target="_blank">
6
+ <img alt="Version" src="https://img.shields.io/badge/version-0.1.0-blue.svg">
7
+ </a>
8
+ <a href="./LICENSE" target="_blank">
9
+ <img alt="License: MIT" src="https://img.shields.io/badge/License-MIT-green.svg" />
10
+ </a>
11
+ </p>
12
+ </div>
13
+
14
+ ## 📝 Table of content
15
+
16
+ - 👋 [Introduction](#👋-introduction)
17
+
18
+ ## 👋 Introduction
19
+
20
+ Welcome to the NestJS Boilerplate. This project provides a solid foundation for building scalable and maintainable backend applications with NestJS, following the [Clean Architecture](https://blog.cleancoder.com/uncle-bob/2012/08/13/the-clean-architecture.html). It also integrates concepts from [Domain-Driven Design (DDD)](https://martinfowler.com/bliki/DomainDrivenDesign.html) to help organize your code around the core business logic.
package/dist/main.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=main.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"main.d.ts","sourceRoot":"","sources":["../src/main.ts"],"names":[],"mappings":""}
package/dist/main.js ADDED
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=main.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"main.js","sourceRoot":"","sources":["../src/main.ts"],"names":[],"mappings":""}
@@ -0,0 +1,8 @@
1
+ import type { DomainEvent } from "./domain-event.js";
2
+ import { Entity } from "./entity.js";
3
+ export declare abstract class AggregateRoot<Properties extends Record<keyof Properties, unknown>> extends Entity<Properties> {
4
+ private readonly _events;
5
+ protected commit(event: DomainEvent): void;
6
+ pullDomainEvents(): DomainEvent<Record<string, unknown>>[];
7
+ }
8
+ //# sourceMappingURL=aggregate-root.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"aggregate-root.d.ts","sourceRoot":"","sources":["../../src/primitives/aggregate-root.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAErC,8BAAsB,aAAa,CACjC,UAAU,SAAS,MAAM,CAAC,MAAM,UAAU,EAAE,OAAO,CAAC,CACpD,SAAQ,MAAM,CAAC,UAAU,CAAC;IAC1B,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAqB;IAE7C,SAAS,CAAC,MAAM,CAAC,KAAK,EAAE,WAAW;IAInC,gBAAgB;CAMjB"}
@@ -0,0 +1,13 @@
1
+ import { Entity } from "./entity.js";
2
+ export class AggregateRoot extends Entity {
3
+ _events = [];
4
+ commit(event) {
5
+ this._events.push(event);
6
+ }
7
+ pullDomainEvents() {
8
+ const events = [...this._events];
9
+ this._events.length = 0;
10
+ return events;
11
+ }
12
+ }
13
+ //# sourceMappingURL=aggregate-root.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"aggregate-root.js","sourceRoot":"","sources":["../../src/primitives/aggregate-root.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAErC,MAAM,OAAgB,aAEpB,SAAQ,MAAkB;IACT,OAAO,GAAkB,EAAE,CAAC;IAEnC,MAAM,CAAC,KAAkB;QACjC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAC3B,CAAC;IAED,gBAAgB;QACd,MAAM,MAAM,GAAG,CAAC,GAAG,IAAI,CAAC,OAAO,CAAC,CAAC;QACjC,IAAI,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC;QAExB,OAAO,MAAM,CAAC;IAChB,CAAC;CACF"}
@@ -0,0 +1,11 @@
1
+ interface CreateDomainEventProps<Payload = Record<string, unknown>> {
2
+ payload: Payload;
3
+ }
4
+ export declare abstract class DomainEvent<Payload = Record<string, unknown>> {
5
+ readonly id: string;
6
+ readonly payload: Payload;
7
+ readonly type: string;
8
+ constructor(properties: CreateDomainEventProps<Payload>);
9
+ }
10
+ export {};
11
+ //# sourceMappingURL=domain-event.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"domain-event.d.ts","sourceRoot":"","sources":["../../src/primitives/domain-event.ts"],"names":[],"mappings":"AAEA,UAAU,sBAAsB,CAAC,OAAO,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IAChE,OAAO,EAAE,OAAO,CAAC;CAClB;AAED,8BAAsB,WAAW,CAAC,OAAO,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IACjE,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAC1B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;gBAEV,UAAU,EAAE,sBAAsB,CAAC,OAAO,CAAC;CAKxD"}
@@ -0,0 +1,12 @@
1
+ import { randomUUID } from "node:crypto";
2
+ export class DomainEvent {
3
+ id;
4
+ payload;
5
+ type;
6
+ constructor(properties) {
7
+ this.id = randomUUID();
8
+ this.payload = properties.payload;
9
+ this.type = this.constructor.name;
10
+ }
11
+ }
12
+ //# sourceMappingURL=domain-event.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"domain-event.js","sourceRoot":"","sources":["../../src/primitives/domain-event.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAMzC,MAAM,OAAgB,WAAW;IACtB,EAAE,CAAS;IACX,OAAO,CAAU;IACjB,IAAI,CAAS;IAEtB,YAAY,UAA2C;QACrD,IAAI,CAAC,EAAE,GAAG,UAAU,EAAE,CAAC;QACvB,IAAI,CAAC,OAAO,GAAG,UAAU,CAAC,OAAO,CAAC;QAClC,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC;IACpC,CAAC;CACF"}
@@ -0,0 +1,21 @@
1
+ interface EntityProperties {
2
+ id: string;
3
+ }
4
+ interface CreateEntityProperties<Properties extends Record<keyof Properties, unknown>> {
5
+ id?: EntityProperties["id"];
6
+ properties: Properties;
7
+ }
8
+ export declare abstract class Entity<Properties extends Record<keyof Properties, unknown>> {
9
+ readonly id: EntityProperties["id"];
10
+ protected readonly _properties: Properties;
11
+ constructor({ id, properties }: CreateEntityProperties<Properties>);
12
+ static fromSnapshot<Constructor extends new (...args: any) => any>(this: Constructor, snapshot: InstanceType<Constructor>["_properties"] & EntityProperties): InstanceType<Constructor>;
13
+ get properties(): Readonly<{
14
+ id: string;
15
+ } & Properties>;
16
+ snapshot(): Properties & {
17
+ id: string;
18
+ };
19
+ }
20
+ export {};
21
+ //# sourceMappingURL=entity.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"entity.d.ts","sourceRoot":"","sources":["../../src/primitives/entity.ts"],"names":[],"mappings":"AAEA,UAAU,gBAAgB;IACxB,EAAE,EAAE,MAAM,CAAC;CACZ;AAED,UAAU,sBAAsB,CAAC,UAAU,SAAS,MAAM,CAAC,MAAM,UAAU,EAAE,OAAO,CAAC;IACnF,EAAE,CAAC,EAAE,gBAAgB,CAAC,IAAI,CAAC,CAAC;IAC5B,UAAU,EAAE,UAAU,CAAC;CACxB;AAED,8BAAsB,MAAM,CAAC,UAAU,SAAS,MAAM,CAAC,MAAM,UAAU,EAAE,OAAO,CAAC;IAC/E,SAAgB,EAAE,EAAE,gBAAgB,CAAC,IAAI,CAAC,CAAC;IAC3C,SAAS,CAAC,QAAQ,CAAC,WAAW,EAAE,UAAU,CAAC;gBAE/B,EAAE,EAAE,EAAE,UAAU,EAAE,EAAE,sBAAsB,CAAC,UAAU,CAAC;IAKlE,MAAM,CAAC,YAAY,CAAC,WAAW,SAAS,KAAK,GAAG,IAAI,EAAE,GAAG,KAAK,GAAG,EAC/D,IAAI,EAAE,WAAW,EACjB,QAAQ,EAAE,YAAY,CAAC,WAAW,CAAC,CAAC,aAAa,CAAC,GAAG,gBAAgB,GACpE,YAAY,CAAC,WAAW,CAAC;IAQ5B,IAAI,UAAU;;oBAKb;IAED,QAAQ;;;CAIT"}
@@ -0,0 +1,26 @@
1
+ import { randomUUID } from "node:crypto";
2
+ export class Entity {
3
+ id;
4
+ _properties;
5
+ constructor({ id, properties }) {
6
+ this.id = id ?? randomUUID();
7
+ this._properties = properties;
8
+ }
9
+ static fromSnapshot(snapshot) {
10
+ const { id, ...properties } = snapshot;
11
+ // 'this' inside a static method correctly refers to the class (constructor function) that invoked it.
12
+ // biome-ignore lint:complexity/noThisInStatic
13
+ return new this({ id, properties });
14
+ }
15
+ get properties() {
16
+ return Object.freeze({
17
+ id: this.id,
18
+ ...this._properties,
19
+ });
20
+ }
21
+ snapshot() {
22
+ const snapshot = { ...this._properties, id: this.id };
23
+ return snapshot;
24
+ }
25
+ }
26
+ //# sourceMappingURL=entity.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"entity.js","sourceRoot":"","sources":["../../src/primitives/entity.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAWzC,MAAM,OAAgB,MAAM;IACV,EAAE,CAAyB;IACxB,WAAW,CAAa;IAE3C,YAAY,EAAE,EAAE,EAAE,UAAU,EAAsC;QAChE,IAAI,CAAC,EAAE,GAAG,EAAE,IAAI,UAAU,EAAE,CAAC;QAC7B,IAAI,CAAC,WAAW,GAAG,UAAU,CAAC;IAChC,CAAC;IAED,MAAM,CAAC,YAAY,CAEjB,QAAqE;QAErE,MAAM,EAAE,EAAE,EAAE,GAAG,UAAU,EAAE,GAAG,QAAQ,CAAC;QAEvC,sGAAsG;QACtG,8CAA8C;QAC9C,OAAO,IAAI,IAAI,CAAC,EAAE,EAAE,EAAE,UAAU,EAAE,CAAC,CAAC;IACtC,CAAC;IAED,IAAI,UAAU;QACZ,OAAO,MAAM,CAAC,MAAM,CAAC;YACnB,EAAE,EAAE,IAAI,CAAC,EAAE;YACX,GAAG,IAAI,CAAC,WAAW;SACpB,CAAC,CAAC;IACL,CAAC;IAED,QAAQ;QACN,MAAM,QAAQ,GAAG,EAAE,GAAG,IAAI,CAAC,WAAW,EAAE,EAAE,EAAE,IAAI,CAAC,EAAE,EAAE,CAAC;QACtD,OAAO,QAAQ,CAAC;IAClB,CAAC;CACF"}
package/package.json ADDED
@@ -0,0 +1,23 @@
1
+ {
2
+ "name": "@inovys/domain-driven-design",
3
+ "version": "0.1.0-RC.1",
4
+ "type": "module",
5
+ "files": [
6
+ "dist"
7
+ ],
8
+ "exports": {
9
+ ".": {
10
+ "import": "./dist/main.js",
11
+ "types": "./dist/main.d.ts"
12
+ }
13
+ },
14
+ "devDependencies": {
15
+ "@types/node": "^25.5.2",
16
+ "oxfmt": "^0.43.0",
17
+ "oxlint": "^1.58.0",
18
+ "typescript": "^6.0.2"
19
+ },
20
+ "scripts": {
21
+ "build": "tsc -p tsconfig.json"
22
+ }
23
+ }