ddd-node 25.0.0 → 26.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/dist/base/decorators/index.d.ts +1 -0
- package/dist/base/decorators/index.js +1 -0
- package/dist/base/decorators/model.d.ts +2 -2
- package/dist/base/decorators/model.js +1 -1
- package/dist/base/decorators/prop.js +1 -1
- package/dist/base/decorators/props-validator.d.ts +2 -0
- package/dist/base/decorators/props-validator.js +8 -0
- package/dist/base/decorators/static.d.ts +2 -2
- package/dist/base/decorators/static.js +2 -2
- package/dist/base/meta/model-props-map.d.ts +4 -4
- package/dist/base/meta/model-props-map.js +24 -24
- package/dist/base/meta/model-props-validator.d.ts +5 -5
- package/dist/base/meta/model-props-validator.js +13 -13
- package/dist/base/meta/model-static-values.d.ts +8 -8
- package/dist/base/meta/model-static-values.js +21 -21
- package/dist/base/model/model-descriptor.d.ts +6 -6
- package/dist/base/model/model.d.ts +6 -6
- package/dist/base/model/model.js +18 -18
- package/dist/core/enum/enum-builder.js +1 -1
- package/dist/core/enum/enum.js +1 -1
- package/dist/package.json +1 -1
- package/package.json +1 -1
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { AnyModel, ModelClass } from "../model";
|
|
2
|
-
import {
|
|
2
|
+
import { ModelPropsValidator } from "../meta";
|
|
3
3
|
export type ModelOptions<T extends AnyModel = AnyModel> = {
|
|
4
4
|
name?: string;
|
|
5
5
|
version?: number;
|
|
6
6
|
domain?: string;
|
|
7
|
-
propsValidator?:
|
|
7
|
+
propsValidator?: ModelPropsValidator<T>;
|
|
8
8
|
autoRegisterModel?: boolean;
|
|
9
9
|
};
|
|
10
10
|
export declare function Model<T extends ModelClass, I extends InstanceType<T> = InstanceType<T>>(options?: ModelOptions<I>): any;
|
|
@@ -48,7 +48,7 @@ function Model(p1, p2, p3) {
|
|
|
48
48
|
domain.modelRegistry.registerModel(target);
|
|
49
49
|
}
|
|
50
50
|
if (modelOptions?.propsValidator)
|
|
51
|
-
(0, meta_1.
|
|
51
|
+
(0, meta_1.defineModelPropsValidator)(target, modelOptions.propsValidator);
|
|
52
52
|
};
|
|
53
53
|
}
|
|
54
54
|
exports.Model = Model;
|
|
@@ -4,7 +4,7 @@ exports.Prop = void 0;
|
|
|
4
4
|
const meta_1 = require("../meta");
|
|
5
5
|
const Prop = (propTargetKey) => {
|
|
6
6
|
return (target, key) => {
|
|
7
|
-
(0, meta_1.
|
|
7
|
+
(0, meta_1.defineModelProp)(target, key, propTargetKey ?? key);
|
|
8
8
|
};
|
|
9
9
|
};
|
|
10
10
|
exports.Prop = Prop;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PropsValidator = void 0;
|
|
4
|
+
const __1 = require("..");
|
|
5
|
+
const PropsValidator = (target, key, propertyDescriptor) => {
|
|
6
|
+
(0, __1.defineModelPropsValidator)(target, propertyDescriptor.value);
|
|
7
|
+
};
|
|
8
|
+
exports.PropsValidator = PropsValidator;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { ModelClass } from "../model";
|
|
2
|
-
import {
|
|
3
|
-
export declare const Static: <T extends ModelClass<import("../model").AnyModel>, I extends InstanceType<T> = InstanceType<T>>(builder:
|
|
2
|
+
import { ModelStaticValueBuilder } from "../meta";
|
|
3
|
+
export declare const Static: <T extends ModelClass<import("../model").AnyModel>, I extends InstanceType<T> = InstanceType<T>>(builder: ModelStaticValueBuilder<I>) => (target: T, key: PropertyKey) => void;
|
|
@@ -4,8 +4,8 @@ exports.Static = void 0;
|
|
|
4
4
|
const meta_1 = require("../meta");
|
|
5
5
|
const Static = (builder) => {
|
|
6
6
|
return (target, key) => {
|
|
7
|
-
(0, meta_1.
|
|
8
|
-
(0, meta_1.
|
|
7
|
+
(0, meta_1.setModelStaticValue)(target, key, builder);
|
|
8
|
+
(0, meta_1.defineModelStaticValueProperty)(target, key);
|
|
9
9
|
};
|
|
10
10
|
};
|
|
11
11
|
exports.Static = Static;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { AnyModel, PropsOf } from "../model";
|
|
2
|
-
export declare class
|
|
2
|
+
export declare class ModelPropsMap<T extends AnyModel = AnyModel> extends Map<PropertyKey, keyof PropsOf<T>> {
|
|
3
3
|
}
|
|
4
|
-
export declare const
|
|
5
|
-
export declare const
|
|
6
|
-
export declare const
|
|
4
|
+
export declare const getOwnModelPropsMap: <T extends AnyModel = AnyModel>(target: object) => ModelPropsMap<T>;
|
|
5
|
+
export declare const defineModelProp: <T extends AnyModel = AnyModel>(target: object, key: PropertyKey, propTargetKey?: keyof PropsOf<T> | undefined) => void;
|
|
6
|
+
export declare const getModelPropsMap: <T extends AnyModel = AnyModel>(target: object) => ModelPropsMap<T>;
|
|
@@ -1,45 +1,45 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.getModelPropsMap = exports.defineModelProp = exports.getOwnModelPropsMap = exports.ModelPropsMap = void 0;
|
|
4
4
|
const model_1 = require("../model");
|
|
5
|
-
const
|
|
6
|
-
class
|
|
5
|
+
const OwnModelPropsMapMetaKey = Symbol.for("OWN_MODEL_PROPS_MAP");
|
|
6
|
+
class ModelPropsMap extends Map {
|
|
7
7
|
}
|
|
8
|
-
exports.
|
|
8
|
+
exports.ModelPropsMap = ModelPropsMap;
|
|
9
9
|
// target is prototype
|
|
10
|
-
const
|
|
11
|
-
if (!Reflect.hasOwnMetadata(
|
|
12
|
-
Reflect.defineMetadata(
|
|
13
|
-
return Reflect.getOwnMetadata(
|
|
10
|
+
const getOwnModelPropsMap = (target) => {
|
|
11
|
+
if (!Reflect.hasOwnMetadata(OwnModelPropsMapMetaKey, target))
|
|
12
|
+
Reflect.defineMetadata(OwnModelPropsMapMetaKey, new ModelPropsMap(), target);
|
|
13
|
+
return Reflect.getOwnMetadata(OwnModelPropsMapMetaKey, target);
|
|
14
14
|
};
|
|
15
|
-
exports.
|
|
16
|
-
const
|
|
17
|
-
const
|
|
15
|
+
exports.getOwnModelPropsMap = getOwnModelPropsMap;
|
|
16
|
+
const defineModelProp = (target, key, propTargetKey) => {
|
|
17
|
+
const ownModelPropsMap = (0, exports.getOwnModelPropsMap)(target);
|
|
18
18
|
if (propTargetKey)
|
|
19
|
-
|
|
19
|
+
ownModelPropsMap.set(key, propTargetKey);
|
|
20
20
|
};
|
|
21
|
-
exports.
|
|
22
|
-
const
|
|
23
|
-
const
|
|
24
|
-
if (!Reflect.hasOwnMetadata(
|
|
21
|
+
exports.defineModelProp = defineModelProp;
|
|
22
|
+
const ModelPropsMapMetaKey = Symbol.for("MODEL_PROPS_MAP");
|
|
23
|
+
const getModelPropsMap = (target) => {
|
|
24
|
+
if (!Reflect.hasOwnMetadata(ModelPropsMapMetaKey, target)) {
|
|
25
25
|
const buildPropsMap = (target) => {
|
|
26
26
|
let _target = target;
|
|
27
|
-
const result = new
|
|
27
|
+
const result = new ModelPropsMap();
|
|
28
28
|
const ownPropsMapList = [];
|
|
29
29
|
do {
|
|
30
30
|
if (model_1.ModelBase.isModel(_target)) {
|
|
31
|
-
const
|
|
32
|
-
ownPropsMapList.unshift(
|
|
31
|
+
const ownModelPropsMap = (0, exports.getOwnModelPropsMap)(_target);
|
|
32
|
+
ownPropsMapList.unshift(ownModelPropsMap);
|
|
33
33
|
}
|
|
34
34
|
_target = Reflect.getPrototypeOf(_target);
|
|
35
35
|
} while (_target !== null);
|
|
36
|
-
ownPropsMapList.forEach((
|
|
37
|
-
|
|
36
|
+
ownPropsMapList.forEach((ownModelPropsMap) => {
|
|
37
|
+
ownModelPropsMap.forEach((targetPropKey, key) => result.set(key, targetPropKey));
|
|
38
38
|
});
|
|
39
39
|
return result;
|
|
40
40
|
};
|
|
41
|
-
Reflect.defineMetadata(
|
|
41
|
+
Reflect.defineMetadata(ModelPropsMapMetaKey, buildPropsMap(target), target);
|
|
42
42
|
}
|
|
43
|
-
return Reflect.getOwnMetadata(
|
|
43
|
+
return Reflect.getOwnMetadata(ModelPropsMapMetaKey, target);
|
|
44
44
|
};
|
|
45
|
-
exports.
|
|
45
|
+
exports.getModelPropsMap = getModelPropsMap;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { AnyModel, PropsOf } from "../model";
|
|
2
|
-
export type
|
|
3
|
-
export declare const
|
|
4
|
-
export declare const
|
|
5
|
-
export declare const
|
|
6
|
-
export declare const
|
|
2
|
+
export type ModelPropsValidator<T extends AnyModel = AnyModel> = (props: PropsOf<T>) => void;
|
|
3
|
+
export declare const defineModelPropsValidator: <T extends AnyModel>(target: object, validator: ModelPropsValidator<T>) => void;
|
|
4
|
+
export declare const getOwnModelPropsValidator: <T extends AnyModel>(target: object) => ModelPropsValidator<T> | undefined;
|
|
5
|
+
export declare const ModelPropsValidatorsMetaKey: unique symbol;
|
|
6
|
+
export declare const getModelPropsValidators: (target: object) => ModelPropsValidator[];
|
|
@@ -3,31 +3,31 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.
|
|
6
|
+
exports.getModelPropsValidators = exports.ModelPropsValidatorsMetaKey = exports.getOwnModelPropsValidator = exports.defineModelPropsValidator = void 0;
|
|
7
7
|
const lodash_1 = __importDefault(require("lodash"));
|
|
8
|
-
const OwnPropsValidatorMetaKey = Symbol.for("
|
|
9
|
-
const
|
|
8
|
+
const OwnPropsValidatorMetaKey = Symbol.for("OWN_MODEL_PROPS_VALIDATOR");
|
|
9
|
+
const defineModelPropsValidator = (target, validator) => {
|
|
10
10
|
Reflect.defineMetadata(OwnPropsValidatorMetaKey, validator, target);
|
|
11
11
|
};
|
|
12
|
-
exports.
|
|
13
|
-
const
|
|
12
|
+
exports.defineModelPropsValidator = defineModelPropsValidator;
|
|
13
|
+
const getOwnModelPropsValidator = (target) => {
|
|
14
14
|
return Reflect.getOwnMetadata(OwnPropsValidatorMetaKey, target);
|
|
15
15
|
};
|
|
16
|
-
exports.
|
|
17
|
-
exports.
|
|
18
|
-
const
|
|
19
|
-
if (!Reflect.hasOwnMetadata(exports.
|
|
16
|
+
exports.getOwnModelPropsValidator = getOwnModelPropsValidator;
|
|
17
|
+
exports.ModelPropsValidatorsMetaKey = Symbol.for("MODEL_PROPS_VALIDATORS");
|
|
18
|
+
const getModelPropsValidators = (target) => {
|
|
19
|
+
if (!Reflect.hasOwnMetadata(exports.ModelPropsValidatorsMetaKey, target)) {
|
|
20
20
|
let result = [];
|
|
21
21
|
let _target = target;
|
|
22
22
|
do {
|
|
23
|
-
const ownValidator = (0, exports.
|
|
23
|
+
const ownValidator = (0, exports.getOwnModelPropsValidator)(_target);
|
|
24
24
|
if (ownValidator)
|
|
25
25
|
result.push(ownValidator);
|
|
26
26
|
_target = Reflect.getPrototypeOf(_target);
|
|
27
27
|
} while (_target !== null);
|
|
28
28
|
result = lodash_1.default.uniq(result);
|
|
29
|
-
Reflect.defineMetadata(exports.
|
|
29
|
+
Reflect.defineMetadata(exports.ModelPropsValidatorsMetaKey, result, target);
|
|
30
30
|
}
|
|
31
|
-
return Reflect.getOwnMetadata(exports.
|
|
31
|
+
return Reflect.getOwnMetadata(exports.ModelPropsValidatorsMetaKey, target);
|
|
32
32
|
};
|
|
33
|
-
exports.
|
|
33
|
+
exports.getModelPropsValidators = getModelPropsValidators;
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { AnyModel, ModelClass } from "../model";
|
|
2
|
-
export type
|
|
3
|
-
export declare class
|
|
2
|
+
export type ModelStaticValueBuilder<T extends AnyModel = AnyModel> = () => T;
|
|
3
|
+
export declare class ModelStaticValue<T extends AnyModel = AnyModel> {
|
|
4
4
|
private _value;
|
|
5
|
-
constructor(value: T |
|
|
5
|
+
constructor(value: T | ModelStaticValueBuilder<T>);
|
|
6
6
|
get value(): T;
|
|
7
7
|
}
|
|
8
|
-
export declare class
|
|
8
|
+
export declare class ModelStaticValuesMap<T extends AnyModel = AnyModel> extends Map<PropertyKey, ModelStaticValue<T>> {
|
|
9
9
|
}
|
|
10
|
-
export declare const
|
|
11
|
-
export declare const
|
|
12
|
-
export declare const
|
|
13
|
-
export declare const
|
|
10
|
+
export declare const getOwnModelStaticValues: <T extends AnyModel>(target: object) => ModelStaticValuesMap<T>;
|
|
11
|
+
export declare const setModelStaticValue: <T extends AnyModel>(target: object, key: PropertyKey, value: T | ModelStaticValueBuilder<T>) => void;
|
|
12
|
+
export declare const getModelStaticValue: (target: object, key: PropertyKey) => AnyModel | undefined;
|
|
13
|
+
export declare const defineModelStaticValueProperty: (target: ModelClass, key: PropertyKey) => void;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
class
|
|
3
|
+
exports.defineModelStaticValueProperty = exports.getModelStaticValue = exports.setModelStaticValue = exports.getOwnModelStaticValues = exports.ModelStaticValuesMap = exports.ModelStaticValue = void 0;
|
|
4
|
+
class ModelStaticValue {
|
|
5
5
|
constructor(value) {
|
|
6
6
|
this._value = value;
|
|
7
7
|
}
|
|
@@ -12,43 +12,43 @@ class StaticValue {
|
|
|
12
12
|
return this._value;
|
|
13
13
|
}
|
|
14
14
|
}
|
|
15
|
-
exports.
|
|
16
|
-
const
|
|
17
|
-
class
|
|
15
|
+
exports.ModelStaticValue = ModelStaticValue;
|
|
16
|
+
const OwnModelStaticValuesMetaKey = Symbol.for("OWN_MODEL_STATIC_VALUES");
|
|
17
|
+
class ModelStaticValuesMap extends Map {
|
|
18
18
|
}
|
|
19
|
-
exports.
|
|
20
|
-
const
|
|
21
|
-
if (!Reflect.hasOwnMetadata(
|
|
22
|
-
Reflect.defineMetadata(
|
|
23
|
-
return Reflect.getOwnMetadata(
|
|
19
|
+
exports.ModelStaticValuesMap = ModelStaticValuesMap;
|
|
20
|
+
const getOwnModelStaticValues = (target) => {
|
|
21
|
+
if (!Reflect.hasOwnMetadata(OwnModelStaticValuesMetaKey, target))
|
|
22
|
+
Reflect.defineMetadata(OwnModelStaticValuesMetaKey, new ModelStaticValuesMap(), target);
|
|
23
|
+
return Reflect.getOwnMetadata(OwnModelStaticValuesMetaKey, target);
|
|
24
24
|
};
|
|
25
|
-
exports.
|
|
26
|
-
const
|
|
27
|
-
const staticValues = (0, exports.
|
|
28
|
-
staticValues.set(key, new
|
|
25
|
+
exports.getOwnModelStaticValues = getOwnModelStaticValues;
|
|
26
|
+
const setModelStaticValue = (target, key, value) => {
|
|
27
|
+
const staticValues = (0, exports.getOwnModelStaticValues)(target);
|
|
28
|
+
staticValues.set(key, new ModelStaticValue(value));
|
|
29
29
|
};
|
|
30
|
-
exports.
|
|
31
|
-
const
|
|
30
|
+
exports.setModelStaticValue = setModelStaticValue;
|
|
31
|
+
const getModelStaticValue = (target, key) => {
|
|
32
32
|
let _target = target;
|
|
33
33
|
do {
|
|
34
|
-
const staticValues = (0, exports.
|
|
34
|
+
const staticValues = (0, exports.getOwnModelStaticValues)(_target);
|
|
35
35
|
if (staticValues.has(key))
|
|
36
36
|
return staticValues.get(key)?.value;
|
|
37
37
|
_target = Reflect.getPrototypeOf(_target);
|
|
38
38
|
} while (_target !== null);
|
|
39
39
|
return undefined;
|
|
40
40
|
};
|
|
41
|
-
exports.
|
|
42
|
-
const
|
|
41
|
+
exports.getModelStaticValue = getModelStaticValue;
|
|
42
|
+
const defineModelStaticValueProperty = (target, key) => {
|
|
43
43
|
Object.defineProperty(target, key, {
|
|
44
44
|
configurable: false,
|
|
45
45
|
enumerable: true,
|
|
46
46
|
get() {
|
|
47
|
-
return (0, exports.
|
|
47
|
+
return (0, exports.getModelStaticValue)(target, key);
|
|
48
48
|
},
|
|
49
49
|
set() {
|
|
50
50
|
throw new Error("Static value is readonly");
|
|
51
51
|
},
|
|
52
52
|
});
|
|
53
53
|
};
|
|
54
|
-
exports.
|
|
54
|
+
exports.defineModelStaticValueProperty = defineModelStaticValueProperty;
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { AnyModel } from "./model";
|
|
2
|
-
import { ModelId, ModelName, ModelVersion,
|
|
2
|
+
import { ModelId, ModelName, ModelVersion, ModelPropsMap, ModelPropsValidator, ModelStaticValuesMap } from "../meta";
|
|
3
3
|
export interface ModelDescriptor<T extends AnyModel = AnyModel> {
|
|
4
4
|
modelId: ModelId;
|
|
5
5
|
modelName: ModelName;
|
|
6
6
|
modelVersion: ModelVersion;
|
|
7
7
|
modelMutable: boolean;
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
8
|
+
ownModelPropsValidator?: ModelPropsValidator<T>;
|
|
9
|
+
modelPropsValidators: ModelPropsValidator[];
|
|
10
|
+
ownModelStaticValues: ModelStaticValuesMap<T>;
|
|
11
|
+
ownModelPropsMap: ModelPropsMap<T>;
|
|
12
|
+
modelPropsMap: ModelPropsMap<T>;
|
|
13
13
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { AbstractClass, Class } from "type-fest";
|
|
2
2
|
import { ClassStatic } from "../../types";
|
|
3
|
-
import { ModelId, ModelName,
|
|
3
|
+
import { ModelId, ModelName, ModelPropsMap, ModelPropsValidator, ModelStaticValuesMap, ModelVersion } from "../meta";
|
|
4
4
|
import { ModelDescriptor } from "./model-descriptor";
|
|
5
5
|
export interface Props {
|
|
6
6
|
[key: PropertyKey]: any;
|
|
@@ -16,11 +16,11 @@ export declare class ModelBase<P extends Props> {
|
|
|
16
16
|
static modelName<T extends AnyModel>(this: ModelClass<T>): ModelName;
|
|
17
17
|
static modelVersion<T extends AnyModel>(this: ModelClass<T>): ModelVersion;
|
|
18
18
|
static modelId<T extends AnyModel>(this: ModelClass<T>): ModelId;
|
|
19
|
-
static
|
|
20
|
-
static
|
|
21
|
-
static
|
|
22
|
-
static
|
|
23
|
-
static
|
|
19
|
+
static ownModelPropsValidator<T extends AnyModel>(this: ModelClass<T>): ModelPropsValidator<T> | undefined;
|
|
20
|
+
static modelPropsValidators<T extends AnyModel>(this: ModelClass<T>): ModelPropsValidator[];
|
|
21
|
+
static ownModelStaticValues<T extends AnyModel>(this: ModelClass<T>): ModelStaticValuesMap<T>;
|
|
22
|
+
static ownModelPropsMap<T extends AnyModel>(this: ModelClass<T>): ModelPropsMap<T>;
|
|
23
|
+
static modelPropsMap<T extends AnyModel>(this: ModelClass<T>): ModelPropsMap<T>;
|
|
24
24
|
constructor();
|
|
25
25
|
redefineModel(): void;
|
|
26
26
|
protected redefineProp<K extends keyof P>(key: keyof this, propTargetKey: K): void;
|
package/dist/base/model/model.js
CHANGED
|
@@ -23,27 +23,27 @@ class ModelBase {
|
|
|
23
23
|
static modelId() {
|
|
24
24
|
return (0, meta_1.getModelId)(this);
|
|
25
25
|
}
|
|
26
|
-
static
|
|
27
|
-
return (0, meta_1.
|
|
26
|
+
static ownModelPropsValidator() {
|
|
27
|
+
return (0, meta_1.getOwnModelPropsValidator)(this);
|
|
28
28
|
}
|
|
29
|
-
static
|
|
30
|
-
return (0, meta_1.
|
|
29
|
+
static modelPropsValidators() {
|
|
30
|
+
return (0, meta_1.getModelPropsValidators)(this);
|
|
31
31
|
}
|
|
32
|
-
static
|
|
33
|
-
return (0, meta_1.
|
|
32
|
+
static ownModelStaticValues() {
|
|
33
|
+
return (0, meta_1.getOwnModelStaticValues)(this);
|
|
34
34
|
}
|
|
35
|
-
static
|
|
36
|
-
return (0, meta_1.
|
|
35
|
+
static ownModelPropsMap() {
|
|
36
|
+
return (0, meta_1.getOwnModelPropsMap)(this.prototype);
|
|
37
37
|
}
|
|
38
|
-
static
|
|
39
|
-
return (0, meta_1.
|
|
38
|
+
static modelPropsMap() {
|
|
39
|
+
return (0, meta_1.getModelPropsMap)(this.prototype);
|
|
40
40
|
}
|
|
41
41
|
constructor() {
|
|
42
42
|
this._props = ModelBase.EMPTY_PROPS;
|
|
43
43
|
this.redefineModel();
|
|
44
44
|
}
|
|
45
45
|
redefineModel() {
|
|
46
|
-
this.modelDescriptor().
|
|
46
|
+
this.modelDescriptor().modelPropsMap.forEach((propTargetKey, key) => {
|
|
47
47
|
this.redefineProp(key, propTargetKey);
|
|
48
48
|
});
|
|
49
49
|
}
|
|
@@ -64,16 +64,16 @@ class ModelBase {
|
|
|
64
64
|
modelId: modelClass.modelId(),
|
|
65
65
|
modelName: modelClass.modelName(),
|
|
66
66
|
modelVersion: modelClass.modelVersion(),
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
67
|
+
ownModelPropsValidator: modelClass.ownModelPropsValidator(),
|
|
68
|
+
modelPropsValidators: modelClass.modelPropsValidators(),
|
|
69
|
+
ownModelStaticValues: modelClass.ownModelStaticValues(),
|
|
70
|
+
ownModelPropsMap: modelClass.ownModelPropsMap(),
|
|
71
|
+
modelPropsMap: modelClass.modelPropsMap(),
|
|
72
72
|
};
|
|
73
73
|
}
|
|
74
74
|
validateProps(props) {
|
|
75
|
-
const
|
|
76
|
-
|
|
75
|
+
const modelPropsValidators = this.modelDescriptor().modelPropsValidators;
|
|
76
|
+
modelPropsValidators.forEach((propsValidator) => propsValidator.call(this.constructor, props));
|
|
77
77
|
}
|
|
78
78
|
validate() {
|
|
79
79
|
this.validateProps(this._props);
|
|
@@ -16,7 +16,7 @@ class EnumBuilder extends base_1.ModelBuilder {
|
|
|
16
16
|
throw new Error("Cannot parse enum without value");
|
|
17
17
|
const { enumClass } = this;
|
|
18
18
|
let result;
|
|
19
|
-
enumClass.
|
|
19
|
+
enumClass.ownModelStaticValues().forEach((staticValue) => {
|
|
20
20
|
if (staticValue.value instanceof enumClass) {
|
|
21
21
|
const staticEnum = staticValue.value;
|
|
22
22
|
if (staticEnum.value === this._value && !result) {
|
package/dist/core/enum/enum.js
CHANGED
|
@@ -17,7 +17,7 @@ let EnumBase = class EnumBase extends base_1.ModelBase {
|
|
|
17
17
|
return new _1.EnumBuilder(this);
|
|
18
18
|
}
|
|
19
19
|
static values() {
|
|
20
|
-
return Array.from(this.
|
|
20
|
+
return Array.from(this.ownModelStaticValues().values()).map((staticValue) => staticValue.value);
|
|
21
21
|
}
|
|
22
22
|
static from(value) {
|
|
23
23
|
return this.builder().withValue(value).build();
|
package/dist/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"name":"ddd-node","version":"
|
|
1
|
+
{"name":"ddd-node","version":"26.0.0","description":"Domain Driven Design base for NodeJs","type":"commonjs","main":"index.js","types":"index.d.ts","files":["dist"],"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","ts-node":"^10.9.1","tsconfig-paths":"^4.2.0","typescript":"^5.2.2"},"dependencies":{"lodash":"^4.17.21","reflect-metadata":"^0.1.13","tsc-alias":"^1.8.8","type-fest":"^4.20.1","uuid":"^9.0.1"}}
|