ddd-node 24.6.0 → 24.7.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/model/model.d.ts +3 -3
- package/dist/base/model/model.js +1 -1
- package/dist/core/message/command/command.builder.js +1 -1
- package/dist/core/repository/repository.d.ts +1 -1
- package/dist/core/value-object/value-object.d.ts +2 -1
- package/dist/core/value-object/value-object.js +4 -1
- package/dist/package.json +1 -1
- package/package.json +1 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { AbstractClass, Class } from "type-fest";
|
|
2
|
-
import { ModelId, ModelName, ModelVersion, PropsMap, PropsValidator, StaticValuesMap } from "../meta";
|
|
3
2
|
import { ClassStatic } from "../../types";
|
|
3
|
+
import { ModelId, ModelName, ModelVersion, PropsMap, PropsValidator, StaticValuesMap } from "../meta";
|
|
4
4
|
import { ModelDescriptor } from "./model-descriptor";
|
|
5
5
|
export interface Props {
|
|
6
6
|
[key: PropertyKey]: any;
|
|
@@ -23,7 +23,7 @@ export declare class ModelBase<P extends Props> {
|
|
|
23
23
|
static propsMap<T extends AnyModel>(this: ModelClass<T>): PropsMap<T>;
|
|
24
24
|
constructor();
|
|
25
25
|
redefineModel(): void;
|
|
26
|
-
protected redefineProp(key: keyof this, propTargetKey:
|
|
26
|
+
protected redefineProp<K extends keyof P>(key: keyof this, propTargetKey: K): void;
|
|
27
27
|
modelDescriptor(): ModelDescriptor<typeof this>;
|
|
28
28
|
validateProps(props: P): void;
|
|
29
29
|
validate(): void;
|
|
@@ -33,7 +33,7 @@ export declare class ModelBase<P extends Props> {
|
|
|
33
33
|
protected initializeProps(props: P): void;
|
|
34
34
|
}
|
|
35
35
|
export type AnyModel = ModelBase<Props>;
|
|
36
|
-
export type PropsOf<T extends AnyModel> = T extends ModelBase<infer P
|
|
36
|
+
export type PropsOf<T extends AnyModel> = T extends ModelBase<infer P> ? P : never;
|
|
37
37
|
export interface ModelClass<T extends AnyModel = AnyModel> extends Class<T>, ClassStatic<typeof ModelBase<PropsOf<T>>> {
|
|
38
38
|
}
|
|
39
39
|
export interface AbstractModelClass<T extends AnyModel = AnyModel> extends AbstractClass<T>, ClassStatic<typeof ModelBase<PropsOf<T>>> {
|
package/dist/base/model/model.js
CHANGED
|
@@ -73,7 +73,7 @@ class ModelBase {
|
|
|
73
73
|
}
|
|
74
74
|
validateProps(props) {
|
|
75
75
|
const propsValidators = this.modelDescriptor().propsValidators;
|
|
76
|
-
propsValidators.forEach((propsValidator) => propsValidator(props));
|
|
76
|
+
propsValidators.forEach((propsValidator) => propsValidator.call(this.constructor, props));
|
|
77
77
|
}
|
|
78
78
|
validate() {
|
|
79
79
|
this.validateProps(this._props);
|
|
@@ -6,8 +6,9 @@ export declare class ValueObjectBase<P extends Props> extends ModelBase<P> {
|
|
|
6
6
|
props(): P;
|
|
7
7
|
equals<V extends AnyValueObject>(vo: V): boolean;
|
|
8
8
|
with(props: Partial<P>): typeof this;
|
|
9
|
+
clone(): this;
|
|
9
10
|
getEqualityValue(): string;
|
|
10
|
-
getEqualityObject(): any;
|
|
11
|
+
protected getEqualityObject(): any;
|
|
11
12
|
}
|
|
12
13
|
export type AnyValueObject = ValueObjectBase<Props>;
|
|
13
14
|
export interface ValueObjectClass<T extends AnyValueObject = AnyValueObject> extends Class<T>, ClassStatic<typeof ValueObjectBase<PropsOf<T>>> {
|
|
@@ -33,6 +33,9 @@ let ValueObjectBase = ValueObjectBase_1 = class ValueObjectBase extends base_1.M
|
|
|
33
33
|
const newProps = lodash_1.default.merge(this.props(), props);
|
|
34
34
|
return new this.constructor(newProps);
|
|
35
35
|
}
|
|
36
|
+
clone() {
|
|
37
|
+
return this.with({});
|
|
38
|
+
}
|
|
36
39
|
getEqualityValue() {
|
|
37
40
|
return JSON.stringify(this.getEqualityObject());
|
|
38
41
|
}
|
|
@@ -43,8 +46,8 @@ let ValueObjectBase = ValueObjectBase_1 = class ValueObjectBase extends base_1.M
|
|
|
43
46
|
for (let [key, value] of Object.entries(props)) {
|
|
44
47
|
if (Array.isArray(value)) {
|
|
45
48
|
result[key] = value.map((v) => valueOf(v));
|
|
49
|
+
const stringValueOf = (v) => JSON.stringify(v);
|
|
46
50
|
result[key].sort((a, b) => {
|
|
47
|
-
const stringValueOf = (v) => JSON.stringify(v);
|
|
48
51
|
return stringValueOf(a).localeCompare(stringValueOf(b));
|
|
49
52
|
});
|
|
50
53
|
continue;
|
package/dist/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"name":"ddd-node","version":"24.
|
|
1
|
+
{"name":"ddd-node","version":"24.7.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"}}
|