@mat3ra/mode 2025.12.2-0 → 2026.3.4-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.
@@ -34,5 +34,6 @@ export declare class Model extends Model_base implements BaseModel {
34
34
  protected _stringToSlugifiedObject(slug: SlugifiedEntryOrSlug): SlugifiedEntry;
35
35
  get isUnknown(): boolean;
36
36
  protected get subtypeSlug(): string;
37
+ calculateHash(): string;
37
38
  }
38
39
  export {};
package/dist/js/model.js CHANGED
@@ -5,6 +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
9
  const lodash_1 = __importDefault(require("lodash"));
9
10
  const default_models_1 = require("./default_models");
10
11
  const ModelSchemaMixin_1 = require("./generated/ModelSchemaMixin");
@@ -116,6 +117,7 @@ class Model extends entity_1.InMemoryEntity {
116
117
  method: this.Method.toJSONWithCleanData(),
117
118
  };
118
119
  }
120
+ // eslint-disable-next-line class-methods-use-this
119
121
  _stringToSlugifiedObject(slug) {
120
122
  if (lodash_1.default.isString(slug)) {
121
123
  return { slug };
@@ -129,6 +131,14 @@ class Model extends entity_1.InMemoryEntity {
129
131
  const subtype = this.subtype;
130
132
  return typeof subtype === "string" ? subtype : subtype.slug;
131
133
  }
134
+ calculateHash() {
135
+ var _a;
136
+ const json = this.toJSON();
137
+ if (this.Method.omitInHashCalculation) {
138
+ (_a = json.method) === null || _a === void 0 ? true : delete _a.data;
139
+ }
140
+ return utils_1.Utils.hash.calculateHashFromObject(json);
141
+ }
132
142
  }
133
143
  exports.Model = Model;
134
144
  (0, ModelSchemaMixin_1.modelSchemaMixin)(Model.prototype);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mat3ra/mode",
3
- "version": "2025.12.2-0",
3
+ "version": "2026.3.4-0",
4
4
  "description": "MOdel and method DEfinitions",
5
5
  "scripts": {
6
6
  "test": "nyc --reporter=text mocha --recursive --bail",
@@ -31,6 +31,7 @@
31
31
  "license": "Apache-2.0",
32
32
  "homepage": "https://github.com/Exabyte-io/mode",
33
33
  "dependencies": {
34
+ "@mat3ra/utils": "^2026.3.2-0",
34
35
  "@babel/cli": "7.16.0",
35
36
  "@babel/core": "7.16.0",
36
37
  "@babel/eslint-parser": "7.16.3",
package/src/js/model.ts CHANGED
@@ -7,6 +7,7 @@ import type {
7
7
  SlugifiedEntry,
8
8
  SlugifiedEntryOrSlug,
9
9
  } from "@mat3ra/esse/dist/js/types";
10
+ import { Utils } from "@mat3ra/utils";
10
11
  import lodash from "lodash";
11
12
 
12
13
  import { DFTModelConfig } from "./default_models";
@@ -142,6 +143,7 @@ export class Model extends (InMemoryEntity as Base) implements BaseModel {
142
143
  };
143
144
  }
144
145
 
146
+ // eslint-disable-next-line class-methods-use-this
145
147
  protected _stringToSlugifiedObject(slug: SlugifiedEntryOrSlug): SlugifiedEntry {
146
148
  if (lodash.isString(slug)) {
147
149
  return { slug } as SlugifiedEntry;
@@ -157,6 +159,16 @@ export class Model extends (InMemoryEntity as Base) implements BaseModel {
157
159
  const subtype = this.subtype as SlugifiedEntryOrSlug;
158
160
  return typeof subtype === "string" ? subtype : subtype.slug;
159
161
  }
162
+
163
+ calculateHash(): string {
164
+ const json = this.toJSON() as Record<string, unknown> & {
165
+ method?: { data?: unknown };
166
+ };
167
+ if (this.Method.omitInHashCalculation) {
168
+ delete json.method?.data;
169
+ }
170
+ return Utils.hash.calculateHashFromObject(json as Record<string, unknown>);
171
+ }
160
172
  }
161
173
 
162
174
  modelSchemaMixin(Model.prototype);