@mat3ra/mode 2025.11.5-2 → 2025.11.6-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/js/model.d.ts +1 -1
- package/dist/js/model.js +6 -10
- package/package.json +1 -1
- package/src/js/model.ts +8 -14
package/dist/js/model.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ import type { ApplicationSchemaBase, BaseMethod, BaseModel, SlugifiedEntry, Slug
|
|
|
4
4
|
import { type ModelSchemaMixin } from "./generated/ModelSchemaMixin";
|
|
5
5
|
import { Method } from "./method";
|
|
6
6
|
import { MethodFactory } from "./methods/factory";
|
|
7
|
-
import type {
|
|
7
|
+
import type { MethodTreeBranch, ModelConfig, ModelTree } from "./types";
|
|
8
8
|
type Base = typeof InMemoryEntity & Constructor<ModelSchemaMixin>;
|
|
9
9
|
declare const Model_base: Base;
|
|
10
10
|
export declare class Model extends Model_base implements BaseModel {
|
package/dist/js/model.js
CHANGED
|
@@ -14,17 +14,14 @@ const tree_1 = require("./tree");
|
|
|
14
14
|
const EMPTY_BRANCH = { methods: {} };
|
|
15
15
|
class Model extends entity_1.InMemoryEntity {
|
|
16
16
|
constructor(config) {
|
|
17
|
-
const { application, ...entityConfig } = config;
|
|
17
|
+
const { application, method = method_1.Method.defaultConfig, ...entityConfig } = config;
|
|
18
18
|
super(entityConfig);
|
|
19
19
|
this._application = application;
|
|
20
20
|
this._MethodFactory = factory_1.MethodFactory;
|
|
21
|
+
if (method) {
|
|
22
|
+
this.setProp("method", method);
|
|
23
|
+
}
|
|
21
24
|
}
|
|
22
|
-
// get type(): string {
|
|
23
|
-
// return this.prop<string>("type", this.defaultType);
|
|
24
|
-
// }
|
|
25
|
-
// get subtype(): StringOrNamedSlug {
|
|
26
|
-
// return this.prop<StringOrNamedSlug>("subtype", this.defaultSubtype);
|
|
27
|
-
// }
|
|
28
25
|
setSubtype(subtype) {
|
|
29
26
|
this.setProp("subtype", subtype);
|
|
30
27
|
this.setMethod(this._MethodFactory.create(this.defaultMethodConfig));
|
|
@@ -71,14 +68,13 @@ class Model extends entity_1.InMemoryEntity {
|
|
|
71
68
|
}
|
|
72
69
|
get Method() {
|
|
73
70
|
if (!this._method) {
|
|
74
|
-
|
|
75
|
-
const config = methodOrConfig || this.defaultMethodConfig;
|
|
76
|
-
this._method = this._MethodFactory.create(config);
|
|
71
|
+
this._method = this._MethodFactory.create(this.method);
|
|
77
72
|
}
|
|
78
73
|
return this._method;
|
|
79
74
|
}
|
|
80
75
|
setMethod(method) {
|
|
81
76
|
this._method = method;
|
|
77
|
+
this.setProp("method", method.toJSON());
|
|
82
78
|
}
|
|
83
79
|
get methodsFromTree() {
|
|
84
80
|
return this.treeBranchForSubType.methods || {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mat3ra/mode",
|
|
3
|
-
"version": "2025.11.
|
|
3
|
+
"version": "2025.11.6-1",
|
|
4
4
|
"description": "MOdel and method DEfinitions",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"test": "nyc --reporter=text mocha --extension ts --recursive --bail --require ts-node/register/transpile-only \"tests/**/*.test.ts\"",
|
package/src/js/model.ts
CHANGED
|
@@ -14,7 +14,7 @@ import { type ModelSchemaMixin, modelSchemaMixin } from "./generated/ModelSchema
|
|
|
14
14
|
import { Method } from "./method";
|
|
15
15
|
import { MethodFactory } from "./methods/factory";
|
|
16
16
|
import { getTreeByApplicationNameAndVersion, MODEL_TREE, treeSlugToNamedObject } from "./tree";
|
|
17
|
-
import type {
|
|
17
|
+
import type { MethodTreeBranch, ModelConfig, ModelTree } from "./types";
|
|
18
18
|
|
|
19
19
|
const EMPTY_BRANCH: MethodTreeBranch = { methods: {} };
|
|
20
20
|
|
|
@@ -28,20 +28,15 @@ export class Model extends (InMemoryEntity as Base) implements BaseModel {
|
|
|
28
28
|
protected _method?: Method;
|
|
29
29
|
|
|
30
30
|
constructor(config: ModelConfig) {
|
|
31
|
-
const { application, ...entityConfig } = config
|
|
31
|
+
const { application, method = Method.defaultConfig, ...entityConfig } = config;
|
|
32
32
|
super(entityConfig);
|
|
33
33
|
this._application = application as ApplicationSchemaBase | undefined;
|
|
34
34
|
this._MethodFactory = MethodFactory;
|
|
35
|
+
if (method) {
|
|
36
|
+
this.setProp("method", method);
|
|
37
|
+
}
|
|
35
38
|
}
|
|
36
39
|
|
|
37
|
-
// get type(): string {
|
|
38
|
-
// return this.prop<string>("type", this.defaultType);
|
|
39
|
-
// }
|
|
40
|
-
|
|
41
|
-
// get subtype(): StringOrNamedSlug {
|
|
42
|
-
// return this.prop<StringOrNamedSlug>("subtype", this.defaultSubtype);
|
|
43
|
-
// }
|
|
44
|
-
|
|
45
40
|
setSubtype(subtype: SlugifiedEntryOrSlug): void {
|
|
46
41
|
this.setProp("subtype", subtype);
|
|
47
42
|
this.setMethod(this._MethodFactory.create(this.defaultMethodConfig));
|
|
@@ -93,15 +88,14 @@ export class Model extends (InMemoryEntity as Base) implements BaseModel {
|
|
|
93
88
|
|
|
94
89
|
get Method(): Method {
|
|
95
90
|
if (!this._method) {
|
|
96
|
-
|
|
97
|
-
const config = methodOrConfig || this.defaultMethodConfig;
|
|
98
|
-
this._method = this._MethodFactory.create(config);
|
|
91
|
+
this._method = this._MethodFactory.create(this.method);
|
|
99
92
|
}
|
|
100
93
|
return this._method;
|
|
101
94
|
}
|
|
102
95
|
|
|
103
96
|
setMethod(method: Method): void {
|
|
104
97
|
this._method = method;
|
|
98
|
+
this.setProp("method", method.toJSON());
|
|
105
99
|
}
|
|
106
100
|
|
|
107
101
|
get methodsFromTree(): Record<string, string[]> {
|
|
@@ -113,7 +107,7 @@ export class Model extends (InMemoryEntity as Base) implements BaseModel {
|
|
|
113
107
|
}
|
|
114
108
|
|
|
115
109
|
get methodSubtypes(): SlugifiedEntry[] {
|
|
116
|
-
const { type } = this.method;
|
|
110
|
+
const { type } = this.method as Method;
|
|
117
111
|
const subtypes = this.methodsFromTree[type] || [];
|
|
118
112
|
return subtypes.map((slug) => treeSlugToNamedObject(slug));
|
|
119
113
|
}
|