Merge branch 'feature/typescript_backend' into feature/typescript_backend_2

This commit is contained in:
Elian Doran
2024-03-30 10:54:06 +02:00
34 changed files with 2239 additions and 5736 deletions

View File

@@ -18,6 +18,10 @@ interface ContentOpts {
forceFrontendReload?: boolean;
}
/**
* This interface contains the data that is shared across all the objects of a given derived class of {@link AbstractBeccaEntity}.
* For example, all BAttributes will share their content, but all BBranches will have another set of this data.
*/
interface ConstructorData<T extends AbstractBeccaEntity<T>> {
primaryKeyName: string;
entityName: string;
@@ -26,18 +30,20 @@ interface ConstructorData<T extends AbstractBeccaEntity<T>> {
/**
* Base class for all backend entities.
*
* @type T the same entity type needed for self-reference in {@link ConstructorData}.
*/
abstract class AbstractBeccaEntity<T extends AbstractBeccaEntity<T>> {
protected utcDateModified?: string;
protected dateCreated?: string;
protected dateModified?: string;
protected isSynced?: boolean;
protected blobId?: string;
utcDateCreated!: string;
isProtected?: boolean;
isSynced?: boolean;
blobId?: string;
protected beforeSaving() {
const constructorData = (this.constructor as unknown as ConstructorData<T>);
@@ -46,7 +52,7 @@ abstract class AbstractBeccaEntity<T extends AbstractBeccaEntity<T>> {
}
}
protected getUtcDateChanged() {
getUtcDateChanged() {
return this.utcDateModified || this.utcDateCreated;
}
@@ -70,7 +76,7 @@ abstract class AbstractBeccaEntity<T extends AbstractBeccaEntity<T>> {
});
}
protected generateHash(isDeleted: boolean): string {
generateHash(isDeleted?: boolean): string {
const constructorData = (this.constructor as unknown as ConstructorData<T>);
let contentToHash = "";