@mat3ra/mode 2026.5.29-0 → 2026.6.3-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.
@@ -1,9 +1,10 @@
1
1
  import { InMemoryEntity } from "@mat3ra/code/dist/js/entity";
2
+ import { type HashedEntity } from "@mat3ra/code/dist/js/entity/mixins/HashedEntityMixin";
2
3
  import type { Constructor } from "@mat3ra/code/dist/js/utils/types";
3
4
  import type { AnyObject } from "@mat3ra/esse/dist/js/esse/types";
4
5
  import type { BaseMethod, SlugifiedEntry } from "@mat3ra/esse/dist/js/types";
5
6
  import { type MethodSchemaMixin } from "./generated/MethodSchemaMixin";
6
- type Base = typeof InMemoryEntity & Constructor<MethodSchemaMixin>;
7
+ type Base = typeof InMemoryEntity & Constructor<MethodSchemaMixin> & Constructor<HashedEntity>;
7
8
  interface MethodData extends Record<string, unknown> {
8
9
  searchText?: string;
9
10
  }
@@ -20,8 +21,8 @@ export declare class Method extends Method_base implements BaseMethod {
20
21
  get searchText(): string;
21
22
  setSearchText(searchText: string): void;
22
23
  setData(data?: MethodData): void;
23
- get omitInHashCalculation(): boolean;
24
24
  cleanData(fieldsToExclude?: string[]): MethodData;
25
25
  toJSONWithCleanData(fieldsToExclude?: string[]): BaseMethod;
26
+ getHashObject(): Record<string, unknown>;
26
27
  }
27
28
  export {};
package/dist/js/method.js CHANGED
@@ -1,12 +1,9 @@
1
1
  "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
2
  Object.defineProperty(exports, "__esModule", { value: true });
6
3
  exports.Method = void 0;
7
4
  const entity_1 = require("@mat3ra/code/dist/js/entity");
5
+ const HashedEntityMixin_1 = require("@mat3ra/code/dist/js/entity/mixins/HashedEntityMixin");
8
6
  const utils_1 = require("@mat3ra/code/dist/js/utils");
9
- const lodash_1 = __importDefault(require("lodash"));
10
7
  const default_methods_1 = require("./default_methods");
11
8
  const MethodSchemaMixin_1 = require("./generated/MethodSchemaMixin");
