ddd-node 6.1.0 → 7.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/core/model.d.ts +4 -4
- package/dist/core/model.js +3 -2
- package/package.json +1 -1
package/dist/core/model.d.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { Class } from "../types/class";
|
|
2
2
|
export declare class Model<Props extends object> {
|
|
3
|
-
protected _props
|
|
3
|
+
protected _props: Props;
|
|
4
4
|
constructor(props?: Props);
|
|
5
|
-
static isModel(obj: object):
|
|
6
|
-
protected
|
|
5
|
+
static isModel(obj: object): obj is AnyModel;
|
|
6
|
+
protected initializeProps(props: Props): void;
|
|
7
7
|
validate(): void;
|
|
8
8
|
get type(): `${string}#${string}`;
|
|
9
|
-
props(): Props
|
|
9
|
+
props(): Props;
|
|
10
10
|
}
|
|
11
11
|
export type AnyModel = Model<object>;
|
|
12
12
|
export type PropsOf<T> = T extends Model<infer P> ? P : never;
|
package/dist/core/model.js
CHANGED
|
@@ -8,12 +8,13 @@ const lodash_1 = __importDefault(require("lodash"));
|
|
|
8
8
|
const metadata_1 = require("./metadata");
|
|
9
9
|
class Model {
|
|
10
10
|
constructor(props) {
|
|
11
|
-
|
|
11
|
+
if (props)
|
|
12
|
+
this.initializeProps(props);
|
|
12
13
|
}
|
|
13
14
|
static isModel(obj) {
|
|
14
15
|
return obj instanceof Model;
|
|
15
16
|
}
|
|
16
|
-
|
|
17
|
+
initializeProps(props) {
|
|
17
18
|
if (!this._props) {
|
|
18
19
|
this._props = props;
|
|
19
20
|
this.validate();
|