@mat3ra/mode 2025.11.5-1 → 2025.11.6-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.
@@ -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 { ModelConfig, MethodTreeBranch, ModelTree } from "./types";
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
@@ -19,12 +19,6 @@ class Model extends entity_1.InMemoryEntity {
19
19
  this._application = application;
20
20
  this._MethodFactory = factory_1.MethodFactory;
21
21
  }
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
22
  setSubtype(subtype) {
29
23
  this.setProp("subtype", subtype);
30
24
  this.setMethod(this._MethodFactory.create(this.defaultMethodConfig));
@@ -71,14 +65,13 @@ class Model extends entity_1.InMemoryEntity {
71
65
  }
72
66
  get Method() {
73
67
  if (!this._method) {
74
- const methodOrConfig = this.method;
75
- const config = methodOrConfig || this.defaultMethodConfig;
76
- this._method = this._MethodFactory.create(config);
68
+ this._method = this._MethodFactory.create(this.method || this.defaultMethodConfig);
77
69
  }
78
70
  return this._method;
79
71
  }
80
72
  setMethod(method) {
81
73
  this._method = method;
74
+ this.setProp("method", method.toJSON());
82
75
  }
83
76
  get methodsFromTree() {
84
77
  return this.treeBranchForSubType.methods || {};
@@ -117,7 +110,7 @@ class Model extends entity_1.InMemoryEntity {
117
110
  ...json,
118
111
  type: this.type,
119
112
  subtype: this.subtype,
120
- method: this.method.toJSONWithCleanData(),
113
+ method: this.Method.toJSONWithCleanData(),
121
114
  };
122
115
  }
123
116
  _stringToSlugifiedObject(slug) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mat3ra/mode",
3
- "version": "2025.11.5-1",
3
+ "version": "2025.11.6-0",
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 { ModelConfig, MethodTreeBranch, ModelTree } from "./types";
17
+ import type { MethodTreeBranch, ModelConfig, ModelTree } from "./types";
18
18
 
19
19
  const EMPTY_BRANCH: MethodTreeBranch = { methods: {} };
20
20
 
@@ -28,20 +28,12 @@ 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 as any;
31
+ const { application, ...entityConfig } = config;
32
32
  super(entityConfig);
33
33
  this._application = application as ApplicationSchemaBase | undefined;
34
34
  this._MethodFactory = MethodFactory;
35
35
  }
36
36
 
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
37
  setSubtype(subtype: SlugifiedEntryOrSlug): void {
46
38
  this.setProp("subtype", subtype);
47
39
  this.setMethod(this._MethodFactory.create(this.defaultMethodConfig));
@@ -93,15 +85,14 @@ export class Model extends (InMemoryEntity as Base) implements BaseModel {
93
85
 
94
86
  get Method(): Method {
95
87
  if (!this._method) {
96
- const methodOrConfig = this.method;
97
- const config = methodOrConfig || this.defaultMethodConfig;
98
- this._method = this._MethodFactory.create(config);
88
+ this._method = this._MethodFactory.create(this.method || this.defaultMethodConfig);
99
89
  }
100
90
  return this._method;
101
91
  }
102
92
 
103
93
  setMethod(method: Method): void {
104
94
  this._method = method;
95
+ this.setProp("method", method.toJSON());
105
96
  }
106
97
 
107
98
  get methodsFromTree(): Record<string, string[]> {
@@ -113,7 +104,7 @@ export class Model extends (InMemoryEntity as Base) implements BaseModel {
113
104
  }
114
105
 
115
106
  get methodSubtypes(): SlugifiedEntry[] {
116
- const { type } = this.method;
107
+ const { type } = this.method as Method;
117
108
  const subtypes = this.methodsFromTree[type] || [];
118
109
  return subtypes.map((slug) => treeSlugToNamedObject(slug));
119
110
  }
@@ -144,7 +135,7 @@ export class Model extends (InMemoryEntity as Base) implements BaseModel {
144
135
  ...json,
145
136
  type: this.type,
146
137
  subtype: this.subtype,
147
- method: (this.method as any).toJSONWithCleanData(),
138
+ method: this.Method.toJSONWithCleanData(),
148
139
  };
149
140
  }
150
141