Skip to content

Commit 1922da6

Browse files
authored
Merge pull request #106 from Exabyte-io/chore/SOF-7506
SOF-7506: entity types fixes
2 parents 1039be8 + 012509d commit 1922da6

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+6922
-3583
lines changed

.github/workflows/cicd.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ jobs:
6969
node-version:
7070
- 14.x
7171
- 20.x
72+
- 22.x
7273

7374
steps:
7475
- name: Checkout this repository

dist/js/constants.d.ts

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,24 @@
11
export namespace coefficients {
2-
const EV_TO_RY: number;
3-
const BOHR_TO_ANGSTROM: number;
4-
const ANGSTROM_TO_BOHR: number;
5-
const EV_A_TO_RY_BOHR: number;
2+
let EV_TO_RY: number;
3+
let BOHR_TO_ANGSTROM: number;
4+
let ANGSTROM_TO_BOHR: number;
5+
let EV_A_TO_RY_BOHR: number;
66
}
77
export namespace tolerance {
8-
const length: number;
9-
const lengthAngstrom: number;
10-
const pointsDistance: number;
8+
let length: number;
9+
let lengthAngstrom: number;
10+
let pointsDistance: number;
1111
}
1212
export namespace units {
13-
const bohr: string;
14-
const angstrom: string;
15-
const degree: string;
16-
const radian: string;
17-
const alat: string;
13+
let bohr: string;
14+
let angstrom: string;
15+
let degree: string;
16+
let radian: string;
17+
let alat: string;
1818
}
1919
export namespace ATOMIC_COORD_UNITS {
20-
const crystal: string;
21-
const cartesian: string;
20+
let crystal: string;
21+
let cartesian: string;
2222
}
2323
export const HASH_TOLERANCE: 3;
2424
declare namespace _default {

dist/js/context/mixins.d.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ export declare function MaterialContextMixin<T extends Constructor>(superclass:
1717
_material: Material;
1818
extraData?: {
1919
materialHash: string;
20-
} | undefined;
21-
isEdited?: boolean | undefined;
20+
};
21+
isEdited?: boolean;
2222
readonly isEditedIsSetToFalseOnMaterialUpdate: boolean;
2323
updateMaterialHash(): void;
2424
readonly isMaterialCreatedDefault: boolean;
@@ -46,10 +46,10 @@ export declare function MethodDataContextMixin<T extends Constructor>(superclass
4646
[x: string]: any;
4747
_methodData: any;
4848
isEdited: boolean;
49-
methodDataHash?: string | undefined;
49+
methodDataHash?: string;
5050
extraData?: {
51-
methodDataHash?: string | undefined;
52-
} | undefined;
51+
methodDataHash?: string;
52+
};
5353
_initMethodDataHash(): void;
5454
readonly methodData: any;
5555
readonly isMethodDataUpdated: boolean;

dist/js/context/mixins.js

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,13 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
33
return (mod && mod.__esModule) ? mod : { "default": mod };
44
};
55
Object.defineProperty(exports, "__esModule", { value: true });
6-
exports.JobContextMixin = exports.WorkflowContextMixin = exports.MethodDataContextMixin = exports.MaterialsContextMixin = exports.MaterialsSetContextMixin = exports.MaterialContextMixin = exports.ApplicationContextMixin = void 0;
6+
exports.ApplicationContextMixin = ApplicationContextMixin;
7+
exports.MaterialContextMixin = MaterialContextMixin;
8+
exports.MaterialsSetContextMixin = MaterialsSetContextMixin;
9+
exports.MaterialsContextMixin = MaterialsContextMixin;
10+
exports.MethodDataContextMixin = MethodDataContextMixin;
11+
exports.WorkflowContextMixin = WorkflowContextMixin;
12+
exports.JobContextMixin = JobContextMixin;
713
const crypto_js_1 = __importDefault(require("crypto-js"));
814
const utils_1 = require("../entity/set/ordered/utils");
915
function ApplicationContextMixin(superclass) {
@@ -25,7 +31,6 @@ function ApplicationContextMixin(superclass) {
2531
}
2632
};
2733
}
28-
exports.ApplicationContextMixin = ApplicationContextMixin;
2934
function MaterialContextMixin(superclass) {
3035
return class MaterialContextMixin extends superclass {
3136
constructor(...args) {
@@ -64,7 +69,6 @@ function MaterialContextMixin(superclass) {
6469
}
6570
};
6671
}
67-
exports.MaterialContextMixin = MaterialContextMixin;
6872
function MaterialsSetContextMixin(superclass) {
6973
return class MaterialsSetContextMixin extends superclass {
7074
constructor(...params) {
@@ -82,7 +86,6 @@ function MaterialsSetContextMixin(superclass) {
8286
}
8387
};
8488
}
85-
exports.MaterialsSetContextMixin = MaterialsSetContextMixin;
8689
function MaterialsContextMixin(superclass) {
8790
return class MaterialsContextMixin extends superclass {
8891
constructor(...params) {
@@ -103,7 +106,6 @@ function MaterialsContextMixin(superclass) {
103106
}
104107
};
105108
}
106-
exports.MaterialsContextMixin = MaterialsContextMixin;
107109
function MethodDataContextMixin(superclass) {
108110
return class extends superclass {
109111
constructor(...params) {
@@ -142,7 +144,6 @@ function MethodDataContextMixin(superclass) {
142144
}
143145
};
144146
}
145-
exports.MethodDataContextMixin = MethodDataContextMixin;
146147
function WorkflowContextMixin(superclass) {
147148
return class extends superclass {
148149
constructor(...params) {
@@ -156,7 +157,6 @@ function WorkflowContextMixin(superclass) {
156157
}
157158
};
158159
}
159-
exports.WorkflowContextMixin = WorkflowContextMixin;
160160
function JobContextMixin(superclass) {
161161
return class extends superclass {
162162
constructor(...params) {
@@ -170,4 +170,3 @@ function JobContextMixin(superclass) {
170170
}
171171
};
172172
}
173-
exports.JobContextMixin = JobContextMixin;

dist/js/context/registry.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
export class ContextProviderRegistryContainer {
22
_providers: any[];
3-
set providers(arg: any[]);
3+
set providers(p: any[]);
44
get providers(): any[];
55
addProvider({ name, instance }: {
66
name: any;

dist/js/entity/in_memory.d.ts

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { AnyObject } from "@mat3ra/esse/dist/js/esse/types";
22
import { JSONSchema } from "@mat3ra/esse/dist/js/esse/utils";
3-
import { EntityReferenceSchema } from "@mat3ra/esse/dist/js/types";
3+
import { BaseInMemoryEntitySchema, EntityReferenceSchema } from "@mat3ra/esse/dist/js/types";
44
export declare enum ValidationErrorCode {
55
IN_MEMORY_ENTITY_DATA_INVALID = "IN_MEMORY_ENTITY_DATA_INVALID"
66
}
@@ -17,7 +17,7 @@ export declare class EntityError extends Error {
1717
details?: ErrorDetails;
1818
});
1919
}
20-
export declare class InMemoryEntity {
20+
export declare class InMemoryEntity implements BaseInMemoryEntitySchema {
2121
static create(config: object): InMemoryEntity;
2222
static _isDeepCloneRequired: boolean;
2323
static allowJsonSchemaTypesCoercing: boolean;
@@ -56,13 +56,9 @@ export declare class InMemoryEntity {
5656
validate(): void;
5757
clean(config: AnyObject): AnyObject;
5858
isValid(): boolean;
59-
get id(): string;
60-
set id(id: string);
6159
static get cls(): string;
6260
get cls(): string;
6361
getClsName(): string;
64-
get slug(): string;
65-
get isSystemEntity(): boolean;
6662
/**
6763
* @summary get small identifying payload of object
6864
* @param byIdOnly if true, return only the id
@@ -77,6 +73,16 @@ export declare class InMemoryEntity {
7773
* @param name the name of the entity to choose
7874
*/
7975
getEntityByName(entities: InMemoryEntity[], entity: string, name: string): InMemoryEntity;
76+
get id(): string;
77+
set id(id: string);
78+
get _id(): string;
79+
set _id(id: string);
80+
get schemaVersion(): string;
81+
set schemaVersion(schemaVersion: string);
82+
get systemName(): string;
83+
set systemName(systemName: string);
84+
get slug(): string;
85+
get isSystemEntity(): boolean;
8086
}
8187
export type InMemoryEntityConstructor<T extends InMemoryEntity = InMemoryEntity> = new (...args: any[]) => T;
8288
export {};

dist/js/entity/in_memory.js

Lines changed: 49 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
1515
}) : function(o, v) {
1616
o["default"] = v;
1717
});
18-
var __importStar = (this && this.__importStar) || function (mod) {
19-
if (mod && mod.__esModule) return mod;
20-
var result = {};
21-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22-
__setModuleDefault(result, mod);
23-
return result;
24-
};
18+
var __importStar = (this && this.__importStar) || (function () {
19+
var ownKeys = function(o) {
20+
ownKeys = Object.getOwnPropertyNames || function (o) {
21+
var ar = [];
22+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23+
return ar;
24+
};
25+
return ownKeys(o);
26+
};
27+
return function (mod) {
28+
if (mod && mod.__esModule) return mod;
29+
var result = {};
30+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31+
__setModuleDefault(result, mod);
32+
return result;
33+
};
34+
})();
2535
var __importDefault = (this && this.__importDefault) || function (mod) {
2636
return (mod && mod.__esModule) ? mod : { "default": mod };
2737
};
@@ -35,7 +45,7 @@ const clone_1 = require("../utils/clone");
3545
var ValidationErrorCode;
3646
(function (ValidationErrorCode) {
3747
ValidationErrorCode["IN_MEMORY_ENTITY_DATA_INVALID"] = "IN_MEMORY_ENTITY_DATA_INVALID";
38-
})(ValidationErrorCode = exports.ValidationErrorCode || (exports.ValidationErrorCode = {}));
48+
})(ValidationErrorCode || (exports.ValidationErrorCode = ValidationErrorCode = {}));
3949
class EntityError extends Error {
4050
constructor({ code, details }) {
4151
super(code);
@@ -160,12 +170,6 @@ class InMemoryEntity {
160170
return false;
161171
}
162172
}
163-
get id() {
164-
return this.prop("_id", "");
165-
}
166-
set id(id) {
167-
this.setProp("_id", id);
168-
}
169173
static get cls() {
170174
return this.prototype.constructor.name;
171175
}
@@ -176,12 +180,6 @@ class InMemoryEntity {
176180
getClsName() {
177181
return this.constructor.name;
178182
}
179-
get slug() {
180-
return this.prop("slug", "");
181-
}
182-
get isSystemEntity() {
183-
return Boolean(this.prop("systemName", ""));
184-
}
185183
/**
186184
* @summary get small identifying payload of object
187185
* @param byIdOnly if true, return only the id
@@ -220,6 +218,37 @@ class InMemoryEntity {
220218
}
221219
return filtered[0];
222220
}
221+
// Properties from BaseInMemoryEntitySchema
222+
get id() {
223+
return this.prop("_id", "");
224+
}
225+
set id(id) {
226+
this.setProp("_id", id);
227+
}
228+
get _id() {
229+
return this.prop("_id", "");
230+
}
231+
set _id(id) {
232+
this.setProp("_id", id);
233+
}
234+
get schemaVersion() {
235+
return this.prop("schemaVersion", "");
236+
}
237+
set schemaVersion(schemaVersion) {
238+
this.setProp("schemaVersion", schemaVersion);
239+
}
240+
get systemName() {
241+
return this.prop("systemName", "");
242+
}
243+
set systemName(systemName) {
244+
this.setProp("systemName", systemName);
245+
}
246+
get slug() {
247+
return this.prop("slug", "");
248+
}
249+
get isSystemEntity() {
250+
return Boolean(this.systemName);
251+
}
223252
}
224253
exports.InMemoryEntity = InMemoryEntity;
225254
// Override if deepClone of config is required

dist/js/entity/index.js

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
1515
}) : function(o, v) {
1616
o["default"] = v;
1717
});
18-
var __importStar = (this && this.__importStar) || function (mod) {
19-
if (mod && mod.__esModule) return mod;
20-
var result = {};
21-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22-
__setModuleDefault(result, mod);
23-
return result;
24-
};
18+
var __importStar = (this && this.__importStar) || (function () {
19+
var ownKeys = function(o) {
20+
ownKeys = Object.getOwnPropertyNames || function (o) {
21+
var ar = [];
22+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23+
return ar;
24+
};
25+
return ownKeys(o);
26+
};
27+
return function (mod) {
28+
if (mod && mod.__esModule) return mod;
29+
var result = {};
30+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31+
__setModuleDefault(result, mod);
32+
return result;
33+
};
34+
})();
2535
Object.defineProperty(exports, "__esModule", { value: true });
2636
exports.FlowchartItemMixin = exports.FlowchartEntityMixin = exports.ContextAndRenderFieldsMixin = exports.OrderedInMemoryEntityInSetMixin = exports.OrderedInMemoryEntitySetMixin = exports.InMemoryEntityInSetMixin = exports.InMemoryEntitySetMixin = exports.selectorsForEntitySet = exports.constructEntitySetFactoryByConfig = exports.ENTITY_SET_TYPES = exports.InMemoryEntitySet = exports.HashedInputArrayMixin = exports.RuntimeContextFieldMixin = exports.RuntimeItemsMixin = exports.NamedEntityMixin = exports.HasScopeTrackMixin = exports.TaggableMixin = exports.HasMetadataMixin = exports.HasDescriptionMixin = exports.DefaultableMixin = exports.HasConsistencyChecksMixin = exports.HasConsistencyChecksHasMetadataNamedDefaultableInMemoryEntity = exports.NamedDefaultableRepetitionRuntimeItemsImportantSettingsContextAndRenderHashedInMemoryEntity = exports.NamedDefaultableRepetitionImportantSettingsInMemoryEntity = exports.NamedDefaultableRepetitionContextAndRenderInMemoryEntity = exports.HasMetadataNamedDefaultableInMemoryEntity = exports.NamedDefaultableInMemoryEntity = exports.DefaultableInMemoryEntity = exports.NamedInMemoryEntity = exports.InMemoryEntity = void 0;
2737
const in_memory_1 = require("./in_memory");

0 commit comments

Comments
 (0)