Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions dist/js/method.d.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import { InMemoryEntity } from "@mat3ra/code/dist/js/entity";
import { type HashedEntity } from "@mat3ra/code/dist/js/entity/mixins/HashedEntityMixin";
import type { Constructor } from "@mat3ra/code/dist/js/utils/types";
import type { AnyObject } from "@mat3ra/esse/dist/js/esse/types";
import type { BaseMethod, SlugifiedEntry } from "@mat3ra/esse/dist/js/types";
import { type MethodSchemaMixin } from "./generated/MethodSchemaMixin";
type Base = typeof InMemoryEntity & Constructor<MethodSchemaMixin>;
type Base = typeof InMemoryEntity & Constructor<MethodSchemaMixin> & Constructor<HashedEntity>;
interface MethodData extends Record<string, unknown> {
searchText?: string;
}
Expand All @@ -20,8 +21,8 @@ export declare class Method extends Method_base implements BaseMethod {
get searchText(): string;
setSearchText(searchText: string): void;
setData(data?: MethodData): void;
get omitInHashCalculation(): boolean;
cleanData(fieldsToExclude?: string[]): MethodData;
toJSONWithCleanData(fieldsToExclude?: string[]): BaseMethod;
getHashObject(): Record<string, unknown>;
}
export {};
15 changes: 7 additions & 8 deletions dist/js/method.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.Method = void 0;
const entity_1 = require("@mat3ra/code/dist/js/entity");
const HashedEntityMixin_1 = require("@mat3ra/code/dist/js/entity/mixins/HashedEntityMixin");
const utils_1 = require("@mat3ra/code/dist/js/utils");
const lodash_1 = __importDefault(require("lodash"));
const default_methods_1 = require("./default_methods");
const MethodSchemaMixin_1 = require("./generated/MethodSchemaMixin");
class Method extends entity_1.InMemoryEntity {
Expand Down Expand Up @@ -34,10 +31,6 @@ class Method extends entity_1.InMemoryEntity {
setData(data = {}) {
this.setProp("data", data);
}
get omitInHashCalculation() {
const data = this.data;
return !(data === null || data === void 0 ? void 0 : data.searchText) && lodash_1.default.isEmpty(lodash_1.default.omit(data, "searchText"));
}
cleanData(fieldsToExclude = []) {
const filteredData = { ...this.data };
fieldsToExclude.forEach((field) => {
Expand All @@ -49,6 +42,12 @@ class Method extends entity_1.InMemoryEntity {
const json = { ...this._json, data: this.cleanData(fieldsToExclude) };
return (0, utils_1.deepClone)(json);
}
getHashObject() {
const json = { ...this.toJSONWithCleanData() };
delete json.data;
return json;
}
}
exports.Method = Method;
(0, MethodSchemaMixin_1.methodSchemaMixin)(Method.prototype);
(0, HashedEntityMixin_1.hashedEntityMixin)(Method.prototype);
5 changes: 3 additions & 2 deletions dist/js/model.d.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import { InMemoryEntity } from "@mat3ra/code/dist/js/entity";
import { type HashedEntity } from "@mat3ra/code/dist/js/entity/mixins/HashedEntityMixin";
import type { Constructor } from "@mat3ra/code/dist/js/utils/types";
import type { AnyObject } from "@mat3ra/esse/dist/js/esse/types";
import type { AnyModelSchema, ApplicationSchema, BaseMethod, BaseModel, SlugifiedEntry, SlugifiedEntryOrSlug } from "@mat3ra/esse/dist/js/types";
import { type ModelSchemaMixin } from "./generated/ModelSchemaMixin";
import { Method } from "./method";
import { MethodFactory } from "./methods/factory";
import type { MethodTreeBranch, ModelConfig, ModelTree } from "./types";
type Base = typeof InMemoryEntity & Constructor<ModelSchemaMixin>;
type Base = typeof InMemoryEntity & Constructor<ModelSchemaMixin> & Constructor<HashedEntity>;
declare const Model_base: Base;
export declare class Model extends Model_base implements BaseModel {
protected _application?: ApplicationSchema;
Expand Down Expand Up @@ -43,6 +44,6 @@ export declare class Model extends Model_base implements BaseModel {
protected _stringToSlugifiedObject(slug: SlugifiedEntryOrSlug): SlugifiedEntry;
get isUnknown(): boolean;
protected get subtypeSlug(): string;
calculateHash(): string;
getHashObject(): Record<string, unknown>;
}
export {};
12 changes: 5 additions & 7 deletions dist/js/model.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
Object.defineProperty(exports, "__esModule", { value: true });
exports.Model = void 0;
const entity_1 = require("@mat3ra/code/dist/js/entity");
const utils_1 = require("@mat3ra/utils");
const HashedEntityMixin_1 = require("@mat3ra/code/dist/js/entity/mixins/HashedEntityMixin");
const lodash_1 = __importDefault(require("lodash"));
const default_models_1 = require("./default_models");
const ModelSchemaMixin_1 = require("./generated/ModelSchemaMixin");
Expand Down Expand Up @@ -129,14 +129,12 @@ class Model extends entity_1.InMemoryEntity {
const subtype = this.subtype;
return typeof subtype === "string" ? subtype : subtype.slug;
}
calculateHash() {
var _a;
getHashObject() {
const json = this.toJSON();
if (this.Method.omitInHashCalculation) {
(_a = json.method) === null || _a === void 0 ? true : delete _a.data;
}
return utils_1.Utils.hash.calculateHashFromObject(json);
json.method = this.Method.calculateHash();
return json;
}
}
exports.Model = Model;
(0, ModelSchemaMixin_1.modelSchemaMixin)(Model.prototype);
(0, HashedEntityMixin_1.hashedEntityMixin)(Model.prototype);
32 changes: 16 additions & 16 deletions dist/js/tree.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,47 +3,47 @@ import type { ModelTree } from "./types";
export declare const MODEL_TREE: {
dft: {
gga: {
refiners: string[];
modifiers: string[];
functionals: string[];
methods: {
pseudopotential: string[];
localorbital: string[];
pseudopotential: string[];
unknown: string[];
};
functionals: string[];
};
lda: {
refiners: string[];
modifiers: string[];
refiners: string[];
};
hybrid: {
functionals: string[];
methods: {
pseudopotential: string[];
localorbital: string[];
pseudopotential: string[];
unknown: string[];
};
functionals: string[];
};
hybrid: {
lda: {
functionals: string[];
methods: {
pseudopotential: string[];
localorbital: string[];
pseudopotential: string[];
unknown: string[];
};
functionals: string[];
modifiers: string[];
refiners: string[];
};
other: {
functionals: string[];
methods: {
pseudopotential: string[];
localorbital: string[];
pseudopotential: string[];
unknown: string[];
};
functionals: string[];
};
};
ml: {
re: {
methods: {
linear: string[];
kernel_ridge: string[];
linear: string[];
};
};
};
Expand All @@ -56,9 +56,9 @@ export declare const MODEL_TREE: {
};
}, MODEL_NAMES: {
dft: string;
lda: string;
gga: string;
hybrid: string;
lda: string;
ml: string;
re: string;
};
Expand Down
Loading
Loading