ddd-node 9.1.0 → 9.2.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/dist/core/aggregate.d.ts +3 -5
- package/dist/core/aggregate.js +2 -2
- package/dist/core/entity.d.ts +2 -4
- package/dist/core/entity.js +2 -2
- package/dist/core/id/built/index.d.ts +2 -0
- package/dist/core/id/built/index.js +18 -0
- package/dist/core/id/built/snowflake.generator.d.ts +8 -0
- package/dist/core/id/built/snowflake.generator.js +16 -0
- package/dist/core/id/built/uuid4.generator.d.ts +5 -0
- package/dist/core/id/built/uuid4.generator.js +16 -0
- package/dist/core/id/id-generator.d.ts +8 -0
- package/dist/core/id/id-generator.js +17 -0
- package/dist/core/id/id.d.ts +6 -0
- package/dist/core/id/id.js +15 -0
- package/dist/core/id/index.d.ts +3 -0
- package/dist/core/id/index.js +19 -0
- package/dist/core/index.d.ts +0 -4
- package/dist/core/index.js +0 -4
- package/dist/core/{command.d.ts → message/command.d.ts} +2 -3
- package/dist/core/{event.d.ts → message/event.d.ts} +3 -5
- package/dist/core/message/index.d.ts +3 -0
- package/dist/core/message/index.js +19 -0
- package/dist/core/{message.d.ts → message/message.d.ts} +2 -2
- package/dist/core/{message.js → message/message.js} +2 -2
- package/dist/core/metadata.d.ts +2 -3
- package/dist/core/model/index.d.ts +3 -0
- package/dist/core/model/index.js +19 -0
- package/dist/core/{model-type.d.ts → model/model-type.d.ts} +1 -2
- package/dist/core/{model-with-id.d.ts → model/model-with-id.d.ts} +1 -1
- package/dist/core/{model-with-id.js → model/model-with-id.js} +2 -2
- package/dist/core/{model.d.ts → model/model.d.ts} +1 -1
- package/dist/core/{model.js → model/model.js} +1 -1
- package/dist/core/registry.d.ts +1 -2
- package/dist/core/value-object.d.ts +1 -1
- package/dist/decorators/aggregate.d.ts +1 -3
- package/dist/decorators/aggregate.js +6 -7
- package/dist/decorators/command.d.ts +1 -1
- package/dist/decorators/command.js +2 -2
- package/dist/decorators/entity.d.ts +1 -1
- package/dist/decorators/entity.js +2 -2
- package/dist/decorators/event.d.ts +1 -1
- package/dist/decorators/event.js +2 -2
- package/dist/decorators/id.d.ts +1 -1
- package/dist/decorators/id.js +2 -2
- package/dist/decorators/model.d.ts +1 -2
- package/dist/decorators/model.js +3 -4
- package/dist/decorators/value-object.d.ts +1 -1
- package/dist/decorators/value-object.js +2 -2
- package/package.json +2 -1
- package/tsconfig.json +4 -4
- package/dist/core/id.d.ts +0 -17
- package/dist/core/id.js +0 -40
- /package/dist/core/{command.js → message/command.js} +0 -0
- /package/dist/core/{event.js → message/event.js} +0 -0
- /package/dist/core/{model-type.js → model/model-type.js} +0 -0
package/dist/core/aggregate.d.ts
CHANGED
|
@@ -1,10 +1,8 @@
|
|
|
1
|
-
import { Class } from "../types/
|
|
2
|
-
import { ClassStatic } from "../types/class-static";
|
|
3
|
-
import { AnyCommand } from "./command";
|
|
1
|
+
import { Class, ClassStatic } from "../types/index";
|
|
4
2
|
import { Entity, EntityMetadata } from "./entity";
|
|
5
|
-
import { AnyEvent, EventClass, EventClassWithTypedConstructor } from "./event";
|
|
6
3
|
import { Id } from "./id";
|
|
7
|
-
import {
|
|
4
|
+
import { AnyCommand, AnyEvent, EventClass, EventClassWithTypedConstructor } from "./message";
|
|
5
|
+
import { PropsOf } from "./model/model";
|
|
8
6
|
export interface AggregateBaseMetadata extends EntityMetadata {
|
|
9
7
|
version: number;
|
|
10
8
|
}
|
package/dist/core/aggregate.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.AggregateES = exports.Aggregate = exports.AggregateBase = void 0;
|
|
4
|
-
const
|
|
4
|
+
const _utils_1 = require("../utils/index");
|
|
5
5
|
const entity_1 = require("./entity");
|
|
6
6
|
const metadata_1 = require("./metadata");
|
|
7
7
|
class AggregateBase extends entity_1.Entity {
|
|
@@ -152,7 +152,7 @@ class AggregateES extends AggregateBase {
|
|
|
152
152
|
}
|
|
153
153
|
handleCommand(command) {
|
|
154
154
|
const handler = this.getHandlerForCommand(command);
|
|
155
|
-
const events = (0,
|
|
155
|
+
const events = (0, _utils_1.toArray)(handler.call(this, command));
|
|
156
156
|
events.forEach((event) => {
|
|
157
157
|
var _a;
|
|
158
158
|
event.setContext({
|
package/dist/core/entity.d.ts
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
import { Class } from "../types/
|
|
2
|
-
import { ClassStatic } from "../types/class-static";
|
|
1
|
+
import { Class, ClassStatic } from "../types/index";
|
|
3
2
|
import { Id } from "./id";
|
|
4
|
-
import { PropsOf } from "./model";
|
|
5
|
-
import { ModelWithId } from "./model-with-id";
|
|
3
|
+
import { ModelWithId, PropsOf } from "./model";
|
|
6
4
|
export interface EntityMetadata {
|
|
7
5
|
readonly id: Id;
|
|
8
6
|
}
|
package/dist/core/entity.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Entity = void 0;
|
|
4
|
-
const
|
|
5
|
-
class Entity extends
|
|
4
|
+
const model_1 = require("./model");
|
|
5
|
+
class Entity extends model_1.ModelWithId {
|
|
6
6
|
constructor(metadata, props) {
|
|
7
7
|
super(props);
|
|
8
8
|
this._id = metadata.id;
|
|
@@ -0,0 +1,18 @@
|
|
|
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("./snowflake.generator"), exports);
|
|
18
|
+
__exportStar(require("./uuid4.generator"), exports);
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { SnowflakeOpts } from "nodejs-snowflake";
|
|
2
|
+
import { IdGenerator } from "../id-generator";
|
|
3
|
+
export declare class SnowflakeGenerator extends IdGenerator {
|
|
4
|
+
private snowflake;
|
|
5
|
+
constructor(options?: SnowflakeOpts);
|
|
6
|
+
generateValue(): string;
|
|
7
|
+
validateValue(value: string): void;
|
|
8
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SnowflakeGenerator = void 0;
|
|
4
|
+
const nodejs_snowflake_1 = require("nodejs-snowflake");
|
|
5
|
+
const id_generator_1 = require("../id-generator");
|
|
6
|
+
class SnowflakeGenerator extends id_generator_1.IdGenerator {
|
|
7
|
+
constructor(options) {
|
|
8
|
+
super();
|
|
9
|
+
this.snowflake = new nodejs_snowflake_1.Snowflake(options);
|
|
10
|
+
}
|
|
11
|
+
generateValue() {
|
|
12
|
+
return this.snowflake.getUniqueID().toString(16);
|
|
13
|
+
}
|
|
14
|
+
validateValue(value) { }
|
|
15
|
+
}
|
|
16
|
+
exports.SnowflakeGenerator = SnowflakeGenerator;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Uuid4Generator = void 0;
|
|
4
|
+
const uuid_1 = require("uuid");
|
|
5
|
+
const id_generator_1 = require("../id-generator");
|
|
6
|
+
class Uuid4Generator extends id_generator_1.IdGenerator {
|
|
7
|
+
generateValue() {
|
|
8
|
+
return (0, uuid_1.v4)();
|
|
9
|
+
}
|
|
10
|
+
validateValue(value) {
|
|
11
|
+
const isUuid = (0, uuid_1.validate)(value);
|
|
12
|
+
const isV4 = (0, uuid_1.version)(value) === 4;
|
|
13
|
+
return isUuid && isV4;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
exports.Uuid4Generator = Uuid4Generator;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.IdGenerator = void 0;
|
|
4
|
+
const id_1 = require("./id");
|
|
5
|
+
class IdGenerator {
|
|
6
|
+
fromValue(value) {
|
|
7
|
+
this.validateValue(value);
|
|
8
|
+
return new id_1.Id(value);
|
|
9
|
+
}
|
|
10
|
+
fromId(id) {
|
|
11
|
+
return this.fromValue(id.value);
|
|
12
|
+
}
|
|
13
|
+
newId() {
|
|
14
|
+
return this.fromValue(this.generateValue());
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
exports.IdGenerator = IdGenerator;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Id = void 0;
|
|
4
|
+
class Id {
|
|
5
|
+
constructor(value) {
|
|
6
|
+
this._value = value;
|
|
7
|
+
}
|
|
8
|
+
get value() {
|
|
9
|
+
return this._value;
|
|
10
|
+
}
|
|
11
|
+
equals(id) {
|
|
12
|
+
return this._value === id._value;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
exports.Id = Id;
|
|
@@ -0,0 +1,19 @@
|
|
|
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("./built"), exports);
|
|
18
|
+
__exportStar(require("./id"), exports);
|
|
19
|
+
__exportStar(require("./id-generator"), exports);
|
package/dist/core/index.d.ts
CHANGED
|
@@ -1,14 +1,10 @@
|
|
|
1
1
|
export * from "./aggregate";
|
|
2
|
-
export * from "./command";
|
|
3
2
|
export * from "./entity";
|
|
4
3
|
export * from "./error";
|
|
5
|
-
export * from "./event";
|
|
6
4
|
export * from "./id";
|
|
7
5
|
export * from "./message";
|
|
8
6
|
export * from "./metadata";
|
|
9
7
|
export * from "./model";
|
|
10
|
-
export * from "./model-type";
|
|
11
|
-
export * from "./model-with-id";
|
|
12
8
|
export * from "./registry";
|
|
13
9
|
export * from "./repository";
|
|
14
10
|
export * from "./value-object";
|
package/dist/core/index.js
CHANGED
|
@@ -15,16 +15,12 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("./aggregate"), exports);
|
|
18
|
-
__exportStar(require("./command"), exports);
|
|
19
18
|
__exportStar(require("./entity"), exports);
|
|
20
19
|
__exportStar(require("./error"), exports);
|
|
21
|
-
__exportStar(require("./event"), exports);
|
|
22
20
|
__exportStar(require("./id"), exports);
|
|
23
21
|
__exportStar(require("./message"), exports);
|
|
24
22
|
__exportStar(require("./metadata"), exports);
|
|
25
23
|
__exportStar(require("./model"), exports);
|
|
26
|
-
__exportStar(require("./model-type"), exports);
|
|
27
|
-
__exportStar(require("./model-with-id"), exports);
|
|
28
24
|
__exportStar(require("./registry"), exports);
|
|
29
25
|
__exportStar(require("./repository"), exports);
|
|
30
26
|
__exportStar(require("./value-object"), exports);
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { Class } from "
|
|
2
|
-
import {
|
|
1
|
+
import { Class, ClassStatic } from "../../types/index";
|
|
2
|
+
import { PropsOf } from "../model";
|
|
3
3
|
import { Message, MessageContext, MessageMetadata } from "./message";
|
|
4
|
-
import { PropsOf } from "./model";
|
|
5
4
|
export interface CommandMetadata extends MessageMetadata {
|
|
6
5
|
}
|
|
7
6
|
export declare class Command<Props extends object> extends Message<Props> {
|
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
import { Class } from "
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import { Class, ClassStatic } from "../../types/index";
|
|
2
|
+
import { Id } from "../id";
|
|
3
|
+
import { ModelTypePattern, PropsOf } from "../model";
|
|
4
4
|
import { Message, MessageContext, MessageMetadata } from "./message";
|
|
5
|
-
import { PropsOf } from "./model";
|
|
6
|
-
import { ModelTypePattern } from "./model-type";
|
|
7
5
|
export type EventSource = Readonly<{
|
|
8
6
|
type: ModelTypePattern;
|
|
9
7
|
id: Id;
|
|
@@ -0,0 +1,19 @@
|
|
|
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("./command"), exports);
|
|
18
|
+
__exportStar(require("./event"), exports);
|
|
19
|
+
__exportStar(require("./message"), exports);
|
|
@@ -5,8 +5,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.Message = void 0;
|
|
7
7
|
const lodash_1 = __importDefault(require("lodash"));
|
|
8
|
-
const
|
|
9
|
-
class Message extends
|
|
8
|
+
const model_1 = require("../model");
|
|
9
|
+
class Message extends model_1.ModelWithId {
|
|
10
10
|
constructor(metadata, props) {
|
|
11
11
|
var _a;
|
|
12
12
|
super(props);
|
package/dist/core/metadata.d.ts
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import "reflect-metadata";
|
|
2
2
|
import { CommandHandler, EventApplier } from "./aggregate";
|
|
3
|
-
import { AnyCommand } from "./command";
|
|
4
|
-
import { AnyEvent } from "./event";
|
|
5
|
-
import { ModelTypePattern } from "./model-type";
|
|
6
3
|
import { IdGenerator } from "./id";
|
|
4
|
+
import { ModelTypePattern } from "./model";
|
|
5
|
+
import { AnyCommand, AnyEvent } from "./message";
|
|
7
6
|
export declare const MODEL_TYPE = "MODEL_TYPE";
|
|
8
7
|
export declare const defineModelType: (target: object, type: ModelTypePattern) => void;
|
|
9
8
|
export declare const getModelType: (target: object) => ModelTypePattern;
|
|
@@ -0,0 +1,19 @@
|
|
|
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("./model"), exports);
|
|
18
|
+
__exportStar(require("./model-type"), exports);
|
|
19
|
+
__exportStar(require("./model-with-id"), exports);
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { Class } from "
|
|
2
|
-
import { ClassStatic } from "../types/class-static";
|
|
1
|
+
import { Class, ClassStatic } from "../../types/index";
|
|
3
2
|
export declare const seperator: "#";
|
|
4
3
|
export type ModelTypePattern<Prefix extends string = string> = `${Prefix}${typeof seperator}${string}`;
|
|
5
4
|
export declare const ModelTypePatternRegex: RegExp;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ModelWithId = void 0;
|
|
4
|
-
const id_1 = require("
|
|
5
|
-
const metadata_1 = require("
|
|
4
|
+
const id_1 = require("../id");
|
|
5
|
+
const metadata_1 = require("../metadata");
|
|
6
6
|
const model_1 = require("./model");
|
|
7
7
|
class ModelWithId extends model_1.Model {
|
|
8
8
|
static getIdGenerator() {
|
|
@@ -5,7 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.Model = void 0;
|
|
7
7
|
const lodash_1 = __importDefault(require("lodash"));
|
|
8
|
-
const metadata_1 = require("
|
|
8
|
+
const metadata_1 = require("../metadata");
|
|
9
9
|
class Model {
|
|
10
10
|
constructor(props) {
|
|
11
11
|
if (props)
|
package/dist/core/registry.d.ts
CHANGED
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
import { AggregateClass, AggregateESClass, CommandHandler, EventApplier } from "../core/
|
|
2
|
-
import { AnyCommand, CommandClass } from "../core/command";
|
|
3
|
-
import { AnyEvent, EventClass } from "../core/event";
|
|
1
|
+
import { AggregateClass, AggregateESClass, AnyCommand, AnyEvent, CommandClass, CommandHandler, EventApplier, EventClass } from "../core/index";
|
|
4
2
|
export declare const aggregate: (name?: string) => <T extends AggregateClass | AggregateESClass>(target: T) => void;
|
|
5
3
|
export declare const applyEvent: <T extends AnyEvent>(eventClass: EventClass<T>) => <U extends EventApplier<T>>(target: object, propertyKey: string, descriptor: TypedPropertyDescriptor<U>) => void;
|
|
6
4
|
export declare const handleCommand: <T extends AnyCommand>(commandClass: CommandClass<T>) => <U extends CommandHandler<T>>(target: object, propertyKey: string, descriptor: TypedPropertyDescriptor<U>) => void;
|
|
@@ -1,19 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.handleCommand = exports.applyEvent = exports.aggregate = void 0;
|
|
4
|
-
const
|
|
5
|
-
const model_type_1 = require("../core/model-type");
|
|
4
|
+
const _core_1 = require("../core/index");
|
|
6
5
|
const model_1 = require("./model");
|
|
7
6
|
const aggregate = (name) => (target) => {
|
|
8
|
-
const aggregateType = new
|
|
7
|
+
const aggregateType = new _core_1.AggregateType(name !== null && name !== void 0 ? name : target.name);
|
|
9
8
|
(0, model_1.model)(aggregateType.value)(target);
|
|
10
9
|
};
|
|
11
10
|
exports.aggregate = aggregate;
|
|
12
11
|
const applyEvent = (eventClass) => {
|
|
13
12
|
return (target, propertyKey, descriptor) => {
|
|
14
13
|
if (typeof descriptor.value === "function") {
|
|
15
|
-
const type = (0,
|
|
16
|
-
(0,
|
|
14
|
+
const type = (0, _core_1.getModelType)(eventClass.prototype);
|
|
15
|
+
(0, _core_1.defineEventApplier)(target, type, descriptor.value);
|
|
17
16
|
}
|
|
18
17
|
};
|
|
19
18
|
};
|
|
@@ -21,8 +20,8 @@ exports.applyEvent = applyEvent;
|
|
|
21
20
|
const handleCommand = (commandClass) => {
|
|
22
21
|
return (target, propertyKey, descriptor) => {
|
|
23
22
|
if (typeof descriptor.value === "function") {
|
|
24
|
-
const type = (0,
|
|
25
|
-
(0,
|
|
23
|
+
const type = (0, _core_1.getModelType)(commandClass.prototype);
|
|
24
|
+
(0, _core_1.defineCommandHandler)(target, type, descriptor.value);
|
|
26
25
|
}
|
|
27
26
|
};
|
|
28
27
|
};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { CommandClass } from "../core/
|
|
1
|
+
import { CommandClass } from "../core/index";
|
|
2
2
|
export declare const command: (name?: string) => <T extends CommandClass>(target: T) => void;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.command = void 0;
|
|
4
|
-
const
|
|
4
|
+
const _core_1 = require("../core/index");
|
|
5
5
|
const model_1 = require("./model");
|
|
6
6
|
const command = (name) => (target) => {
|
|
7
|
-
const commandType = new
|
|
7
|
+
const commandType = new _core_1.CommandType(name !== null && name !== void 0 ? name : target.name);
|
|
8
8
|
(0, model_1.model)(commandType.value)(target);
|
|
9
9
|
};
|
|
10
10
|
exports.command = command;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { EntityClass } from "../core/
|
|
1
|
+
import { EntityClass } from "../core/index";
|
|
2
2
|
export declare const entity: (name?: string) => <T extends EntityClass>(target: T) => void;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.entity = void 0;
|
|
4
|
-
const
|
|
4
|
+
const _core_1 = require("../core/index");
|
|
5
5
|
const model_1 = require("./model");
|
|
6
6
|
const entity = (name) => (target) => {
|
|
7
|
-
const entityType = new
|
|
7
|
+
const entityType = new _core_1.EntityType(name !== null && name !== void 0 ? name : target.name);
|
|
8
8
|
(0, model_1.model)(entityType.value)(target);
|
|
9
9
|
};
|
|
10
10
|
exports.entity = entity;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { EventClass } from "../core/
|
|
1
|
+
import { EventClass } from "../core/index";
|
|
2
2
|
export declare const event: (name?: string) => <T extends EventClass>(target: T) => void;
|
package/dist/decorators/event.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.event = void 0;
|
|
4
|
-
const
|
|
4
|
+
const _core_1 = require("../core/index");
|
|
5
5
|
const model_1 = require("./model");
|
|
6
6
|
const event = (name) => (target) => {
|
|
7
|
-
const eventType = new
|
|
7
|
+
const eventType = new _core_1.EventType(name !== null && name !== void 0 ? name : target.name);
|
|
8
8
|
(0, model_1.model)(eventType.value)(target);
|
|
9
9
|
};
|
|
10
10
|
exports.event = event;
|
package/dist/decorators/id.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { IdGenerator } from "../core/
|
|
1
|
+
import { IdGenerator } from "../core/index";
|
|
2
2
|
export declare const id: <T extends IdGenerator>(idGenerator: T) => (target: object) => void;
|
package/dist/decorators/id.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.id = void 0;
|
|
4
|
-
const
|
|
4
|
+
const _core_1 = require("../core/index");
|
|
5
5
|
const id = (idGenerator) => {
|
|
6
6
|
return (target) => {
|
|
7
7
|
console.log("Target", target);
|
|
8
|
-
(0,
|
|
8
|
+
(0, _core_1.defineIdGenerator)(target, idGenerator);
|
|
9
9
|
};
|
|
10
10
|
};
|
|
11
11
|
exports.id = id;
|
package/dist/decorators/model.js
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.model = void 0;
|
|
4
|
-
const
|
|
5
|
-
const registry_1 = require("../core/registry");
|
|
4
|
+
const _core_1 = require("../core/index");
|
|
6
5
|
const model = (type) => {
|
|
7
6
|
return (target) => {
|
|
8
|
-
|
|
9
|
-
(0,
|
|
7
|
+
_core_1.ModelRegistry.instance().registerModel(type, target);
|
|
8
|
+
(0, _core_1.defineModelType)(target.prototype, type);
|
|
10
9
|
};
|
|
11
10
|
};
|
|
12
11
|
exports.model = model;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { ValueObjectClass } from "../core/
|
|
1
|
+
import { ValueObjectClass } from "../core/index";
|
|
2
2
|
export declare const valueObject: (name?: string) => <T extends ValueObjectClass>(target: T) => void;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.valueObject = void 0;
|
|
4
|
-
const
|
|
4
|
+
const _core_1 = require("../core/index");
|
|
5
5
|
const model_1 = require("./model");
|
|
6
6
|
const valueObject = (name) => (target) => {
|
|
7
|
-
const valueObjectType = new
|
|
7
|
+
const valueObjectType = new _core_1.ValueObjectType(name !== null && name !== void 0 ? name : target.name);
|
|
8
8
|
(0, model_1.model)(valueObjectType.value)(target);
|
|
9
9
|
};
|
|
10
10
|
exports.valueObject = valueObject;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ddd-node",
|
|
3
|
-
"version": "9.1
|
|
3
|
+
"version": "9.2.1",
|
|
4
4
|
"description": "Domain Driven Design base for NodeJs",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -29,6 +29,7 @@
|
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
31
|
"lodash": "^4.17.21",
|
|
32
|
+
"nodejs-snowflake": "^2.0.1",
|
|
32
33
|
"reflect-metadata": "^0.1.13",
|
|
33
34
|
"tsc-alias": "^1.8.8",
|
|
34
35
|
"uuid": "^9.0.1"
|
package/tsconfig.json
CHANGED
|
@@ -30,10 +30,10 @@
|
|
|
30
30
|
// "moduleResolution": "node10", /* Specify how TypeScript looks up a file from a given module specifier. */
|
|
31
31
|
"baseUrl": "./" /* Specify the base directory to resolve non-relative module names. */,
|
|
32
32
|
"paths": {
|
|
33
|
-
"#core
|
|
34
|
-
"#decorators
|
|
35
|
-
"#utils
|
|
36
|
-
"#types
|
|
33
|
+
"#core": ["src/core/index"],
|
|
34
|
+
"#decorators": ["src/dedcorators/index"],
|
|
35
|
+
"#utils": ["src/utils/index"],
|
|
36
|
+
"#types": ["src/types/index"]
|
|
37
37
|
} /* Specify a set of entries that re-map imports to additional lookup locations. */,
|
|
38
38
|
// "rootDirs": [], /* Allow multiple folders to be treated as one when resolving modules. */
|
|
39
39
|
// "typeRoots": [], /* Specify multiple folders that act like './node_modules/@types'. */
|
package/dist/core/id.d.ts
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
export declare class Id {
|
|
2
|
-
private _value;
|
|
3
|
-
constructor(value: string);
|
|
4
|
-
get value(): string;
|
|
5
|
-
equals(id: Id): boolean;
|
|
6
|
-
}
|
|
7
|
-
export declare abstract class IdGenerator {
|
|
8
|
-
abstract generateValue(): string;
|
|
9
|
-
abstract validateValue(value: string): void;
|
|
10
|
-
fromValue(value: string): Id;
|
|
11
|
-
fromId(id: Id): Id;
|
|
12
|
-
newId(): Id;
|
|
13
|
-
}
|
|
14
|
-
export declare class Uuid4Generator extends IdGenerator {
|
|
15
|
-
generateValue(): string;
|
|
16
|
-
validateValue(value: string): boolean;
|
|
17
|
-
}
|
package/dist/core/id.js
DELETED
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Uuid4Generator = exports.IdGenerator = exports.Id = void 0;
|
|
4
|
-
const uuid_1 = require("uuid");
|
|
5
|
-
class Id {
|
|
6
|
-
constructor(value) {
|
|
7
|
-
this._value = value;
|
|
8
|
-
}
|
|
9
|
-
get value() {
|
|
10
|
-
return this._value;
|
|
11
|
-
}
|
|
12
|
-
equals(id) {
|
|
13
|
-
return this._value === id._value;
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
exports.Id = Id;
|
|
17
|
-
class IdGenerator {
|
|
18
|
-
fromValue(value) {
|
|
19
|
-
this.validateValue(value);
|
|
20
|
-
return new Id(value);
|
|
21
|
-
}
|
|
22
|
-
fromId(id) {
|
|
23
|
-
return this.fromValue(id.value);
|
|
24
|
-
}
|
|
25
|
-
newId() {
|
|
26
|
-
return this.fromValue(this.generateValue());
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
exports.IdGenerator = IdGenerator;
|
|
30
|
-
class Uuid4Generator extends IdGenerator {
|
|
31
|
-
generateValue() {
|
|
32
|
-
return (0, uuid_1.v4)();
|
|
33
|
-
}
|
|
34
|
-
validateValue(value) {
|
|
35
|
-
const isUuid = (0, uuid_1.validate)(value);
|
|
36
|
-
const isV4 = (0, uuid_1.version)(value) === 4;
|
|
37
|
-
return isUuid && isV4;
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
exports.Uuid4Generator = Uuid4Generator;
|
|
File without changes
|
|
File without changes
|
|
File without changes
|