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
8 changes: 6 additions & 2 deletions dist/js/entity/in_memory.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ import { AnyObject } from "@mat3ra/esse/dist/js/esse/types";
import { JSONSchema } from "@mat3ra/esse/dist/js/esse/utils";
import { BaseInMemoryEntitySchema, EntityReferenceSchema } from "@mat3ra/esse/dist/js/types";
export declare enum ValidationErrorCode {
IN_MEMORY_ENTITY_DATA_INVALID = "IN_MEMORY_ENTITY_DATA_INVALID"
IN_MEMORY_ENTITY_DATA_INVALID = "IN_MEMORY_ENTITY_DATA_INVALID",
ENTITY_REFERENCE_ERROR = "ENTITY_REFERENCE_ERROR"
}
interface ErrorDetails {
error?: object | null;
Expand Down Expand Up @@ -64,7 +65,10 @@ export declare class InMemoryEntity implements BaseInMemoryEntitySchema {
* @param byIdOnly if true, return only the id
* @returns identifying data
*/
getAsEntityReference(byIdOnly?: boolean): EntityReferenceSchema;
getAsEntityReference(byIdOnly: true): {
_id: string;
};
getAsEntityReference(byIdOnly: false): Required<EntityReferenceSchema>;
/**
* @summary Pluck an entity from a collection by name.
* If no name is provided and no entity has prop isDefault, return the first entity
Expand Down
15 changes: 10 additions & 5 deletions dist/js/entity/in_memory.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ const clone_1 = require("../utils/clone");
var ValidationErrorCode;
(function (ValidationErrorCode) {
ValidationErrorCode["IN_MEMORY_ENTITY_DATA_INVALID"] = "IN_MEMORY_ENTITY_DATA_INVALID";
ValidationErrorCode["ENTITY_REFERENCE_ERROR"] = "ENTITY_REFERENCE_ERROR";
})(ValidationErrorCode || (exports.ValidationErrorCode = ValidationErrorCode = {}));
class EntityError extends Error {
constructor({ code, details }) {
Expand Down Expand Up @@ -180,12 +181,16 @@ class InMemoryEntity {
getClsName() {
return this.constructor.name;
}
/**
* @summary get small identifying payload of object
* @param byIdOnly if true, return only the id
* @returns identifying data
*/
getAsEntityReference(byIdOnly = false) {
if (!this.id) {
throw new EntityError({
code: ValidationErrorCode.ENTITY_REFERENCE_ERROR,
details: {
json: this._json,
schema: this.constructor.jsonSchema || {},
},
});
}
if (byIdOnly) {
return { _id: this.id };
}
Expand Down
15 changes: 12 additions & 3 deletions dist/js/entity/mixins/context.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,10 @@ export declare function ContextAndRenderFieldsMixin<T extends InMemoryEntityCons
isValid(): boolean;
readonly cls: string;
getClsName(): string;
getAsEntityReference(byIdOnly?: boolean): import("@mat3ra/esse/dist/js/types").EntityReferenceSchema;
getAsEntityReference(byIdOnly: true): {
_id: string;
};
getAsEntityReference(byIdOnly: false): Required<import("@mat3ra/esse/dist/js/types").EntityReferenceSchema>;
getEntityByName(entities: import("../in_memory").InMemoryEntity[], entity: string, name: string): import("../in_memory").InMemoryEntity;
id: string;
_id: string;
Expand Down Expand Up @@ -59,7 +62,10 @@ export declare function DomainContextProviderMixin<T extends InMemoryEntityConst
isValid(): boolean;
readonly cls: string;
getClsName(): string;
getAsEntityReference(byIdOnly?: boolean): import("@mat3ra/esse/dist/js/types").EntityReferenceSchema;
getAsEntityReference(byIdOnly: true): {
_id: string;
};
getAsEntityReference(byIdOnly: false): Required<import("@mat3ra/esse/dist/js/types").EntityReferenceSchema>;
getEntityByName(entities: import("../in_memory").InMemoryEntity[], entity: string, name: string): import("../in_memory").InMemoryEntity;
id: string;
_id: string;
Expand Down Expand Up @@ -92,7 +98,10 @@ export declare function ImportantSettingsProviderMixin<T extends InMemoryEntityC
isValid(): boolean;
readonly cls: string;
getClsName(): string;
getAsEntityReference(byIdOnly?: boolean): import("@mat3ra/esse/dist/js/types").EntityReferenceSchema;
getAsEntityReference(byIdOnly: true): {
_id: string;
};
getAsEntityReference(byIdOnly: false): Required<import("@mat3ra/esse/dist/js/types").EntityReferenceSchema>;
getEntityByName(entities: import("../in_memory").InMemoryEntity[], entity: string, name: string): import("../in_memory").InMemoryEntity;
id: string;
_id: string;
Expand Down
5 changes: 4 additions & 1 deletion dist/js/entity/mixins/context_runtime.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,10 @@ export declare function RuntimeContextFieldMixin<T extends InMemoryEntityConstru
isValid(): boolean;
readonly cls: string;
getClsName(): string;
getAsEntityReference(byIdOnly?: boolean): import("@mat3ra/esse/dist/js/types").EntityReferenceSchema;
getAsEntityReference(byIdOnly: true): {
_id: string;
};
getAsEntityReference(byIdOnly: false): Required<import("@mat3ra/esse/dist/js/types").EntityReferenceSchema>;
getEntityByName(entities: import("../in_memory").InMemoryEntity[], entity: string, name: string): import("../in_memory").InMemoryEntity;
id: string;
_id: string;
Expand Down
10 changes: 8 additions & 2 deletions dist/js/entity/mixins/flowchart.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,10 @@ export declare function FlowchartItemMixin<T extends InMemoryEntityConstructor>(
isValid(): boolean;
readonly cls: string;
getClsName(): string;
getAsEntityReference(byIdOnly?: boolean): import("@mat3ra/esse/dist/js/types").EntityReferenceSchema;
getAsEntityReference(byIdOnly: true): {
_id: string;
};
getAsEntityReference(byIdOnly: false): Required<import("@mat3ra/esse/dist/js/types").EntityReferenceSchema>;
getEntityByName(entities: import("../in_memory").InMemoryEntity[], entity: string, name: string): import("../in_memory").InMemoryEntity;
id: string;
_id: string;
Expand Down Expand Up @@ -55,7 +58,10 @@ export declare function FlowchartEntityMixin<T extends InMemoryEntityConstructor
isValid(): boolean;
readonly cls: string;
getClsName(): string;
getAsEntityReference(byIdOnly?: boolean): import("@mat3ra/esse/dist/js/types").EntityReferenceSchema;
getAsEntityReference(byIdOnly: true): {
_id: string;
};
getAsEntityReference(byIdOnly: false): Required<import("@mat3ra/esse/dist/js/types").EntityReferenceSchema>;
getEntityByName(entities: import("../in_memory").InMemoryEntity[], entity: string, name: string): import("../in_memory").InMemoryEntity;
id: string;
_id: string;
Expand Down
10 changes: 8 additions & 2 deletions dist/js/entity/mixins/hash.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,10 @@ export declare function HashedEntityMixin<T extends InMemoryEntityConstructor>(s
isValid(): boolean;
readonly cls: string;
getClsName(): string;
getAsEntityReference(byIdOnly?: boolean): import("@mat3ra/esse/dist/js/types").EntityReferenceSchema;
getAsEntityReference(byIdOnly: true): {
_id: string;
};
getAsEntityReference(byIdOnly: false): Required<import("@mat3ra/esse/dist/js/types").EntityReferenceSchema>;
getEntityByName(entities: import("../in_memory").InMemoryEntity[], entity: string, name: string): import("../in_memory").InMemoryEntity;
id: string;
_id: string;
Expand Down Expand Up @@ -53,7 +56,10 @@ export declare function HashedInputArrayMixin<T extends InMemoryEntityConstructo
isValid(): boolean;
readonly cls: string;
getClsName(): string;
getAsEntityReference(byIdOnly?: boolean): import("@mat3ra/esse/dist/js/types").EntityReferenceSchema;
getAsEntityReference(byIdOnly: true): {
_id: string;
};
getAsEntityReference(byIdOnly: false): Required<import("@mat3ra/esse/dist/js/types").EntityReferenceSchema>;
getEntityByName(entities: import("../in_memory").InMemoryEntity[], entity: string, name: string): import("../in_memory").InMemoryEntity;
id: string;
_id: string;
Expand Down
35 changes: 28 additions & 7 deletions dist/js/entity/mixins/props.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@ export declare function DefaultableMixin<T extends Constructor<InMemoryEntity> =
isValid(): boolean;
readonly cls: string;
getClsName(): string;
getAsEntityReference(byIdOnly?: boolean): import("@mat3ra/esse/dist/js/types").EntityReferenceSchema;
getAsEntityReference(byIdOnly: true): {
_id: string;
};
getAsEntityReference(byIdOnly: false): Required<import("@mat3ra/esse/dist/js/types").EntityReferenceSchema>;
getEntityByName(entities: InMemoryEntity[], entity: string, name: string): InMemoryEntity;
id: string;
_id: string;
Expand Down Expand Up @@ -50,7 +53,10 @@ export declare function TaggableMixin<T extends InMemoryEntityConstructor>(super
isValid(): boolean;
readonly cls: string;
getClsName(): string;
getAsEntityReference(byIdOnly?: boolean): import("@mat3ra/esse/dist/js/types").EntityReferenceSchema;
getAsEntityReference(byIdOnly: true): {
_id: string;
};
getAsEntityReference(byIdOnly: false): Required<import("@mat3ra/esse/dist/js/types").EntityReferenceSchema>;
getEntityByName(entities: InMemoryEntity[], entity: string, name: string): InMemoryEntity;
id: string;
_id: string;
Expand Down Expand Up @@ -78,7 +84,10 @@ export declare function HasScopeTrackMixin<T extends InMemoryEntityConstructor>(
isValid(): boolean;
readonly cls: string;
getClsName(): string;
getAsEntityReference(byIdOnly?: boolean): import("@mat3ra/esse/dist/js/types").EntityReferenceSchema;
getAsEntityReference(byIdOnly: true): {
_id: string;
};
getAsEntityReference(byIdOnly: false): Required<import("@mat3ra/esse/dist/js/types").EntityReferenceSchema>;
getEntityByName(entities: InMemoryEntity[], entity: string, name: string): InMemoryEntity;
id: string;
_id: string;
Expand Down Expand Up @@ -107,7 +116,10 @@ export declare function HasMetadataMixin<T extends InMemoryEntityConstructor>(su
isValid(): boolean;
readonly cls: string;
getClsName(): string;
getAsEntityReference(byIdOnly?: boolean): import("@mat3ra/esse/dist/js/types").EntityReferenceSchema;
getAsEntityReference(byIdOnly: true): {
_id: string;
};
getAsEntityReference(byIdOnly: false): Required<import("@mat3ra/esse/dist/js/types").EntityReferenceSchema>;
getEntityByName(entities: InMemoryEntity[], entity: string, name: string): InMemoryEntity;
id: string;
_id: string;
Expand Down Expand Up @@ -136,7 +148,10 @@ export declare function HasDescriptionMixin<T extends InMemoryEntityConstructor>
isValid(): boolean;
readonly cls: string;
getClsName(): string;
getAsEntityReference(byIdOnly?: boolean): import("@mat3ra/esse/dist/js/types").EntityReferenceSchema;
getAsEntityReference(byIdOnly: true): {
_id: string;
};
getAsEntityReference(byIdOnly: false): Required<import("@mat3ra/esse/dist/js/types").EntityReferenceSchema>;
getEntityByName(entities: InMemoryEntity[], entity: string, name: string): InMemoryEntity;
id: string;
_id: string;
Expand Down Expand Up @@ -165,7 +180,10 @@ export declare function NamedEntityMixin<T extends InMemoryEntityConstructor>(su
isValid(): boolean;
readonly cls: string;
getClsName(): string;
getAsEntityReference(byIdOnly?: boolean): import("@mat3ra/esse/dist/js/types").EntityReferenceSchema;
getAsEntityReference(byIdOnly: true): {
_id: string;
};
getAsEntityReference(byIdOnly: false): Required<import("@mat3ra/esse/dist/js/types").EntityReferenceSchema>;
getEntityByName(entities: InMemoryEntity[], entity: string, name: string): InMemoryEntity;
id: string;
_id: string;
Expand Down Expand Up @@ -194,7 +212,10 @@ export declare function HasConsistencyChecksMixin<T extends InMemoryEntityConstr
isValid(): boolean;
readonly cls: string;
getClsName(): string;
getAsEntityReference(byIdOnly?: boolean): import("@mat3ra/esse/dist/js/types").EntityReferenceSchema;
getAsEntityReference(byIdOnly: true): {
_id: string;
};
getAsEntityReference(byIdOnly: false): Required<import("@mat3ra/esse/dist/js/types").EntityReferenceSchema>;
getEntityByName(entities: InMemoryEntity[], entity: string, name: string): InMemoryEntity;
id: string;
_id: string;
Expand Down
5 changes: 4 additions & 1 deletion dist/js/entity/mixins/repetition.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,10 @@ export declare function HasRepetitionMixin<T extends InMemoryEntityConstructor>(
isValid(): boolean;
readonly cls: string;
getClsName(): string;
getAsEntityReference(byIdOnly?: boolean): import("@mat3ra/esse/dist/js/types").EntityReferenceSchema;
getAsEntityReference(byIdOnly: true): {
_id: string;
};
getAsEntityReference(byIdOnly: false): Required<import("@mat3ra/esse/dist/js/types").EntityReferenceSchema>;
getEntityByName(entities: import("../in_memory").InMemoryEntity[], entity: string, name: string): import("../in_memory").InMemoryEntity;
id: string;
_id: string;
Expand Down
15 changes: 12 additions & 3 deletions dist/js/entity/mixins/runtime_items.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,10 @@ export declare function RuntimeItemsMixin<T extends InMemoryEntityConstructor>(s
isValid(): boolean;
readonly cls: string;
getClsName(): string;
getAsEntityReference(byIdOnly?: boolean): import("@mat3ra/esse/dist/js/types").EntityReferenceSchema;
getAsEntityReference(byIdOnly: true): {
_id: string;
};
getAsEntityReference(byIdOnly: false): Required<import("@mat3ra/esse/dist/js/types").EntityReferenceSchema>;
getEntityByName(entities: import("../in_memory").InMemoryEntity[], entity: string, name: string): import("../in_memory").InMemoryEntity;
id: string;
_id: string;
Expand Down Expand Up @@ -103,7 +106,10 @@ export declare function RuntimeItemsUILogicMixin<T extends InMemoryEntityConstru
isValid(): boolean;
readonly cls: string;
getClsName(): string;
getAsEntityReference(byIdOnly?: boolean): import("@mat3ra/esse/dist/js/types").EntityReferenceSchema;
getAsEntityReference(byIdOnly: true): {
_id: string;
};
getAsEntityReference(byIdOnly: false): Required<import("@mat3ra/esse/dist/js/types").EntityReferenceSchema>;
getEntityByName(entities: import("../in_memory").InMemoryEntity[], entity: string, name: string): import("../in_memory").InMemoryEntity;
id: string;
_id: string;
Expand Down Expand Up @@ -133,7 +139,10 @@ export declare function RuntimeItemsUIAllowedMixin<T extends InMemoryEntityConst
isValid(): boolean;
readonly cls: string;
getClsName(): string;
getAsEntityReference(byIdOnly?: boolean): import("@mat3ra/esse/dist/js/types").EntityReferenceSchema;
getAsEntityReference(byIdOnly: true): {
_id: string;
};
getAsEntityReference(byIdOnly: false): Required<import("@mat3ra/esse/dist/js/types").EntityReferenceSchema>;
getEntityByName(entities: import("../in_memory").InMemoryEntity[], entity: string, name: string): import("../in_memory").InMemoryEntity;
id: string;
_id: string;
Expand Down
Loading
Loading