12
9
  class Method extends entity_1.InMemoryEntity {
@@ -34,10 +31,6 @@ class Method extends entity_1.InMemoryEntity {
34
31
  setData(data = {}) {
35
32
  this.setProp("data", data);
36
33
  }
37
- get omitInHashCalculation() {
38
- const data = this.data;
39
- return !(data === null || data === void 0 ? void 0 : data.searchText) && lodash_1.default.isEmpty(lodash_1.default.omit(data, "searchText"));
40
- }
41
34
  cleanData(fieldsToExclude = []) {
42
35
  const filteredData = { ...this.data };
43
36
  fieldsToExclude.forEach((field) => {
@@ -49,6 +42,12 @@ class Method extends entity_1.InMemoryEntity {
49
42
  const json = { ...this._json, data: this.cleanData(fieldsToExclude) };
50
43
  return (0, utils_1.deepClone)(json);
51
44
  }
45
+ getHashObject() {
46
+ const json = { ...this.toJSONWithCleanData() };
47
+ delete json.data;
48
+ return json;
49
+ }
52
50
  }
53
51
  exports.Method = Method;
54
52
  (0, MethodSchemaMixin_1.methodSchemaMixin)(Method.prototype);
53
+ (0, HashedEntityMixin_1.hashedEntityMixin)(Method.prototype);
@@ -1,4 +1,5 @@
1
1
  import { InMemoryEntity } from "@mat3ra/code/dist/js/entity";
2
+ import { type HashedEntity } from "@mat3ra/code/dist/js/entity/mixins/HashedEntityMixin";
2
3
  import type { Constructor } from "@mat3ra/code/dist/js/utils/types";
3
4
  import type { AnyObject } from "@mat3ra/esse/dist/js/esse/types";
4
5
  import type { AnyModelSchema, ApplicationSchema, BaseMethod, BaseModel, SlugifiedEntry, SlugifiedEntryOrSlug } from "@mat3ra/esse/dist/js/types";
@@ -6,7 +7,7 @@ import { type ModelSchemaMixin } from "./generated/ModelSchemaMixin";
6
7
  import { Method } from "./method";
7
8
  import { MethodFactory } from "./methods/factory";
8
9
  import type { MethodTreeBranch, ModelConfig, ModelTree } from "./types";
9
- type Base = typeof InMemoryEntity & Constructor<ModelSchemaMixin>;
10
+ type Base = typeof InMemoryEntity & Constructor<ModelSchemaMixin> & Constructor<HashedEntity>;
10
11
  declare const Model_base: Base;
11
12
  export declare class Model extends Model_base implements BaseModel {
12
13
  protected _application?: ApplicationSchema;
@@ -43,6 +44,6 @@ export declare class Model extends Model_base implements BaseModel {
43
44
  protected _stringToSlugifiedObject(slug: SlugifiedEntryOrSlug): SlugifiedEntry;
44
45
  get isUnknown(): boolean;
45
46
  protected get subtypeSlug(): string;
46
- calculateHash(): string;
47
+ getHashObject(): Record<string, unknown>;
47
48
  }
48
49
  export {};
package/dist/js/model.js CHANGED
@@ -5,7 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.Model = void 0;
7
7
  const entity_1 = require("@mat3ra/code/dist/js/entity");
8
- const utils_1 = require("@mat3ra/utils");
8
+ const HashedEntityMixin_1 = require("@mat3ra/code/dist/js/entity/mixins/HashedEntityMixin");
9
9
  const lodash_1 = __importDefault(require("lodash"));
10
10
  const default_models_1 = require("./default_models");
11
11
  const ModelSchemaMixin_1 = require("./generated/ModelSchemaMixin");
@@ -129,14 +129,12 @@ class Model extends entity_1.InMemoryEntity {
129
129
  const subtype = this.subtype;
130
130
  return typeof subtype === "string" ? subtype : subtype.slug;
131
131
  }
132
- calculateHash() {
133
- var _a;
132
+ getHashObject() {
134
133
  const json = this.toJSON();
135
- if (this.Method.omitInHashCalculation) {
136
- (_a = json.method) === null || _a === void 0 ? true : delete _a.data;
137
- }
138
- return utils_1.Utils.hash.calculateHashFromObject(json);
134
+ json.method = this.Method.calculateHash();
135
+ return json;
139
136
  }
140
137
  }
141
138
  exports.Model = Model;
142
139
  (0, ModelSchemaMixin_1.modelSchemaMixin)(Model.prototype);
140
+ (0, HashedEntityMixin_1.hashedEntityMixin)(Model.prototype);
package/dist/js/tree.d.ts CHANGED
@@ -3,47 +3,47 @@ import type { ModelTree } from "./types";
3
3
  export declare const MODEL_TREE: {
4
4
  dft: {
5
5
  gga: {
6
- refiners: string[];
7
- modifiers: string[];
6
+ functionals: string[];
8
7
  methods: {
9
- pseudopotential: string[];
10
8
  localorbital: string[];
9
+ pseudopotential: string[];
11
10
  unknown: string[];
12
11
  };
13
- functionals: string[];
14
- };
15
- lda: {
16
- refiners: string[];
17
12
  modifiers: string[];
13
+ refiners: string[];
14
+ };
15
+ hybrid: {
16
+ functionals: string[];
18
17
  methods: {
19
- pseudopotential: string[];
20
18
  localorbital: string[];
19
+ pseudopotential: string[];
21
20
  unknown: string[];
22
21
  };
23
- functionals: string[];
24
22
  };
25
- hybrid: {
23
+ lda: {
24
+ functionals: string[];
26
25
  methods: {
27
- pseudopotential: string[];
28
26
  localorbital: string[];
27
+ pseudopotential: string[];
29
28
  unknown: string[];
30
29
  };
31
- functionals: string[];
30
+ modifiers: string[];
31
+ refiners: string[];
32
32
  };
33
33
  other: {
34
+ functionals: string[];
34
35
  methods: {
35
- pseudopotential: string[];
36
36
  localorbital: string[];
37
+ pseudopotential: string[];
37
38
  unknown: string[];
38
39
  };
39
- functionals: string[];
40
40
  };
41
41
  };
42
42
  ml: {
43
43
  re: {
44
44
  methods: {
45
- linear: string[];
46
45
  kernel_ridge: string[];
46
+ linear: string[];
47
47
  };
48
48
  };
49
49
  };
@@ -56,9 +56,9 @@ export declare const MODEL_TREE: {
56
56
  };
57
57
  }, MODEL_NAMES: {
58
58
  dft: string;
59
- lda: string;
60
59
  gga: string;
61
60
  hybrid: string;
61
+ lda: string;
62
62
  ml: string;
63
63
  re: string;
64
64
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mat3ra/mode",
3
- "version": "2026.5.29-0",
3
+ "version": "2026.6.3-0",
4
4
  "description": "MOdel and method DEfinitions",
5
5
  "scripts": {
6
6
  "test": "nyc --reporter=text mocha --recursive --bail",
@@ -57,7 +57,7 @@
57
57
  "@mat3ra/code": "2026.5.27-0",
58
58
  "@mat3ra/esse": "2026.5.27-0",
59
59
  "@mat3ra/prode": "2026.5.28-0",
60
- "@mat3ra/standata": "2025.11.12-0",
60
+ "@mat3ra/standata": "2026.5.28-0",
61
61
  "@mat3ra/tsconfig": "2024.6.3-0",
62
62
  "@types/chai": "^4.3.11",
63
63
  "@types/mocha": "^10.0.6",
package/src/js/method.ts CHANGED
@@ -1,14 +1,17 @@
1
1
  import { InMemoryEntity } from "@mat3ra/code/dist/js/entity";
2
+ import {
3
+ type HashedEntity,
4
+ hashedEntityMixin,
5
+ } from "@mat3ra/code/dist/js/entity/mixins/HashedEntityMixin";
2
6
  import { deepClone } from "@mat3ra/code/dist/js/utils";
3
7
  import type { Constructor } from "@mat3ra/code/dist/js/utils/types";
4
8
  import type { AnyObject } from "@mat3ra/esse/dist/js/esse/types";
5
9
  import type { BaseMethod, SlugifiedEntry } from "@mat3ra/esse/dist/js/types";
6
- import lodash from "lodash";
7
10
 
8
11
  import { PseudopotentialMethodConfig } from "./default_methods";
9
12
  import { type MethodSchemaMixin, methodSchemaMixin } from "./generated/MethodSchemaMixin";
10
13
 
11
- type Base = typeof InMemoryEntity & Constructor<MethodSchemaMixin>;
14
+ type Base = typeof InMemoryEntity & Constructor<MethodSchemaMixin> & Constructor<HashedEntity>;
12
15
 
13
16
  interface MethodData extends Record<string, unknown> {
14
17
  searchText?: string;
@@ -48,11 +51,6 @@ export class Method extends (InMemoryEntity as Base) implements BaseMethod {
48
51
  this.setProp("data", data);
49
52
  }
50
53
 
51
- get omitInHashCalculation(): boolean {
52
- const data = this.data as MethodData;
53
- return !data?.searchText && lodash.isEmpty(lodash.omit(data, "searchText"));
54
- }
55
-
56
54
  cleanData(fieldsToExclude: string[] = []): MethodData {
57
55
  const filteredData = { ...(this.data as MethodData) };
58
56
  fieldsToExclude.forEach((field) => {
@@ -65,6 +63,13 @@ export class Method extends (InMemoryEntity as Base) implements BaseMethod {
65
63
  const json = { ...this._json, data: this.cleanData(fieldsToExclude) };
66
64
  return deepClone(json);
67
65
  }
66
+
67
+ getHashObject(): Record<string, unknown> {
68
+ const json = { ...this.toJSONWithCleanData() } as Record<string, unknown>;
69
+ delete json.data;
70
+ return json;
71
+ }
68
72
  }
69
73
 
70
74
  methodSchemaMixin(Method.prototype);
75
+ hashedEntityMixin(Method.prototype);
package/src/js/model.ts CHANGED
@@ -1,4 +1,8 @@
1
1
  import { InMemoryEntity } from "@mat3ra/code/dist/js/entity";
2
+ import {
3
+ type HashedEntity,
4
+ hashedEntityMixin,
5
+ } from "@mat3ra/code/dist/js/entity/mixins/HashedEntityMixin";
2
6
  import type { Constructor } from "@mat3ra/code/dist/js/utils/types";
3
7
  import type { AnyObject } from "@mat3ra/esse/dist/js/esse/types";
4
8
  import type {
@@ -9,7 +13,6 @@ import type {
9
13
  SlugifiedEntry,
10
14
  SlugifiedEntryOrSlug,
11
15
  } from "@mat3ra/esse/dist/js/types";
12
- import { Utils } from "@mat3ra/utils";
13
16
  import lodash from "lodash";
14
17
 
15
18
  import { DFTModelConfig } from "./default_models";
@@ -21,7 +24,7 @@ import type { MethodTreeBranch, ModelConfig, ModelTree } from "./types";
21
24
 
22
25
  const EMPTY_BRANCH: MethodTreeBranch = { methods: {} };
23
26
 
24
- type Base = typeof InMemoryEntity & Constructor<ModelSchemaMixin>;
27
+ type Base = typeof InMemoryEntity & Constructor<ModelSchemaMixin> & Constructor<HashedEntity>;
25
28
 
26
29
  export class Model extends (InMemoryEntity as Base) implements BaseModel {
27
30
  protected _application?: ApplicationSchema;
@@ -162,15 +165,12 @@ export class Model extends (InMemoryEntity as Base) implements BaseModel {
162
165
  return typeof subtype === "string" ? subtype : subtype.slug;
163
166
  }
164
167
 
165
- calculateHash(): string {
166
- const json = this.toJSON() as Record<string, unknown> & {
167
- method?: { data?: unknown };
168
- };
169
- if (this.Method.omitInHashCalculation) {
170
- delete json.method?.data;
171
- }
172
- return Utils.hash.calculateHashFromObject(json as Record<string, unknown>);
168
+ getHashObject(): Record<string, unknown> {
169
+ const json = this.toJSON() as Record<string, unknown>;
170
+ json.method = this.Method.calculateHash();
171
+ return json;
173
172
  }
174
173
  }
175
174
 
176
175
  modelSchemaMixin(Model.prototype);
176
+ hashedEntityMixin(Model.prototype);