Skip to content

Commit 2cf3ebc

Browse files
committed
chore: entity types fixes
1 parent 1039be8 commit 2cf3ebc

23 files changed

+6483
-3054
lines changed

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: 31 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -160,12 +160,6 @@ class InMemoryEntity {
160160
return false;
161161
}
162162
}
163-
get id() {
164-
return this.prop("_id", "");
165-
}
166-
set id(id) {
167-
this.setProp("_id", id);
168-
}
169163
static get cls() {
170164
return this.prototype.constructor.name;
171165
}
@@ -176,12 +170,6 @@ class InMemoryEntity {
176170
getClsName() {
177171
return this.constructor.name;
178172
}
179-
get slug() {
180-
return this.prop("slug", "");
181-
}
182-
get isSystemEntity() {
183-
return Boolean(this.prop("systemName", ""));
184-
}
185173
/**
186174
* @summary get small identifying payload of object
187175
* @param byIdOnly if true, return only the id
@@ -220,6 +208,37 @@ class InMemoryEntity {
220208
}
221209
return filtered[0];
222210
}
211+
// Properties from BaseInMemoryEntitySchema
212+
get id() {
213+
return this.prop("_id", "");
214+
}
215+
set id(id) {
216+
this.setProp("_id", id);
217+
}
218+
get _id() {
219+
return this.prop("_id", "");
220+
}
221+
set _id(id) {
222+
this.setProp("_id", id);
223+
}
224+
get schemaVersion() {
225+
return this.prop("schemaVersion", "");
226+
}
227+
set schemaVersion(schemaVersion) {
228+
this.setProp("schemaVersion", schemaVersion);
229+
}
230+
get systemName() {
231+
return this.prop("systemName", "");
232+
}
233+
set systemName(systemName) {
234+
this.setProp("systemName", systemName);
235+
}
236+
get slug() {
237+
return this.prop("slug", "");
238+
}
239+
get isSystemEntity() {
240+
return Boolean(this.systemName);
241+
}
223242
}
224243
exports.InMemoryEntity = InMemoryEntity;
225244
// Override if deepClone of config is required

dist/js/entity/mixins/context.d.ts

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,16 @@ export declare function ContextAndRenderFieldsMixin<T extends InMemoryEntityCons
2525
validate(): void;
2626
clean(config: AnyObject): AnyObject;
2727
isValid(): boolean;
28-
id: string;
2928
readonly cls: string;
3029
getClsName(): string;
31-
readonly slug: string;
32-
readonly isSystemEntity: boolean;
3330
getAsEntityReference(byIdOnly?: boolean): import("@mat3ra/esse/dist/js/types").EntityReferenceSchema;
3431
getEntityByName(entities: import("../in_memory").InMemoryEntity[], entity: string, name: string): import("../in_memory").InMemoryEntity;
32+
id: string;
33+
_id: string;
34+
schemaVersion: string;
35+
systemName: string;
36+
readonly slug: string;
37+
readonly isSystemEntity: boolean;
3538
};
3639
} & T;
3740
export interface ContextProvider {
@@ -54,13 +57,16 @@ export declare function DomainContextProviderMixin<T extends InMemoryEntityConst
5457
validate(): void;
5558
clean(config: AnyObject): AnyObject;
5659
isValid(): boolean;
57-
id: string;
5860
readonly cls: string;
5961
getClsName(): string;
60-
readonly slug: string;
61-
readonly isSystemEntity: boolean;
6262
getAsEntityReference(byIdOnly?: boolean): import("@mat3ra/esse/dist/js/types").EntityReferenceSchema;
6363
getEntityByName(entities: import("../in_memory").InMemoryEntity[], entity: string, name: string): import("../in_memory").InMemoryEntity;
64+
id: string;
65+
_id: string;
66+
schemaVersion: string;
67+
systemName: string;
68+
readonly slug: string;
69+
readonly isSystemEntity: boolean;
6470
};
6571
} & T;
6672
export declare function ImportantSettingsProviderMixin<T extends InMemoryEntityConstructor>(superclass: T): {
@@ -84,12 +90,15 @@ export declare function ImportantSettingsProviderMixin<T extends InMemoryEntityC
8490
validate(): void;
8591
clean(config: AnyObject): AnyObject;
8692
isValid(): boolean;
87-
id: string;
8893
readonly cls: string;
8994
getClsName(): string;
90-
readonly slug: string;
91-
readonly isSystemEntity: boolean;
9295
getAsEntityReference(byIdOnly?: boolean): import("@mat3ra/esse/dist/js/types").EntityReferenceSchema;
9396
getEntityByName(entities: import("../in_memory").InMemoryEntity[], entity: string, name: string): import("../in_memory").InMemoryEntity;
97+
id: string;
98+
_id: string;
99+
schemaVersion: string;
100+
systemName: string;
101+
readonly slug: string;
102+
readonly isSystemEntity: boolean;
94103
};
95104
} & T;

dist/js/entity/mixins/context_runtime.d.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,16 @@ export declare function RuntimeContextFieldMixin<T extends InMemoryEntityConstru
2121
validate(): void;
2222
clean(config: import("@mat3ra/esse/dist/js/esse/types").AnyObject): import("@mat3ra/esse/dist/js/esse/types").AnyObject;
2323
isValid(): boolean;
24-
id: string;
2524
readonly cls: string;
2625
getClsName(): string;
27-
readonly slug: string;
28-
readonly isSystemEntity: boolean;
2926
getAsEntityReference(byIdOnly?: boolean): import("@mat3ra/esse/dist/js/types").EntityReferenceSchema;
3027
getEntityByName(entities: import("../in_memory").InMemoryEntity[], entity: string, name: string): import("../in_memory").InMemoryEntity;
28+
id: string;
29+
_id: string;
30+
schemaVersion: string;
31+
systemName: string;
32+
readonly slug: string;
33+
readonly isSystemEntity: boolean;
3134
};
3235
} & T;
3336
export {};

dist/js/entity/mixins/flowchart.d.ts

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,16 @@ export declare function FlowchartItemMixin<T extends InMemoryEntityConstructor>(
1818
validate(): void;
1919
clean(config: import("@mat3ra/esse/dist/js/esse/types").AnyObject): import("@mat3ra/esse/dist/js/esse/types").AnyObject;
2020
isValid(): boolean;
21-
id: string;
2221
readonly cls: string;
2322
getClsName(): string;
24-
readonly slug: string;
25-
readonly isSystemEntity: boolean;
2623
getAsEntityReference(byIdOnly?: boolean): import("@mat3ra/esse/dist/js/types").EntityReferenceSchema;
2724
getEntityByName(entities: import("../in_memory").InMemoryEntity[], entity: string, name: string): import("../in_memory").InMemoryEntity;
25+
id: string;
26+
_id: string;
27+
schemaVersion: string;
28+
systemName: string;
29+
readonly slug: string;
30+
readonly isSystemEntity: boolean;
2831
};
2932
} & T;
3033
export declare function FlowchartEntityMixin<T extends InMemoryEntityConstructor>(superclass: T): {
@@ -50,12 +53,15 @@ export declare function FlowchartEntityMixin<T extends InMemoryEntityConstructor
5053
validate(): void;
5154
clean(config: import("@mat3ra/esse/dist/js/esse/types").AnyObject): import("@mat3ra/esse/dist/js/esse/types").AnyObject;
5255
isValid(): boolean;
53-
id: string;
5456
readonly cls: string;
5557
getClsName(): string;
56-
readonly slug: string;
57-
readonly isSystemEntity: boolean;
5858
getAsEntityReference(byIdOnly?: boolean): import("@mat3ra/esse/dist/js/types").EntityReferenceSchema;
5959
getEntityByName(entities: import("../in_memory").InMemoryEntity[], entity: string, name: string): import("../in_memory").InMemoryEntity;
60+
id: string;
61+
_id: string;
62+
schemaVersion: string;
63+
systemName: string;
64+
readonly slug: string;
65+
readonly isSystemEntity: boolean;
6066
};
6167
} & T;

dist/js/entity/mixins/hash.d.ts

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,16 @@ export declare function HashedEntityMixin<T extends InMemoryEntityConstructor>(s
2222
validate(): void;
2323
clean(config: import("@mat3ra/esse/dist/js/esse/types").AnyObject): import("@mat3ra/esse/dist/js/esse/types").AnyObject;
2424
isValid(): boolean;
25-
id: string;
2625
readonly cls: string;
2726
getClsName(): string;
28-
readonly slug: string;
29-
readonly isSystemEntity: boolean;
3027
getAsEntityReference(byIdOnly?: boolean): import("@mat3ra/esse/dist/js/types").EntityReferenceSchema;
3128
getEntityByName(entities: import("../in_memory").InMemoryEntity[], entity: string, name: string): import("../in_memory").InMemoryEntity;
29+
id: string;
30+
_id: string;
31+
schemaVersion: string;
32+
systemName: string;
33+
readonly slug: string;
34+
readonly isSystemEntity: boolean;
3235
};
3336
} & T;
3437
export declare function HashedInputArrayMixin<T extends InMemoryEntityConstructor>(superclass: T): {
@@ -48,12 +51,15 @@ export declare function HashedInputArrayMixin<T extends InMemoryEntityConstructo
4851
validate(): void;
4952
clean(config: import("@mat3ra/esse/dist/js/esse/types").AnyObject): import("@mat3ra/esse/dist/js/esse/types").AnyObject;
5053
isValid(): boolean;
51-
id: string;
5254
readonly cls: string;
5355
getClsName(): string;
54-
readonly slug: string;
55-
readonly isSystemEntity: boolean;
5656
getAsEntityReference(byIdOnly?: boolean): import("@mat3ra/esse/dist/js/types").EntityReferenceSchema;
5757
getEntityByName(entities: import("../in_memory").InMemoryEntity[], entity: string, name: string): import("../in_memory").InMemoryEntity;
58+
id: string;
59+
_id: string;
60+
schemaVersion: string;
61+
systemName: string;
62+
readonly slug: string;
63+
readonly isSystemEntity: boolean;
5864
};
5965
} & T;

0 commit comments

Comments
 (0)