Skip to content
Merged
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
21 changes: 15 additions & 6 deletions src/lib/convertAasTypes.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import type {
import { jsonization } from '@aas-core-works/aas-core3.0-typescript';
import {
AssetAdministrationShell as CoreAssetAdministrationShell,
AssetInformation as CoreAssetInformation,
Reference as CoreReference,
} from '@aas-core-works/aas-core3.0-typescript/types';
import type {
import {
AssetAdministrationShell as ApiAssetAdministrationShell,
AssetInformation as ApiAssetInformation,
Reference as ApiReference,
} from '../generated/types.gen';
import { jsonization } from '@aas-core-works/aas-core3.0-typescript';

/**
* Convert an API AssetAdministrationShell to a Core Works AssetAdministrationShell
Expand All @@ -27,7 +27,10 @@ export function convertApiAasToCoreAas(aas: ApiAssetAdministrationShell): CoreAs
if (instanceOrError.error !== null) {
throw instanceOrError.error;
}
return instanceOrError.mustValue();
const instance = instanceOrError.mustValue();
// set the prototype
Object.setPrototypeOf(instance, CoreAssetAdministrationShell.prototype);
return instance;
}

/**
Expand Down Expand Up @@ -65,7 +68,10 @@ export function convertApiAssetInformationToCoreAssetInformation(
if (instanceOrError.error !== null) {
throw instanceOrError.error;
}
return instanceOrError.mustValue();
const instance = instanceOrError.mustValue();
// set the prototype
Object.setPrototypeOf(instance, CoreAssetInformation.prototype);
return instance;
}

/**
Expand Down Expand Up @@ -103,7 +109,10 @@ export function convertApiReferenceToCoreReference(reference: ApiReference): Cor
if (instanceOrError.error !== null) {
throw instanceOrError.error;
}
return instanceOrError.mustValue();
const instance = instanceOrError.mustValue();
// set the prototype
Object.setPrototypeOf(instance, CoreReference.prototype);
return instance;
}

/**
Expand Down