basyx-typescript-sdk 0.2.2 → 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -3
- package/bundle/index.js +17534 -857
- package/bundle/index.js.map +1 -1
- package/dist/clients/AasDiscoveryClient.d.ts +67 -0
- package/dist/clients/AasDiscoveryClient.js +115 -0
- package/dist/clients/AasRegistryClient.d.ts +163 -0
- package/dist/clients/AasRegistryClient.js +287 -0
- package/dist/clients/AasRepositoryClient.d.ts +790 -103
- package/dist/clients/AasRepositoryClient.js +1323 -215
- package/dist/clients/AasxFileClient.d.ts +81 -0
- package/dist/clients/AasxFileClient.js +148 -0
- package/dist/clients/ConceptDescriptionRepositoryClient.d.ts +83 -0
- package/dist/clients/ConceptDescriptionRepositoryClient.js +143 -0
- package/dist/clients/SubmodelRegistryClient.d.ts +77 -0
- package/dist/clients/SubmodelRegistryClient.js +138 -0
- package/dist/clients/SubmodelRepositoryClient.d.ts +354 -0
- package/dist/clients/SubmodelRepositoryClient.js +585 -0
- package/dist/clients/index.d.ts +6 -0
- package/dist/clients/index.js +6 -0
- package/dist/generated/AasDiscoveryService/apis/AssetAdministrationShellBasicDiscoveryAPIApi.d.ts +80 -0
- package/dist/generated/AasDiscoveryService/apis/AssetAdministrationShellBasicDiscoveryAPIApi.js +156 -0
- package/dist/generated/AasDiscoveryService/apis/DescriptionAPIApi.d.ts +26 -0
- package/dist/generated/AasDiscoveryService/apis/DescriptionAPIApi.js +40 -0
- package/dist/generated/AasDiscoveryService/apis/index.d.ts +2 -0
- package/dist/generated/AasDiscoveryService/apis/index.js +4 -0
- package/dist/generated/AasDiscoveryService/index.d.ts +3 -0
- package/dist/generated/AasDiscoveryService/index.js +5 -0
- package/dist/generated/AasDiscoveryService/models/index.d.ts +297 -0
- package/dist/generated/AasDiscoveryService/models/index.js +48 -0
- package/dist/generated/AasDiscoveryService/runtime.d.ts +181 -0
- package/dist/generated/AasDiscoveryService/runtime.js +326 -0
- package/dist/generated/AasRegistryService/apis/AssetAdministrationShellRegistryAPIApi.d.ts +139 -0
- package/dist/generated/AasRegistryService/apis/AssetAdministrationShellRegistryAPIApi.js +312 -0
- package/dist/generated/AasRegistryService/apis/DescriptionAPIApi.d.ts +26 -0
- package/dist/generated/AasRegistryService/apis/DescriptionAPIApi.js +40 -0
- package/dist/generated/AasRegistryService/apis/index.d.ts +2 -0
- package/dist/generated/AasRegistryService/apis/index.js +4 -0
- package/dist/generated/AasRegistryService/index.d.ts +3 -0
- package/dist/generated/AasRegistryService/index.js +5 -0
- package/dist/generated/AasRegistryService/models/index.d.ts +1070 -0
- package/dist/generated/AasRegistryService/models/index.js +151 -0
- package/dist/generated/AasRegistryService/runtime.d.ts +181 -0
- package/dist/generated/AasRegistryService/runtime.js +326 -0
- package/dist/generated/AasRepositoryService/apis/AssetAdministrationShellRepositoryAPIApi.d.ts +870 -0
- package/dist/generated/AasRepositoryService/apis/AssetAdministrationShellRepositoryAPIApi.js +1842 -0
- package/dist/generated/AasRepositoryService/apis/DescriptionAPIApi.d.ts +26 -0
- package/dist/generated/AasRepositoryService/apis/DescriptionAPIApi.js +40 -0
- package/dist/generated/AasRepositoryService/apis/SerializationAPIApi.d.ts +30 -0
- package/dist/generated/AasRepositoryService/apis/SerializationAPIApi.js +49 -0
- package/dist/generated/AasRepositoryService/apis/index.d.ts +3 -0
- package/dist/generated/AasRepositoryService/apis/index.js +5 -0
- package/dist/generated/AasRepositoryService/index.d.ts +3 -0
- package/dist/generated/AasRepositoryService/index.js +5 -0
- package/dist/generated/AasRepositoryService/models/index.d.ts +4585 -0
- package/dist/generated/AasRepositoryService/models/index.js +221 -0
- package/dist/generated/AasRepositoryService/runtime.d.ts +181 -0
- package/dist/generated/AasRepositoryService/runtime.js +326 -0
- package/dist/generated/AasxFileService/apis/AASXFileServerAPIApi.d.ts +78 -0
- package/dist/generated/AasxFileService/apis/AASXFileServerAPIApi.js +184 -0
- package/dist/generated/AasxFileService/apis/index.d.ts +1 -0
- package/dist/generated/AasxFileService/apis/index.js +3 -0
- package/dist/generated/AasxFileService/index.d.ts +3 -0
- package/dist/generated/AasxFileService/index.js +5 -0
- package/dist/generated/AasxFileService/models/index.d.ts +80 -0
- package/dist/generated/AasxFileService/models/index.js +10 -0
- package/dist/generated/AasxFileService/runtime.d.ts +181 -0
- package/dist/generated/AasxFileService/runtime.js +326 -0
- package/dist/generated/ConceptDescriptionRepositoryService/apis/ConceptDescriptionRepositoryAPIApi.d.ts +78 -0
- package/dist/generated/ConceptDescriptionRepositoryService/apis/ConceptDescriptionRepositoryAPIApi.js +164 -0
- package/dist/generated/ConceptDescriptionRepositoryService/apis/DescriptionAPIApi.d.ts +26 -0
- package/dist/generated/ConceptDescriptionRepositoryService/apis/DescriptionAPIApi.js +40 -0
- package/dist/generated/ConceptDescriptionRepositoryService/apis/SerializationAPIApi.d.ts +30 -0
- package/dist/generated/ConceptDescriptionRepositoryService/apis/SerializationAPIApi.js +49 -0
- package/dist/generated/ConceptDescriptionRepositoryService/apis/index.d.ts +3 -0
- package/dist/generated/ConceptDescriptionRepositoryService/apis/index.js +5 -0
- package/dist/generated/ConceptDescriptionRepositoryService/index.d.ts +3 -0
- package/dist/generated/ConceptDescriptionRepositoryService/index.js +5 -0
- package/dist/generated/ConceptDescriptionRepositoryService/models/index.d.ts +2869 -0
- package/dist/generated/ConceptDescriptionRepositoryService/models/index.js +209 -0
- package/dist/generated/ConceptDescriptionRepositoryService/runtime.d.ts +181 -0
- package/dist/generated/ConceptDescriptionRepositoryService/runtime.js +326 -0
- package/dist/generated/SubmodelRegistryService/apis/DescriptionAPIApi.d.ts +26 -0
- package/dist/generated/SubmodelRegistryService/apis/DescriptionAPIApi.js +40 -0
- package/dist/generated/SubmodelRegistryService/apis/SubmodelRegistryAPIApi.d.ts +75 -0
- package/dist/generated/SubmodelRegistryService/apis/SubmodelRegistryAPIApi.js +155 -0
- package/dist/generated/SubmodelRegistryService/apis/index.d.ts +2 -0
- package/dist/generated/SubmodelRegistryService/apis/index.js +4 -0
- package/dist/generated/SubmodelRegistryService/index.d.ts +3 -0
- package/dist/generated/SubmodelRegistryService/index.js +5 -0
- package/dist/generated/SubmodelRegistryService/models/index.d.ts +924 -0
- package/dist/generated/SubmodelRegistryService/models/index.js +141 -0
- package/dist/generated/SubmodelRegistryService/runtime.d.ts +181 -0
- package/dist/generated/SubmodelRegistryService/runtime.js +326 -0
- package/dist/generated/SubmodelRepositoryService/apis/DescriptionAPIApi.d.ts +26 -0
- package/dist/generated/SubmodelRepositoryService/apis/DescriptionAPIApi.js +40 -0
- package/dist/generated/SubmodelRepositoryService/apis/SerializationAPIApi.d.ts +30 -0
- package/dist/generated/SubmodelRepositoryService/apis/SerializationAPIApi.js +49 -0
- package/dist/generated/SubmodelRepositoryService/apis/SubmodelRepositoryAPIApi.d.ts +802 -0
- package/dist/generated/SubmodelRepositoryService/apis/SubmodelRepositoryAPIApi.js +1572 -0
- package/dist/generated/SubmodelRepositoryService/apis/index.d.ts +3 -0
- package/dist/generated/SubmodelRepositoryService/apis/index.js +5 -0
- package/dist/generated/SubmodelRepositoryService/index.d.ts +3 -0
- package/dist/generated/SubmodelRepositoryService/index.js +5 -0
- package/dist/generated/SubmodelRepositoryService/models/index.d.ts +4623 -0
- package/dist/generated/SubmodelRepositoryService/models/index.js +221 -0
- package/dist/generated/SubmodelRepositoryService/runtime.d.ts +181 -0
- package/dist/generated/SubmodelRepositoryService/runtime.js +326 -0
- package/dist/generated/index.d.ts +8 -2
- package/dist/generated/index.js +8 -3
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/lib/apiConfig.d.ts +2 -0
- package/dist/lib/apiConfig.js +41 -0
- package/dist/lib/base64Url.js +4 -0
- package/dist/lib/convertAasDescriptorTypes.d.ts +34 -0
- package/dist/lib/convertAasDescriptorTypes.js +76 -0
- package/dist/lib/convertAasDiscoveryTypes.d.ts +18 -0
- package/dist/lib/convertAasDiscoveryTypes.js +39 -0
- package/dist/lib/convertAasTypes.d.ts +7 -7
- package/dist/lib/convertAasTypes.js +5 -0
- package/dist/lib/convertConceptDescriptionTypes.d.ts +18 -0
- package/dist/lib/convertConceptDescriptionTypes.js +39 -0
- package/dist/lib/convertSubmodelTypes.d.ts +34 -0
- package/dist/lib/convertSubmodelTypes.js +69 -0
- package/dist/lib/descriptorJsonization.d.ts +12 -0
- package/dist/lib/descriptorJsonization.js +172 -0
- package/dist/lib/errorHandler.d.ts +9 -0
- package/dist/lib/errorHandler.js +113 -0
- package/dist/models/Descriptors.d.ts +51 -0
- package/dist/models/Descriptors.js +56 -0
- package/dist/models/index.d.ts +0 -1
- package/dist/models/index.js +0 -1
- package/dist/utils/DescriptorUtils.d.ts +9 -0
- package/dist/utils/DescriptorUtils.js +37 -0
- package/dist/utils/KeyTypesUtil.d.ts +24 -0
- package/dist/utils/KeyTypesUtil.js +55 -0
- package/dist/utils/MultiLanguagePropertyUtils.d.ts +24 -0
- package/dist/utils/MultiLanguagePropertyUtils.js +46 -0
- package/dist/utils/ReferableUtils.d.ts +69 -0
- package/dist/utils/ReferableUtils.js +220 -0
- package/dist/utils/ReferenceUtil.d.ts +9 -0
- package/dist/utils/ReferenceUtil.js +22 -0
- package/dist/utils/SemanticIdUtils.d.ts +119 -0
- package/dist/utils/SemanticIdUtils.js +363 -0
- package/package.json +14 -11
- package/dist/generated/schemas.gen.d.ts +0 -2357
- package/dist/generated/schemas.gen.js +0 -2789
- package/dist/generated/sdk.gen.d.ts +0 -822
- package/dist/generated/sdk.gen.js +0 -2225
- package/dist/generated/types.gen.d.ts +0 -10829
- package/dist/generated/types.gen.js +0 -2
- package/dist/lib/createAasRepoClient.d.ts +0 -9
- package/dist/lib/createAasRepoClient.js +0 -15
- package/dist/models/aas-repository.d.ts +0 -65
- package/dist/models/aas-repository.js +0 -1
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { ConceptDescription as CoreConceptDescription } from '@aas-core-works/aas-core3.0-typescript/types';
|
|
2
|
+
import { ConceptDescriptionRepositoryService } from '../generated';
|
|
3
|
+
/**
|
|
4
|
+
* Convert an API ConceptDescription to a Core Works ConceptDescription
|
|
5
|
+
*
|
|
6
|
+
* @function convertApiCDToCoreCD
|
|
7
|
+
* @param {ApiConceptDescription} aas - The API ConceptDescription to convert
|
|
8
|
+
* @returns {CoreConceptDescription} The Core Works ConceptDescription
|
|
9
|
+
*/
|
|
10
|
+
export declare function convertApiCDToCoreCD(conceptDescription: ConceptDescriptionRepositoryService.ConceptDescription): CoreConceptDescription;
|
|
11
|
+
/**
|
|
12
|
+
* Convert a Core Works ConceptDescription to an API ConceptDescription
|
|
13
|
+
*
|
|
14
|
+
* @function convertCoreCDToApiCD
|
|
15
|
+
* @param {CoreConceptDescription} aas - The Core Works ConceptDescription to convert
|
|
16
|
+
* @returns {ApiConceptDescription} The API ConceptDescription
|
|
17
|
+
*/
|
|
18
|
+
export declare function convertCoreCDToApiCD(conceptDescription: CoreConceptDescription): ConceptDescriptionRepositoryService.ConceptDescription;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { jsonization } from '@aas-core-works/aas-core3.0-typescript';
|
|
2
|
+
import { ConceptDescription as CoreConceptDescription } from '@aas-core-works/aas-core3.0-typescript/types';
|
|
3
|
+
/**
|
|
4
|
+
* Convert an API ConceptDescription to a Core Works ConceptDescription
|
|
5
|
+
*
|
|
6
|
+
* @function convertApiCDToCoreCD
|
|
7
|
+
* @param {ApiConceptDescription} aas - The API ConceptDescription to convert
|
|
8
|
+
* @returns {CoreConceptDescription} The Core Works ConceptDescription
|
|
9
|
+
*/
|
|
10
|
+
export function convertApiCDToCoreCD(conceptDescription) {
|
|
11
|
+
// first stringify
|
|
12
|
+
let conceptDescriptionStr = JSON.stringify(conceptDescription);
|
|
13
|
+
// then parse
|
|
14
|
+
conceptDescriptionStr = JSON.parse(conceptDescriptionStr);
|
|
15
|
+
// then jsonize
|
|
16
|
+
const instanceOrError = jsonization.conceptDescriptionFromJsonable(conceptDescriptionStr);
|
|
17
|
+
if (instanceOrError.error !== null) {
|
|
18
|
+
throw instanceOrError.error;
|
|
19
|
+
}
|
|
20
|
+
const instance = instanceOrError.mustValue();
|
|
21
|
+
// set the prototype
|
|
22
|
+
Object.setPrototypeOf(instance, CoreConceptDescription.prototype);
|
|
23
|
+
return instance;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Convert a Core Works ConceptDescription to an API ConceptDescription
|
|
27
|
+
*
|
|
28
|
+
* @function convertCoreCDToApiCD
|
|
29
|
+
* @param {CoreConceptDescription} aas - The Core Works ConceptDescription to convert
|
|
30
|
+
* @returns {ApiConceptDescription} The API ConceptDescription
|
|
31
|
+
*/
|
|
32
|
+
export function convertCoreCDToApiCD(conceptDescription) {
|
|
33
|
+
// first jsonize
|
|
34
|
+
const jsonableConceptDescription = jsonization.toJsonable(conceptDescription);
|
|
35
|
+
// then stringify
|
|
36
|
+
const conceptDescriptionStr = JSON.stringify(jsonableConceptDescription);
|
|
37
|
+
// then parse
|
|
38
|
+
return JSON.parse(conceptDescriptionStr);
|
|
39
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { ISubmodelElement as CoreSubmodelElement, Submodel as CoreSubmodel } from '@aas-core-works/aas-core3.0-typescript/types';
|
|
2
|
+
import { SubmodelRepositoryService } from '../generated';
|
|
3
|
+
/**
|
|
4
|
+
* Convert an API Submodel to a Core Works Submodel
|
|
5
|
+
*
|
|
6
|
+
* @function convertApiSubmodelToCoreSubmodel
|
|
7
|
+
* @param {ApiSubmodel} submodel - The API Submodel to convert
|
|
8
|
+
* @returns {CoreSubmodel} The Core Works Submodel
|
|
9
|
+
*/
|
|
10
|
+
export declare function convertApiSubmodelToCoreSubmodel(submodel: SubmodelRepositoryService.Submodel): CoreSubmodel;
|
|
11
|
+
/**
|
|
12
|
+
* Convert a Core Works Submodel to an API Submodel
|
|
13
|
+
*
|
|
14
|
+
* @function convertCoreSubmodelToApiSubmodel
|
|
15
|
+
* @param {CoreSubmodel} submodel - The Core Works Submodel to convert
|
|
16
|
+
* @returns {ApiSubmodel} The API Submodel
|
|
17
|
+
*/
|
|
18
|
+
export declare function convertCoreSubmodelToApiSubmodel(submodel: CoreSubmodel): SubmodelRepositoryService.Submodel;
|
|
19
|
+
/**
|
|
20
|
+
* Convert an API SubmodelElement to a Core Works SubmodelElement
|
|
21
|
+
*
|
|
22
|
+
* @function convertApiSubmodelElementToCoreSubmodelElement
|
|
23
|
+
* @param {ApiSubmodelElement} submodelElement - The API SubmodelElement to convert
|
|
24
|
+
* @returns {CoreSubmodelElement} The Core Works SubmodelElement
|
|
25
|
+
*/
|
|
26
|
+
export declare function convertApiSubmodelElementToCoreSubmodelElement(submodelElement: SubmodelRepositoryService.SubmodelElement): CoreSubmodelElement;
|
|
27
|
+
/**
|
|
28
|
+
* Convert a Core Works SubmodelElement to an API SubmodelElement
|
|
29
|
+
*
|
|
30
|
+
* @function convertCoreSubmodelElementToApiSubmodelElement
|
|
31
|
+
* @param {CoreSubmodelElement} submodelElement - The Core Works SubmodelElement to convert
|
|
32
|
+
* @returns {ApiSubmodelElement} The API SubmodelElement
|
|
33
|
+
*/
|
|
34
|
+
export declare function convertCoreSubmodelElementToApiSubmodelElement(submodelElement: CoreSubmodelElement): SubmodelRepositoryService.SubmodelElement;
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { jsonization } from '@aas-core-works/aas-core3.0-typescript';
|
|
2
|
+
import { Submodel as CoreSubmodel, } from '@aas-core-works/aas-core3.0-typescript/types';
|
|
3
|
+
/**
|
|
4
|
+
* Convert an API Submodel to a Core Works Submodel
|
|
5
|
+
*
|
|
6
|
+
* @function convertApiSubmodelToCoreSubmodel
|
|
7
|
+
* @param {ApiSubmodel} submodel - The API Submodel to convert
|
|
8
|
+
* @returns {CoreSubmodel} The Core Works Submodel
|
|
9
|
+
*/
|
|
10
|
+
export function convertApiSubmodelToCoreSubmodel(submodel) {
|
|
11
|
+
let submodelStr = JSON.stringify(submodel);
|
|
12
|
+
submodelStr = JSON.parse(submodelStr);
|
|
13
|
+
const instanceOrError = jsonization.submodelFromJsonable(submodelStr);
|
|
14
|
+
if (instanceOrError.error !== null) {
|
|
15
|
+
throw instanceOrError.error;
|
|
16
|
+
}
|
|
17
|
+
const instance = instanceOrError.mustValue();
|
|
18
|
+
Object.setPrototypeOf(instance, CoreSubmodel.prototype);
|
|
19
|
+
return instance;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Convert a Core Works Submodel to an API Submodel
|
|
23
|
+
*
|
|
24
|
+
* @function convertCoreSubmodelToApiSubmodel
|
|
25
|
+
* @param {CoreSubmodel} submodel - The Core Works Submodel to convert
|
|
26
|
+
* @returns {ApiSubmodel} The API Submodel
|
|
27
|
+
*/
|
|
28
|
+
export function convertCoreSubmodelToApiSubmodel(submodel) {
|
|
29
|
+
// first jsonize
|
|
30
|
+
const jsonableSubmodel = jsonization.toJsonable(submodel);
|
|
31
|
+
// then stringify
|
|
32
|
+
const submodelStr = JSON.stringify(jsonableSubmodel);
|
|
33
|
+
// then parse
|
|
34
|
+
return JSON.parse(submodelStr);
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Convert an API SubmodelElement to a Core Works SubmodelElement
|
|
38
|
+
*
|
|
39
|
+
* @function convertApiSubmodelElementToCoreSubmodelElement
|
|
40
|
+
* @param {ApiSubmodelElement} submodelElement - The API SubmodelElement to convert
|
|
41
|
+
* @returns {CoreSubmodelElement} The Core Works SubmodelElement
|
|
42
|
+
*/
|
|
43
|
+
export function convertApiSubmodelElementToCoreSubmodelElement(submodelElement) {
|
|
44
|
+
const submodelElementStr = JSON.stringify(submodelElement);
|
|
45
|
+
const submodelElementObj = JSON.parse(submodelElementStr);
|
|
46
|
+
//submodelElementStr = JSON.parse(submodelElementStr);
|
|
47
|
+
const instanceOrError = jsonization.submodelElementFromJsonable(submodelElementObj);
|
|
48
|
+
if (instanceOrError.error !== null) {
|
|
49
|
+
throw instanceOrError.error;
|
|
50
|
+
}
|
|
51
|
+
const instance = instanceOrError.mustValue();
|
|
52
|
+
//Object.setPrototypeOf(instance, CoreSubmodelElement.prototype);
|
|
53
|
+
return instance;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Convert a Core Works SubmodelElement to an API SubmodelElement
|
|
57
|
+
*
|
|
58
|
+
* @function convertCoreSubmodelElementToApiSubmodelElement
|
|
59
|
+
* @param {CoreSubmodelElement} submodelElement - The Core Works SubmodelElement to convert
|
|
60
|
+
* @returns {ApiSubmodelElement} The API SubmodelElement
|
|
61
|
+
*/
|
|
62
|
+
export function convertCoreSubmodelElementToApiSubmodelElement(submodelElement) {
|
|
63
|
+
// first jsonize
|
|
64
|
+
const jsonableSubmodelElement = jsonization.toJsonable(submodelElement);
|
|
65
|
+
// then stringify
|
|
66
|
+
const submodelElementStr = JSON.stringify(jsonableSubmodelElement);
|
|
67
|
+
// then parse
|
|
68
|
+
return JSON.parse(submodelElementStr);
|
|
69
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { common } from '@aas-core-works/aas-core3.0-typescript';
|
|
2
|
+
import { DeserializationError, JsonValue } from '@aas-core-works/aas-core3.0-typescript/jsonization';
|
|
3
|
+
import { AssetAdministrationShellDescriptor, Endpoint, ProtocolInformation, ProtocolInformationSecurityAttributes, SubmodelDescriptor } from '../models/Descriptors';
|
|
4
|
+
export declare function assetAdministrationShellDescriptorFromJsonable(json: JsonValue): common.Either<AssetAdministrationShellDescriptor, DeserializationError>;
|
|
5
|
+
export declare function submodelDescriptorFromJsonable(json: JsonValue): common.Either<SubmodelDescriptor, DeserializationError>;
|
|
6
|
+
export declare function endpointFromJsonable(json: any): Endpoint;
|
|
7
|
+
export declare function protocolInformationFromJsonable(json: any): ProtocolInformation;
|
|
8
|
+
export declare function toJsonableAssetAdministrationShellDescriptor(descriptor: AssetAdministrationShellDescriptor): Record<string, JsonValue>;
|
|
9
|
+
export declare function toJsonableSubmodelDescriptor(descriptor: SubmodelDescriptor): Record<string, JsonValue>;
|
|
10
|
+
export declare function toJsonableEndpoint(endpoint: Endpoint): Record<string, JsonValue>;
|
|
11
|
+
export declare function toJsonableProtocolInformation(info: ProtocolInformation): Record<string, JsonValue>;
|
|
12
|
+
export declare function toJsonableSecurityAttribute(attr: ProtocolInformationSecurityAttributes): Record<string, JsonValue>;
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
import { common } from '@aas-core-works/aas-core3.0-typescript';
|
|
2
|
+
import { administrativeInformationFromJsonable, assetKindFromJsonable, DeserializationError, extensionFromJsonable, langStringNameTypeFromJsonable, langStringTextTypeFromJsonable, referenceFromJsonable, specificAssetIdFromJsonable, toJsonable, } from '@aas-core-works/aas-core3.0-typescript/jsonization';
|
|
3
|
+
//import { AasRegistryService } from '../generated';
|
|
4
|
+
import { AssetAdministrationShellDescriptor, SubmodelDescriptor, } from '../models/Descriptors';
|
|
5
|
+
export function assetAdministrationShellDescriptorFromJsonable(json) {
|
|
6
|
+
if (json === null) {
|
|
7
|
+
return new common.Either(null, new DeserializationError('Expected a JSON object, but got null'));
|
|
8
|
+
}
|
|
9
|
+
if (Array.isArray(json)) {
|
|
10
|
+
return new common.Either(null, new DeserializationError('Expected a JSON object, but got a JSON array'));
|
|
11
|
+
}
|
|
12
|
+
if (typeof json !== 'object') {
|
|
13
|
+
return new common.Either(null, new DeserializationError(`Expected a JSON object, but got: ${typeof json}`));
|
|
14
|
+
}
|
|
15
|
+
const obj = json;
|
|
16
|
+
try {
|
|
17
|
+
const displayName = obj.displayName
|
|
18
|
+
? obj.displayName.map((e) => langStringNameTypeFromJsonable(e).mustValue())
|
|
19
|
+
: null;
|
|
20
|
+
const description = obj.description
|
|
21
|
+
? obj.description.map((e) => langStringTextTypeFromJsonable(e).mustValue())
|
|
22
|
+
: null;
|
|
23
|
+
const extensions = obj.extensions
|
|
24
|
+
? obj.extensions.map((e) => extensionFromJsonable(e).mustValue())
|
|
25
|
+
: null;
|
|
26
|
+
const administration = obj.administration
|
|
27
|
+
? administrativeInformationFromJsonable(obj.administration).mustValue()
|
|
28
|
+
: null;
|
|
29
|
+
const assetKind = obj.assetKind ? assetKindFromJsonable(obj.assetKind).mustValue() : null;
|
|
30
|
+
const specificAssetIds = obj.specificAssetIds
|
|
31
|
+
? obj.specificAssetIds.map((e) => specificAssetIdFromJsonable(e).mustValue())
|
|
32
|
+
: null;
|
|
33
|
+
const submodelDescriptors = obj.submodelDescriptors
|
|
34
|
+
? obj.submodelDescriptors.map((e) => submodelDescriptorFromJsonable(e).mustValue())
|
|
35
|
+
: null;
|
|
36
|
+
const endpoints = obj.endpoints ? obj.endpoints.map(endpointFromJsonable) : null;
|
|
37
|
+
return new common.Either(new AssetAdministrationShellDescriptor(obj.id, displayName, description, extensions, administration, obj.idShort ?? null, assetKind, obj.assetType ?? null, obj.globalAssetId ?? null, specificAssetIds, submodelDescriptors, endpoints), null);
|
|
38
|
+
}
|
|
39
|
+
catch (err) {
|
|
40
|
+
return new common.Either(null, new DeserializationError(err.message));
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
export function submodelDescriptorFromJsonable(json) {
|
|
44
|
+
if (json === null) {
|
|
45
|
+
return new common.Either(null, new DeserializationError('Expected a JSON object, but got null'));
|
|
46
|
+
}
|
|
47
|
+
if (Array.isArray(json)) {
|
|
48
|
+
return new common.Either(null, new DeserializationError('Expected a JSON object, but got a JSON array'));
|
|
49
|
+
}
|
|
50
|
+
if (typeof json !== 'object') {
|
|
51
|
+
return new common.Either(null, new DeserializationError(`Expected a JSON object, but got: ${typeof json}`));
|
|
52
|
+
}
|
|
53
|
+
const obj = json;
|
|
54
|
+
try {
|
|
55
|
+
const displayName = obj.displayName
|
|
56
|
+
? obj.displayName.map((e) => langStringNameTypeFromJsonable(e).mustValue())
|
|
57
|
+
: null;
|
|
58
|
+
const description = obj.description
|
|
59
|
+
? obj.description.map((e) => langStringTextTypeFromJsonable(e).mustValue())
|
|
60
|
+
: null;
|
|
61
|
+
const extensions = obj.extensions
|
|
62
|
+
? obj.extensions.map((e) => extensionFromJsonable(e).mustValue())
|
|
63
|
+
: null;
|
|
64
|
+
const semanticId = obj.semanticId ? referenceFromJsonable(obj.semanticId).mustValue() : null;
|
|
65
|
+
const administration = obj.administration
|
|
66
|
+
? administrativeInformationFromJsonable(obj.administration).mustValue()
|
|
67
|
+
: null;
|
|
68
|
+
const supplementalSemanticIds = obj.supplementalSemanticIds
|
|
69
|
+
? obj.supplementalSemanticIds.map((e) => referenceFromJsonable(e).mustValue())
|
|
70
|
+
: null;
|
|
71
|
+
//const endpoints = json.endpoints?.map(endpointFromJsonable);
|
|
72
|
+
const endpoints = obj.endpoints.map(endpointFromJsonable);
|
|
73
|
+
return new common.Either(new SubmodelDescriptor(obj.id, endpoints, administration, obj.idShort ?? null, semanticId, supplementalSemanticIds, displayName, description, extensions), null);
|
|
74
|
+
}
|
|
75
|
+
catch (err) {
|
|
76
|
+
return new common.Either(null, new DeserializationError(err.message));
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
export function endpointFromJsonable(json) {
|
|
80
|
+
return {
|
|
81
|
+
//_interface: json._interface,
|
|
82
|
+
_interface: json.interface,
|
|
83
|
+
protocolInformation: protocolInformationFromJsonable(json.protocolInformation),
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
export function protocolInformationFromJsonable(json) {
|
|
87
|
+
return {
|
|
88
|
+
href: json.href,
|
|
89
|
+
endpointProtocol: json.endpointProtocol ?? null,
|
|
90
|
+
endpointProtocolVersion: json.endpointProtocolVersion ?? null,
|
|
91
|
+
subprotocol: json.subprotocol ?? null,
|
|
92
|
+
subprotocolBody: json.subprotocolBody ?? null,
|
|
93
|
+
subprotocolBodyEncoding: json.subprotocolBodyEncoding ?? null,
|
|
94
|
+
securityAttributes: json.securityAttributes ?? null,
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
export function toJsonableAssetAdministrationShellDescriptor(descriptor) {
|
|
98
|
+
return {
|
|
99
|
+
id: descriptor.id,
|
|
100
|
+
...(descriptor.idShort !== null && { idShort: descriptor.idShort }),
|
|
101
|
+
...(descriptor.description !== null && {
|
|
102
|
+
description: descriptor.description.map(toJsonable),
|
|
103
|
+
}),
|
|
104
|
+
...(descriptor.displayName !== null && {
|
|
105
|
+
displayName: descriptor.displayName.map(toJsonable),
|
|
106
|
+
}),
|
|
107
|
+
...(descriptor.extensions !== null && {
|
|
108
|
+
extensions: descriptor.extensions.map(toJsonable),
|
|
109
|
+
}),
|
|
110
|
+
...(descriptor.administration !== null && { administration: toJsonable(descriptor.administration) }),
|
|
111
|
+
...(descriptor.assetKind !== null && { assetKind: descriptor.assetKind }),
|
|
112
|
+
...(descriptor.assetType !== null && { assetType: descriptor.assetType }),
|
|
113
|
+
...(descriptor.globalAssetId !== null && { globalAssetId: descriptor.globalAssetId }),
|
|
114
|
+
...(descriptor.specificAssetIds !== null && {
|
|
115
|
+
specificAssetIds: descriptor.specificAssetIds.map(toJsonable),
|
|
116
|
+
}),
|
|
117
|
+
...(descriptor.submodelDescriptors !== null && {
|
|
118
|
+
submodelDescriptors: descriptor.submodelDescriptors.map(toJsonableSubmodelDescriptor),
|
|
119
|
+
}),
|
|
120
|
+
...(descriptor.endpoints !== null && {
|
|
121
|
+
endpoints: descriptor.endpoints.map(toJsonableEndpoint),
|
|
122
|
+
}),
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
export function toJsonableSubmodelDescriptor(descriptor) {
|
|
126
|
+
return {
|
|
127
|
+
id: descriptor.id,
|
|
128
|
+
endpoints: descriptor.endpoints.map(toJsonableEndpoint),
|
|
129
|
+
...(descriptor.idShort !== null && { idShort: descriptor.idShort }),
|
|
130
|
+
...(descriptor.administration !== null && { administration: toJsonable(descriptor.administration) }),
|
|
131
|
+
...(descriptor.semanticId !== null && { semanticId: toJsonable(descriptor.semanticId) }),
|
|
132
|
+
...(descriptor.supplementalSemanticIds !== null && {
|
|
133
|
+
supplementalSemanticIds: descriptor.supplementalSemanticIds.map(toJsonable),
|
|
134
|
+
}),
|
|
135
|
+
...(descriptor.displayName !== null && {
|
|
136
|
+
displayName: descriptor.displayName.map(toJsonable),
|
|
137
|
+
}),
|
|
138
|
+
...(descriptor.description !== null && {
|
|
139
|
+
description: descriptor.description.map(toJsonable),
|
|
140
|
+
}),
|
|
141
|
+
...(descriptor.extensions !== null && {
|
|
142
|
+
extensions: descriptor.extensions.map(toJsonable),
|
|
143
|
+
}),
|
|
144
|
+
};
|
|
145
|
+
}
|
|
146
|
+
export function toJsonableEndpoint(endpoint) {
|
|
147
|
+
return {
|
|
148
|
+
//_interface: endpoint._interface,
|
|
149
|
+
interface: endpoint._interface,
|
|
150
|
+
protocolInformation: toJsonableProtocolInformation(endpoint.protocolInformation),
|
|
151
|
+
};
|
|
152
|
+
}
|
|
153
|
+
export function toJsonableProtocolInformation(info) {
|
|
154
|
+
return {
|
|
155
|
+
href: info.href,
|
|
156
|
+
...(info.endpointProtocol !== null && { endpointProtocol: info.endpointProtocol }),
|
|
157
|
+
...(info.endpointProtocolVersion !== null && { endpointProtocolVersion: info.endpointProtocolVersion }),
|
|
158
|
+
...(info.subprotocol !== null && { subprotocol: info.subprotocol }),
|
|
159
|
+
...(info.subprotocolBody !== null && { subprotocolBody: info.subprotocolBody }),
|
|
160
|
+
...(info.subprotocolBodyEncoding !== null && { subprotocolBodyEncoding: info.subprotocolBodyEncoding }),
|
|
161
|
+
...(info.securityAttributes !== null && {
|
|
162
|
+
securityAttributes: info.securityAttributes.map(toJsonableSecurityAttribute),
|
|
163
|
+
}),
|
|
164
|
+
};
|
|
165
|
+
}
|
|
166
|
+
export function toJsonableSecurityAttribute(attr) {
|
|
167
|
+
return {
|
|
168
|
+
type: attr.type,
|
|
169
|
+
key: attr.key,
|
|
170
|
+
value: attr.value,
|
|
171
|
+
};
|
|
172
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { AasDiscoveryService, AasRegistryService, AasRepositoryService, AasxFileService, ConceptDescriptionRepositoryService, SubmodelRegistryService, SubmodelRepositoryService } from '../generated';
|
|
2
|
+
/**
|
|
3
|
+
* Processes errors from API calls and standardizes them to a Result object
|
|
4
|
+
* with a consistent messages array following the API spec guidelines.
|
|
5
|
+
*
|
|
6
|
+
* @param err The error thrown during an API call
|
|
7
|
+
* @returns A standardized Result object containing error messages
|
|
8
|
+
*/
|
|
9
|
+
export declare function handleApiError(err: unknown): Promise<AasRepositoryService.Result | SubmodelRepositoryService.Result | ConceptDescriptionRepositoryService.Result | AasRegistryService.Result | SubmodelRegistryService.Result | AasDiscoveryService.Result | AasxFileService.Result>;
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
//import { FetchError, Message, RequiredError, ResponseError, Result } from '../generated';
|
|
2
|
+
import { AasDiscoveryService, AasRegistryService, AasRepositoryService, AasxFileService, ConceptDescriptionRepositoryService, SubmodelRegistryService, SubmodelRepositoryService, } from '../generated';
|
|
3
|
+
/**
|
|
4
|
+
* Processes errors from API calls and standardizes them to a Result object
|
|
5
|
+
* with a consistent messages array following the API spec guidelines.
|
|
6
|
+
*
|
|
7
|
+
* @param err The error thrown during an API call
|
|
8
|
+
* @returns A standardized Result object containing error messages
|
|
9
|
+
*/
|
|
10
|
+
export async function handleApiError(err) {
|
|
11
|
+
try {
|
|
12
|
+
// Check if the error already has the expected format with messages array
|
|
13
|
+
const errorAny = err;
|
|
14
|
+
if (errorAny?.messages && Array.isArray(errorAny.messages)) {
|
|
15
|
+
return { messages: errorAny.messages };
|
|
16
|
+
}
|
|
17
|
+
// Get current timestamp with millisecond precision as a string
|
|
18
|
+
const timestamp = (new Date().getTime() / 1000).toString();
|
|
19
|
+
let message = {
|
|
20
|
+
code: '500',
|
|
21
|
+
messageType: 'Exception',
|
|
22
|
+
timestamp: timestamp,
|
|
23
|
+
text: 'Unknown error',
|
|
24
|
+
};
|
|
25
|
+
// Handle different error types
|
|
26
|
+
if (err instanceof AasRepositoryService.RequiredError ||
|
|
27
|
+
err instanceof SubmodelRepositoryService.RequiredError ||
|
|
28
|
+
err instanceof ConceptDescriptionRepositoryService.RequiredError ||
|
|
29
|
+
err instanceof AasRegistryService.RequiredError ||
|
|
30
|
+
err instanceof SubmodelRegistryService.RequiredError ||
|
|
31
|
+
err instanceof AasDiscoveryService.RequiredError ||
|
|
32
|
+
err instanceof AasxFileService.RequiredError) {
|
|
33
|
+
message = {
|
|
34
|
+
code: '400',
|
|
35
|
+
messageType: 'Exception',
|
|
36
|
+
text: err.message || `Required parameter missing: ${err.field}`,
|
|
37
|
+
timestamp: timestamp,
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
else if (err instanceof AasRepositoryService.ResponseError ||
|
|
41
|
+
err instanceof SubmodelRepositoryService.ResponseError ||
|
|
42
|
+
err instanceof ConceptDescriptionRepositoryService.ResponseError ||
|
|
43
|
+
err instanceof AasRegistryService.ResponseError ||
|
|
44
|
+
err instanceof SubmodelRegistryService.ResponseError ||
|
|
45
|
+
err instanceof AasDiscoveryService.ResponseError ||
|
|
46
|
+
err instanceof AasxFileService.ResponseError) {
|
|
47
|
+
// Try to parse response body for messages
|
|
48
|
+
const responseBody = err.response;
|
|
49
|
+
try {
|
|
50
|
+
// Check if the response already contains a messages array
|
|
51
|
+
const responseData = responseBody && responseBody.json ? await responseBody.json() : null;
|
|
52
|
+
if (responseData?.messages && Array.isArray(responseData.messages)) {
|
|
53
|
+
return { messages: responseData.messages };
|
|
54
|
+
}
|
|
55
|
+
// Otherwise, create a message with the status code
|
|
56
|
+
message = {
|
|
57
|
+
code: err.response.status.toString(),
|
|
58
|
+
messageType: 'Exception',
|
|
59
|
+
text: err.message || `HTTP ${err.response.status} - Response returned an error code`,
|
|
60
|
+
timestamp: timestamp,
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
catch {
|
|
64
|
+
// If we can't parse the body, create a basic message
|
|
65
|
+
message = {
|
|
66
|
+
code: err.response.status.toString(),
|
|
67
|
+
messageType: 'Exception',
|
|
68
|
+
text: `HTTP ${err.response.status} - Response returned an error code`,
|
|
69
|
+
timestamp: timestamp,
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
else if (err instanceof AasRepositoryService.FetchError ||
|
|
74
|
+
err instanceof SubmodelRepositoryService.FetchError ||
|
|
75
|
+
err instanceof ConceptDescriptionRepositoryService.FetchError ||
|
|
76
|
+
err instanceof AasRegistryService.FetchError ||
|
|
77
|
+
err instanceof SubmodelRegistryService.FetchError ||
|
|
78
|
+
err instanceof AasDiscoveryService.FetchError ||
|
|
79
|
+
err instanceof AasxFileService.FetchError) {
|
|
80
|
+
message = {
|
|
81
|
+
code: '0',
|
|
82
|
+
messageType: 'Exception',
|
|
83
|
+
text: err.message || 'Network request failed',
|
|
84
|
+
timestamp: timestamp,
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
else if (err instanceof Error) {
|
|
88
|
+
message = {
|
|
89
|
+
code: '500',
|
|
90
|
+
messageType: 'Exception',
|
|
91
|
+
text: err.message || 'Unknown error occurred',
|
|
92
|
+
timestamp: timestamp,
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
return { messages: [message] };
|
|
96
|
+
}
|
|
97
|
+
catch (handlerError) {
|
|
98
|
+
// If our error handler throws an error, capture that and return a fallback error
|
|
99
|
+
console.error('Error in error handler:', handlerError);
|
|
100
|
+
// Get current timestamp with millisecond precision as a string for the fallback error
|
|
101
|
+
const timestamp = (new Date().getTime() / 1000).toString();
|
|
102
|
+
return {
|
|
103
|
+
messages: [
|
|
104
|
+
{
|
|
105
|
+
code: '500',
|
|
106
|
+
messageType: 'Exception',
|
|
107
|
+
text: 'An error occurred while processing another error',
|
|
108
|
+
timestamp: timestamp,
|
|
109
|
+
},
|
|
110
|
+
],
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import type { AdministrativeInformation, AssetKind, Extension, LangStringNameType, LangStringTextType, Reference, SpecificAssetId } from '@aas-core-works/aas-core3.0-typescript/types';
|
|
2
|
+
export declare class AssetAdministrationShellDescriptor {
|
|
3
|
+
id: string;
|
|
4
|
+
displayName: Array<LangStringNameType> | null;
|
|
5
|
+
description: Array<LangStringTextType> | null;
|
|
6
|
+
extensions: Array<Extension> | null;
|
|
7
|
+
administration: AdministrativeInformation | null;
|
|
8
|
+
idShort: string | null;
|
|
9
|
+
assetKind: AssetKind | null;
|
|
10
|
+
assetType: string | null;
|
|
11
|
+
globalAssetId: string | null;
|
|
12
|
+
specificAssetIds: Array<SpecificAssetId> | null;
|
|
13
|
+
submodelDescriptors: Array<SubmodelDescriptor> | null;
|
|
14
|
+
endpoints: Array<Endpoint> | null;
|
|
15
|
+
constructor(id: string, displayName?: Array<LangStringNameType> | null, description?: Array<LangStringTextType> | null, extensions?: Array<Extension> | null, administration?: AdministrativeInformation | null, idShort?: string | null, assetKind?: AssetKind | null, assetType?: string | null, globalAssetId?: string | null, specificAssetIds?: Array<SpecificAssetId> | null, submodelDescriptors?: Array<SubmodelDescriptor> | null, endpoints?: Array<Endpoint> | null);
|
|
16
|
+
}
|
|
17
|
+
export declare class SubmodelDescriptor {
|
|
18
|
+
id: string;
|
|
19
|
+
endpoints: Array<Endpoint>;
|
|
20
|
+
administration: AdministrativeInformation | null;
|
|
21
|
+
idShort: string | null;
|
|
22
|
+
semanticId: Reference | null;
|
|
23
|
+
supplementalSemanticIds: Array<Reference> | null;
|
|
24
|
+
displayName: Array<LangStringNameType> | null;
|
|
25
|
+
description: Array<LangStringTextType> | null;
|
|
26
|
+
extensions: Array<Extension> | null;
|
|
27
|
+
constructor(id: string, endpoints: Array<Endpoint>, administration?: AdministrativeInformation | null, idShort?: string | null, semanticId?: Reference | null, supplementalSemanticIds?: Array<Reference> | null, displayName?: Array<LangStringNameType> | null, description?: Array<LangStringTextType> | null, extensions?: Array<Extension> | null);
|
|
28
|
+
}
|
|
29
|
+
export interface Endpoint {
|
|
30
|
+
_interface: string;
|
|
31
|
+
protocolInformation: ProtocolInformation;
|
|
32
|
+
}
|
|
33
|
+
export interface ProtocolInformation {
|
|
34
|
+
href: string;
|
|
35
|
+
endpointProtocol: string | null;
|
|
36
|
+
endpointProtocolVersion: Array<string> | null;
|
|
37
|
+
subprotocol: string | null;
|
|
38
|
+
subprotocolBody: string | null;
|
|
39
|
+
subprotocolBodyEncoding: string | null;
|
|
40
|
+
securityAttributes: Array<ProtocolInformationSecurityAttributes> | null;
|
|
41
|
+
}
|
|
42
|
+
export interface ProtocolInformationSecurityAttributes {
|
|
43
|
+
type: ProtocolInformationSecurityAttributesTypeEnum;
|
|
44
|
+
key: string;
|
|
45
|
+
value: string;
|
|
46
|
+
}
|
|
47
|
+
export declare enum ProtocolInformationSecurityAttributesTypeEnum {
|
|
48
|
+
None = 0,
|
|
49
|
+
RfcTlsa = 1,
|
|
50
|
+
W3CDid = 2
|
|
51
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
export class AssetAdministrationShellDescriptor {
|
|
2
|
+
id;
|
|
3
|
+
displayName;
|
|
4
|
+
description;
|
|
5
|
+
extensions;
|
|
6
|
+
administration;
|
|
7
|
+
idShort;
|
|
8
|
+
assetKind;
|
|
9
|
+
assetType;
|
|
10
|
+
globalAssetId;
|
|
11
|
+
specificAssetIds;
|
|
12
|
+
submodelDescriptors;
|
|
13
|
+
endpoints;
|
|
14
|
+
constructor(id, displayName = null, description = null, extensions = null, administration = null, idShort = null, assetKind = null, assetType = null, globalAssetId = null, specificAssetIds = null, submodelDescriptors = null, endpoints = null) {
|
|
15
|
+
this.id = id;
|
|
16
|
+
this.displayName = displayName;
|
|
17
|
+
this.description = description;
|
|
18
|
+
this.extensions = extensions;
|
|
19
|
+
this.administration = administration;
|
|
20
|
+
this.idShort = idShort;
|
|
21
|
+
this.assetKind = assetKind;
|
|
22
|
+
this.assetType = assetType;
|
|
23
|
+
this.globalAssetId = globalAssetId;
|
|
24
|
+
this.specificAssetIds = specificAssetIds;
|
|
25
|
+
this.submodelDescriptors = submodelDescriptors;
|
|
26
|
+
this.endpoints = endpoints;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
export class SubmodelDescriptor {
|
|
30
|
+
id;
|
|
31
|
+
endpoints;
|
|
32
|
+
administration;
|
|
33
|
+
idShort;
|
|
34
|
+
semanticId;
|
|
35
|
+
supplementalSemanticIds;
|
|
36
|
+
displayName;
|
|
37
|
+
description;
|
|
38
|
+
extensions;
|
|
39
|
+
constructor(id, endpoints, administration = null, idShort = null, semanticId = null, supplementalSemanticIds = null, displayName = null, description = null, extensions = null) {
|
|
40
|
+
this.id = id;
|
|
41
|
+
this.endpoints = endpoints;
|
|
42
|
+
this.administration = administration;
|
|
43
|
+
this.idShort = idShort;
|
|
44
|
+
this.semanticId = semanticId;
|
|
45
|
+
this.supplementalSemanticIds = supplementalSemanticIds;
|
|
46
|
+
this.displayName = displayName;
|
|
47
|
+
this.description = description;
|
|
48
|
+
this.extensions = extensions;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
export var ProtocolInformationSecurityAttributesTypeEnum;
|
|
52
|
+
(function (ProtocolInformationSecurityAttributesTypeEnum) {
|
|
53
|
+
ProtocolInformationSecurityAttributesTypeEnum[ProtocolInformationSecurityAttributesTypeEnum["None"] = 0] = "None";
|
|
54
|
+
ProtocolInformationSecurityAttributesTypeEnum[ProtocolInformationSecurityAttributesTypeEnum["RfcTlsa"] = 1] = "RfcTlsa";
|
|
55
|
+
ProtocolInformationSecurityAttributesTypeEnum[ProtocolInformationSecurityAttributesTypeEnum["W3CDid"] = 2] = "W3CDid";
|
|
56
|
+
})(ProtocolInformationSecurityAttributesTypeEnum || (ProtocolInformationSecurityAttributesTypeEnum = {}));
|
package/dist/models/index.d.ts
CHANGED
package/dist/models/index.js
CHANGED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { AssetAdministrationShellDescriptor, SubmodelDescriptor } from '../models/Descriptors';
|
|
2
|
+
/**
|
|
3
|
+
* Extracts the endpoint from a descriptor based on the given interface short name.
|
|
4
|
+
*
|
|
5
|
+
* @param {Object} descriptor - The descriptor containing endpoint information.
|
|
6
|
+
* @param {string} interfaceShortName - The short name of the interface to match against endpoint interfaces.
|
|
7
|
+
* @returns {string} The href of the matching endpoint's protocol information if found, otherwise an empty string.
|
|
8
|
+
*/
|
|
9
|
+
export declare function extractEndpointHref(descriptor: AssetAdministrationShellDescriptor | SubmodelDescriptor, interfaceShortName: string): string;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Extracts the endpoint from a descriptor based on the given interface short name.
|
|
3
|
+
*
|
|
4
|
+
* @param {Object} descriptor - The descriptor containing endpoint information.
|
|
5
|
+
* @param {string} interfaceShortName - The short name of the interface to match against endpoint interfaces.
|
|
6
|
+
* @returns {string} The href of the matching endpoint's protocol information if found, otherwise an empty string.
|
|
7
|
+
*/
|
|
8
|
+
export function extractEndpointHref(descriptor, interfaceShortName) {
|
|
9
|
+
const failResponse = '';
|
|
10
|
+
const interfaceShortNames = [
|
|
11
|
+
'AAS',
|
|
12
|
+
'SUBMODEL',
|
|
13
|
+
'SERIALIZE',
|
|
14
|
+
'DESCRIPTION',
|
|
15
|
+
'AASX-FILE',
|
|
16
|
+
'AAS-REGISTRY',
|
|
17
|
+
'SUBMODEL-REGISTRY',
|
|
18
|
+
'AAS-REPOSITORY',
|
|
19
|
+
'SUBMODEL-REPOSITORY',
|
|
20
|
+
'CD-REPOSITORY',
|
|
21
|
+
'AAS-DISCOVERY',
|
|
22
|
+
];
|
|
23
|
+
if (!interfaceShortName || interfaceShortName.trim() === '')
|
|
24
|
+
return failResponse;
|
|
25
|
+
interfaceShortName = interfaceShortName.trim();
|
|
26
|
+
interfaceShortName = interfaceShortName.toUpperCase();
|
|
27
|
+
if (!interfaceShortNames.some((iShortName) => interfaceShortName.startsWith(`${iShortName}-`))) {
|
|
28
|
+
return failResponse;
|
|
29
|
+
}
|
|
30
|
+
if (!Array.isArray(descriptor?.endpoints) || descriptor?.endpoints.length === 0) {
|
|
31
|
+
return failResponse;
|
|
32
|
+
}
|
|
33
|
+
const endpoints = descriptor.endpoints;
|
|
34
|
+
// find the right endpoint based on the interfaceShortName (has to match endpoint.interface)
|
|
35
|
+
const endpoint = endpoints.find((endpoint) => endpoint?._interface === interfaceShortName);
|
|
36
|
+
return endpoint?.protocolInformation?.href ? endpoint.protocolInformation.href : '';
|
|
37
|
+
}
|