basyx-typescript-sdk 1.0.1 → 1.0.3
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 +380 -8
- package/bundle/index.cjs +2423 -257
- package/bundle/index.cjs.map +1 -1
- package/bundle/index.mjs +2346 -244
- package/bundle/index.mjs.map +1 -1
- package/dist/clients/AasDiscoveryClient.js +0 -2
- package/dist/clients/AasRegistryClient.js +0 -5
- package/dist/clients/AasRepositoryClient.js +0 -1
- package/dist/clients/AasxFileClient.js +0 -6
- package/dist/clients/SubmodelRegistryClient.js +0 -2
- package/dist/clients/SubmodelRepositoryClient.js +0 -4
- package/dist/index.d.ts +6 -1
- package/dist/index.js +28 -1
- package/dist/lib/base64Url.js +11 -2
- package/dist/lib/descriptorJsonization.js +20 -1
- package/dist/lib/index.d.ts +9 -0
- package/dist/lib/index.js +12 -0
- package/dist/models/index.d.ts +1 -0
- package/dist/models/index.js +1 -0
- package/dist/services/AasService.d.ts +240 -0
- package/dist/services/AasService.js +726 -0
- package/dist/services/SubmodelService.d.ts +192 -0
- package/dist/services/SubmodelService.js +574 -0
- package/dist/services/index.d.ts +4 -0
- package/dist/services/index.js +2 -0
- package/dist/utils/SemanticIdUtils.js +0 -1
- package/dist/utils/index.d.ts +12 -0
- package/dist/utils/index.js +14 -0
- package/package.json +2 -2
package/bundle/index.cjs
CHANGED
|
@@ -2484,7 +2484,7 @@ const StateOfEvent$3 = {
|
|
|
2484
2484
|
/* tslint:disable */
|
|
2485
2485
|
/* eslint-disable */
|
|
2486
2486
|
|
|
2487
|
-
var index$
|
|
2487
|
+
var index$8 = /*#__PURE__*/Object.freeze({
|
|
2488
2488
|
__proto__: null,
|
|
2489
2489
|
AasSubmodelElements: AasSubmodelElements$3,
|
|
2490
2490
|
AssetAdministrationShellRepositoryAPIApi: AssetAdministrationShellRepositoryAPIApi,
|
|
@@ -4412,7 +4412,7 @@ const StateOfEvent$2 = {
|
|
|
4412
4412
|
/* tslint:disable */
|
|
4413
4413
|
/* eslint-disable */
|
|
4414
4414
|
|
|
4415
|
-
var index$
|
|
4415
|
+
var index$7 = /*#__PURE__*/Object.freeze({
|
|
4416
4416
|
__proto__: null,
|
|
4417
4417
|
AasSubmodelElements: AasSubmodelElements$2,
|
|
4418
4418
|
AssetKind: AssetKind$3,
|
|
@@ -4926,7 +4926,7 @@ const StateOfEvent$1 = {
|
|
|
4926
4926
|
|
|
4927
4927
|
/* tslint:disable */
|
|
4928
4928
|
|
|
4929
|
-
var index$
|
|
4929
|
+
var index$6 = /*#__PURE__*/Object.freeze({
|
|
4930
4930
|
__proto__: null,
|
|
4931
4931
|
AasSubmodelElements: AasSubmodelElements$1,
|
|
4932
4932
|
AssetKind: AssetKind$2,
|
|
@@ -5436,7 +5436,7 @@ const ModelType$2 = {
|
|
|
5436
5436
|
/**
|
|
5437
5437
|
* @export
|
|
5438
5438
|
*/
|
|
5439
|
-
const ProtocolInformationSecurityAttributesTypeEnum$
|
|
5439
|
+
const ProtocolInformationSecurityAttributesTypeEnum$1 = {
|
|
5440
5440
|
None: 'NONE',
|
|
5441
5441
|
RfcTlsa: 'RFC_TLSA',
|
|
5442
5442
|
W3CDid: 'W3C_DID'
|
|
@@ -5453,7 +5453,7 @@ const ReferenceTypes$3 = {
|
|
|
5453
5453
|
/* tslint:disable */
|
|
5454
5454
|
/* eslint-disable */
|
|
5455
5455
|
|
|
5456
|
-
var index$
|
|
5456
|
+
var index$5 = /*#__PURE__*/Object.freeze({
|
|
5457
5457
|
__proto__: null,
|
|
5458
5458
|
AssetAdministrationShellRegistryAPIApi: AssetAdministrationShellRegistryAPIApi,
|
|
5459
5459
|
AssetKind: AssetKind$1,
|
|
@@ -5463,7 +5463,7 @@ var index$4 = /*#__PURE__*/Object.freeze({
|
|
|
5463
5463
|
KeyTypes: KeyTypes$3,
|
|
5464
5464
|
MessageMessageTypeEnum: MessageMessageTypeEnum$3,
|
|
5465
5465
|
ModelType: ModelType$2,
|
|
5466
|
-
ProtocolInformationSecurityAttributesTypeEnum: ProtocolInformationSecurityAttributesTypeEnum$
|
|
5466
|
+
ProtocolInformationSecurityAttributesTypeEnum: ProtocolInformationSecurityAttributesTypeEnum$1,
|
|
5467
5467
|
ReferenceTypes: ReferenceTypes$3
|
|
5468
5468
|
});
|
|
5469
5469
|
|
|
@@ -5790,7 +5790,7 @@ const ModelType$1 = {
|
|
|
5790
5790
|
/**
|
|
5791
5791
|
* @export
|
|
5792
5792
|
*/
|
|
5793
|
-
const ProtocolInformationSecurityAttributesTypeEnum
|
|
5793
|
+
const ProtocolInformationSecurityAttributesTypeEnum = {
|
|
5794
5794
|
None: 'NONE',
|
|
5795
5795
|
RfcTlsa: 'RFC_TLSA',
|
|
5796
5796
|
W3CDid: 'W3C_DID'
|
|
@@ -5807,7 +5807,7 @@ const ReferenceTypes$2 = {
|
|
|
5807
5807
|
/* tslint:disable */
|
|
5808
5808
|
/* eslint-disable */
|
|
5809
5809
|
|
|
5810
|
-
var index$
|
|
5810
|
+
var index$4 = /*#__PURE__*/Object.freeze({
|
|
5811
5811
|
__proto__: null,
|
|
5812
5812
|
DataTypeDefXsd: DataTypeDefXsd$1,
|
|
5813
5813
|
DataTypeIec61360: DataTypeIec61360$1,
|
|
@@ -5815,7 +5815,7 @@ var index$3 = /*#__PURE__*/Object.freeze({
|
|
|
5815
5815
|
KeyTypes: KeyTypes$2,
|
|
5816
5816
|
MessageMessageTypeEnum: MessageMessageTypeEnum$2,
|
|
5817
5817
|
ModelType: ModelType$1,
|
|
5818
|
-
ProtocolInformationSecurityAttributesTypeEnum: ProtocolInformationSecurityAttributesTypeEnum
|
|
5818
|
+
ProtocolInformationSecurityAttributesTypeEnum: ProtocolInformationSecurityAttributesTypeEnum,
|
|
5819
5819
|
ReferenceTypes: ReferenceTypes$2,
|
|
5820
5820
|
SubmodelRegistryAPIApi: SubmodelRegistryAPIApi
|
|
5821
5821
|
});
|
|
@@ -6068,7 +6068,7 @@ const ReferenceTypes$1 = {
|
|
|
6068
6068
|
/* tslint:disable */
|
|
6069
6069
|
/* eslint-disable */
|
|
6070
6070
|
|
|
6071
|
-
var index$
|
|
6071
|
+
var index$3 = /*#__PURE__*/Object.freeze({
|
|
6072
6072
|
__proto__: null,
|
|
6073
6073
|
AssetAdministrationShellBasicDiscoveryAPIApi: AssetAdministrationShellBasicDiscoveryAPIApi,
|
|
6074
6074
|
DescriptionAPIApi: DescriptionAPIApi,
|
|
@@ -6275,7 +6275,7 @@ const MessageMessageTypeEnum = {
|
|
|
6275
6275
|
/* tslint:disable */
|
|
6276
6276
|
/* eslint-disable */
|
|
6277
6277
|
|
|
6278
|
-
var index$
|
|
6278
|
+
var index$2 = /*#__PURE__*/Object.freeze({
|
|
6279
6279
|
__proto__: null,
|
|
6280
6280
|
AASXFileServerAPIApi: AASXFileServerAPIApi,
|
|
6281
6281
|
MessageMessageTypeEnum: MessageMessageTypeEnum
|
|
@@ -6337,6 +6337,48 @@ function base64Encode$1(string, urlSafe = true) {
|
|
|
6337
6337
|
.replace(/=+$/, ''); // Remove padding (=)
|
|
6338
6338
|
return urlSafeBase64String;
|
|
6339
6339
|
}
|
|
6340
|
+
/**
|
|
6341
|
+
* Decodes a URL-safe Base64 encoded string into its original representation.
|
|
6342
|
+
*
|
|
6343
|
+
* The process includes:
|
|
6344
|
+
* 1. Trimming the input string.
|
|
6345
|
+
* 2. Replacing URL-safe characters '-' and '_' with their Base64 equivalents '+' and '/'.
|
|
6346
|
+
* 3. Restoring padding if missing.
|
|
6347
|
+
* 4. Decoding from Base64.
|
|
6348
|
+
* 5. Escaping the decoded string before decoding percent-encoded characters.
|
|
6349
|
+
*
|
|
6350
|
+
* @function base64Decode
|
|
6351
|
+
* @param {string} urlSafeBase64String - The URL-safe Base64 encoded string to decode.
|
|
6352
|
+
* @returns {string} The decoded string.
|
|
6353
|
+
*/
|
|
6354
|
+
function base64Decode(urlSafeBase64String) {
|
|
6355
|
+
if (urlSafeBase64String === null || urlSafeBase64String === undefined)
|
|
6356
|
+
return '';
|
|
6357
|
+
urlSafeBase64String = urlSafeBase64String.trim();
|
|
6358
|
+
if (urlSafeBase64String === '')
|
|
6359
|
+
return '';
|
|
6360
|
+
let base64String = urlSafeBase64String
|
|
6361
|
+
.replace(/-/g, '+') // Replace - with +
|
|
6362
|
+
.replace(/_/g, '/') // Replace _ with /
|
|
6363
|
+
.replace(/%3D/g, '=');
|
|
6364
|
+
// Restore missing padding if needed.
|
|
6365
|
+
const incompleteFourChars = base64String.length % 4;
|
|
6366
|
+
if (incompleteFourChars > 0)
|
|
6367
|
+
base64String += '=='.substring(0, 4 - incompleteFourChars);
|
|
6368
|
+
const encodedUriComponent = atob(base64String);
|
|
6369
|
+
const escapedEncodedUriComponent = escape(encodedUriComponent);
|
|
6370
|
+
try {
|
|
6371
|
+
const decodedString = decodeURIComponent(escapedEncodedUriComponent);
|
|
6372
|
+
return decodedString;
|
|
6373
|
+
}
|
|
6374
|
+
catch {
|
|
6375
|
+
// If decodeURIComponent fails, it usually means the decoded string does not contain valid percent-encoded sequences.
|
|
6376
|
+
// This can happen if the original input to base64Encode did not require URI encoding (e.g., only contained ASCII characters).
|
|
6377
|
+
// In such cases, we return the unescaped string directly as a fallback.
|
|
6378
|
+
// Example: base64Decode(base64Encode("simpleASCII")) will not require URI decoding.
|
|
6379
|
+
return unescape(escapedEncodedUriComponent);
|
|
6380
|
+
}
|
|
6381
|
+
}
|
|
6340
6382
|
|
|
6341
6383
|
/**
|
|
6342
6384
|
* Provide an implementation of the Asset Administration Shell (AAS) V3.0.
|
|
@@ -6858,6 +6900,71 @@ return 7;// Submodel
|
|
|
6858
6900
|
/**
|
|
6859
6901
|
* Enumeration of all possible elements of a {@link SubmodelElementList}.
|
|
6860
6902
|
*/let AasSubmodelElements=/*#__PURE__*/function(AasSubmodelElements){AasSubmodelElements[AasSubmodelElements["AnnotatedRelationshipElement"]=0]="AnnotatedRelationshipElement";AasSubmodelElements[AasSubmodelElements["BasicEventElement"]=1]="BasicEventElement";AasSubmodelElements[AasSubmodelElements["Blob"]=2]="Blob";AasSubmodelElements[AasSubmodelElements["Capability"]=3]="Capability";AasSubmodelElements[AasSubmodelElements["DataElement"]=4]="DataElement";AasSubmodelElements[AasSubmodelElements["Entity"]=5]="Entity";AasSubmodelElements[AasSubmodelElements["EventElement"]=6]="EventElement";AasSubmodelElements[AasSubmodelElements["File"]=7]="File";AasSubmodelElements[AasSubmodelElements["MultiLanguageProperty"]=8]="MultiLanguageProperty";AasSubmodelElements[AasSubmodelElements["Operation"]=9]="Operation";AasSubmodelElements[AasSubmodelElements["Property"]=10]="Property";AasSubmodelElements[AasSubmodelElements["Range"]=11]="Range";AasSubmodelElements[AasSubmodelElements["ReferenceElement"]=12]="ReferenceElement";AasSubmodelElements[AasSubmodelElements["RelationshipElement"]=13]="RelationshipElement";AasSubmodelElements[AasSubmodelElements["SubmodelElement"]=14]="SubmodelElement";AasSubmodelElements[AasSubmodelElements["SubmodelElementList"]=15]="SubmodelElementList";AasSubmodelElements[AasSubmodelElements["SubmodelElementCollection"]=16]="SubmodelElementCollection";return AasSubmodelElements;}({});/**
|
|
6903
|
+
* A property is a data element that has a multi-language value.
|
|
6904
|
+
*
|
|
6905
|
+
* Constraint `AASd-012`:
|
|
6906
|
+
* If both the {@link MultiLanguageProperty.value} and the {@link MultiLanguageProperty.valueId} are present then for each
|
|
6907
|
+
* string in a specific language the meaning must be the same as specified in
|
|
6908
|
+
* {@link MultiLanguageProperty.valueId}.
|
|
6909
|
+
*/class MultiLanguageProperty extends Class{/**
|
|
6910
|
+
* Indicate the runtime model type of the instance.
|
|
6911
|
+
*/modelType(){// NOTE (mristin, 2022-12-03):
|
|
6912
|
+
// We yield numbers instead of literals to avoid name lookups on platforms
|
|
6913
|
+
// which do not provide JIT compilation of hot paths.
|
|
6914
|
+
return 12;// MultiLanguageProperty
|
|
6915
|
+
}/**
|
|
6916
|
+
* An extension of the element.
|
|
6917
|
+
*/ /**
|
|
6918
|
+
* Yield from {@link extensions} if it is set, or yield nothing.
|
|
6919
|
+
*/*overExtensionsOrEmpty(){if(this.extensions!==null){yield*this.extensions;}return;}/**
|
|
6920
|
+
* Yield from {@link displayName} if it is set, or yield nothing.
|
|
6921
|
+
*/*overDisplayNameOrEmpty(){if(this.displayName!==null){yield*this.displayName;}return;}/**
|
|
6922
|
+
* Yield from {@link description} if it is set, or yield nothing.
|
|
6923
|
+
*/*overDescriptionOrEmpty(){if(this.description!==null){yield*this.description;}return;}/**
|
|
6924
|
+
* Yield from {@link supplementalSemanticIds} if it is set, or yield nothing.
|
|
6925
|
+
*/*overSupplementalSemanticIdsOrEmpty(){if(this.supplementalSemanticIds!==null){yield*this.supplementalSemanticIds;}return;}/**
|
|
6926
|
+
* Yield from {@link qualifiers} if it is set, or yield nothing.
|
|
6927
|
+
*/*overQualifiersOrEmpty(){if(this.qualifiers!==null){yield*this.qualifiers;}return;}/**
|
|
6928
|
+
* Yield from {@link embeddedDataSpecifications} if it is set, or yield nothing.
|
|
6929
|
+
*/*overEmbeddedDataSpecificationsOrEmpty(){if(this.embeddedDataSpecifications!==null){yield*this.embeddedDataSpecifications;}return;}/**
|
|
6930
|
+
* Yield from {@link value} if it is set, or yield nothing.
|
|
6931
|
+
*/*overValueOrEmpty(){if(this.value!==null){yield*this.value;}return;}/**
|
|
6932
|
+
* @returns {@link category} if set or the default value otherwise.
|
|
6933
|
+
*/categoryOrDefault(){return this.category!==null?this.category:"VARIABLE";}/**
|
|
6934
|
+
* Iterate over the instances referenced from this instance.
|
|
6935
|
+
*
|
|
6936
|
+
* We do not recurse into the referenced instances.
|
|
6937
|
+
*
|
|
6938
|
+
* @returns Iterator over the referenced instances
|
|
6939
|
+
*/*descendOnce(){if(this.extensions!==null){yield*this.extensions;}if(this.displayName!==null){yield*this.displayName;}if(this.description!==null){yield*this.description;}if(this.semanticId!==null){yield this.semanticId;}if(this.supplementalSemanticIds!==null){yield*this.supplementalSemanticIds;}if(this.qualifiers!==null){yield*this.qualifiers;}if(this.embeddedDataSpecifications!==null){yield*this.embeddedDataSpecifications;}if(this.value!==null){yield*this.value;}if(this.valueId!==null){yield this.valueId;}}/**
|
|
6940
|
+
* Iterate recursively over the instances referenced from this instance.
|
|
6941
|
+
*
|
|
6942
|
+
* @returns Iterator over the referenced instances
|
|
6943
|
+
*/*descend(){if(this.extensions!==null){for(const anItem of this.extensions){yield anItem;yield*anItem.descend();}}if(this.displayName!==null){for(const anotherItem of this.displayName){yield anotherItem;yield*anotherItem.descend();}}if(this.description!==null){for(const yetAnotherItem of this.description){yield yetAnotherItem;yield*yetAnotherItem.descend();}}if(this.semanticId!==null){yield this.semanticId;yield*this.semanticId.descend();}if(this.supplementalSemanticIds!==null){for(const yetYetAnotherItem of this.supplementalSemanticIds){yield yetYetAnotherItem;yield*yetYetAnotherItem.descend();}}if(this.qualifiers!==null){for(const yetYetYetAnotherItem of this.qualifiers){yield yetYetYetAnotherItem;yield*yetYetYetAnotherItem.descend();}}if(this.embeddedDataSpecifications!==null){for(const yetYetYetYetAnotherItem of this.embeddedDataSpecifications){yield yetYetYetYetAnotherItem;yield*yetYetYetYetAnotherItem.descend();}}if(this.value!==null){for(const yetYetYetYetYetAnotherItem of this.value){yield yetYetYetYetYetAnotherItem;yield*yetYetYetYetYetAnotherItem.descend();}}if(this.valueId!==null){yield this.valueId;yield*this.valueId.descend();}}/**
|
|
6944
|
+
* Dispatch `visitor` on this instance.
|
|
6945
|
+
*
|
|
6946
|
+
* @param visitor - to visit this instance
|
|
6947
|
+
*/accept(visitor){visitor.visitMultiLanguageProperty(this);}/**
|
|
6948
|
+
* Dispatch `visitor` with `context` on this instance.
|
|
6949
|
+
*
|
|
6950
|
+
* @param visitor - to visit this instance
|
|
6951
|
+
* @param context - to be passed along to the dispatched visitor method
|
|
6952
|
+
* @typeParam ContextT - type of the context
|
|
6953
|
+
*/acceptWithContext(visitor,context){visitor.visitMultiLanguagePropertyWithContext(this,context);}/**
|
|
6954
|
+
* Dispatch the `transformer` on this instance.
|
|
6955
|
+
*
|
|
6956
|
+
* @param transformer - to transform this instance
|
|
6957
|
+
* @returns transformation of this instance
|
|
6958
|
+
* @paramType T - type of the transformation result
|
|
6959
|
+
*/transform(transformer){return transformer.transformMultiLanguageProperty(this);}/**
|
|
6960
|
+
* Dispatch the `transformer` on this instance in `context`.
|
|
6961
|
+
*
|
|
6962
|
+
* @param transformer - to transform this instance
|
|
6963
|
+
* @param context - to be passed along to the `transformer`
|
|
6964
|
+
* @returns transformation of this instance
|
|
6965
|
+
* @paramType T - type of the transformation result
|
|
6966
|
+
* @paramType ContextT - type of the transformation context
|
|
6967
|
+
*/transformWithContext(transformer,context){return transformer.transformMultiLanguagePropertyWithContext(this,context);}constructor(extensions=null,category=null,idShort=null,displayName=null,description=null,semanticId=null,supplementalSemanticIds=null,qualifiers=null,embeddedDataSpecifications=null,value=null,valueId=null){super();this.extensions=extensions;this.idShort=idShort;this.displayName=displayName;this.category=category;this.description=description;this.semanticId=semanticId;this.supplementalSemanticIds=supplementalSemanticIds;this.qualifiers=qualifiers;this.embeddedDataSpecifications=embeddedDataSpecifications;this.value=value;this.valueId=valueId;}}/**
|
|
6861
6968
|
* Enumeration for denoting whether an entity is a self-managed entity or a co-managed
|
|
6862
6969
|
* entity.
|
|
6863
6970
|
*/let EntityType=/*#__PURE__*/function(EntityType){EntityType[EntityType["CoManagedEntity"]=0]="CoManagedEntity";EntityType[EntityType["SelfManagedEntity"]=1]="SelfManagedEntity";return EntityType;}({});/**
|
|
@@ -7275,18 +7382,18 @@ return 28;// LangStringTextType
|
|
|
7275
7382
|
// which do not provide JIT compilation of hot paths.
|
|
7276
7383
|
return 30;// EmbeddedDataSpecification
|
|
7277
7384
|
}/**
|
|
7278
|
-
*
|
|
7385
|
+
* Reference to the data specification
|
|
7279
7386
|
*/ /**
|
|
7280
7387
|
* Iterate over the instances referenced from this instance.
|
|
7281
7388
|
*
|
|
7282
7389
|
* We do not recurse into the referenced instances.
|
|
7283
7390
|
*
|
|
7284
7391
|
* @returns Iterator over the referenced instances
|
|
7285
|
-
*/*descendOnce(){yield this.
|
|
7392
|
+
*/*descendOnce(){yield this.dataSpecification;yield this.dataSpecificationContent;}/**
|
|
7286
7393
|
* Iterate recursively over the instances referenced from this instance.
|
|
7287
7394
|
*
|
|
7288
7395
|
* @returns Iterator over the referenced instances
|
|
7289
|
-
*/*descend(){yield this.
|
|
7396
|
+
*/*descend(){yield this.dataSpecification;yield*this.dataSpecification.descend();yield this.dataSpecificationContent;yield*this.dataSpecificationContent.descend();}/**
|
|
7290
7397
|
* Dispatch `visitor` on this instance.
|
|
7291
7398
|
*
|
|
7292
7399
|
* @param visitor - to visit this instance
|
|
@@ -7310,7 +7417,7 @@ return 30;// EmbeddedDataSpecification
|
|
|
7310
7417
|
* @returns transformation of this instance
|
|
7311
7418
|
* @paramType T - type of the transformation result
|
|
7312
7419
|
* @paramType ContextT - type of the transformation context
|
|
7313
|
-
*/transformWithContext(transformer,context){return transformer.transformEmbeddedDataSpecificationWithContext(this,context);}constructor(dataSpecificationContent
|
|
7420
|
+
*/transformWithContext(transformer,context){return transformer.transformEmbeddedDataSpecificationWithContext(this,context);}constructor(dataSpecification,dataSpecificationContent){super();this.dataSpecification=dataSpecification;this.dataSpecificationContent=dataSpecificationContent;}}let DataTypeIec61360=/*#__PURE__*/function(DataTypeIec61360){DataTypeIec61360[DataTypeIec61360["Date"]=0]="Date";DataTypeIec61360[DataTypeIec61360["String"]=1]="String";DataTypeIec61360[DataTypeIec61360["StringTranslatable"]=2]="StringTranslatable";DataTypeIec61360[DataTypeIec61360["IntegerMeasure"]=3]="IntegerMeasure";DataTypeIec61360[DataTypeIec61360["IntegerCount"]=4]="IntegerCount";DataTypeIec61360[DataTypeIec61360["IntegerCurrency"]=5]="IntegerCurrency";DataTypeIec61360[DataTypeIec61360["RealMeasure"]=6]="RealMeasure";DataTypeIec61360[DataTypeIec61360["RealCount"]=7]="RealCount";DataTypeIec61360[DataTypeIec61360["RealCurrency"]=8]="RealCurrency";DataTypeIec61360[DataTypeIec61360["Boolean"]=9]="Boolean";DataTypeIec61360[DataTypeIec61360["Iri"]=10]="Iri";DataTypeIec61360[DataTypeIec61360["Irdi"]=11]="Irdi";DataTypeIec61360[DataTypeIec61360["Rational"]=12]="Rational";DataTypeIec61360[DataTypeIec61360["RationalMeasure"]=13]="RationalMeasure";DataTypeIec61360[DataTypeIec61360["Time"]=14]="Time";DataTypeIec61360[DataTypeIec61360["Timestamp"]=15]="Timestamp";DataTypeIec61360[DataTypeIec61360["File"]=16]="File";DataTypeIec61360[DataTypeIec61360["Html"]=17]="Html";DataTypeIec61360[DataTypeIec61360["Blob"]=18]="Blob";return DataTypeIec61360;}({});/**
|
|
7314
7421
|
* Value represented by up to four variants of a numeric value in a specific role:
|
|
7315
7422
|
* `MIN`, `NOM`, `TYP` and `MAX`. True means that the value is available,
|
|
7316
7423
|
* false means the value is not available.
|
|
@@ -7727,7 +7834,12 @@ return 37;// DataSpecificationIec61360
|
|
|
7727
7834
|
*
|
|
7728
7835
|
* @param that - instance to be transformed
|
|
7729
7836
|
* @returns transformed `that`
|
|
7730
|
-
*/}
|
|
7837
|
+
*/}/**
|
|
7838
|
+
* Check the type of `that` instance.
|
|
7839
|
+
*
|
|
7840
|
+
* @param that - instance to be type-checked
|
|
7841
|
+
* @returns `true` if the type check is successful
|
|
7842
|
+
*/function isMultiLanguageProperty(that){return that instanceof MultiLanguageProperty;}// Do NOT edit or append.
|
|
7731
7843
|
|
|
7732
7844
|
/**
|
|
7733
7845
|
* Convert an API SpecificAssetId to a Core Works SpecificAssetId
|
|
@@ -7884,7 +7996,6 @@ class AasDiscoveryClient {
|
|
|
7884
7996
|
cursor: cursor,
|
|
7885
7997
|
});
|
|
7886
7998
|
const shellIds = result.result ?? [];
|
|
7887
|
-
console.log('all shellIds:', shellIds);
|
|
7888
7999
|
return {
|
|
7889
8000
|
success: true,
|
|
7890
8001
|
data: { pagedResult: result.pagingMetadata, result: shellIds },
|
|
@@ -7914,7 +8025,6 @@ class AasDiscoveryClient {
|
|
|
7914
8025
|
aasIdentifier: encodedAasIdentifier,
|
|
7915
8026
|
specificAssetId: specificAssetId.map(convertCoreAssetIdToApiAssetId),
|
|
7916
8027
|
});
|
|
7917
|
-
console.log('created asset links:', result);
|
|
7918
8028
|
return { success: true, data: result.map(convertApiAssetIdToCoreAssetId) };
|
|
7919
8029
|
}
|
|
7920
8030
|
catch (err) {
|
|
@@ -8528,18 +8638,6 @@ class SetterForExtension {
|
|
|
8528
8638
|
value = null;
|
|
8529
8639
|
refersTo = null;
|
|
8530
8640
|
|
|
8531
|
-
/**
|
|
8532
|
-
* Ignore `jsonable` and do not set anything.
|
|
8533
|
-
*
|
|
8534
|
-
* @param jsonable - to be ignored instead of set
|
|
8535
|
-
* @returns error, if any
|
|
8536
|
-
*/
|
|
8537
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
8538
|
-
ignore(jsonable) {
|
|
8539
|
-
// Intentionally empty.
|
|
8540
|
-
return null;
|
|
8541
|
-
}
|
|
8542
|
-
|
|
8543
8641
|
/**
|
|
8544
8642
|
* Parse `jsonable` as the value of {@link semanticId}.
|
|
8545
8643
|
*
|
|
@@ -8722,18 +8820,6 @@ class SetterForAdministrativeInformation {
|
|
|
8722
8820
|
creator = null;
|
|
8723
8821
|
templateId = null;
|
|
8724
8822
|
|
|
8725
|
-
/**
|
|
8726
|
-
* Ignore `jsonable` and do not set anything.
|
|
8727
|
-
*
|
|
8728
|
-
* @param jsonable - to be ignored instead of set
|
|
8729
|
-
* @returns error, if any
|
|
8730
|
-
*/
|
|
8731
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
8732
|
-
ignore(jsonable) {
|
|
8733
|
-
// Intentionally empty.
|
|
8734
|
-
return null;
|
|
8735
|
-
}
|
|
8736
|
-
|
|
8737
8823
|
/**
|
|
8738
8824
|
* Parse `jsonable` as the value of {@link embeddedDataSpecifications}.
|
|
8739
8825
|
*
|
|
@@ -8899,18 +8985,6 @@ class SetterForSpecificAssetId {
|
|
|
8899
8985
|
value = null;
|
|
8900
8986
|
externalSubjectId = null;
|
|
8901
8987
|
|
|
8902
|
-
/**
|
|
8903
|
-
* Ignore `jsonable` and do not set anything.
|
|
8904
|
-
*
|
|
8905
|
-
* @param jsonable - to be ignored instead of set
|
|
8906
|
-
* @returns error, if any
|
|
8907
|
-
*/
|
|
8908
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
8909
|
-
ignore(jsonable) {
|
|
8910
|
-
// Intentionally empty.
|
|
8911
|
-
return null;
|
|
8912
|
-
}
|
|
8913
|
-
|
|
8914
8988
|
/**
|
|
8915
8989
|
* Parse `jsonable` as the value of {@link semanticId}.
|
|
8916
8990
|
*
|
|
@@ -9080,18 +9154,6 @@ class SetterForReference {
|
|
|
9080
9154
|
referredSemanticId = null;
|
|
9081
9155
|
keys = null;
|
|
9082
9156
|
|
|
9083
|
-
/**
|
|
9084
|
-
* Ignore `jsonable` and do not set anything.
|
|
9085
|
-
*
|
|
9086
|
-
* @param jsonable - to be ignored instead of set
|
|
9087
|
-
* @returns error, if any
|
|
9088
|
-
*/
|
|
9089
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
9090
|
-
ignore(jsonable) {
|
|
9091
|
-
// Intentionally empty.
|
|
9092
|
-
return null;
|
|
9093
|
-
}
|
|
9094
|
-
|
|
9095
9157
|
/**
|
|
9096
9158
|
* Parse `jsonable` as the value of {@link type}.
|
|
9097
9159
|
*
|
|
@@ -9210,18 +9272,6 @@ class SetterForKey {
|
|
|
9210
9272
|
type = null;
|
|
9211
9273
|
value = null;
|
|
9212
9274
|
|
|
9213
|
-
/**
|
|
9214
|
-
* Ignore `jsonable` and do not set anything.
|
|
9215
|
-
*
|
|
9216
|
-
* @param jsonable - to be ignored instead of set
|
|
9217
|
-
* @returns error, if any
|
|
9218
|
-
*/
|
|
9219
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
9220
|
-
ignore(jsonable) {
|
|
9221
|
-
// Intentionally empty.
|
|
9222
|
-
return null;
|
|
9223
|
-
}
|
|
9224
|
-
|
|
9225
9275
|
/**
|
|
9226
9276
|
* Parse `jsonable` as the value of {@link type}.
|
|
9227
9277
|
*
|
|
@@ -9344,18 +9394,6 @@ class SetterForLangStringNameType {
|
|
|
9344
9394
|
language = null;
|
|
9345
9395
|
text = null;
|
|
9346
9396
|
|
|
9347
|
-
/**
|
|
9348
|
-
* Ignore `jsonable` and do not set anything.
|
|
9349
|
-
*
|
|
9350
|
-
* @param jsonable - to be ignored instead of set
|
|
9351
|
-
* @returns error, if any
|
|
9352
|
-
*/
|
|
9353
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
9354
|
-
ignore(jsonable) {
|
|
9355
|
-
// Intentionally empty.
|
|
9356
|
-
return null;
|
|
9357
|
-
}
|
|
9358
|
-
|
|
9359
9397
|
/**
|
|
9360
9398
|
* Parse `jsonable` as the value of {@link language}.
|
|
9361
9399
|
*
|
|
@@ -9442,18 +9480,6 @@ class SetterForLangStringTextType {
|
|
|
9442
9480
|
language = null;
|
|
9443
9481
|
text = null;
|
|
9444
9482
|
|
|
9445
|
-
/**
|
|
9446
|
-
* Ignore `jsonable` and do not set anything.
|
|
9447
|
-
*
|
|
9448
|
-
* @param jsonable - to be ignored instead of set
|
|
9449
|
-
* @returns error, if any
|
|
9450
|
-
*/
|
|
9451
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
9452
|
-
ignore(jsonable) {
|
|
9453
|
-
// Intentionally empty.
|
|
9454
|
-
return null;
|
|
9455
|
-
}
|
|
9456
|
-
|
|
9457
9483
|
/**
|
|
9458
9484
|
* Parse `jsonable` as the value of {@link language}.
|
|
9459
9485
|
*
|
|
@@ -9551,7 +9577,7 @@ function dataSpecificationContentFromJsonable(jsonable) {
|
|
|
9551
9577
|
}
|
|
9552
9578
|
const modelType = jsonable["modelType"];
|
|
9553
9579
|
if (modelType === undefined) {
|
|
9554
|
-
return newDeserializationError("
|
|
9580
|
+
return newDeserializationError("The required property modelType is missing");
|
|
9555
9581
|
}
|
|
9556
9582
|
if (typeof modelType !== "string") {
|
|
9557
9583
|
return newDeserializationError(`Expected the property modelType to be a string, but got: ${typeof modelType}`);
|
|
@@ -9568,49 +9594,37 @@ function dataSpecificationContentFromJsonable(jsonable) {
|
|
|
9568
9594
|
* of {@link types!EmbeddedDataSpecification}.
|
|
9569
9595
|
*/
|
|
9570
9596
|
class SetterForEmbeddedDataSpecification {
|
|
9571
|
-
dataSpecificationContent = null;
|
|
9572
9597
|
dataSpecification = null;
|
|
9598
|
+
dataSpecificationContent = null;
|
|
9573
9599
|
|
|
9574
9600
|
/**
|
|
9575
|
-
*
|
|
9576
|
-
*
|
|
9577
|
-
* @param jsonable - to be ignored instead of set
|
|
9578
|
-
* @returns error, if any
|
|
9579
|
-
*/
|
|
9580
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
9581
|
-
ignore(jsonable) {
|
|
9582
|
-
// Intentionally empty.
|
|
9583
|
-
return null;
|
|
9584
|
-
}
|
|
9585
|
-
|
|
9586
|
-
/**
|
|
9587
|
-
* Parse `jsonable` as the value of {@link dataSpecificationContent}.
|
|
9601
|
+
* Parse `jsonable` as the value of {@link dataSpecification}.
|
|
9588
9602
|
*
|
|
9589
9603
|
* @param jsonable - to be parsed
|
|
9590
9604
|
* @returns error, if any
|
|
9591
9605
|
*/
|
|
9592
|
-
|
|
9593
|
-
const parsedOrError =
|
|
9606
|
+
setDataSpecificationFromJsonable(jsonable) {
|
|
9607
|
+
const parsedOrError = referenceFromJsonable(jsonable);
|
|
9594
9608
|
if (parsedOrError.error !== null) {
|
|
9595
9609
|
return parsedOrError.error;
|
|
9596
9610
|
} else {
|
|
9597
|
-
this.
|
|
9611
|
+
this.dataSpecification = parsedOrError.mustValue();
|
|
9598
9612
|
return null;
|
|
9599
9613
|
}
|
|
9600
9614
|
}
|
|
9601
9615
|
|
|
9602
9616
|
/**
|
|
9603
|
-
* Parse `jsonable` as the value of {@link
|
|
9617
|
+
* Parse `jsonable` as the value of {@link dataSpecificationContent}.
|
|
9604
9618
|
*
|
|
9605
9619
|
* @param jsonable - to be parsed
|
|
9606
9620
|
* @returns error, if any
|
|
9607
9621
|
*/
|
|
9608
|
-
|
|
9609
|
-
const parsedOrError =
|
|
9622
|
+
setDataSpecificationContentFromJsonable(jsonable) {
|
|
9623
|
+
const parsedOrError = dataSpecificationContentFromJsonable(jsonable);
|
|
9610
9624
|
if (parsedOrError.error !== null) {
|
|
9611
9625
|
return parsedOrError.error;
|
|
9612
9626
|
} else {
|
|
9613
|
-
this.
|
|
9627
|
+
this.dataSpecificationContent = parsedOrError.mustValue();
|
|
9614
9628
|
return null;
|
|
9615
9629
|
}
|
|
9616
9630
|
}
|
|
@@ -9652,10 +9666,13 @@ function embeddedDataSpecificationFromJsonable(jsonable) {
|
|
|
9652
9666
|
return new Either(null, error);
|
|
9653
9667
|
}
|
|
9654
9668
|
}
|
|
9669
|
+
if (setter.dataSpecification === null) {
|
|
9670
|
+
return newDeserializationError("The required property 'dataSpecification' is missing");
|
|
9671
|
+
}
|
|
9655
9672
|
if (setter.dataSpecificationContent === null) {
|
|
9656
9673
|
return newDeserializationError("The required property 'dataSpecificationContent' is missing");
|
|
9657
9674
|
}
|
|
9658
|
-
return new Either(new EmbeddedDataSpecification(setter.
|
|
9675
|
+
return new Either(new EmbeddedDataSpecification(setter.dataSpecification, setter.dataSpecificationContent), null);
|
|
9659
9676
|
}
|
|
9660
9677
|
|
|
9661
9678
|
/**
|
|
@@ -9686,18 +9703,6 @@ class SetterForLevelType {
|
|
|
9686
9703
|
typ = null;
|
|
9687
9704
|
max = null;
|
|
9688
9705
|
|
|
9689
|
-
/**
|
|
9690
|
-
* Ignore `jsonable` and do not set anything.
|
|
9691
|
-
*
|
|
9692
|
-
* @param jsonable - to be ignored instead of set
|
|
9693
|
-
* @returns error, if any
|
|
9694
|
-
*/
|
|
9695
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
9696
|
-
ignore(jsonable) {
|
|
9697
|
-
// Intentionally empty.
|
|
9698
|
-
return null;
|
|
9699
|
-
}
|
|
9700
|
-
|
|
9701
9706
|
/**
|
|
9702
9707
|
* Parse `jsonable` as the value of {@link min}.
|
|
9703
9708
|
*
|
|
@@ -9822,18 +9827,6 @@ class SetterForValueReferencePair {
|
|
|
9822
9827
|
value = null;
|
|
9823
9828
|
valueId = null;
|
|
9824
9829
|
|
|
9825
|
-
/**
|
|
9826
|
-
* Ignore `jsonable` and do not set anything.
|
|
9827
|
-
*
|
|
9828
|
-
* @param jsonable - to be ignored instead of set
|
|
9829
|
-
* @returns error, if any
|
|
9830
|
-
*/
|
|
9831
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
9832
|
-
ignore(jsonable) {
|
|
9833
|
-
// Intentionally empty.
|
|
9834
|
-
return null;
|
|
9835
|
-
}
|
|
9836
|
-
|
|
9837
9830
|
/**
|
|
9838
9831
|
* Parse `jsonable` as the value of {@link value}.
|
|
9839
9832
|
*
|
|
@@ -9919,18 +9912,6 @@ function valueReferencePairFromJsonable(jsonable) {
|
|
|
9919
9912
|
class SetterForValueList {
|
|
9920
9913
|
valueReferencePairs = null;
|
|
9921
9914
|
|
|
9922
|
-
/**
|
|
9923
|
-
* Ignore `jsonable` and do not set anything.
|
|
9924
|
-
*
|
|
9925
|
-
* @param jsonable - to be ignored instead of set
|
|
9926
|
-
* @returns error, if any
|
|
9927
|
-
*/
|
|
9928
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
9929
|
-
ignore(jsonable) {
|
|
9930
|
-
// Intentionally empty.
|
|
9931
|
-
return null;
|
|
9932
|
-
}
|
|
9933
|
-
|
|
9934
9915
|
/**
|
|
9935
9916
|
* Parse `jsonable` as the value of {@link valueReferencePairs}.
|
|
9936
9917
|
*
|
|
@@ -10014,18 +9995,6 @@ class SetterForLangStringPreferredNameTypeIec61360 {
|
|
|
10014
9995
|
language = null;
|
|
10015
9996
|
text = null;
|
|
10016
9997
|
|
|
10017
|
-
/**
|
|
10018
|
-
* Ignore `jsonable` and do not set anything.
|
|
10019
|
-
*
|
|
10020
|
-
* @param jsonable - to be ignored instead of set
|
|
10021
|
-
* @returns error, if any
|
|
10022
|
-
*/
|
|
10023
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
10024
|
-
ignore(jsonable) {
|
|
10025
|
-
// Intentionally empty.
|
|
10026
|
-
return null;
|
|
10027
|
-
}
|
|
10028
|
-
|
|
10029
9998
|
/**
|
|
10030
9999
|
* Parse `jsonable` as the value of {@link language}.
|
|
10031
10000
|
*
|
|
@@ -10112,18 +10081,6 @@ class SetterForLangStringShortNameTypeIec61360 {
|
|
|
10112
10081
|
language = null;
|
|
10113
10082
|
text = null;
|
|
10114
10083
|
|
|
10115
|
-
/**
|
|
10116
|
-
* Ignore `jsonable` and do not set anything.
|
|
10117
|
-
*
|
|
10118
|
-
* @param jsonable - to be ignored instead of set
|
|
10119
|
-
* @returns error, if any
|
|
10120
|
-
*/
|
|
10121
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
10122
|
-
ignore(jsonable) {
|
|
10123
|
-
// Intentionally empty.
|
|
10124
|
-
return null;
|
|
10125
|
-
}
|
|
10126
|
-
|
|
10127
10084
|
/**
|
|
10128
10085
|
* Parse `jsonable` as the value of {@link language}.
|
|
10129
10086
|
*
|
|
@@ -10210,18 +10167,6 @@ class SetterForLangStringDefinitionTypeIec61360 {
|
|
|
10210
10167
|
language = null;
|
|
10211
10168
|
text = null;
|
|
10212
10169
|
|
|
10213
|
-
/**
|
|
10214
|
-
* Ignore `jsonable` and do not set anything.
|
|
10215
|
-
*
|
|
10216
|
-
* @param jsonable - to be ignored instead of set
|
|
10217
|
-
* @returns error, if any
|
|
10218
|
-
*/
|
|
10219
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
10220
|
-
ignore(jsonable) {
|
|
10221
|
-
// Intentionally empty.
|
|
10222
|
-
return null;
|
|
10223
|
-
}
|
|
10224
|
-
|
|
10225
10170
|
/**
|
|
10226
10171
|
* Parse `jsonable` as the value of {@link language}.
|
|
10227
10172
|
*
|
|
@@ -10318,17 +10263,8 @@ class SetterForDataSpecificationIec61360 {
|
|
|
10318
10263
|
value = null;
|
|
10319
10264
|
levelType = null;
|
|
10320
10265
|
|
|
10321
|
-
|
|
10322
|
-
|
|
10323
|
-
*
|
|
10324
|
-
* @param jsonable - to be ignored instead of set
|
|
10325
|
-
* @returns error, if any
|
|
10326
|
-
*/
|
|
10327
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
10328
|
-
ignore(jsonable) {
|
|
10329
|
-
// Intentionally empty.
|
|
10330
|
-
return null;
|
|
10331
|
-
}
|
|
10266
|
+
// Used only for verification, not for dispatch!
|
|
10267
|
+
modelType = null;
|
|
10332
10268
|
|
|
10333
10269
|
/**
|
|
10334
10270
|
* Parse `jsonable` as the value of {@link preferredName}.
|
|
@@ -10569,6 +10505,24 @@ class SetterForDataSpecificationIec61360 {
|
|
|
10569
10505
|
return null;
|
|
10570
10506
|
}
|
|
10571
10507
|
}
|
|
10508
|
+
|
|
10509
|
+
/**
|
|
10510
|
+
* Parse `jsonable` as the model type of the concrete instance.
|
|
10511
|
+
*
|
|
10512
|
+
* This is intended only for verification, and no dispatch is performed.
|
|
10513
|
+
*
|
|
10514
|
+
* @param jsonable - to be parsed
|
|
10515
|
+
* @returns error, if any
|
|
10516
|
+
*/
|
|
10517
|
+
setModelTypeFromJsonable(jsonable) {
|
|
10518
|
+
const parsedOrError = stringFromJsonable(jsonable);
|
|
10519
|
+
if (parsedOrError.error !== null) {
|
|
10520
|
+
return parsedOrError.error;
|
|
10521
|
+
} else {
|
|
10522
|
+
this.modelType = parsedOrError.mustValue();
|
|
10523
|
+
return null;
|
|
10524
|
+
}
|
|
10525
|
+
}
|
|
10572
10526
|
}
|
|
10573
10527
|
|
|
10574
10528
|
/**
|
|
@@ -10610,24 +10564,31 @@ function dataSpecificationIec61360FromJsonable(jsonable) {
|
|
|
10610
10564
|
if (setter.preferredName === null) {
|
|
10611
10565
|
return newDeserializationError("The required property 'preferredName' is missing");
|
|
10612
10566
|
}
|
|
10567
|
+
if (setter.modelType === null) {
|
|
10568
|
+
return newDeserializationError("The required property 'modelType' is missing");
|
|
10569
|
+
} else if (setter.modelType != "DataSpecificationIec61360") {
|
|
10570
|
+
return newDeserializationError("Expected model type 'DataSpecificationIec61360', " + `but got: ${setter.modelType}`);
|
|
10571
|
+
}
|
|
10613
10572
|
return new Either(new DataSpecificationIec61360(setter.preferredName, setter.shortName, setter.unit, setter.unitId, setter.sourceOfDefinition, setter.symbol, setter.dataType, setter.definition, setter.valueFormat, setter.valueList, setter.value, setter.levelType), null);
|
|
10614
10573
|
}
|
|
10615
|
-
const SETTER_MAP_FOR_EXTENSION = new Map([["semanticId", SetterForExtension.prototype.setSemanticIdFromJsonable], ["supplementalSemanticIds", SetterForExtension.prototype.setSupplementalSemanticIdsFromJsonable], ["name", SetterForExtension.prototype.setNameFromJsonable], ["valueType", SetterForExtension.prototype.setValueTypeFromJsonable], ["value", SetterForExtension.prototype.setValueFromJsonable], ["refersTo", SetterForExtension.prototype.setRefersToFromJsonable]
|
|
10616
|
-
const SETTER_MAP_FOR_ADMINISTRATIVE_INFORMATION = new Map([["embeddedDataSpecifications", SetterForAdministrativeInformation.prototype.setEmbeddedDataSpecificationsFromJsonable], ["version", SetterForAdministrativeInformation.prototype.setVersionFromJsonable], ["revision", SetterForAdministrativeInformation.prototype.setRevisionFromJsonable], ["creator", SetterForAdministrativeInformation.prototype.setCreatorFromJsonable], ["templateId", SetterForAdministrativeInformation.prototype.setTemplateIdFromJsonable]
|
|
10617
|
-
const SETTER_MAP_FOR_SPECIFIC_ASSET_ID = new Map([["semanticId", SetterForSpecificAssetId.prototype.setSemanticIdFromJsonable], ["supplementalSemanticIds", SetterForSpecificAssetId.prototype.setSupplementalSemanticIdsFromJsonable], ["name", SetterForSpecificAssetId.prototype.setNameFromJsonable], ["value", SetterForSpecificAssetId.prototype.setValueFromJsonable], ["externalSubjectId", SetterForSpecificAssetId.prototype.setExternalSubjectIdFromJsonable]
|
|
10618
|
-
const SETTER_MAP_FOR_REFERENCE = new Map([["type", SetterForReference.prototype.setTypeFromJsonable], ["referredSemanticId", SetterForReference.prototype.setReferredSemanticIdFromJsonable], ["keys", SetterForReference.prototype.setKeysFromJsonable]
|
|
10619
|
-
const SETTER_MAP_FOR_KEY = new Map([["type", SetterForKey.prototype.setTypeFromJsonable], ["value", SetterForKey.prototype.setValueFromJsonable]
|
|
10620
|
-
const SETTER_MAP_FOR_LANG_STRING_NAME_TYPE = new Map([["language", SetterForLangStringNameType.prototype.setLanguageFromJsonable], ["text", SetterForLangStringNameType.prototype.setTextFromJsonable]
|
|
10621
|
-
const SETTER_MAP_FOR_LANG_STRING_TEXT_TYPE = new Map([["language", SetterForLangStringTextType.prototype.setLanguageFromJsonable], ["text", SetterForLangStringTextType.prototype.setTextFromJsonable]
|
|
10574
|
+
const SETTER_MAP_FOR_EXTENSION = new Map([["semanticId", SetterForExtension.prototype.setSemanticIdFromJsonable], ["supplementalSemanticIds", SetterForExtension.prototype.setSupplementalSemanticIdsFromJsonable], ["name", SetterForExtension.prototype.setNameFromJsonable], ["valueType", SetterForExtension.prototype.setValueTypeFromJsonable], ["value", SetterForExtension.prototype.setValueFromJsonable], ["refersTo", SetterForExtension.prototype.setRefersToFromJsonable]]);
|
|
10575
|
+
const SETTER_MAP_FOR_ADMINISTRATIVE_INFORMATION = new Map([["embeddedDataSpecifications", SetterForAdministrativeInformation.prototype.setEmbeddedDataSpecificationsFromJsonable], ["version", SetterForAdministrativeInformation.prototype.setVersionFromJsonable], ["revision", SetterForAdministrativeInformation.prototype.setRevisionFromJsonable], ["creator", SetterForAdministrativeInformation.prototype.setCreatorFromJsonable], ["templateId", SetterForAdministrativeInformation.prototype.setTemplateIdFromJsonable]]);
|
|
10576
|
+
const SETTER_MAP_FOR_SPECIFIC_ASSET_ID = new Map([["semanticId", SetterForSpecificAssetId.prototype.setSemanticIdFromJsonable], ["supplementalSemanticIds", SetterForSpecificAssetId.prototype.setSupplementalSemanticIdsFromJsonable], ["name", SetterForSpecificAssetId.prototype.setNameFromJsonable], ["value", SetterForSpecificAssetId.prototype.setValueFromJsonable], ["externalSubjectId", SetterForSpecificAssetId.prototype.setExternalSubjectIdFromJsonable]]);
|
|
10577
|
+
const SETTER_MAP_FOR_REFERENCE = new Map([["type", SetterForReference.prototype.setTypeFromJsonable], ["referredSemanticId", SetterForReference.prototype.setReferredSemanticIdFromJsonable], ["keys", SetterForReference.prototype.setKeysFromJsonable]]);
|
|
10578
|
+
const SETTER_MAP_FOR_KEY = new Map([["type", SetterForKey.prototype.setTypeFromJsonable], ["value", SetterForKey.prototype.setValueFromJsonable]]);
|
|
10579
|
+
const SETTER_MAP_FOR_LANG_STRING_NAME_TYPE = new Map([["language", SetterForLangStringNameType.prototype.setLanguageFromJsonable], ["text", SetterForLangStringNameType.prototype.setTextFromJsonable]]);
|
|
10580
|
+
const SETTER_MAP_FOR_LANG_STRING_TEXT_TYPE = new Map([["language", SetterForLangStringTextType.prototype.setLanguageFromJsonable], ["text", SetterForLangStringTextType.prototype.setTextFromJsonable]]);
|
|
10622
10581
|
const DATA_SPECIFICATION_CONTENT_FROM_JSONABLE_DISPATCH = new Map([["DataSpecificationIec61360", dataSpecificationIec61360FromJsonable]]);
|
|
10623
|
-
const SETTER_MAP_FOR_EMBEDDED_DATA_SPECIFICATION = new Map([["
|
|
10624
|
-
const SETTER_MAP_FOR_LEVEL_TYPE = new Map([["min", SetterForLevelType.prototype.setMinFromJsonable], ["nom", SetterForLevelType.prototype.setNomFromJsonable], ["typ", SetterForLevelType.prototype.setTypFromJsonable], ["max", SetterForLevelType.prototype.setMaxFromJsonable]
|
|
10625
|
-
const SETTER_MAP_FOR_VALUE_REFERENCE_PAIR = new Map([["value", SetterForValueReferencePair.prototype.setValueFromJsonable], ["valueId", SetterForValueReferencePair.prototype.setValueIdFromJsonable]
|
|
10626
|
-
const SETTER_MAP_FOR_VALUE_LIST = new Map([["valueReferencePairs", SetterForValueList.prototype.setValueReferencePairsFromJsonable]
|
|
10627
|
-
const SETTER_MAP_FOR_LANG_STRING_PREFERRED_NAME_TYPE_IEC_61360 = new Map([["language", SetterForLangStringPreferredNameTypeIec61360.prototype.setLanguageFromJsonable], ["text", SetterForLangStringPreferredNameTypeIec61360.prototype.setTextFromJsonable]
|
|
10628
|
-
const SETTER_MAP_FOR_LANG_STRING_SHORT_NAME_TYPE_IEC_61360 = new Map([["language", SetterForLangStringShortNameTypeIec61360.prototype.setLanguageFromJsonable], ["text", SetterForLangStringShortNameTypeIec61360.prototype.setTextFromJsonable]
|
|
10629
|
-
const SETTER_MAP_FOR_LANG_STRING_DEFINITION_TYPE_IEC_61360 = new Map([["language", SetterForLangStringDefinitionTypeIec61360.prototype.setLanguageFromJsonable], ["text", SetterForLangStringDefinitionTypeIec61360.prototype.setTextFromJsonable]
|
|
10630
|
-
const SETTER_MAP_FOR_DATA_SPECIFICATION_IEC_61360 = new Map([["preferredName", SetterForDataSpecificationIec61360.prototype.setPreferredNameFromJsonable], ["shortName", SetterForDataSpecificationIec61360.prototype.setShortNameFromJsonable], ["unit", SetterForDataSpecificationIec61360.prototype.setUnitFromJsonable], ["unitId", SetterForDataSpecificationIec61360.prototype.setUnitIdFromJsonable], ["sourceOfDefinition", SetterForDataSpecificationIec61360.prototype.setSourceOfDefinitionFromJsonable], ["symbol", SetterForDataSpecificationIec61360.prototype.setSymbolFromJsonable], ["dataType", SetterForDataSpecificationIec61360.prototype.setDataTypeFromJsonable], ["definition", SetterForDataSpecificationIec61360.prototype.setDefinitionFromJsonable], ["valueFormat", SetterForDataSpecificationIec61360.prototype.setValueFormatFromJsonable], ["valueList", SetterForDataSpecificationIec61360.prototype.setValueListFromJsonable], ["value", SetterForDataSpecificationIec61360.prototype.setValueFromJsonable], ["levelType", SetterForDataSpecificationIec61360.prototype.setLevelTypeFromJsonable], [
|
|
10582
|
+
const SETTER_MAP_FOR_EMBEDDED_DATA_SPECIFICATION = new Map([["dataSpecification", SetterForEmbeddedDataSpecification.prototype.setDataSpecificationFromJsonable], ["dataSpecificationContent", SetterForEmbeddedDataSpecification.prototype.setDataSpecificationContentFromJsonable]]);
|
|
10583
|
+
const SETTER_MAP_FOR_LEVEL_TYPE = new Map([["min", SetterForLevelType.prototype.setMinFromJsonable], ["nom", SetterForLevelType.prototype.setNomFromJsonable], ["typ", SetterForLevelType.prototype.setTypFromJsonable], ["max", SetterForLevelType.prototype.setMaxFromJsonable]]);
|
|
10584
|
+
const SETTER_MAP_FOR_VALUE_REFERENCE_PAIR = new Map([["value", SetterForValueReferencePair.prototype.setValueFromJsonable], ["valueId", SetterForValueReferencePair.prototype.setValueIdFromJsonable]]);
|
|
10585
|
+
const SETTER_MAP_FOR_VALUE_LIST = new Map([["valueReferencePairs", SetterForValueList.prototype.setValueReferencePairsFromJsonable]]);
|
|
10586
|
+
const SETTER_MAP_FOR_LANG_STRING_PREFERRED_NAME_TYPE_IEC_61360 = new Map([["language", SetterForLangStringPreferredNameTypeIec61360.prototype.setLanguageFromJsonable], ["text", SetterForLangStringPreferredNameTypeIec61360.prototype.setTextFromJsonable]]);
|
|
10587
|
+
const SETTER_MAP_FOR_LANG_STRING_SHORT_NAME_TYPE_IEC_61360 = new Map([["language", SetterForLangStringShortNameTypeIec61360.prototype.setLanguageFromJsonable], ["text", SetterForLangStringShortNameTypeIec61360.prototype.setTextFromJsonable]]);
|
|
10588
|
+
const SETTER_MAP_FOR_LANG_STRING_DEFINITION_TYPE_IEC_61360 = new Map([["language", SetterForLangStringDefinitionTypeIec61360.prototype.setLanguageFromJsonable], ["text", SetterForLangStringDefinitionTypeIec61360.prototype.setTextFromJsonable]]);
|
|
10589
|
+
const SETTER_MAP_FOR_DATA_SPECIFICATION_IEC_61360 = new Map([["preferredName", SetterForDataSpecificationIec61360.prototype.setPreferredNameFromJsonable], ["shortName", SetterForDataSpecificationIec61360.prototype.setShortNameFromJsonable], ["unit", SetterForDataSpecificationIec61360.prototype.setUnitFromJsonable], ["unitId", SetterForDataSpecificationIec61360.prototype.setUnitIdFromJsonable], ["sourceOfDefinition", SetterForDataSpecificationIec61360.prototype.setSourceOfDefinitionFromJsonable], ["symbol", SetterForDataSpecificationIec61360.prototype.setSymbolFromJsonable], ["dataType", SetterForDataSpecificationIec61360.prototype.setDataTypeFromJsonable], ["definition", SetterForDataSpecificationIec61360.prototype.setDefinitionFromJsonable], ["valueFormat", SetterForDataSpecificationIec61360.prototype.setValueFormatFromJsonable], ["valueList", SetterForDataSpecificationIec61360.prototype.setValueListFromJsonable], ["value", SetterForDataSpecificationIec61360.prototype.setValueFromJsonable], ["levelType", SetterForDataSpecificationIec61360.prototype.setLevelTypeFromJsonable], [
|
|
10590
|
+
// The model type here is used only for verification, not for dispatch.
|
|
10591
|
+
"modelType", SetterForDataSpecificationIec61360.prototype.setModelTypeFromJsonable]]);
|
|
10631
10592
|
|
|
10632
10593
|
// endregion
|
|
10633
10594
|
|
|
@@ -12147,10 +12108,8 @@ class Serializer extends AbstractTransformer {
|
|
|
12147
12108
|
*/
|
|
12148
12109
|
transformEmbeddedDataSpecification(that) {
|
|
12149
12110
|
const jsonable = {};
|
|
12111
|
+
jsonable["dataSpecification"] = this.transform(that.dataSpecification);
|
|
12150
12112
|
jsonable["dataSpecificationContent"] = this.transform(that.dataSpecificationContent);
|
|
12151
|
-
if (that.dataSpecification !== null) {
|
|
12152
|
-
jsonable["dataSpecification"] = this.transform(that.dataSpecification);
|
|
12153
|
-
}
|
|
12154
12113
|
return jsonable;
|
|
12155
12114
|
}
|
|
12156
12115
|
|
|
@@ -12364,13 +12323,29 @@ class SubmodelDescriptor {
|
|
|
12364
12323
|
this.extensions = extensions;
|
|
12365
12324
|
}
|
|
12366
12325
|
}
|
|
12367
|
-
|
|
12326
|
+
exports.ProtocolInformationSecurityAttributesTypeEnum = void 0;
|
|
12368
12327
|
(function (ProtocolInformationSecurityAttributesTypeEnum) {
|
|
12369
12328
|
ProtocolInformationSecurityAttributesTypeEnum[ProtocolInformationSecurityAttributesTypeEnum["None"] = 0] = "None";
|
|
12370
12329
|
ProtocolInformationSecurityAttributesTypeEnum[ProtocolInformationSecurityAttributesTypeEnum["RfcTlsa"] = 1] = "RfcTlsa";
|
|
12371
12330
|
ProtocolInformationSecurityAttributesTypeEnum[ProtocolInformationSecurityAttributesTypeEnum["W3CDid"] = 2] = "W3CDid";
|
|
12372
|
-
})(ProtocolInformationSecurityAttributesTypeEnum || (ProtocolInformationSecurityAttributesTypeEnum = {}));
|
|
12331
|
+
})(exports.ProtocolInformationSecurityAttributesTypeEnum || (exports.ProtocolInformationSecurityAttributesTypeEnum = {}));
|
|
12373
12332
|
|
|
12333
|
+
/**
|
|
12334
|
+
* Convert AssetKind enum to its JSON string representation.
|
|
12335
|
+
* The Core library uses numeric enums (e.g., Instance = 1), but the API expects strings.
|
|
12336
|
+
*/
|
|
12337
|
+
function assetKindToJsonable(assetKind) {
|
|
12338
|
+
switch (assetKind) {
|
|
12339
|
+
case AssetKind.Instance:
|
|
12340
|
+
return 'Instance';
|
|
12341
|
+
case AssetKind.Type:
|
|
12342
|
+
return 'Type';
|
|
12343
|
+
case AssetKind.NotApplicable:
|
|
12344
|
+
return 'NotApplicable';
|
|
12345
|
+
default:
|
|
12346
|
+
throw new Error(`Unknown AssetKind value: ${assetKind}`);
|
|
12347
|
+
}
|
|
12348
|
+
}
|
|
12374
12349
|
function assetAdministrationShellDescriptorFromJsonable(json) {
|
|
12375
12350
|
if (json === null) {
|
|
12376
12351
|
return new aasCore3_0Typescript.common.Either(null, new DeserializationError('Expected a JSON object, but got null'));
|
|
@@ -12477,7 +12452,9 @@ function toJsonableAssetAdministrationShellDescriptor(descriptor) {
|
|
|
12477
12452
|
extensions: descriptor.extensions.map(toJsonable),
|
|
12478
12453
|
}),
|
|
12479
12454
|
...(descriptor.administration !== null && { administration: toJsonable(descriptor.administration) }),
|
|
12480
|
-
...(descriptor.assetKind !== null && {
|
|
12455
|
+
...(descriptor.assetKind !== null && {
|
|
12456
|
+
assetKind: assetKindToJsonable(descriptor.assetKind),
|
|
12457
|
+
}),
|
|
12481
12458
|
...(descriptor.assetType !== null && { assetType: descriptor.assetType }),
|
|
12482
12459
|
...(descriptor.globalAssetId !== null && { globalAssetId: descriptor.globalAssetId }),
|
|
12483
12460
|
...(descriptor.specificAssetIds !== null && {
|
|
@@ -12640,7 +12617,6 @@ class AasRegistryClient {
|
|
|
12640
12617
|
assetType: encodedAssetType,
|
|
12641
12618
|
});
|
|
12642
12619
|
const aasDescriptors = (result.result ?? []).map(convertApiAasDescriptorToCoreAasDescriptor);
|
|
12643
|
-
console.log('all aas descriptors:', aasDescriptors);
|
|
12644
12620
|
return {
|
|
12645
12621
|
success: true,
|
|
12646
12622
|
data: { pagedResult: result.pagingMetadata, result: aasDescriptors },
|
|
@@ -12667,7 +12643,6 @@ class AasRegistryClient {
|
|
|
12667
12643
|
const result = await apiInstance.postAssetAdministrationShellDescriptor({
|
|
12668
12644
|
assetAdministrationShellDescriptor: convertCoreAasDescriptorToApiAasDescriptor(assetAdministrationShellDescriptor),
|
|
12669
12645
|
});
|
|
12670
|
-
console.log('created aas descriptor:', result);
|
|
12671
12646
|
return { success: true, data: convertApiAasDescriptorToCoreAasDescriptor(result) };
|
|
12672
12647
|
}
|
|
12673
12648
|
catch (err) {
|
|
@@ -12771,7 +12746,6 @@ class AasRegistryClient {
|
|
|
12771
12746
|
cursor: cursor,
|
|
12772
12747
|
});
|
|
12773
12748
|
const submodelDescriptors = (result.result ?? []).map(convertApiSubmodelDescriptorToCoreSubmodelDescriptor);
|
|
12774
|
-
console.log('all submodel descriptors:', submodelDescriptors);
|
|
12775
12749
|
return {
|
|
12776
12750
|
success: true,
|
|
12777
12751
|
data: { pagedResult: result.pagingMetadata, result: submodelDescriptors },
|
|
@@ -12801,12 +12775,10 @@ class AasRegistryClient {
|
|
|
12801
12775
|
aasIdentifier: encodedAasIdentifier,
|
|
12802
12776
|
submodelDescriptor: convertCoreSubmodelDescriptorToApiSubmodelDescriptor(submodelDescriptor),
|
|
12803
12777
|
});
|
|
12804
|
-
console.log('created submodel descriptor:', result);
|
|
12805
12778
|
return { success: true, data: convertApiSubmodelDescriptorToCoreSubmodelDescriptor(result) };
|
|
12806
12779
|
}
|
|
12807
12780
|
catch (err) {
|
|
12808
12781
|
const customError = await handleApiError(err);
|
|
12809
|
-
//console.log('error during creation of submodel descriptor:', customError);
|
|
12810
12782
|
return { success: false, error: customError };
|
|
12811
12783
|
}
|
|
12812
12784
|
}
|
|
@@ -13999,7 +13971,6 @@ class AasRepositoryClient {
|
|
|
13999
13971
|
idShortPath: idShortPath,
|
|
14000
13972
|
submodelElement: convertCoreSubmodelElementToApiSubmodelElement(submodelElement),
|
|
14001
13973
|
});
|
|
14002
|
-
console.log('created element at specified path:', result);
|
|
14003
13974
|
return { success: true, data: convertApiSubmodelElementToCoreSubmodelElement(result) };
|
|
14004
13975
|
}
|
|
14005
13976
|
catch (err) {
|
|
@@ -14619,14 +14590,12 @@ class AasxFileClient {
|
|
|
14619
14590
|
const result = await apiInstance.getAllAASXPackageIds({
|
|
14620
14591
|
aasId: aasId,
|
|
14621
14592
|
});
|
|
14622
|
-
console.log('received packages:', result);
|
|
14623
14593
|
return {
|
|
14624
14594
|
success: true,
|
|
14625
14595
|
data: { result },
|
|
14626
14596
|
};
|
|
14627
14597
|
}
|
|
14628
14598
|
catch (err) {
|
|
14629
|
-
console.error('Failed to fetch AASX packagees:', err);
|
|
14630
14599
|
const customError = await handleApiError(err);
|
|
14631
14600
|
return { success: false, error: customError };
|
|
14632
14601
|
}
|
|
@@ -14653,11 +14622,9 @@ class AasxFileClient {
|
|
|
14653
14622
|
file: file,
|
|
14654
14623
|
fileName: fileName,
|
|
14655
14624
|
});
|
|
14656
|
-
console.log('created aasx package: ', result);
|
|
14657
14625
|
return { success: true, data: result };
|
|
14658
14626
|
}
|
|
14659
14627
|
catch (err) {
|
|
14660
|
-
console.error('Failed to create AASX package:', err);
|
|
14661
14628
|
const customError = await handleApiError(err);
|
|
14662
14629
|
return { success: false, error: customError };
|
|
14663
14630
|
}
|
|
@@ -14679,11 +14646,9 @@ class AasxFileClient {
|
|
|
14679
14646
|
const result = await apiInstance.getAASXByPackageId({
|
|
14680
14647
|
packageId: encodedPackageId,
|
|
14681
14648
|
});
|
|
14682
|
-
console.log('received aasx package by id: ', result);
|
|
14683
14649
|
return { success: true, data: result };
|
|
14684
14650
|
}
|
|
14685
14651
|
catch (err) {
|
|
14686
|
-
console.error('Failed to fetch AASX package by id:', err);
|
|
14687
14652
|
const customError = await handleApiError(err);
|
|
14688
14653
|
return { success: false, error: customError };
|
|
14689
14654
|
}
|
|
@@ -14943,7 +14908,6 @@ class SubmodelRegistryClient {
|
|
|
14943
14908
|
cursor: cursor,
|
|
14944
14909
|
});
|
|
14945
14910
|
const submodelDescriptors = (result.result ?? []).map(convertApiSubmodelDescriptorToCoreSubmodelDescriptor);
|
|
14946
|
-
console.log('all submodel descriptors:', submodelDescriptors);
|
|
14947
14911
|
return {
|
|
14948
14912
|
success: true,
|
|
14949
14913
|
data: { pagedResult: result.pagingMetadata, result: submodelDescriptors },
|
|
@@ -14970,7 +14934,6 @@ class SubmodelRegistryClient {
|
|
|
14970
14934
|
const result = await apiInstance.postSubmodelDescriptor({
|
|
14971
14935
|
submodelDescriptor: convertCoreSubmodelDescriptorToApiSubmodelDescriptor(submodelDescriptor),
|
|
14972
14936
|
});
|
|
14973
|
-
console.log('created submodel descriptor:', result);
|
|
14974
14937
|
return { success: true, data: convertApiSubmodelDescriptorToCoreSubmodelDescriptor(result) };
|
|
14975
14938
|
}
|
|
14976
14939
|
catch (err) {
|
|
@@ -15087,7 +15050,6 @@ class SubmodelRepositoryClient {
|
|
|
15087
15050
|
extent: extent,
|
|
15088
15051
|
});
|
|
15089
15052
|
const submodels = (result.result ?? []).map(convertApiSubmodelToCoreSubmodel);
|
|
15090
|
-
console.log('all submodels:', submodels);
|
|
15091
15053
|
return {
|
|
15092
15054
|
success: true,
|
|
15093
15055
|
data: { pagedResult: result.pagingMetadata, result: submodels },
|
|
@@ -15225,7 +15187,6 @@ class SubmodelRepositoryClient {
|
|
|
15225
15187
|
extent: extent,
|
|
15226
15188
|
});
|
|
15227
15189
|
const submodelElements = (result.result ?? []).map(convertApiSubmodelElementToCoreSubmodelElement);
|
|
15228
|
-
console.log('all submodelElements:', submodelElements);
|
|
15229
15190
|
return {
|
|
15230
15191
|
success: true,
|
|
15231
15192
|
data: { pagedResult: result.pagingMetadata, result: submodelElements },
|
|
@@ -15284,7 +15245,6 @@ class SubmodelRepositoryClient {
|
|
|
15284
15245
|
level: level,
|
|
15285
15246
|
extent: extent,
|
|
15286
15247
|
});
|
|
15287
|
-
console.log('data:', result);
|
|
15288
15248
|
return { success: true, data: convertApiSubmodelElementToCoreSubmodelElement(result) };
|
|
15289
15249
|
}
|
|
15290
15250
|
catch (err) {
|
|
@@ -15313,7 +15273,6 @@ class SubmodelRepositoryClient {
|
|
|
15313
15273
|
idShortPath: idShortPath,
|
|
15314
15274
|
submodelElement: convertCoreSubmodelElementToApiSubmodelElement(submodelElement),
|
|
15315
15275
|
});
|
|
15316
|
-
console.log('created element at specified path:', result);
|
|
15317
15276
|
return { success: true, data: convertApiSubmodelElementToCoreSubmodelElement(result) };
|
|
15318
15277
|
}
|
|
15319
15278
|
catch (err) {
|
|
@@ -15638,38 +15597,2245 @@ class SubmodelRepositoryClient {
|
|
|
15638
15597
|
}
|
|
15639
15598
|
}
|
|
15640
15599
|
|
|
15641
|
-
|
|
15642
|
-
|
|
15600
|
+
/**
|
|
15601
|
+
* Extracts the endpoint from a descriptor based on the given interface short name.
|
|
15602
|
+
*
|
|
15603
|
+
* @param {Object} descriptor - The descriptor containing endpoint information.
|
|
15604
|
+
* @param {string} interfaceShortName - The short name of the interface to match against endpoint interfaces.
|
|
15605
|
+
* @returns {string} The href of the matching endpoint's protocol information if found, otherwise an empty string.
|
|
15606
|
+
*/
|
|
15607
|
+
function extractEndpointHref(descriptor, interfaceShortName) {
|
|
15608
|
+
const failResponse = '';
|
|
15609
|
+
const interfaceShortNames = [
|
|
15610
|
+
'AAS',
|
|
15611
|
+
'SUBMODEL',
|
|
15612
|
+
'SERIALIZE',
|
|
15613
|
+
'DESCRIPTION',
|
|
15614
|
+
'AASX-FILE',
|
|
15615
|
+
'AAS-REGISTRY',
|
|
15616
|
+
'SUBMODEL-REGISTRY',
|
|
15617
|
+
'AAS-REPOSITORY',
|
|
15618
|
+
'SUBMODEL-REPOSITORY',
|
|
15619
|
+
'CD-REPOSITORY',
|
|
15620
|
+
'AAS-DISCOVERY',
|
|
15621
|
+
];
|
|
15622
|
+
if (!interfaceShortName || interfaceShortName.trim() === '')
|
|
15623
|
+
return failResponse;
|
|
15624
|
+
interfaceShortName = interfaceShortName.trim();
|
|
15625
|
+
interfaceShortName = interfaceShortName.toUpperCase();
|
|
15626
|
+
if (!interfaceShortNames.some((iShortName) => interfaceShortName.startsWith(`${iShortName}-`))) {
|
|
15627
|
+
return failResponse;
|
|
15628
|
+
}
|
|
15629
|
+
if (!Array.isArray(descriptor?.endpoints) || descriptor?.endpoints.length === 0) {
|
|
15630
|
+
return failResponse;
|
|
15631
|
+
}
|
|
15632
|
+
const endpoints = descriptor.endpoints;
|
|
15633
|
+
// find the right endpoint based on the interfaceShortName (has to match endpoint.interface)
|
|
15634
|
+
const endpoint = endpoints.find((endpoint) => endpoint?._interface === interfaceShortName);
|
|
15635
|
+
return endpoint?.protocolInformation?.href ? endpoint.protocolInformation.href : '';
|
|
15636
|
+
}
|
|
15637
|
+
|
|
15638
|
+
var DescriptorUtils = /*#__PURE__*/Object.freeze({
|
|
15639
|
+
__proto__: null,
|
|
15640
|
+
extractEndpointHref: extractEndpointHref
|
|
15641
|
+
});
|
|
15642
|
+
|
|
15643
|
+
/**
|
|
15644
|
+
* SubmodelService combines Submodel Registry, Submodel Repository, and Concept Description Repository clients
|
|
15645
|
+
* to provide higher-level functionality for working with Submodels.
|
|
15646
|
+
*
|
|
15647
|
+
* This service demonstrates the multi-client pattern by orchestrating
|
|
15648
|
+
* operations across different BaSyx components, including the Submodel Registry,
|
|
15649
|
+
* Submodel Repository, and Concept Description Repository.
|
|
15650
|
+
*/
|
|
15651
|
+
class SubmodelService {
|
|
15652
|
+
registryClient;
|
|
15653
|
+
repositoryClient;
|
|
15654
|
+
conceptDescriptionClient;
|
|
15655
|
+
registryConfig;
|
|
15656
|
+
repositoryConfig;
|
|
15657
|
+
conceptDescriptionRepositoryConfig;
|
|
15658
|
+
constructor(config) {
|
|
15659
|
+
this.registryClient = new SubmodelRegistryClient();
|
|
15660
|
+
this.repositoryClient = new SubmodelRepositoryClient();
|
|
15661
|
+
this.conceptDescriptionClient = new ConceptDescriptionRepositoryClient();
|
|
15662
|
+
this.registryConfig = config.registryConfig;
|
|
15663
|
+
this.repositoryConfig = config.repositoryConfig;
|
|
15664
|
+
this.conceptDescriptionRepositoryConfig = config.conceptDescriptionRepositoryConfig;
|
|
15665
|
+
}
|
|
15666
|
+
/**
|
|
15667
|
+
* Retrieves a list of all Submodels.
|
|
15668
|
+
*
|
|
15669
|
+
* This method first attempts to fetch Submodel Descriptors from the Registry,
|
|
15670
|
+
* then uses the descriptor endpoints to fetch the actual submodels.
|
|
15671
|
+
* If a registry is not configured or fails, it falls back to fetching
|
|
15672
|
+
* Submodels directly from the Repository.
|
|
15673
|
+
*
|
|
15674
|
+
* @param options Object containing:
|
|
15675
|
+
* - preferRegistry?: Whether to prefer registry over repository (default: true)
|
|
15676
|
+
* - limit?: Maximum number of elements to retrieve
|
|
15677
|
+
* - cursor?: Pagination cursor
|
|
15678
|
+
* - includeConceptDescriptions?: Whether to fetch concept descriptions (default: false)
|
|
15679
|
+
*
|
|
15680
|
+
* @returns Either `{ success: true; data: { submodels, source, conceptDescriptions? } }` or `{ success: false; error: ... }`.
|
|
15681
|
+
*/
|
|
15682
|
+
async getSubmodelList(options) {
|
|
15683
|
+
const preferRegistry = options?.preferRegistry ?? true;
|
|
15684
|
+
const includeConceptDescriptions = options?.includeConceptDescriptions ?? false;
|
|
15685
|
+
// Try registry first if configured and preferred
|
|
15686
|
+
if (preferRegistry && this.registryConfig) {
|
|
15687
|
+
const registryResult = await this.registryClient.getAllSubmodelDescriptors({
|
|
15688
|
+
configuration: this.registryConfig,
|
|
15689
|
+
limit: options?.limit,
|
|
15690
|
+
cursor: options?.cursor,
|
|
15691
|
+
});
|
|
15692
|
+
if (registryResult.success) {
|
|
15693
|
+
const descriptors = registryResult.data.result;
|
|
15694
|
+
// Fetch submodels from their endpoints
|
|
15695
|
+
const submodelPromises = descriptors.map(async (descriptor) => {
|
|
15696
|
+
const endpoint = descriptor.endpoints?.[0]?.protocolInformation?.href;
|
|
15697
|
+
if (!endpoint) {
|
|
15698
|
+
return null;
|
|
15699
|
+
}
|
|
15700
|
+
const submodelResult = await this.getSubmodelByEndpoint({ endpoint });
|
|
15701
|
+
return submodelResult.success ? submodelResult.data.submodel : null;
|
|
15702
|
+
});
|
|
15703
|
+
const submodels = (await Promise.all(submodelPromises)).filter((sm) => sm !== null);
|
|
15704
|
+
// Fetch concept descriptions if requested
|
|
15705
|
+
let conceptDescriptions;
|
|
15706
|
+
if (includeConceptDescriptions) {
|
|
15707
|
+
conceptDescriptions = await this.fetchConceptDescriptionsForSubmodels(submodels);
|
|
15708
|
+
}
|
|
15709
|
+
return {
|
|
15710
|
+
success: true,
|
|
15711
|
+
data: {
|
|
15712
|
+
submodels,
|
|
15713
|
+
source: 'registry',
|
|
15714
|
+
...(conceptDescriptions && { conceptDescriptions }),
|
|
15715
|
+
},
|
|
15716
|
+
};
|
|
15717
|
+
}
|
|
15718
|
+
}
|
|
15719
|
+
// Fall back to repository if registry failed or not configured
|
|
15720
|
+
if (this.repositoryConfig) {
|
|
15721
|
+
const repositoryResult = await this.repositoryClient.getAllSubmodels({
|
|
15722
|
+
configuration: this.repositoryConfig,
|
|
15723
|
+
limit: options?.limit,
|
|
15724
|
+
cursor: options?.cursor,
|
|
15725
|
+
});
|
|
15726
|
+
if (repositoryResult.success) {
|
|
15727
|
+
const submodels = repositoryResult.data.result;
|
|
15728
|
+
// Fetch concept descriptions if requested
|
|
15729
|
+
let conceptDescriptions;
|
|
15730
|
+
if (includeConceptDescriptions) {
|
|
15731
|
+
conceptDescriptions = await this.fetchConceptDescriptionsForSubmodels(submodels);
|
|
15732
|
+
}
|
|
15733
|
+
return {
|
|
15734
|
+
success: true,
|
|
15735
|
+
data: {
|
|
15736
|
+
submodels,
|
|
15737
|
+
source: 'repository',
|
|
15738
|
+
...(conceptDescriptions && { conceptDescriptions }),
|
|
15739
|
+
},
|
|
15740
|
+
};
|
|
15741
|
+
}
|
|
15742
|
+
return { success: false, error: repositoryResult.error };
|
|
15743
|
+
}
|
|
15744
|
+
return {
|
|
15745
|
+
success: false,
|
|
15746
|
+
error: {
|
|
15747
|
+
errorType: 'ConfigurationError',
|
|
15748
|
+
message: 'Neither registry nor repository configuration provided',
|
|
15749
|
+
},
|
|
15750
|
+
};
|
|
15751
|
+
}
|
|
15752
|
+
/**
|
|
15753
|
+
* Retrieves a Submodel by ID.
|
|
15754
|
+
*
|
|
15755
|
+
* This method first attempts to fetch the descriptor from the registry
|
|
15756
|
+
* and use its endpoint to fetch the submodel. If that fails, it falls back
|
|
15757
|
+
* to fetching directly from the repository.
|
|
15758
|
+
*
|
|
15759
|
+
* @param options Object containing:
|
|
15760
|
+
* - submodelIdentifier: The Submodel identifier
|
|
15761
|
+
* - useRegistryEndpoint?: Whether to try registry endpoint first (default: true)
|
|
15762
|
+
* - includeConceptDescriptions?: Whether to fetch concept descriptions (default: false)
|
|
15763
|
+
*
|
|
15764
|
+
* @returns Either `{ success: true; data: { submodel, descriptor?, conceptDescriptions? } }` or `{ success: false; error: ... }`.
|
|
15765
|
+
*/
|
|
15766
|
+
async getSubmodelById(options) {
|
|
15767
|
+
const { submodelIdentifier, useRegistryEndpoint = true, includeConceptDescriptions = false } = options;
|
|
15768
|
+
// Try registry-based flow first
|
|
15769
|
+
if (useRegistryEndpoint && this.registryConfig) {
|
|
15770
|
+
const descriptorResult = await this.registryClient.getSubmodelDescriptorById({
|
|
15771
|
+
configuration: this.registryConfig,
|
|
15772
|
+
submodelIdentifier,
|
|
15773
|
+
});
|
|
15774
|
+
if (descriptorResult.success) {
|
|
15775
|
+
const descriptor = descriptorResult.data;
|
|
15776
|
+
const endpoint = descriptor.endpoints?.[0]?.protocolInformation?.href;
|
|
15777
|
+
if (endpoint) {
|
|
15778
|
+
const submodelResult = await this.getSubmodelByEndpoint({
|
|
15779
|
+
endpoint,
|
|
15780
|
+
includeConceptDescriptions,
|
|
15781
|
+
});
|
|
15782
|
+
if (submodelResult.success) {
|
|
15783
|
+
return {
|
|
15784
|
+
success: true,
|
|
15785
|
+
data: {
|
|
15786
|
+
submodel: submodelResult.data.submodel,
|
|
15787
|
+
descriptor,
|
|
15788
|
+
...(submodelResult.data.conceptDescriptions && {
|
|
15789
|
+
conceptDescriptions: submodelResult.data.conceptDescriptions,
|
|
15790
|
+
}),
|
|
15791
|
+
},
|
|
15792
|
+
};
|
|
15793
|
+
}
|
|
15794
|
+
}
|
|
15795
|
+
// If endpoint fetch failed, fall through to repository
|
|
15796
|
+
}
|
|
15797
|
+
}
|
|
15798
|
+
// Fall back to repository
|
|
15799
|
+
if (!this.repositoryConfig) {
|
|
15800
|
+
return {
|
|
15801
|
+
success: false,
|
|
15802
|
+
error: {
|
|
15803
|
+
errorType: 'ConfigurationError',
|
|
15804
|
+
message: 'No repository configuration available',
|
|
15805
|
+
},
|
|
15806
|
+
};
|
|
15807
|
+
}
|
|
15808
|
+
const submodelResult = await this.repositoryClient.getSubmodelById({
|
|
15809
|
+
configuration: this.repositoryConfig,
|
|
15810
|
+
submodelIdentifier,
|
|
15811
|
+
});
|
|
15812
|
+
if (submodelResult.success) {
|
|
15813
|
+
const submodel = submodelResult.data;
|
|
15814
|
+
// Fetch concept descriptions if requested
|
|
15815
|
+
let conceptDescriptions;
|
|
15816
|
+
if (includeConceptDescriptions) {
|
|
15817
|
+
conceptDescriptions = await this.fetchConceptDescriptionsForSubmodels([submodel]);
|
|
15818
|
+
}
|
|
15819
|
+
return {
|
|
15820
|
+
success: true,
|
|
15821
|
+
data: {
|
|
15822
|
+
submodel,
|
|
15823
|
+
descriptor: undefined,
|
|
15824
|
+
...(conceptDescriptions && { conceptDescriptions }),
|
|
15825
|
+
},
|
|
15826
|
+
};
|
|
15827
|
+
}
|
|
15828
|
+
return { success: false, error: submodelResult.error };
|
|
15829
|
+
}
|
|
15830
|
+
/**
|
|
15831
|
+
* Gets the endpoint URL for a Submodel by its identifier.
|
|
15832
|
+
*
|
|
15833
|
+
* If registry is configured and useRegistry is true, retrieves the endpoint
|
|
15834
|
+
* from the descriptor's endpoint object. Otherwise, constructs the endpoint
|
|
15835
|
+
* from the repository base path and the encoded Submodel identifier.
|
|
15836
|
+
*
|
|
15837
|
+
* @param options Object containing:
|
|
15838
|
+
* - submodelIdentifier: The Submodel identifier
|
|
15839
|
+
* - useRegistry?: Whether to try getting endpoint from registry (default: true)
|
|
15840
|
+
*
|
|
15841
|
+
* @returns Either `{ success: true; data: endpointUrl }` or `{ success: false; error: ... }`.
|
|
15842
|
+
*/
|
|
15843
|
+
async getSubmodelEndpointById(options) {
|
|
15844
|
+
const { submodelIdentifier, useRegistry = true } = options;
|
|
15845
|
+
// Try registry first if configured and requested
|
|
15846
|
+
if (useRegistry && this.registryConfig) {
|
|
15847
|
+
const descriptorResult = await this.registryClient.getSubmodelDescriptorById({
|
|
15848
|
+
configuration: this.registryConfig,
|
|
15849
|
+
submodelIdentifier,
|
|
15850
|
+
});
|
|
15851
|
+
if (descriptorResult.success) {
|
|
15852
|
+
const endpoint = descriptorResult.data.endpoints?.[0]?.protocolInformation?.href;
|
|
15853
|
+
if (endpoint) {
|
|
15854
|
+
return { success: true, data: endpoint };
|
|
15855
|
+
}
|
|
15856
|
+
}
|
|
15857
|
+
}
|
|
15858
|
+
// Fall back to constructing from repository base
|
|
15859
|
+
if (!this.repositoryConfig) {
|
|
15860
|
+
return {
|
|
15861
|
+
success: false,
|
|
15862
|
+
error: {
|
|
15863
|
+
errorType: 'ConfigurationError',
|
|
15864
|
+
message: 'Repository configuration required',
|
|
15865
|
+
},
|
|
15866
|
+
};
|
|
15867
|
+
}
|
|
15868
|
+
const repositoryBasePath = this.repositoryConfig.basePath || 'http://localhost:8082';
|
|
15869
|
+
const encodedId = base64Encode$1(submodelIdentifier);
|
|
15870
|
+
const endpoint = `${repositoryBasePath}/submodels/${encodedId}`;
|
|
15871
|
+
return { success: true, data: endpoint };
|
|
15872
|
+
}
|
|
15873
|
+
/**
|
|
15874
|
+
* Retrieves a Submodel by its endpoint URL.
|
|
15875
|
+
*
|
|
15876
|
+
* Extracts the base URL and base64url-encoded Submodel identifier from the endpoint,
|
|
15877
|
+
* decodes the identifier, and fetches the submodel from the repository.
|
|
15878
|
+
*
|
|
15879
|
+
* @param options Object containing:
|
|
15880
|
+
* - endpoint: The endpoint URL (format: http://host/submodels/{base64EncodedId})
|
|
15881
|
+
* - includeConceptDescriptions?: Whether to fetch concept descriptions (default: false)
|
|
15882
|
+
*
|
|
15883
|
+
* @returns Either `{ success: true; data: { submodel, conceptDescriptions? } }` or `{ success: false; error: ... }`.
|
|
15884
|
+
*/
|
|
15885
|
+
async getSubmodelByEndpoint(options) {
|
|
15886
|
+
const { endpoint, includeConceptDescriptions = false } = options;
|
|
15887
|
+
// Extract base URL and encoded ID from endpoint
|
|
15888
|
+
// Expected format: http://localhost:8082/submodels/base64EncodedId
|
|
15889
|
+
const match = endpoint.match(/^(https?:\/\/[^/]+(?::\d+)?)\/submodels\/([^/]+)$/);
|
|
15890
|
+
if (!match) {
|
|
15891
|
+
return {
|
|
15892
|
+
success: false,
|
|
15893
|
+
error: {
|
|
15894
|
+
errorType: 'InvalidEndpoint',
|
|
15895
|
+
message: 'Invalid endpoint format. Expected format: http://host/submodels/{base64EncodedId}',
|
|
15896
|
+
},
|
|
15897
|
+
};
|
|
15898
|
+
}
|
|
15899
|
+
const [, baseUrl, encodedId] = match;
|
|
15900
|
+
// Decode the ID
|
|
15901
|
+
const submodelIdentifier = base64Decode(encodedId);
|
|
15902
|
+
// Create configuration for the endpoint
|
|
15903
|
+
const config = new Configuration({ basePath: baseUrl });
|
|
15904
|
+
// Fetch the submodel
|
|
15905
|
+
const submodelResult = await this.repositoryClient.getSubmodelById({
|
|
15906
|
+
configuration: config,
|
|
15907
|
+
submodelIdentifier,
|
|
15908
|
+
});
|
|
15909
|
+
if (!submodelResult.success) {
|
|
15910
|
+
return { success: false, error: submodelResult.error };
|
|
15911
|
+
}
|
|
15912
|
+
const submodel = submodelResult.data;
|
|
15913
|
+
// Fetch concept descriptions if requested
|
|
15914
|
+
let conceptDescriptions;
|
|
15915
|
+
if (includeConceptDescriptions) {
|
|
15916
|
+
conceptDescriptions = await this.fetchConceptDescriptionsForSubmodels([submodel]);
|
|
15917
|
+
}
|
|
15918
|
+
return {
|
|
15919
|
+
success: true,
|
|
15920
|
+
data: {
|
|
15921
|
+
submodel,
|
|
15922
|
+
...(conceptDescriptions && { conceptDescriptions }),
|
|
15923
|
+
},
|
|
15924
|
+
};
|
|
15925
|
+
}
|
|
15926
|
+
/**
|
|
15927
|
+
* Creates a Submodel and optionally registers it in the registry.
|
|
15928
|
+
*
|
|
15929
|
+
* This method creates the Submodel in the repository first. If registry is configured
|
|
15930
|
+
* and registerInRegistry is true, it automatically creates a descriptor from the submodel
|
|
15931
|
+
* and registers it in the registry with the repository endpoint.
|
|
15932
|
+
*
|
|
15933
|
+
* @param options Object containing:
|
|
15934
|
+
* - submodel: The Submodel to create
|
|
15935
|
+
* - registerInRegistry?: Whether to register the descriptor in the registry (default: true)
|
|
15936
|
+
*
|
|
15937
|
+
* @returns Either `{ success: true; data: { submodel, descriptor? } }` or `{ success: false; error: ... }`.
|
|
15938
|
+
*/
|
|
15939
|
+
async createSubmodel(options) {
|
|
15940
|
+
const { submodel, registerInRegistry = true } = options;
|
|
15941
|
+
if (!this.repositoryConfig) {
|
|
15942
|
+
return {
|
|
15943
|
+
success: false,
|
|
15944
|
+
error: {
|
|
15945
|
+
errorType: 'ConfigurationError',
|
|
15946
|
+
message: 'Repository configuration required',
|
|
15947
|
+
},
|
|
15948
|
+
};
|
|
15949
|
+
}
|
|
15950
|
+
// Create Submodel in repository
|
|
15951
|
+
const submodelResult = await this.repositoryClient.postSubmodel({
|
|
15952
|
+
configuration: this.repositoryConfig,
|
|
15953
|
+
submodel: submodel,
|
|
15954
|
+
});
|
|
15955
|
+
if (!submodelResult.success) {
|
|
15956
|
+
return { success: false, error: submodelResult.error };
|
|
15957
|
+
}
|
|
15958
|
+
// Register descriptor in registry if configured and requested
|
|
15959
|
+
if (registerInRegistry && this.registryConfig) {
|
|
15960
|
+
const descriptor = this.createDescriptorFromSubmodel(submodel);
|
|
15961
|
+
const descriptorResult = await this.registryClient.postSubmodelDescriptor({
|
|
15962
|
+
configuration: this.registryConfig,
|
|
15963
|
+
submodelDescriptor: descriptor,
|
|
15964
|
+
});
|
|
15965
|
+
if (!descriptorResult.success) {
|
|
15966
|
+
// Submodel was created but registration failed - return error
|
|
15967
|
+
return { success: false, error: descriptorResult.error };
|
|
15968
|
+
}
|
|
15969
|
+
return {
|
|
15970
|
+
success: true,
|
|
15971
|
+
data: {
|
|
15972
|
+
submodel: submodelResult.data,
|
|
15973
|
+
descriptor: descriptorResult.data,
|
|
15974
|
+
},
|
|
15975
|
+
};
|
|
15976
|
+
}
|
|
15977
|
+
// Registry not configured or registration not requested
|
|
15978
|
+
return {
|
|
15979
|
+
success: true,
|
|
15980
|
+
data: {
|
|
15981
|
+
submodel: submodelResult.data,
|
|
15982
|
+
descriptor: undefined,
|
|
15983
|
+
},
|
|
15984
|
+
};
|
|
15985
|
+
}
|
|
15986
|
+
/**
|
|
15987
|
+
* Updates a Submodel and optionally updates its descriptor in the registry.
|
|
15988
|
+
*
|
|
15989
|
+
* This method updates the Submodel in the repository. If registry is configured
|
|
15990
|
+
* and updateInRegistry is true, it automatically creates/updates the descriptor
|
|
15991
|
+
* in the registry with the updated submodel data.
|
|
15992
|
+
*
|
|
15993
|
+
* @param options Object containing:
|
|
15994
|
+
* - submodel: The updated Submodel
|
|
15995
|
+
* - updateInRegistry?: Whether to update the descriptor in the registry (default: true)
|
|
15996
|
+
*
|
|
15997
|
+
* @returns Either `{ success: true; data: { submodel, descriptor? } }` or `{ success: false; error: ... }`.
|
|
15998
|
+
*/
|
|
15999
|
+
async updateSubmodel(options) {
|
|
16000
|
+
const { submodel, updateInRegistry = true } = options;
|
|
16001
|
+
if (!this.repositoryConfig) {
|
|
16002
|
+
return {
|
|
16003
|
+
success: false,
|
|
16004
|
+
error: {
|
|
16005
|
+
errorType: 'ConfigurationError',
|
|
16006
|
+
message: 'Repository configuration required',
|
|
16007
|
+
},
|
|
16008
|
+
};
|
|
16009
|
+
}
|
|
16010
|
+
// Update Submodel in repository
|
|
16011
|
+
const submodelResult = await this.repositoryClient.putSubmodelById({
|
|
16012
|
+
configuration: this.repositoryConfig,
|
|
16013
|
+
submodelIdentifier: submodel.id,
|
|
16014
|
+
submodel: submodel,
|
|
16015
|
+
});
|
|
16016
|
+
if (!submodelResult.success) {
|
|
16017
|
+
return { success: false, error: submodelResult.error };
|
|
16018
|
+
}
|
|
16019
|
+
// Use the returned submodel if available, otherwise use the input submodel
|
|
16020
|
+
const updatedSubmodel = submodelResult.data || submodel;
|
|
16021
|
+
// Update descriptor in registry if configured and requested
|
|
16022
|
+
if (updateInRegistry && this.registryConfig) {
|
|
16023
|
+
const descriptor = this.createDescriptorFromSubmodel(submodel);
|
|
16024
|
+
const descriptorResult = await this.registryClient.putSubmodelDescriptorById({
|
|
16025
|
+
configuration: this.registryConfig,
|
|
16026
|
+
submodelIdentifier: submodel.id,
|
|
16027
|
+
submodelDescriptor: descriptor,
|
|
16028
|
+
});
|
|
16029
|
+
if (!descriptorResult.success) {
|
|
16030
|
+
// Submodel was updated but registry update failed - return error
|
|
16031
|
+
return { success: false, error: descriptorResult.error };
|
|
16032
|
+
}
|
|
16033
|
+
return {
|
|
16034
|
+
success: true,
|
|
16035
|
+
data: {
|
|
16036
|
+
submodel: updatedSubmodel,
|
|
16037
|
+
descriptor: descriptorResult.data || undefined,
|
|
16038
|
+
},
|
|
16039
|
+
};
|
|
16040
|
+
}
|
|
16041
|
+
// Registry not configured or update not requested
|
|
16042
|
+
return {
|
|
16043
|
+
success: true,
|
|
16044
|
+
data: {
|
|
16045
|
+
submodel: updatedSubmodel,
|
|
16046
|
+
descriptor: undefined,
|
|
16047
|
+
},
|
|
16048
|
+
};
|
|
16049
|
+
}
|
|
16050
|
+
/**
|
|
16051
|
+
* Deletes a Submodel and optionally removes it from the registry.
|
|
16052
|
+
*
|
|
16053
|
+
* This method removes the descriptor from the registry first (if requested),
|
|
16054
|
+
* then deletes the Submodel from the repository.
|
|
16055
|
+
*
|
|
16056
|
+
* @param options Object containing:
|
|
16057
|
+
* - submodelIdentifier: The Submodel identifier to remove
|
|
16058
|
+
* - deleteFromRegistry?: Whether to delete from registry (default: true)
|
|
16059
|
+
*
|
|
16060
|
+
* @returns Either `{ success: true; data: void }` or `{ success: false; error: ... }`.
|
|
16061
|
+
*/
|
|
16062
|
+
async deleteSubmodel(options) {
|
|
16063
|
+
const { submodelIdentifier, deleteFromRegistry = true } = options;
|
|
16064
|
+
// Remove from registry first if configured and requested
|
|
16065
|
+
if (deleteFromRegistry && this.registryConfig) {
|
|
16066
|
+
const registryResult = await this.registryClient.deleteSubmodelDescriptorById({
|
|
16067
|
+
configuration: this.registryConfig,
|
|
16068
|
+
submodelIdentifier,
|
|
16069
|
+
});
|
|
16070
|
+
if (!registryResult.success) {
|
|
16071
|
+
return { success: false, error: registryResult.error };
|
|
16072
|
+
}
|
|
16073
|
+
}
|
|
16074
|
+
// Remove from repository
|
|
16075
|
+
if (this.repositoryConfig) {
|
|
16076
|
+
const repositoryResult = await this.repositoryClient.deleteSubmodelById({
|
|
16077
|
+
configuration: this.repositoryConfig,
|
|
16078
|
+
submodelIdentifier,
|
|
16079
|
+
});
|
|
16080
|
+
if (!repositoryResult.success) {
|
|
16081
|
+
return { success: false, error: repositoryResult.error };
|
|
16082
|
+
}
|
|
16083
|
+
}
|
|
16084
|
+
return { success: true, data: undefined };
|
|
16085
|
+
}
|
|
16086
|
+
/**
|
|
16087
|
+
* Helper method to create a Submodel descriptor from a Submodel.
|
|
16088
|
+
* Populates descriptor fields from the submodel including metadata and endpoint configuration.
|
|
16089
|
+
*
|
|
16090
|
+
* @param submodel The Submodel to create descriptor from
|
|
16091
|
+
* @returns SubmodelDescriptor with all populated fields
|
|
16092
|
+
*/
|
|
16093
|
+
createDescriptorFromSubmodel(submodel) {
|
|
16094
|
+
// Set endpoint using repository base path
|
|
16095
|
+
const repositoryBasePath = this.repositoryConfig.basePath || 'http://localhost:8082';
|
|
16096
|
+
const encodedId = base64Encode$1(submodel.id);
|
|
16097
|
+
const endpoints = [
|
|
16098
|
+
{
|
|
16099
|
+
_interface: 'SUBMODEL-3.0',
|
|
16100
|
+
protocolInformation: {
|
|
16101
|
+
href: `${repositoryBasePath}/submodels/${encodedId}`,
|
|
16102
|
+
endpointProtocol: null,
|
|
16103
|
+
endpointProtocolVersion: null,
|
|
16104
|
+
subprotocol: null,
|
|
16105
|
+
subprotocolBody: null,
|
|
16106
|
+
subprotocolBodyEncoding: null,
|
|
16107
|
+
securityAttributes: null,
|
|
16108
|
+
},
|
|
16109
|
+
},
|
|
16110
|
+
];
|
|
16111
|
+
const descriptor = new SubmodelDescriptor(submodel.id, endpoints, submodel.administration ?? null, submodel.idShort ?? null, submodel.semanticId ?? null, submodel.supplementalSemanticIds ?? null, submodel.displayName ?? null, submodel.description ?? null, submodel.extensions ?? null);
|
|
16112
|
+
return descriptor;
|
|
16113
|
+
}
|
|
16114
|
+
/**
|
|
16115
|
+
* Extracts all unique semantic IDs from a submodel and its elements recursively.
|
|
16116
|
+
* Uses a stack-based approach to traverse the submodel element tree.
|
|
16117
|
+
*
|
|
16118
|
+
* @param submodel The submodel to extract semantic IDs from
|
|
16119
|
+
* @returns Array of unique semantic ID strings
|
|
16120
|
+
*/
|
|
16121
|
+
extractSemanticIds(submodel) {
|
|
16122
|
+
const semanticIds = new Set();
|
|
16123
|
+
// Add submodel's own semantic ID if present
|
|
16124
|
+
if (submodel.semanticId?.keys && submodel.semanticId.keys.length > 0) {
|
|
16125
|
+
const semanticIdValue = submodel.semanticId.keys[0].value;
|
|
16126
|
+
if (semanticIdValue) {
|
|
16127
|
+
semanticIds.add(semanticIdValue);
|
|
16128
|
+
}
|
|
16129
|
+
}
|
|
16130
|
+
// Stack-based traversal of submodel elements
|
|
16131
|
+
const stack = [...(submodel.submodelElements || [])];
|
|
16132
|
+
while (stack.length > 0) {
|
|
16133
|
+
const element = stack.pop();
|
|
16134
|
+
// Add element's semantic ID if present
|
|
16135
|
+
if (element.semanticId?.keys && element.semanticId.keys.length > 0) {
|
|
16136
|
+
const semanticIdValue = element.semanticId.keys[0].value;
|
|
16137
|
+
if (semanticIdValue) {
|
|
16138
|
+
semanticIds.add(semanticIdValue);
|
|
16139
|
+
}
|
|
16140
|
+
}
|
|
16141
|
+
// Add children to stack based on element type
|
|
16142
|
+
const modelType = typeof element.modelType === 'function' ? element.modelType() : element.modelType;
|
|
16143
|
+
if (modelType === ModelType.SubmodelElementCollection) {
|
|
16144
|
+
const collection = element;
|
|
16145
|
+
if (collection.value && Array.isArray(collection.value)) {
|
|
16146
|
+
stack.push(...collection.value);
|
|
16147
|
+
}
|
|
16148
|
+
}
|
|
16149
|
+
else if (modelType === ModelType.SubmodelElementList) {
|
|
16150
|
+
const list = element;
|
|
16151
|
+
if (list.value && Array.isArray(list.value)) {
|
|
16152
|
+
stack.push(...list.value);
|
|
16153
|
+
}
|
|
16154
|
+
}
|
|
16155
|
+
else if (modelType === ModelType.Entity) {
|
|
16156
|
+
const entity = element;
|
|
16157
|
+
if (entity.statements && Array.isArray(entity.statements)) {
|
|
16158
|
+
stack.push(...entity.statements);
|
|
16159
|
+
}
|
|
16160
|
+
}
|
|
16161
|
+
else if (modelType === ModelType.AnnotatedRelationshipElement) {
|
|
16162
|
+
const annotatedRel = element;
|
|
16163
|
+
if (annotatedRel.annotations && Array.isArray(annotatedRel.annotations)) {
|
|
16164
|
+
stack.push(...annotatedRel.annotations);
|
|
16165
|
+
}
|
|
16166
|
+
}
|
|
16167
|
+
}
|
|
16168
|
+
return Array.from(semanticIds);
|
|
16169
|
+
}
|
|
16170
|
+
/**
|
|
16171
|
+
* Fetches concept descriptions for multiple submodels.
|
|
16172
|
+
* Deduplicates semantic IDs across all submodels and fetches each concept description once.
|
|
16173
|
+
* Skips concept descriptions that cannot be resolved.
|
|
16174
|
+
*
|
|
16175
|
+
* @param submodels Array of submodels to fetch concept descriptions for
|
|
16176
|
+
* @returns Array of unique concept descriptions
|
|
16177
|
+
*/
|
|
16178
|
+
async fetchConceptDescriptionsForSubmodels(submodels) {
|
|
16179
|
+
if (!this.conceptDescriptionRepositoryConfig) {
|
|
16180
|
+
return [];
|
|
16181
|
+
}
|
|
16182
|
+
// Extract all semantic IDs from all submodels
|
|
16183
|
+
const allSemanticIds = new Set();
|
|
16184
|
+
for (const submodel of submodels) {
|
|
16185
|
+
const semanticIds = this.extractSemanticIds(submodel);
|
|
16186
|
+
semanticIds.forEach((id) => allSemanticIds.add(id));
|
|
16187
|
+
}
|
|
16188
|
+
// Fetch concept descriptions for all unique semantic IDs
|
|
16189
|
+
const conceptDescriptions = [];
|
|
16190
|
+
const fetchPromises = Array.from(allSemanticIds).map(async (semanticId) => {
|
|
16191
|
+
try {
|
|
16192
|
+
const result = await this.conceptDescriptionClient.getConceptDescriptionById({
|
|
16193
|
+
configuration: this.conceptDescriptionRepositoryConfig,
|
|
16194
|
+
cdIdentifier: semanticId,
|
|
16195
|
+
});
|
|
16196
|
+
if (result.success) {
|
|
16197
|
+
return result.data;
|
|
16198
|
+
}
|
|
16199
|
+
}
|
|
16200
|
+
catch {
|
|
16201
|
+
// Skip concept descriptions that cannot be resolved
|
|
16202
|
+
}
|
|
16203
|
+
return null;
|
|
16204
|
+
});
|
|
16205
|
+
const results = await Promise.all(fetchPromises);
|
|
16206
|
+
conceptDescriptions.push(...results.filter((cd) => cd !== null));
|
|
16207
|
+
return conceptDescriptions;
|
|
16208
|
+
}
|
|
16209
|
+
}
|
|
16210
|
+
|
|
16211
|
+
/**
|
|
16212
|
+
* AasService combines and orchestrates multiple clients and services, including:
|
|
16213
|
+
* - AasRegistryClient
|
|
16214
|
+
* - AasRepositoryClient
|
|
16215
|
+
* - AasDiscoveryClient
|
|
16216
|
+
* - SubmodelService
|
|
16217
|
+
*
|
|
16218
|
+
* It provides higher-level functionality for working with Asset Administration Shells
|
|
16219
|
+
* by coordinating operations across these BaSyx components, demonstrating the multi-client pattern.
|
|
16220
|
+
*/
|
|
16221
|
+
class AasService {
|
|
16222
|
+
registryClient;
|
|
16223
|
+
repositoryClient;
|
|
16224
|
+
discoveryClient;
|
|
16225
|
+
registryConfig;
|
|
16226
|
+
repositoryConfig;
|
|
16227
|
+
discoveryConfig;
|
|
16228
|
+
submodelService;
|
|
16229
|
+
constructor(config) {
|
|
16230
|
+
this.registryClient = new AasRegistryClient();
|
|
16231
|
+
this.repositoryClient = new AasRepositoryClient();
|
|
16232
|
+
this.discoveryClient = new AasDiscoveryClient();
|
|
16233
|
+
this.registryConfig = config.registryConfig;
|
|
16234
|
+
this.repositoryConfig = config.repositoryConfig;
|
|
16235
|
+
this.discoveryConfig = config.discoveryConfig;
|
|
16236
|
+
// Use separate submodel configs if provided, otherwise fall back to AAS configs
|
|
16237
|
+
this.submodelService = new SubmodelService({
|
|
16238
|
+
registryConfig: config.submodelRegistryConfig ?? config.registryConfig,
|
|
16239
|
+
repositoryConfig: config.submodelRepositoryConfig ?? config.repositoryConfig,
|
|
16240
|
+
conceptDescriptionRepositoryConfig: config.conceptDescriptionRepositoryConfig,
|
|
16241
|
+
});
|
|
16242
|
+
}
|
|
16243
|
+
/**
|
|
16244
|
+
* Retrieves a list of all Asset Administration Shells.
|
|
16245
|
+
*
|
|
16246
|
+
* This method first attempts to fetch AAS Descriptors from the Registry,
|
|
16247
|
+
* then uses the descriptor endpoints to fetch the actual shells.
|
|
16248
|
+
* If a registry is not configured or fails, it falls back to fetching
|
|
16249
|
+
* AAS directly from the Repository.
|
|
16250
|
+
*
|
|
16251
|
+
* @param options Object containing:
|
|
16252
|
+
* - preferRegistry?: Whether to prefer registry over repository (default: true)
|
|
16253
|
+
* - limit?: Maximum number of elements to retrieve
|
|
16254
|
+
* - cursor?: Pagination cursor
|
|
16255
|
+
* - includeSubmodels?: Whether to fetch submodels for each shell (default: false)
|
|
16256
|
+
* - includeConceptDescriptions?: Whether to fetch concept descriptions (default: false)
|
|
16257
|
+
*
|
|
16258
|
+
* @returns Either `{ success: true; data: { shells, source, submodels? } }` or `{ success: false; error: ... }`.
|
|
16259
|
+
*/
|
|
16260
|
+
async getAasList(options) {
|
|
16261
|
+
const preferRegistry = options?.preferRegistry ?? true;
|
|
16262
|
+
const includeSubmodels = options?.includeSubmodels ?? false;
|
|
16263
|
+
// Try registry first if configured and preferred
|
|
16264
|
+
if (preferRegistry && this.registryConfig) {
|
|
16265
|
+
const registryResult = await this.registryClient.getAllAssetAdministrationShellDescriptors({
|
|
16266
|
+
configuration: this.registryConfig,
|
|
16267
|
+
limit: options?.limit,
|
|
16268
|
+
cursor: options?.cursor,
|
|
16269
|
+
});
|
|
16270
|
+
if (registryResult.success) {
|
|
16271
|
+
// Fetch actual shells from descriptor endpoints
|
|
16272
|
+
const shells = [];
|
|
16273
|
+
for (const descriptor of registryResult.data.result) {
|
|
16274
|
+
const endpoint = extractEndpointHref(descriptor, 'AAS-3.0');
|
|
16275
|
+
if (endpoint && descriptor.id) {
|
|
16276
|
+
// Extract base URL from endpoint (remove /shells/{id} part)
|
|
16277
|
+
const baseUrl = endpoint.match(/^(https?:\/\/[^/]+(?::\d+)?)/)?.[1] || endpoint;
|
|
16278
|
+
const config = new Configuration({ basePath: baseUrl });
|
|
16279
|
+
const shellResult = await this.repositoryClient.getAssetAdministrationShellById({
|
|
16280
|
+
configuration: config,
|
|
16281
|
+
aasIdentifier: descriptor.id,
|
|
16282
|
+
});
|
|
16283
|
+
if (shellResult.success) {
|
|
16284
|
+
shells.push(shellResult.data);
|
|
16285
|
+
}
|
|
16286
|
+
}
|
|
16287
|
+
}
|
|
16288
|
+
// Fetch submodels if requested
|
|
16289
|
+
let submodelsMap;
|
|
16290
|
+
if (includeSubmodels) {
|
|
16291
|
+
submodelsMap = await this.fetchSubmodelsForShells(shells, options?.includeConceptDescriptions);
|
|
16292
|
+
}
|
|
16293
|
+
return {
|
|
16294
|
+
success: true,
|
|
16295
|
+
data: {
|
|
16296
|
+
shells,
|
|
16297
|
+
source: 'registry',
|
|
16298
|
+
...(submodelsMap && { submodels: submodelsMap }),
|
|
16299
|
+
},
|
|
16300
|
+
};
|
|
16301
|
+
}
|
|
16302
|
+
}
|
|
16303
|
+
// Fall back to repository if registry failed or not configured
|
|
16304
|
+
if (this.repositoryConfig) {
|
|
16305
|
+
const repositoryResult = await this.repositoryClient.getAllAssetAdministrationShells({
|
|
16306
|
+
configuration: this.repositoryConfig,
|
|
16307
|
+
limit: options?.limit,
|
|
16308
|
+
cursor: options?.cursor,
|
|
16309
|
+
});
|
|
16310
|
+
if (repositoryResult.success) {
|
|
16311
|
+
const shells = repositoryResult.data.result;
|
|
16312
|
+
// Fetch submodels if requested
|
|
16313
|
+
let submodelsMap;
|
|
16314
|
+
if (includeSubmodels) {
|
|
16315
|
+
submodelsMap = await this.fetchSubmodelsForShells(shells, options?.includeConceptDescriptions);
|
|
16316
|
+
}
|
|
16317
|
+
return {
|
|
16318
|
+
success: true,
|
|
16319
|
+
data: {
|
|
16320
|
+
shells,
|
|
16321
|
+
source: 'repository',
|
|
16322
|
+
...(submodelsMap && { submodels: submodelsMap }),
|
|
16323
|
+
},
|
|
16324
|
+
};
|
|
16325
|
+
}
|
|
16326
|
+
return { success: false, error: repositoryResult.error };
|
|
16327
|
+
}
|
|
16328
|
+
return {
|
|
16329
|
+
success: false,
|
|
16330
|
+
error: {
|
|
16331
|
+
errorType: 'ConfigurationError',
|
|
16332
|
+
message: 'Neither registry nor repository configuration provided',
|
|
16333
|
+
},
|
|
16334
|
+
};
|
|
16335
|
+
}
|
|
16336
|
+
/**
|
|
16337
|
+
* Retrieves an Asset Administration Shell by ID.
|
|
16338
|
+
*
|
|
16339
|
+
* This method first attempts to fetch the descriptor from the registry
|
|
16340
|
+
* and use its endpoint to fetch the shell. If that fails, it falls back
|
|
16341
|
+
* to fetching directly from the repository.
|
|
16342
|
+
*
|
|
16343
|
+
* @param options Object containing:
|
|
16344
|
+
* - aasIdentifier: The AAS identifier
|
|
16345
|
+
* - useRegistryEndpoint?: Whether to try registry endpoint first (default: true)
|
|
16346
|
+
* - includeSubmodels?: Whether to fetch submodels for the shell (default: false)
|
|
16347
|
+
* - includeConceptDescriptions?: Whether to fetch concept descriptions (default: false)
|
|
16348
|
+
*
|
|
16349
|
+
* @returns Either `{ success: true; data: { shell, descriptor?, submodels? } }` or `{ success: false; error: ... }`.
|
|
16350
|
+
*/
|
|
16351
|
+
async getAasById(options) {
|
|
16352
|
+
const { aasIdentifier, useRegistryEndpoint = true, includeSubmodels = false } = options;
|
|
16353
|
+
// Try registry-based flow first
|
|
16354
|
+
if (useRegistryEndpoint && this.registryConfig) {
|
|
16355
|
+
const descriptorResult = await this.registryClient.getAssetAdministrationShellDescriptorById({
|
|
16356
|
+
configuration: this.registryConfig,
|
|
16357
|
+
aasIdentifier,
|
|
16358
|
+
});
|
|
16359
|
+
if (descriptorResult.success) {
|
|
16360
|
+
const descriptor = descriptorResult.data;
|
|
16361
|
+
const endpoint = extractEndpointHref(descriptor, 'AAS-3.0');
|
|
16362
|
+
if (endpoint) {
|
|
16363
|
+
// Extract base URL from endpoint (remove /shells/{id} part)
|
|
16364
|
+
const baseUrl = endpoint.match(/^(https?:\/\/[^/]+(?::\d+)?)/)?.[1] || endpoint;
|
|
16365
|
+
// Try to fetch from descriptor endpoint
|
|
16366
|
+
const config = new Configuration({ basePath: baseUrl });
|
|
16367
|
+
const shellResult = await this.repositoryClient.getAssetAdministrationShellById({
|
|
16368
|
+
configuration: config,
|
|
16369
|
+
aasIdentifier,
|
|
16370
|
+
});
|
|
16371
|
+
if (shellResult.success) {
|
|
16372
|
+
const shell = shellResult.data;
|
|
16373
|
+
// Fetch submodels if requested
|
|
16374
|
+
let submodels;
|
|
16375
|
+
if (includeSubmodels) {
|
|
16376
|
+
const submodelsMap = await this.fetchSubmodelsForShells([shell], options.includeConceptDescriptions);
|
|
16377
|
+
submodels = submodelsMap[shell.id] || [];
|
|
16378
|
+
}
|
|
16379
|
+
return {
|
|
16380
|
+
success: true,
|
|
16381
|
+
data: {
|
|
16382
|
+
shell,
|
|
16383
|
+
descriptor,
|
|
16384
|
+
...(submodels && { submodels }),
|
|
16385
|
+
},
|
|
16386
|
+
};
|
|
16387
|
+
}
|
|
16388
|
+
}
|
|
16389
|
+
}
|
|
16390
|
+
}
|
|
16391
|
+
// Fall back to repository
|
|
16392
|
+
if (!this.repositoryConfig) {
|
|
16393
|
+
return {
|
|
16394
|
+
success: false,
|
|
16395
|
+
error: {
|
|
16396
|
+
errorType: 'ConfigurationError',
|
|
16397
|
+
message: 'No repository configuration available',
|
|
16398
|
+
},
|
|
16399
|
+
};
|
|
16400
|
+
}
|
|
16401
|
+
const shellResult = await this.repositoryClient.getAssetAdministrationShellById({
|
|
16402
|
+
configuration: this.repositoryConfig,
|
|
16403
|
+
aasIdentifier,
|
|
16404
|
+
});
|
|
16405
|
+
if (shellResult.success) {
|
|
16406
|
+
const shell = shellResult.data;
|
|
16407
|
+
// Fetch submodels if requested
|
|
16408
|
+
let submodels;
|
|
16409
|
+
if (includeSubmodels) {
|
|
16410
|
+
const submodelsMap = await this.fetchSubmodelsForShells([shell], options.includeConceptDescriptions);
|
|
16411
|
+
submodels = submodelsMap[shell.id] || [];
|
|
16412
|
+
}
|
|
16413
|
+
return {
|
|
16414
|
+
success: true,
|
|
16415
|
+
data: {
|
|
16416
|
+
shell,
|
|
16417
|
+
descriptor: undefined,
|
|
16418
|
+
...(submodels && { submodels }),
|
|
16419
|
+
},
|
|
16420
|
+
};
|
|
16421
|
+
}
|
|
16422
|
+
return { success: false, error: shellResult.error };
|
|
16423
|
+
}
|
|
16424
|
+
/**
|
|
16425
|
+
* Gets the endpoint URL for an Asset Administration Shell by its identifier.
|
|
16426
|
+
*
|
|
16427
|
+
* If registry is configured and useRegistry is true, retrieves the endpoint
|
|
16428
|
+
* from the descriptor's endpoint object. Otherwise, constructs the endpoint
|
|
16429
|
+
* from the repository base path and the encoded AAS identifier.
|
|
16430
|
+
*
|
|
16431
|
+
* @param options Object containing:
|
|
16432
|
+
* - aasIdentifier: The AAS identifier
|
|
16433
|
+
* - useRegistry?: Whether to try getting endpoint from registry (default: true)
|
|
16434
|
+
*
|
|
16435
|
+
* @returns Either `{ success: true; data: endpointUrl }` or `{ success: false; error: ... }`.
|
|
16436
|
+
*/
|
|
16437
|
+
async getAasEndpointById(options) {
|
|
16438
|
+
const { aasIdentifier, useRegistry = true } = options;
|
|
16439
|
+
// Try registry first if configured and requested
|
|
16440
|
+
if (useRegistry && this.registryConfig) {
|
|
16441
|
+
const descriptorResult = await this.registryClient.getAssetAdministrationShellDescriptorById({
|
|
16442
|
+
configuration: this.registryConfig,
|
|
16443
|
+
aasIdentifier,
|
|
16444
|
+
});
|
|
16445
|
+
if (descriptorResult.success) {
|
|
16446
|
+
const endpoint = extractEndpointHref(descriptorResult.data, 'AAS-3.0');
|
|
16447
|
+
if (endpoint) {
|
|
16448
|
+
return { success: true, data: endpoint };
|
|
16449
|
+
}
|
|
16450
|
+
}
|
|
16451
|
+
}
|
|
16452
|
+
// Fall back to constructing from repository base
|
|
16453
|
+
if (!this.repositoryConfig) {
|
|
16454
|
+
return {
|
|
16455
|
+
success: false,
|
|
16456
|
+
error: {
|
|
16457
|
+
errorType: 'ConfigurationError',
|
|
16458
|
+
message: 'Repository configuration required',
|
|
16459
|
+
},
|
|
16460
|
+
};
|
|
16461
|
+
}
|
|
16462
|
+
const repositoryBasePath = this.repositoryConfig.basePath || 'http://localhost:8081';
|
|
16463
|
+
const encodedId = base64Encode$1(aasIdentifier);
|
|
16464
|
+
const endpoint = `${repositoryBasePath}/shells/${encodedId}`;
|
|
16465
|
+
return { success: true, data: endpoint };
|
|
16466
|
+
}
|
|
16467
|
+
/**
|
|
16468
|
+
* Retrieves an Asset Administration Shell by its endpoint URL.
|
|
16469
|
+
*
|
|
16470
|
+
* Extracts the base URL and base64url-encoded AAS identifier from the endpoint,
|
|
16471
|
+
* decodes the identifier, and fetches the shell from the repository.
|
|
16472
|
+
*
|
|
16473
|
+
* @param options Object containing:
|
|
16474
|
+
* - endpoint: The endpoint URL (format: http://host/shells/{base64EncodedId})
|
|
16475
|
+
* - includeSubmodels?: Whether to fetch submodels for the shell (default: false)
|
|
16476
|
+
* - includeConceptDescriptions?: Whether to fetch concept descriptions (default: false)
|
|
16477
|
+
*
|
|
16478
|
+
* @returns Either `{ success: true; data: { shell, submodels? } }` or `{ success: false; error: ... }`.
|
|
16479
|
+
*/
|
|
16480
|
+
async getAasByEndpoint(options) {
|
|
16481
|
+
const { endpoint, includeSubmodels = false } = options;
|
|
16482
|
+
// Extract base URL and encoded ID from endpoint
|
|
16483
|
+
// Expected format: http://localhost:8081/shells/base64EncodedId
|
|
16484
|
+
const match = endpoint.match(/^(https?:\/\/[^/]+(?::\d+)?)\/shells\/([^/]+)$/);
|
|
16485
|
+
if (!match) {
|
|
16486
|
+
return {
|
|
16487
|
+
success: false,
|
|
16488
|
+
error: {
|
|
16489
|
+
errorType: 'InvalidEndpoint',
|
|
16490
|
+
message: 'Invalid endpoint format. Expected format: http://host/shells/{base64EncodedId}',
|
|
16491
|
+
},
|
|
16492
|
+
};
|
|
16493
|
+
}
|
|
16494
|
+
const [, baseUrl, encodedId] = match;
|
|
16495
|
+
// Decode the ID
|
|
16496
|
+
const aasIdentifier = base64Decode(encodedId);
|
|
16497
|
+
// Create configuration for the endpoint
|
|
16498
|
+
const config = new Configuration({ basePath: baseUrl });
|
|
16499
|
+
// Fetch the shell
|
|
16500
|
+
const shellResult = await this.repositoryClient.getAssetAdministrationShellById({
|
|
16501
|
+
configuration: config,
|
|
16502
|
+
aasIdentifier,
|
|
16503
|
+
});
|
|
16504
|
+
if (!shellResult.success) {
|
|
16505
|
+
return { success: false, error: shellResult.error };
|
|
16506
|
+
}
|
|
16507
|
+
const shell = shellResult.data;
|
|
16508
|
+
// Fetch submodels if requested
|
|
16509
|
+
let submodels;
|
|
16510
|
+
if (includeSubmodels) {
|
|
16511
|
+
const submodelsMap = await this.fetchSubmodelsForShells([shell], options.includeConceptDescriptions);
|
|
16512
|
+
submodels = submodelsMap[shell.id] || [];
|
|
16513
|
+
}
|
|
16514
|
+
return {
|
|
16515
|
+
success: true,
|
|
16516
|
+
data: {
|
|
16517
|
+
shell,
|
|
16518
|
+
...(submodels && { submodels }),
|
|
16519
|
+
},
|
|
16520
|
+
};
|
|
16521
|
+
}
|
|
16522
|
+
/**
|
|
16523
|
+
* Creates an Asset Administration Shell and optionally registers it in the registry.
|
|
16524
|
+
*
|
|
16525
|
+
* This method creates the AAS in the repository first. If registry is configured
|
|
16526
|
+
* and registerInRegistry is true, it automatically creates a descriptor from the shell
|
|
16527
|
+
* and registers it in the registry with the repository endpoint.
|
|
16528
|
+
*
|
|
16529
|
+
* @param options Object containing:
|
|
16530
|
+
* - shell: The AAS to create
|
|
16531
|
+
* - registerInRegistry?: Whether to register the descriptor in the registry (default: true)
|
|
16532
|
+
*
|
|
16533
|
+
* @returns Either `{ success: true; data: { shell, descriptor? } }` or `{ success: false; error: ... }`.
|
|
16534
|
+
*/
|
|
16535
|
+
async createAas(options) {
|
|
16536
|
+
const { shell, registerInRegistry = true } = options;
|
|
16537
|
+
if (!this.repositoryConfig) {
|
|
16538
|
+
return {
|
|
16539
|
+
success: false,
|
|
16540
|
+
error: {
|
|
16541
|
+
errorType: 'ConfigurationError',
|
|
16542
|
+
message: 'Repository configuration required',
|
|
16543
|
+
},
|
|
16544
|
+
};
|
|
16545
|
+
}
|
|
16546
|
+
// Create AAS in repository
|
|
16547
|
+
const shellResult = await this.repositoryClient.postAssetAdministrationShell({
|
|
16548
|
+
configuration: this.repositoryConfig,
|
|
16549
|
+
assetAdministrationShell: shell,
|
|
16550
|
+
});
|
|
16551
|
+
if (!shellResult.success) {
|
|
16552
|
+
return { success: false, error: shellResult.error };
|
|
16553
|
+
}
|
|
16554
|
+
// Register descriptor in registry if configured and requested
|
|
16555
|
+
if (registerInRegistry && this.registryConfig) {
|
|
16556
|
+
const descriptor = this.createDescriptorFromAas(shell);
|
|
16557
|
+
const descriptorResult = await this.registryClient.postAssetAdministrationShellDescriptor({
|
|
16558
|
+
configuration: this.registryConfig,
|
|
16559
|
+
assetAdministrationShellDescriptor: descriptor,
|
|
16560
|
+
});
|
|
16561
|
+
if (!descriptorResult.success) {
|
|
16562
|
+
// Note: Shell was created but descriptor registration failed
|
|
16563
|
+
return { success: false, error: descriptorResult.error };
|
|
16564
|
+
}
|
|
16565
|
+
return {
|
|
16566
|
+
success: true,
|
|
16567
|
+
data: {
|
|
16568
|
+
shell: shellResult.data,
|
|
16569
|
+
descriptor: descriptorResult.data,
|
|
16570
|
+
},
|
|
16571
|
+
};
|
|
16572
|
+
}
|
|
16573
|
+
// Registry not configured or registration not requested
|
|
16574
|
+
return {
|
|
16575
|
+
success: true,
|
|
16576
|
+
data: {
|
|
16577
|
+
shell: shellResult.data,
|
|
16578
|
+
descriptor: undefined,
|
|
16579
|
+
},
|
|
16580
|
+
};
|
|
16581
|
+
}
|
|
16582
|
+
/**
|
|
16583
|
+
* Updates an Asset Administration Shell and optionally updates its descriptor in the registry.
|
|
16584
|
+
*
|
|
16585
|
+
* This method updates the AAS in the repository. If registry is configured
|
|
16586
|
+
* and updateInRegistry is true, it automatically creates/updates the descriptor
|
|
16587
|
+
* in the registry with the updated shell data.
|
|
16588
|
+
*
|
|
16589
|
+
* @param options Object containing:
|
|
16590
|
+
* - shell: The updated AAS
|
|
16591
|
+
* - updateInRegistry?: Whether to update the descriptor in the registry (default: true)
|
|
16592
|
+
*
|
|
16593
|
+
* @returns Either `{ success: true; data: { shell, descriptor? } }` or `{ success: false; error: ... }`.
|
|
16594
|
+
*/
|
|
16595
|
+
async updateAas(options) {
|
|
16596
|
+
const { shell, updateInRegistry = true } = options;
|
|
16597
|
+
if (!this.repositoryConfig) {
|
|
16598
|
+
return {
|
|
16599
|
+
success: false,
|
|
16600
|
+
error: {
|
|
16601
|
+
errorType: 'ConfigurationError',
|
|
16602
|
+
message: 'Repository configuration required',
|
|
16603
|
+
},
|
|
16604
|
+
};
|
|
16605
|
+
}
|
|
16606
|
+
// Update AAS in repository
|
|
16607
|
+
const shellResult = await this.repositoryClient.putAssetAdministrationShellById({
|
|
16608
|
+
configuration: this.repositoryConfig,
|
|
16609
|
+
aasIdentifier: shell.id,
|
|
16610
|
+
assetAdministrationShell: shell,
|
|
16611
|
+
});
|
|
16612
|
+
if (!shellResult.success) {
|
|
16613
|
+
return { success: false, error: shellResult.error };
|
|
16614
|
+
}
|
|
16615
|
+
// Use the returned shell if available, otherwise use the input shell
|
|
16616
|
+
const updatedShell = shellResult.data || shell;
|
|
16617
|
+
// Update descriptor in registry if configured and requested
|
|
16618
|
+
if (updateInRegistry && this.registryConfig) {
|
|
16619
|
+
const descriptor = this.createDescriptorFromAas(shell);
|
|
16620
|
+
const descriptorResult = await this.registryClient.putAssetAdministrationShellDescriptorById({
|
|
16621
|
+
configuration: this.registryConfig,
|
|
16622
|
+
aasIdentifier: shell.id,
|
|
16623
|
+
assetAdministrationShellDescriptor: descriptor,
|
|
16624
|
+
});
|
|
16625
|
+
if (!descriptorResult.success) {
|
|
16626
|
+
// Note: Shell was updated but descriptor update failed
|
|
16627
|
+
return { success: false, error: descriptorResult.error };
|
|
16628
|
+
}
|
|
16629
|
+
// Use the returned descriptor if available, otherwise use the created descriptor
|
|
16630
|
+
const updatedDescriptor = descriptorResult.data || descriptor;
|
|
16631
|
+
return {
|
|
16632
|
+
success: true,
|
|
16633
|
+
data: {
|
|
16634
|
+
shell: updatedShell,
|
|
16635
|
+
descriptor: updatedDescriptor,
|
|
16636
|
+
},
|
|
16637
|
+
};
|
|
16638
|
+
}
|
|
16639
|
+
// Registry not configured or update not requested
|
|
16640
|
+
return {
|
|
16641
|
+
success: true,
|
|
16642
|
+
data: {
|
|
16643
|
+
shell: updatedShell,
|
|
16644
|
+
descriptor: undefined,
|
|
16645
|
+
},
|
|
16646
|
+
};
|
|
16647
|
+
}
|
|
16648
|
+
/**
|
|
16649
|
+
* Deletes an Asset Administration Shell and optionally removes it from the registry.
|
|
16650
|
+
*
|
|
16651
|
+
* This method removes the descriptor from the registry first (if requested),
|
|
16652
|
+
* then deletes the AAS from the repository.
|
|
16653
|
+
*
|
|
16654
|
+
* @param options Object containing:
|
|
16655
|
+
* - aasIdentifier: The AAS identifier to remove
|
|
16656
|
+
* - deleteFromRegistry?: Whether to delete from registry (default: true)
|
|
16657
|
+
*
|
|
16658
|
+
* @returns Either `{ success: true; data: void }` or `{ success: false; error: ... }`.
|
|
16659
|
+
*/
|
|
16660
|
+
async deleteAas(options) {
|
|
16661
|
+
const { aasIdentifier, deleteFromRegistry = true } = options;
|
|
16662
|
+
// Remove from registry first if configured and requested
|
|
16663
|
+
if (deleteFromRegistry && this.registryConfig) {
|
|
16664
|
+
const registryResult = await this.registryClient.deleteAssetAdministrationShellDescriptorById({
|
|
16665
|
+
configuration: this.registryConfig,
|
|
16666
|
+
aasIdentifier,
|
|
16667
|
+
});
|
|
16668
|
+
if (!registryResult.success) {
|
|
16669
|
+
return { success: false, error: registryResult.error };
|
|
16670
|
+
}
|
|
16671
|
+
}
|
|
16672
|
+
// Remove from repository
|
|
16673
|
+
if (this.repositoryConfig) {
|
|
16674
|
+
const repoResult = await this.repositoryClient.deleteAssetAdministrationShellById({
|
|
16675
|
+
configuration: this.repositoryConfig,
|
|
16676
|
+
aasIdentifier,
|
|
16677
|
+
});
|
|
16678
|
+
if (!repoResult.success) {
|
|
16679
|
+
return { success: false, error: repoResult.error };
|
|
16680
|
+
}
|
|
16681
|
+
}
|
|
16682
|
+
return { success: true, data: undefined };
|
|
16683
|
+
}
|
|
16684
|
+
/**
|
|
16685
|
+
* Retrieves Asset Administration Shells by their asset identifiers.
|
|
16686
|
+
*
|
|
16687
|
+
* This method uses the discovery service to resolve asset IDs to AAS identifiers,
|
|
16688
|
+
* then fetches the corresponding shells. If multiple AAS IDs are found for the given
|
|
16689
|
+
* asset IDs, all matching shells are returned.
|
|
16690
|
+
*
|
|
16691
|
+
* @param options Object containing:
|
|
16692
|
+
* - assetIds: Array of asset identifiers to search for
|
|
16693
|
+
* - includeSubmodels?: Whether to fetch submodels for each shell (default: false)
|
|
16694
|
+
* - includeConceptDescriptions?: Whether to fetch concept descriptions (default: false)
|
|
16695
|
+
*
|
|
16696
|
+
* @returns Either `{ success: true; data: { shells, aasIds } }` or `{ success: false; error: ... }`.
|
|
16697
|
+
*/
|
|
16698
|
+
async getAasByAssetId(options) {
|
|
16699
|
+
const { assetIds, includeSubmodels = false, includeConceptDescriptions = false } = options;
|
|
16700
|
+
if (!this.discoveryConfig) {
|
|
16701
|
+
return {
|
|
16702
|
+
success: false,
|
|
16703
|
+
error: {
|
|
16704
|
+
errorType: 'ConfigurationError',
|
|
16705
|
+
message: 'Discovery service configuration not provided',
|
|
16706
|
+
},
|
|
16707
|
+
};
|
|
16708
|
+
}
|
|
16709
|
+
// Use discovery service to resolve asset IDs to AAS identifiers
|
|
16710
|
+
const discoveryResult = await this.discoveryClient.getAllAssetAdministrationShellIdsByAssetLink({
|
|
16711
|
+
configuration: this.discoveryConfig,
|
|
16712
|
+
assetIds,
|
|
16713
|
+
});
|
|
16714
|
+
if (!discoveryResult.success) {
|
|
16715
|
+
return { success: false, error: discoveryResult.error };
|
|
16716
|
+
}
|
|
16717
|
+
const aasIds = discoveryResult.data.result;
|
|
16718
|
+
if (aasIds.length === 0) {
|
|
16719
|
+
return {
|
|
16720
|
+
success: true,
|
|
16721
|
+
data: {
|
|
16722
|
+
shells: [],
|
|
16723
|
+
aasIds: [],
|
|
16724
|
+
},
|
|
16725
|
+
};
|
|
16726
|
+
}
|
|
16727
|
+
// Fetch all AAS by their identifiers
|
|
16728
|
+
const shellResults = await Promise.all(aasIds.map((aasId) => this.getAasById({
|
|
16729
|
+
aasIdentifier: aasId,
|
|
16730
|
+
includeSubmodels,
|
|
16731
|
+
includeConceptDescriptions,
|
|
16732
|
+
})));
|
|
16733
|
+
// Collect successful results
|
|
16734
|
+
const shells = [];
|
|
16735
|
+
const errors = [];
|
|
16736
|
+
shellResults.forEach((result, index) => {
|
|
16737
|
+
if (result.success) {
|
|
16738
|
+
shells.push(result.data.shell);
|
|
16739
|
+
}
|
|
16740
|
+
else {
|
|
16741
|
+
errors.push({ aasId: aasIds[index], error: result.error });
|
|
16742
|
+
}
|
|
16743
|
+
});
|
|
16744
|
+
// If some shells failed to fetch but others succeeded, still return success with available shells
|
|
16745
|
+
if (shells.length > 0) {
|
|
16746
|
+
return {
|
|
16747
|
+
success: true,
|
|
16748
|
+
data: {
|
|
16749
|
+
shells,
|
|
16750
|
+
aasIds,
|
|
16751
|
+
},
|
|
16752
|
+
};
|
|
16753
|
+
}
|
|
16754
|
+
// If all failed, return error
|
|
16755
|
+
return {
|
|
16756
|
+
success: false,
|
|
16757
|
+
error: {
|
|
16758
|
+
errorType: 'FetchError',
|
|
16759
|
+
message: 'Failed to fetch any AAS',
|
|
16760
|
+
details: errors,
|
|
16761
|
+
},
|
|
16762
|
+
};
|
|
16763
|
+
}
|
|
16764
|
+
/**
|
|
16765
|
+
* Resolves a reference to retrieve the endpoints for the referenced AAS, Submodel, and SubmodelElement path.
|
|
16766
|
+
*
|
|
16767
|
+
* This method parses a Reference object and extracts the AAS ID, Submodel ID, and builds the path
|
|
16768
|
+
* to the SubmodelElement if applicable. It supports ModelReferences with keys pointing to:
|
|
16769
|
+
* - AssetAdministrationShell
|
|
16770
|
+
* - Submodel
|
|
16771
|
+
* - SubmodelElements (including nested elements in collections and lists)
|
|
16772
|
+
*
|
|
16773
|
+
* @param options Object containing:
|
|
16774
|
+
* - reference: The Reference object to resolve
|
|
16775
|
+
*
|
|
16776
|
+
* @returns Either `{ success: true; data: { aasEndpoint?, submodelEndpoint?, submodelElementPath? } }` or `{ success: false; error: ... }`.
|
|
16777
|
+
*/
|
|
16778
|
+
async resolveReference(options) {
|
|
16779
|
+
const { reference } = options;
|
|
16780
|
+
// Only support ModelReference type
|
|
16781
|
+
if (reference.type !== ReferenceTypes.ModelReference) {
|
|
16782
|
+
return {
|
|
16783
|
+
success: false,
|
|
16784
|
+
error: {
|
|
16785
|
+
errorType: 'UnsupportedReferenceType',
|
|
16786
|
+
message: `Reference type '${reference.type}' is not supported. Only 'ModelReference' is supported.`,
|
|
16787
|
+
},
|
|
16788
|
+
};
|
|
16789
|
+
}
|
|
16790
|
+
if (!reference.keys || reference.keys.length === 0) {
|
|
16791
|
+
return {
|
|
16792
|
+
success: false,
|
|
16793
|
+
error: {
|
|
16794
|
+
errorType: 'InvalidReference',
|
|
16795
|
+
message: 'Reference must contain at least one key',
|
|
16796
|
+
},
|
|
16797
|
+
};
|
|
16798
|
+
}
|
|
16799
|
+
let aasEndpoint;
|
|
16800
|
+
let submodelEndpoint;
|
|
16801
|
+
let submodelElementPath;
|
|
16802
|
+
let remainingKeys = [...reference.keys];
|
|
16803
|
+
// Check if first key is AssetAdministrationShell
|
|
16804
|
+
if (remainingKeys[0].type === KeyTypes.AssetAdministrationShell) {
|
|
16805
|
+
const aasId = remainingKeys[0].value;
|
|
16806
|
+
const aasEndpointResult = await this.getAasEndpointById({ aasIdentifier: aasId });
|
|
16807
|
+
if (aasEndpointResult.success) {
|
|
16808
|
+
aasEndpoint = aasEndpointResult.data;
|
|
16809
|
+
}
|
|
16810
|
+
remainingKeys = remainingKeys.slice(1);
|
|
16811
|
+
// Check if next key is Submodel
|
|
16812
|
+
if (remainingKeys.length > 0 && remainingKeys[0].type === KeyTypes.Submodel) {
|
|
16813
|
+
const submodelId = remainingKeys[0].value;
|
|
16814
|
+
const smEndpointResult = await this.submodelService.getSubmodelEndpointById({
|
|
16815
|
+
submodelIdentifier: submodelId,
|
|
16816
|
+
});
|
|
16817
|
+
if (smEndpointResult.success) {
|
|
16818
|
+
submodelEndpoint = smEndpointResult.data;
|
|
16819
|
+
}
|
|
16820
|
+
remainingKeys = remainingKeys.slice(1);
|
|
16821
|
+
}
|
|
16822
|
+
}
|
|
16823
|
+
// Check if first key is Submodel (without AAS context)
|
|
16824
|
+
else if (remainingKeys[0].type === KeyTypes.Submodel) {
|
|
16825
|
+
const submodelId = remainingKeys[0].value;
|
|
16826
|
+
const smEndpointResult = await this.submodelService.getSubmodelEndpointById({
|
|
16827
|
+
submodelIdentifier: submodelId,
|
|
16828
|
+
});
|
|
16829
|
+
if (smEndpointResult.success) {
|
|
16830
|
+
submodelEndpoint = smEndpointResult.data;
|
|
16831
|
+
}
|
|
16832
|
+
remainingKeys = remainingKeys.slice(1);
|
|
16833
|
+
}
|
|
16834
|
+
// Build submodel element path if we have a submodel endpoint and remaining keys
|
|
16835
|
+
if (submodelEndpoint && remainingKeys.length > 0) {
|
|
16836
|
+
submodelElementPath = `${submodelEndpoint}/submodel-elements/`;
|
|
16837
|
+
for (let i = 0; i < remainingKeys.length; i++) {
|
|
16838
|
+
const key = remainingKeys[i];
|
|
16839
|
+
// For SubmodelElementList, we need to fetch the list and find the index
|
|
16840
|
+
if (i > 0 && remainingKeys[i - 1].type === KeyTypes.SubmodelElementList) {
|
|
16841
|
+
// Note: This would require fetching the list to determine the index
|
|
16842
|
+
// For now, we'll just append the value as-is
|
|
16843
|
+
// In a full implementation, you'd fetch the SME and find the index
|
|
16844
|
+
submodelElementPath += `${encodeURIComponent('[' + key.value + ']')}`;
|
|
16845
|
+
}
|
|
16846
|
+
// For SubmodelElementCollection or other nested elements
|
|
16847
|
+
else {
|
|
16848
|
+
if (!submodelElementPath.endsWith('/submodel-elements/')) {
|
|
16849
|
+
submodelElementPath += '.';
|
|
16850
|
+
}
|
|
16851
|
+
submodelElementPath += key.value;
|
|
16852
|
+
}
|
|
16853
|
+
}
|
|
16854
|
+
}
|
|
16855
|
+
return {
|
|
16856
|
+
success: true,
|
|
16857
|
+
data: {
|
|
16858
|
+
aasEndpoint,
|
|
16859
|
+
submodelEndpoint,
|
|
16860
|
+
submodelElementPath,
|
|
16861
|
+
},
|
|
16862
|
+
};
|
|
16863
|
+
}
|
|
16864
|
+
/**
|
|
16865
|
+
* Helper method to create an AAS descriptor from an AssetAdministrationShell.
|
|
16866
|
+
* Populates descriptor fields from the shell including metadata and endpoint configuration.
|
|
16867
|
+
*
|
|
16868
|
+
* @param shell The AssetAdministrationShell to create descriptor from
|
|
16869
|
+
* @returns AssetAdministrationShellDescriptor with all populated fields
|
|
16870
|
+
*/
|
|
16871
|
+
createDescriptorFromAas(shell) {
|
|
16872
|
+
// Create descriptor with all fields from the shell
|
|
16873
|
+
const descriptor = new AssetAdministrationShellDescriptor(shell.id, shell.displayName ?? null, shell.description ?? null, shell.extensions ?? null, shell.administration ?? null, shell.idShort ?? null, shell.assetInformation?.assetKind ?? null, shell.assetInformation?.assetType ?? null, shell.assetInformation?.globalAssetId ?? null, shell.assetInformation?.specificAssetIds ?? null, null, // submodelDescriptors not included here
|
|
16874
|
+
null // endpoints set below
|
|
16875
|
+
);
|
|
16876
|
+
// Set endpoint using repository base path
|
|
16877
|
+
const repositoryBasePath = this.repositoryConfig.basePath || 'http://localhost:8081';
|
|
16878
|
+
const encodedId = base64Encode$1(shell.id);
|
|
16879
|
+
descriptor.endpoints = [
|
|
16880
|
+
{
|
|
16881
|
+
_interface: 'AAS-3.0',
|
|
16882
|
+
protocolInformation: {
|
|
16883
|
+
href: `${repositoryBasePath}/shells/${encodedId}`,
|
|
16884
|
+
endpointProtocol: null,
|
|
16885
|
+
endpointProtocolVersion: null,
|
|
16886
|
+
subprotocol: null,
|
|
16887
|
+
subprotocolBody: null,
|
|
16888
|
+
subprotocolBodyEncoding: null,
|
|
16889
|
+
securityAttributes: null,
|
|
16890
|
+
},
|
|
16891
|
+
},
|
|
16892
|
+
];
|
|
16893
|
+
return descriptor;
|
|
16894
|
+
}
|
|
16895
|
+
/**
|
|
16896
|
+
* Helper method to fetch submodels for a list of shells.
|
|
16897
|
+
* Returns a map of shell IDs to their corresponding submodels.
|
|
16898
|
+
*
|
|
16899
|
+
* @param shells Array of Asset Administration Shells
|
|
16900
|
+
* @param includeConceptDescriptions Whether to fetch concept descriptions for submodels
|
|
16901
|
+
* @returns Record mapping shell IDs to arrays of Submodels
|
|
16902
|
+
*/
|
|
16903
|
+
async fetchSubmodelsForShells(shells, includeConceptDescriptions) {
|
|
16904
|
+
const submodelsMap = {};
|
|
16905
|
+
await Promise.all(shells.map(async (shell) => {
|
|
16906
|
+
const submodelRefs = shell.submodels || [];
|
|
16907
|
+
const submodels = [];
|
|
16908
|
+
for (const submodelRef of submodelRefs) {
|
|
16909
|
+
// Extract submodel ID from reference
|
|
16910
|
+
const submodelId = submodelRef.keys?.[0]?.value;
|
|
16911
|
+
if (!submodelId)
|
|
16912
|
+
continue;
|
|
16913
|
+
// Fetch the submodel
|
|
16914
|
+
const submodelResult = await this.submodelService.getSubmodelById({
|
|
16915
|
+
submodelIdentifier: submodelId,
|
|
16916
|
+
useRegistryEndpoint: false, // Use repository directly for consistency
|
|
16917
|
+
includeConceptDescriptions,
|
|
16918
|
+
});
|
|
16919
|
+
if (submodelResult.success) {
|
|
16920
|
+
submodels.push(submodelResult.data.submodel);
|
|
16921
|
+
}
|
|
16922
|
+
}
|
|
16923
|
+
submodelsMap[shell.id] = submodels;
|
|
16924
|
+
}));
|
|
16925
|
+
return submodelsMap;
|
|
16926
|
+
}
|
|
16927
|
+
}
|
|
16928
|
+
|
|
16929
|
+
// Descriptor Serialization/Deserialization
|
|
16930
|
+
|
|
16931
|
+
var index$1 = /*#__PURE__*/Object.freeze({
|
|
16932
|
+
__proto__: null,
|
|
16933
|
+
applyDefaults: applyDefaults,
|
|
16934
|
+
assetAdministrationShellDescriptorFromJsonable: assetAdministrationShellDescriptorFromJsonable,
|
|
16935
|
+
base64Decode: base64Decode,
|
|
16936
|
+
base64Encode: base64Encode$1,
|
|
16937
|
+
convertApiAasDescriptorToCoreAasDescriptor: convertApiAasDescriptorToCoreAasDescriptor,
|
|
16938
|
+
convertApiAasToCoreAas: convertApiAasToCoreAas,
|
|
16939
|
+
convertApiAssetIdToCoreAssetId: convertApiAssetIdToCoreAssetId,
|
|
16940
|
+
convertApiAssetInformationToCoreAssetInformation: convertApiAssetInformationToCoreAssetInformation,
|
|
16941
|
+
convertApiCDToCoreCD: convertApiCDToCoreCD,
|
|
16942
|
+
convertApiReferenceToCoreReference: convertApiReferenceToCoreReference,
|
|
16943
|
+
convertApiSubmodelDescriptorToCoreSubmodelDescriptor: convertApiSubmodelDescriptorToCoreSubmodelDescriptor,
|
|
16944
|
+
convertApiSubmodelElementToCoreSubmodelElement: convertApiSubmodelElementToCoreSubmodelElement,
|
|
16945
|
+
convertApiSubmodelToCoreSubmodel: convertApiSubmodelToCoreSubmodel,
|
|
16946
|
+
convertCoreAasDescriptorToApiAasDescriptor: convertCoreAasDescriptorToApiAasDescriptor,
|
|
16947
|
+
convertCoreAasToApiAas: convertCoreAasToApiAas,
|
|
16948
|
+
convertCoreAssetIdToApiAssetId: convertCoreAssetIdToApiAssetId,
|
|
16949
|
+
convertCoreAssetInformationToApiAssetInformation: convertCoreAssetInformationToApiAssetInformation,
|
|
16950
|
+
convertCoreCDToApiCD: convertCoreCDToApiCD,
|
|
16951
|
+
convertCoreReferenceToApiReference: convertCoreReferenceToApiReference,
|
|
16952
|
+
convertCoreSubmodelDescriptorToApiSubmodelDescriptor: convertCoreSubmodelDescriptorToApiSubmodelDescriptor,
|
|
16953
|
+
convertCoreSubmodelElementToApiSubmodelElement: convertCoreSubmodelElementToApiSubmodelElement,
|
|
16954
|
+
convertCoreSubmodelToApiSubmodel: convertCoreSubmodelToApiSubmodel,
|
|
16955
|
+
endpointFromJsonable: endpointFromJsonable,
|
|
16956
|
+
handleApiError: handleApiError,
|
|
16957
|
+
protocolInformationFromJsonable: protocolInformationFromJsonable,
|
|
16958
|
+
submodelDescriptorFromJsonable: submodelDescriptorFromJsonable,
|
|
16959
|
+
toJsonableAssetAdministrationShellDescriptor: toJsonableAssetAdministrationShellDescriptor,
|
|
16960
|
+
toJsonableEndpoint: toJsonableEndpoint,
|
|
16961
|
+
toJsonableProtocolInformation: toJsonableProtocolInformation,
|
|
16962
|
+
toJsonableSecurityAttribute: toJsonableSecurityAttribute,
|
|
16963
|
+
toJsonableSubmodelDescriptor: toJsonableSubmodelDescriptor
|
|
16964
|
+
});
|
|
16965
|
+
|
|
16966
|
+
/**
|
|
16967
|
+
* @constant {Array<Object>} keyTypes
|
|
16968
|
+
* @description Enumeration of Key Types as specified in IDTA 01001-3-0-1, page 82.
|
|
16969
|
+
* Each key type has a name and an abbreviation according to different IDTA SMT specifications (see appendix).
|
|
16970
|
+
*
|
|
16971
|
+
* @property {KeyTypes} type - The enum value of the key type.
|
|
16972
|
+
* @property {string} abbreviation - The abbreviation of the key type.
|
|
16973
|
+
*
|
|
16974
|
+
* @example
|
|
16975
|
+
* // Example of a key type
|
|
16976
|
+
* const aasKeyType = keyTypes[1]; // { type: KeyTypes.AssetAdministrationShell, abbreviation: 'AAS' }
|
|
16977
|
+
*/
|
|
16978
|
+
const keyTypes = [
|
|
16979
|
+
{ type: KeyTypes.AnnotatedRelationshipElement, abbreviation: 'RelA' },
|
|
16980
|
+
{ type: KeyTypes.AssetAdministrationShell, abbreviation: 'AAS' },
|
|
16981
|
+
{ type: KeyTypes.BasicEventElement, abbreviation: '' },
|
|
16982
|
+
{ type: KeyTypes.Blob, abbreviation: 'Blob' },
|
|
16983
|
+
{ type: KeyTypes.Capability, abbreviation: 'Cap' },
|
|
16984
|
+
{ type: KeyTypes.ConceptDescription, abbreviation: 'CD' },
|
|
16985
|
+
{ type: KeyTypes.DataElement, abbreviation: '' },
|
|
16986
|
+
{ type: KeyTypes.Entity, abbreviation: 'Ent' },
|
|
16987
|
+
{ type: KeyTypes.EventElement, abbreviation: 'Evt' },
|
|
16988
|
+
{ type: KeyTypes.File, abbreviation: 'File' },
|
|
16989
|
+
{ type: KeyTypes.FragmentReference, abbreviation: '' },
|
|
16990
|
+
{ type: KeyTypes.GlobalReference, abbreviation: 'GlobalRef' },
|
|
16991
|
+
{ type: KeyTypes.Identifiable, abbreviation: '' },
|
|
16992
|
+
{ type: KeyTypes.MultiLanguageProperty, abbreviation: 'MLP' },
|
|
16993
|
+
{ type: KeyTypes.Operation, abbreviation: 'Opr' },
|
|
16994
|
+
{ type: KeyTypes.Property, abbreviation: 'Prop' },
|
|
16995
|
+
{ type: KeyTypes.Range, abbreviation: 'Range' },
|
|
16996
|
+
{ type: KeyTypes.Referable, abbreviation: '' },
|
|
16997
|
+
{ type: KeyTypes.ReferenceElement, abbreviation: 'Ref' },
|
|
16998
|
+
{ type: KeyTypes.RelationshipElement, abbreviation: 'Rel' },
|
|
16999
|
+
{ type: KeyTypes.Submodel, abbreviation: 'SM' },
|
|
17000
|
+
{ type: KeyTypes.SubmodelElement, abbreviation: 'SME' },
|
|
17001
|
+
{ type: KeyTypes.SubmodelElementCollection, abbreviation: 'SMC' },
|
|
17002
|
+
{ type: KeyTypes.SubmodelElementList, abbreviation: 'SML' },
|
|
17003
|
+
];
|
|
17004
|
+
/**
|
|
17005
|
+
* Retrieves the abbreviation for a given Key Type.
|
|
17006
|
+
*
|
|
17007
|
+
* @param {KeyTypes} keyType - The KeyTypes enum value to look up.
|
|
17008
|
+
* @returns {string} The abbreviation for the specified key type, or an empty string if not found or if the input is invalid.
|
|
17009
|
+
*/
|
|
17010
|
+
function getKeyTypeAbbreviation(keyType) {
|
|
17011
|
+
const failResponse = '';
|
|
17012
|
+
//if (!keyTypeName || keyTypeName.trim() === '') return failResponse;
|
|
17013
|
+
if (keyType == null || typeof keyType !== 'number')
|
|
17014
|
+
return failResponse;
|
|
17015
|
+
const foundKeyType = keyTypes.find((kt) => kt.type === keyType);
|
|
17016
|
+
if (foundKeyType && foundKeyType?.abbreviation && foundKeyType.abbreviation.trim() !== '')
|
|
17017
|
+
return foundKeyType.abbreviation;
|
|
17018
|
+
return failResponse;
|
|
17019
|
+
}
|
|
17020
|
+
|
|
17021
|
+
var KeyTypesUtil = /*#__PURE__*/Object.freeze({
|
|
17022
|
+
__proto__: null,
|
|
17023
|
+
getKeyTypeAbbreviation: getKeyTypeAbbreviation,
|
|
17024
|
+
keyTypes: keyTypes
|
|
17025
|
+
});
|
|
17026
|
+
|
|
17027
|
+
/**
|
|
17028
|
+
* Checks whether the given multi-language property object has a non-empty value.
|
|
17029
|
+
*
|
|
17030
|
+
* @param {MultiLanguageProperty} multiLanguageProperty - The multi-language property object to check.
|
|
17031
|
+
* @returns {boolean} True if the multiLanguageProperty has a non-empty value, otherwise false.
|
|
17032
|
+
*/
|
|
17033
|
+
function hasValue(multiLanguageProperty) {
|
|
17034
|
+
if (!isMultiLanguageProperty(multiLanguageProperty) || !multiLanguageProperty?.value?.length) {
|
|
17035
|
+
return false;
|
|
17036
|
+
}
|
|
17037
|
+
return multiLanguageProperty.value.some((langStringSet) => langStringSet?.text?.trim() !== '');
|
|
17038
|
+
}
|
|
17039
|
+
/**
|
|
17040
|
+
* Retrieves the display value from a multi-language property, defaulting to the specified language.
|
|
17041
|
+
*
|
|
17042
|
+
* @param {MultiLanguageProperty} multiLanguageProperty - The multi-language property object.
|
|
17043
|
+
* @param {string} [language='en'] - The language code to look for in the multi-language property values (default is 'en').
|
|
17044
|
+
* @param {string} [defaultValueToDisplay=''] - The default value to return if no appropriate value is found.
|
|
17045
|
+
* @returns {string} The text value in the specified language, or the default value if not found.
|
|
17046
|
+
*/
|
|
17047
|
+
function valueToDisplay(multiLanguageProperty, language = 'en', defaultValueToDisplay = '') {
|
|
17048
|
+
if (isMultiLanguageProperty(multiLanguageProperty) && hasValue(multiLanguageProperty)) {
|
|
17049
|
+
const langStringSet = multiLanguageProperty.value?.find((value) => value?.language === language);
|
|
17050
|
+
if (langStringSet && langStringSet?.text && langStringSet.text.trim() !== '') {
|
|
17051
|
+
return langStringSet.text;
|
|
17052
|
+
}
|
|
17053
|
+
}
|
|
17054
|
+
return defaultValueToDisplay;
|
|
17055
|
+
}
|
|
17056
|
+
/**
|
|
17057
|
+
* Retrieves the first non-empty text string from a multi-language property.
|
|
17058
|
+
*
|
|
17059
|
+
* @param {MultiLanguageProperty} multiLanguageProperty - The multi-language property object.
|
|
17060
|
+
* @returns {string} The first non-empty text string or an empty string if none found.
|
|
17061
|
+
*/
|
|
17062
|
+
function firstLangStringSetText(multiLanguageProperty) {
|
|
17063
|
+
if (isMultiLanguageProperty(multiLanguageProperty) && hasValue(multiLanguageProperty)) {
|
|
17064
|
+
for (const langString of multiLanguageProperty.value || []) {
|
|
17065
|
+
if (langString?.text?.trim()) {
|
|
17066
|
+
return langString.text.trim();
|
|
17067
|
+
}
|
|
17068
|
+
}
|
|
17069
|
+
}
|
|
17070
|
+
return '';
|
|
17071
|
+
}
|
|
17072
|
+
|
|
17073
|
+
var MultiLanguagePropertyUtils = /*#__PURE__*/Object.freeze({
|
|
17074
|
+
__proto__: null,
|
|
17075
|
+
firstLangStringSetText: firstLangStringSetText,
|
|
17076
|
+
hasValue: hasValue,
|
|
17077
|
+
valueToDisplay: valueToDisplay
|
|
17078
|
+
});
|
|
17079
|
+
|
|
17080
|
+
//export function useReferableUtils() {
|
|
17081
|
+
//const { uuidV4Regex } = useIDUtils();
|
|
17082
|
+
const uuidV4Regex = /^[a-f\d]{8}-[a-f\d]{4}-[a-f\d]{4}-[a-f\d]{4}-[a-f\d]{12}$/;
|
|
17083
|
+
/**
|
|
17084
|
+
* Extracts the display name from a Referable object based on the specified language.
|
|
17085
|
+
*
|
|
17086
|
+
* The function follows these steps to determine the display name:
|
|
17087
|
+
* 1. If a `displayName` entry with the specified language is found, it returns its text.
|
|
17088
|
+
* 2. If `defaultNameToDisplay` is provided and not an empty string, it returns this value.
|
|
17089
|
+
* 3. If `idShort` is available and not an empty string, it returns `idShort`.
|
|
17090
|
+
* 4. If `id` is available and not an empty string, it returns `id`.
|
|
17091
|
+
* 5. If none of the above conditions are met, it returns an empty string.
|
|
17092
|
+
*
|
|
17093
|
+
* @param {IReferable} referable - The Referable object to extract the display name from.
|
|
17094
|
+
* @param {string} [language='en'] - The language code for the desired display name text. Defaults to 'en'.
|
|
17095
|
+
* @param {string} [defaultNameToDisplay=''] - The default name to return if no display name is found. Defaults to an empty string.
|
|
17096
|
+
* @returns {string} The determined display name or an appropriate fallback value.
|
|
17097
|
+
*/
|
|
17098
|
+
function nameToDisplay(referable, language = 'en', defaultNameToDisplay = '') {
|
|
17099
|
+
if (referable && Object.keys(referable).length > 0) {
|
|
17100
|
+
// 1.) Check if displayName is available, if so, return displayName
|
|
17101
|
+
if (Array.isArray(referable.displayName) && referable.displayName.length > 0) {
|
|
17102
|
+
const displayNameEn = referable.displayName.find((d) => d.language === language && d.text?.trim() !== '');
|
|
17103
|
+
if (displayNameEn)
|
|
17104
|
+
return displayNameEn.text;
|
|
17105
|
+
}
|
|
17106
|
+
// 2.) Otherwise return defaultNameToDisplay (if specified)
|
|
17107
|
+
if (defaultNameToDisplay.trim() !== '')
|
|
17108
|
+
return defaultNameToDisplay;
|
|
17109
|
+
// 3.) Otherwise return idShort (if available and not empty string)
|
|
17110
|
+
if (referable?.idShort && referable?.idShort.trim() !== '')
|
|
17111
|
+
return referable.idShort;
|
|
17112
|
+
// 4.) If referable is also an identifiable at the same time return id (if available and not empty string)
|
|
17113
|
+
if (hasId(referable) && referable.id?.trim()) {
|
|
17114
|
+
const isSubmodelElementListChild = hasParent(referable) && referable.parent.modelType === 'SubmodelElementList';
|
|
17115
|
+
// Note: Constraint AASd-120: idShort of submodel elements being a direct child of a SubmodelElementList shall not be specified.
|
|
17116
|
+
// This condition avoids the output of an UUID v4
|
|
17117
|
+
if (isSubmodelElementListChild || uuidV4Regex.test(referable.id)) {
|
|
17118
|
+
return defaultNameToDisplay.trim() || '';
|
|
17119
|
+
}
|
|
17120
|
+
return referable.id;
|
|
17121
|
+
}
|
|
17122
|
+
}
|
|
17123
|
+
// 4.) Return defaultNameToDisplay if specified, otherwise return an empty string
|
|
17124
|
+
return defaultNameToDisplay.trim() || '';
|
|
17125
|
+
}
|
|
17126
|
+
function hasId(referable) {
|
|
17127
|
+
return typeof referable?.id === 'string';
|
|
17128
|
+
}
|
|
17129
|
+
function hasParent(obj) {
|
|
17130
|
+
return typeof obj?.parent?.modelType === 'string';
|
|
17131
|
+
}
|
|
17132
|
+
/**
|
|
17133
|
+
* Extracts the description from a Referable object based on the specified language.
|
|
17134
|
+
* If no suitable description is found, it returns a default description.
|
|
17135
|
+
*
|
|
17136
|
+
* The function checks if the Referable object has a non-empty `description` array,
|
|
17137
|
+
* and then it attempts to find a description in the specified language (default is English).
|
|
17138
|
+
*
|
|
17139
|
+
* @param {IReferable} referable - The Referable object containing descriptions.
|
|
17140
|
+
* @param {string} [language='en'] - The language code indicating the desired description language.
|
|
17141
|
+
* @param {string} [defaultDescriptionToDisplay=''] - The default description to return if no matching description is found.
|
|
17142
|
+
* @returns {string} The text of the found description in the specified language or the default description if not found.
|
|
17143
|
+
*/
|
|
17144
|
+
function descriptionToDisplay(referable, language = 'en', defaultDescriptionToDisplay = '') {
|
|
17145
|
+
if (referable &&
|
|
17146
|
+
Object.keys(referable).length > 0 &&
|
|
17147
|
+
Array.isArray(referable?.description) &&
|
|
17148
|
+
referable?.description.length > 0) {
|
|
17149
|
+
const descriptionEn = referable.description.find((description) => description && description.language === language && description.text !== '');
|
|
17150
|
+
if (descriptionEn && descriptionEn.text)
|
|
17151
|
+
return descriptionEn.text;
|
|
17152
|
+
}
|
|
17153
|
+
return defaultDescriptionToDisplay;
|
|
17154
|
+
}
|
|
17155
|
+
/**
|
|
17156
|
+
* Checks if the `idShort` of a Referable object matches the given `idShort`.
|
|
17157
|
+
* The comparison can be performed in two modes:
|
|
17158
|
+
* - **startsWith**: checks if the `idShort` of the Referable object starts with the given `idShort`.
|
|
17159
|
+
* - **strict**: indicates whether the comparison should consider case sensitivity.
|
|
17160
|
+
*
|
|
17161
|
+
* @param {IReferable} referable - The Referable object containing the `idShort` to check.
|
|
17162
|
+
* @param {string} idShort - The `idShort` string to compare against the Referable's `idShort`.
|
|
17163
|
+
* @param {boolean} [startsWith=false] - If true, checks if the Referable's `idShort` starts with the given `idShort`.
|
|
17164
|
+
* @param {boolean} [strict=false] - If true, the check will be case-sensitive.
|
|
17165
|
+
* @returns {boolean} Returns true if a matching `idShort` is found, false otherwise.
|
|
17166
|
+
*/
|
|
17167
|
+
function checkIdShort(referable, idShort, startsWith = false, strict = false) {
|
|
17168
|
+
if (idShort.trim() === '')
|
|
17169
|
+
return false;
|
|
17170
|
+
if (!referable || Object.keys(referable).length === 0 || !referable?.idShort || referable?.idShort.trim() === '')
|
|
17171
|
+
return false;
|
|
17172
|
+
if (startsWith) {
|
|
17173
|
+
// For matching e.g. ProductImage{00} with idShort ProductImage
|
|
17174
|
+
// For matching e.g. Markings__00__
|
|
17175
|
+
if (strict) {
|
|
17176
|
+
return (referable.idShort === idShort ||
|
|
17177
|
+
referable.idShort.startsWith(idShort + '{') ||
|
|
17178
|
+
referable.idShort.startsWith(idShort + '__'));
|
|
17179
|
+
}
|
|
17180
|
+
else {
|
|
17181
|
+
return (referable.idShort.toLowerCase() === idShort.toLowerCase() ||
|
|
17182
|
+
referable.idShort.toLowerCase().startsWith(idShort.toLowerCase() + '{') ||
|
|
17183
|
+
referable.idShort.toLowerCase().startsWith(idShort.toLowerCase() + '__'));
|
|
17184
|
+
}
|
|
17185
|
+
}
|
|
17186
|
+
else {
|
|
17187
|
+
if (strict) {
|
|
17188
|
+
return referable.idShort === idShort;
|
|
17189
|
+
}
|
|
17190
|
+
else {
|
|
17191
|
+
return referable.idShort.toLowerCase() === idShort.toLowerCase();
|
|
17192
|
+
}
|
|
17193
|
+
}
|
|
17194
|
+
}
|
|
17195
|
+
/**
|
|
17196
|
+
* Retrieves a SubmodelElement (SME) by its `idShort` from a given Submodel (SM) or SubmodelElement (SME).
|
|
17197
|
+
* If the `idShort` is not found or if the input is invalid, an empty object is returned.
|
|
17198
|
+
*
|
|
17199
|
+
* The function supports the following types of elements:
|
|
17200
|
+
* - **Submodel (SM)**: Searches through `submodelElements`.
|
|
17201
|
+
* - **SubmodelElementCollection (SMC)** and **SubmodelElementList (SML)**: Searches through their `value` arrays.
|
|
17202
|
+
*
|
|
17203
|
+
* @param {string} idShort - The `idShort` of the SME to search for.
|
|
17204
|
+
* @param {Submodel | ISubmodelElement} submodelElement - The parent SM/SME to search within.
|
|
17205
|
+
* @returns {ISubmodelElement | undefined} The found SME or an empty object if not found or input is invalid.
|
|
17206
|
+
*/
|
|
17207
|
+
function getSubmodelElementByIdShort(idShort, submodelElement) {
|
|
17208
|
+
if (idShort.trim() == '')
|
|
17209
|
+
return undefined;
|
|
17210
|
+
if (!submodelElement?.modelType)
|
|
17211
|
+
return undefined;
|
|
17212
|
+
switch (submodelElement.modelType()) {
|
|
17213
|
+
case ModelType.Submodel: {
|
|
17214
|
+
const submodel = submodelElement;
|
|
17215
|
+
if (submodel.submodelElements && submodel.submodelElements.length > 0) {
|
|
17216
|
+
return submodel.submodelElements.find((sme) => {
|
|
17217
|
+
return checkIdShort(sme, idShort);
|
|
17218
|
+
});
|
|
17219
|
+
}
|
|
17220
|
+
break;
|
|
17221
|
+
}
|
|
17222
|
+
case ModelType.SubmodelElementCollection: {
|
|
17223
|
+
const collection = submodelElement;
|
|
17224
|
+
if (collection.value && collection.value.length > 0) {
|
|
17225
|
+
return collection.value.find((sme) => {
|
|
17226
|
+
return checkIdShort(sme, idShort);
|
|
17227
|
+
});
|
|
17228
|
+
}
|
|
17229
|
+
break;
|
|
17230
|
+
}
|
|
17231
|
+
case ModelType.SubmodelElementList: {
|
|
17232
|
+
const list = submodelElement;
|
|
17233
|
+
if (list.value && list.value.length > 0) {
|
|
17234
|
+
return list.value.find((sme) => {
|
|
17235
|
+
return checkIdShort(sme, idShort);
|
|
17236
|
+
});
|
|
17237
|
+
}
|
|
17238
|
+
break;
|
|
17239
|
+
}
|
|
17240
|
+
}
|
|
17241
|
+
return undefined;
|
|
17242
|
+
}
|
|
17243
|
+
/**
|
|
17244
|
+
* Retrieves an array of SubmodelElements (SMEs) by their `idShort` from a given Submodel (SM) or SubmodelElement (SME).
|
|
17245
|
+
* If the `idShort` is not found or if the input is invalid, an empty array is returned.
|
|
17246
|
+
*
|
|
17247
|
+
* The function supports the following types of elements:
|
|
17248
|
+
* - **Submodel (SM)**: Filters through `submodelElements`.
|
|
17249
|
+
* - **SubmodelElementCollection (SMC)** and **SubmodelElementList (SML)**: Filters through their `value` arrays.
|
|
17250
|
+
*
|
|
17251
|
+
* @param {string} idShort - The `idShort` of the SMEs to search for.
|
|
17252
|
+
* @param {Submodel | ISubmodelElement} submodelElement - The parent SM/SME to search within.
|
|
17253
|
+
* @returns {ISubmodelElement[]} An array of found SMEs matching the `idShort`, or an empty array if not found or input is invalid.
|
|
17254
|
+
*/
|
|
17255
|
+
function getSubmodelElementsByIdShort(idShort, submodelElement) {
|
|
17256
|
+
if (idShort.trim() == '')
|
|
17257
|
+
return [];
|
|
17258
|
+
if (!submodelElement?.modelType)
|
|
17259
|
+
return [];
|
|
17260
|
+
switch (submodelElement.modelType()) {
|
|
17261
|
+
case ModelType.Submodel: {
|
|
17262
|
+
const submodel = submodelElement;
|
|
17263
|
+
if (submodel.submodelElements && submodel.submodelElements.length > 0) {
|
|
17264
|
+
return submodel.submodelElements.filter((sme) => {
|
|
17265
|
+
return checkIdShort(sme, idShort);
|
|
17266
|
+
});
|
|
17267
|
+
}
|
|
17268
|
+
break;
|
|
17269
|
+
}
|
|
17270
|
+
case ModelType.SubmodelElementCollection: {
|
|
17271
|
+
const collection = submodelElement;
|
|
17272
|
+
if (collection.value && collection.value.length > 0) {
|
|
17273
|
+
return collection.value.filter((sme) => {
|
|
17274
|
+
return checkIdShort(sme, idShort);
|
|
17275
|
+
});
|
|
17276
|
+
}
|
|
17277
|
+
break;
|
|
17278
|
+
}
|
|
17279
|
+
case ModelType.SubmodelElementList: {
|
|
17280
|
+
const list = submodelElement;
|
|
17281
|
+
if (list.value && list.value.length > 0) {
|
|
17282
|
+
return list.value.filter((sme) => {
|
|
17283
|
+
return checkIdShort(sme, idShort);
|
|
17284
|
+
});
|
|
17285
|
+
}
|
|
17286
|
+
break;
|
|
17287
|
+
}
|
|
17288
|
+
}
|
|
17289
|
+
return [];
|
|
17290
|
+
}
|
|
17291
|
+
// return {
|
|
17292
|
+
// nameToDisplay,
|
|
17293
|
+
// descriptionToDisplay,
|
|
17294
|
+
// checkIdShort,
|
|
17295
|
+
// getSubmodelElementByIdShort,
|
|
17296
|
+
// getSubmodelElementsByIdShort,
|
|
17297
|
+
// };
|
|
17298
|
+
//}
|
|
17299
|
+
|
|
17300
|
+
var ReferableUtils = /*#__PURE__*/Object.freeze({
|
|
17301
|
+
__proto__: null,
|
|
17302
|
+
checkIdShort: checkIdShort,
|
|
17303
|
+
descriptionToDisplay: descriptionToDisplay,
|
|
17304
|
+
getSubmodelElementByIdShort: getSubmodelElementByIdShort,
|
|
17305
|
+
getSubmodelElementsByIdShort: getSubmodelElementsByIdShort,
|
|
17306
|
+
nameToDisplay: nameToDisplay
|
|
17307
|
+
});
|
|
17308
|
+
|
|
17309
|
+
//import {keyTypes} from '../utils/KeyTypesUtil';
|
|
17310
|
+
/**
|
|
17311
|
+
* Extracts the ID (Key) from a Reference object based on the given Key Type.
|
|
17312
|
+
*
|
|
17313
|
+
* @param {Reference} reference - The Reference object containing ID/Key information.
|
|
17314
|
+
* @param {KeyTypes} keyType - The enum value of the key type.
|
|
17315
|
+
* @returns {string} The ID (Key) of the matching Key Type name if found, otherwise an empty string.
|
|
17316
|
+
*/
|
|
17317
|
+
function extractId(reference, keyType) {
|
|
17318
|
+
const failResponse = '';
|
|
17319
|
+
if (!reference?.keys || reference.keys.length === 0) {
|
|
17320
|
+
return failResponse;
|
|
17321
|
+
}
|
|
17322
|
+
//keyType = keyType.trim();
|
|
17323
|
+
// if (!keyTypes.some((keyTypeOfKeyTypes) => keyTypeOfKeyTypes.type === keyType)) {
|
|
17324
|
+
// return failResponse;
|
|
17325
|
+
// }
|
|
17326
|
+
const keys = reference.keys;
|
|
17327
|
+
// find the key based on the key type
|
|
17328
|
+
const key = keys.find((key) => key?.type === keyType);
|
|
17329
|
+
return key?.value?.trim() || failResponse;
|
|
17330
|
+
}
|
|
17331
|
+
|
|
17332
|
+
var ReferenceUtil = /*#__PURE__*/Object.freeze({
|
|
17333
|
+
__proto__: null,
|
|
17334
|
+
extractId: extractId
|
|
17335
|
+
});
|
|
17336
|
+
|
|
17337
|
+
const versionRevisionRegex = /\/(\d{1,})\/(\d{1,})(\/|$)/; // This regex matches the version/revision string of a semanticId ".../version/revision"
|
|
17338
|
+
/**
|
|
17339
|
+
* Checks if the `semanticId` of a SubmodelElement (SME) matches the given `semanticId`.
|
|
17340
|
+
* The function verifies that the `semanticId` is non-empty and that the SubmodelElement
|
|
17341
|
+
* contains a valid array of semantic ID keys. It also determines the matching strategy
|
|
17342
|
+
* based on the prefix of the keys in the SubmodelElement's semantic ID.
|
|
17343
|
+
*
|
|
17344
|
+
* @param {ISubmodelElement} submodelElement - The SubmodelElement object containing semantic ID keys.
|
|
17345
|
+
* @param {string} semanticId - The `semanticId` string to compare against the SME's `semanticId`.
|
|
17346
|
+
* @returns {boolean} Returns true if a matching `semanticId` is found, false otherwise.
|
|
17347
|
+
*/
|
|
17348
|
+
function checkSemanticId(submodelElement, semanticId) {
|
|
17349
|
+
if (semanticId.trim() == '')
|
|
17350
|
+
return false;
|
|
17351
|
+
semanticId = semanticId.trim();
|
|
17352
|
+
if (!Array.isArray(submodelElement?.semanticId?.keys) || submodelElement.semanticId.keys.length == 0)
|
|
17353
|
+
return false;
|
|
17354
|
+
for (const key of submodelElement.semanticId.keys) {
|
|
17355
|
+
if (key.value.startsWith('0112/')) {
|
|
17356
|
+
return checkSemanticIdIecCdd(key.value, semanticId);
|
|
17357
|
+
}
|
|
17358
|
+
else if (key.value.startsWith('0173-1#') || key.value.startsWith('0173/1///')) {
|
|
17359
|
+
return checkSemanticIdEclassIrdi(key.value, semanticId);
|
|
17360
|
+
}
|
|
17361
|
+
else if (key.value.startsWith('https://api.eclass-cdp.com/0173-1')) {
|
|
17362
|
+
return checkSemanticIdEclassIrdiUrl(key.value, semanticId);
|
|
17363
|
+
}
|
|
17364
|
+
else if (key.value.startsWith('http://') || key.value.startsWith('https://')) {
|
|
17365
|
+
return checkSemanticIdIri(key.value, semanticId);
|
|
17366
|
+
}
|
|
17367
|
+
else {
|
|
17368
|
+
if (key.value === semanticId)
|
|
17369
|
+
return true;
|
|
17370
|
+
}
|
|
17371
|
+
}
|
|
17372
|
+
return false;
|
|
17373
|
+
}
|
|
17374
|
+
/**
|
|
17375
|
+
* Checks whether a given EClass IRDI semantic ID matches an equivalent key value.
|
|
17376
|
+
* The function validates that both `keyValue` and `semanticId` are non-empty. It verifies that the `keyValue`
|
|
17377
|
+
* starts with either "0173-1#" or "0173/1///" and compares the two IDs based on specific criteria for
|
|
17378
|
+
* versioned and non-versioned IDs.
|
|
17379
|
+
*
|
|
17380
|
+
* @param {string} keyValue - The key value representing the original EClass IRDI ID to compare against.
|
|
17381
|
+
* @param {string} semanticId - The EClass semantic ID to be checked for equivalence.
|
|
17382
|
+
* @returns {boolean} Returns true if the `semanticId` matches the `keyValue`, false otherwise.
|
|
17383
|
+
*/
|
|
17384
|
+
function checkSemanticIdEclassIrdi(keyValue, semanticId) {
|
|
17385
|
+
if (semanticId.trim() == '')
|
|
17386
|
+
return false;
|
|
17387
|
+
semanticId = semanticId.trim();
|
|
17388
|
+
if (!keyValue.startsWith('0173-1#') && !keyValue.startsWith('0173/1///'))
|
|
17389
|
+
return false;
|
|
17390
|
+
if (keyValue.startsWith('0173-1#')) {
|
|
17391
|
+
// Eclass IRDI like 0173-1#01-AHF578#001
|
|
17392
|
+
if (new RegExp(/\*\d{2}$/).test(keyValue)) {
|
|
17393
|
+
keyValue = keyValue.slice(0, -3);
|
|
17394
|
+
semanticId = semanticId.slice(0, -3);
|
|
17395
|
+
}
|
|
17396
|
+
if (new RegExp(/[#-]{1}\d{3}$/).test(semanticId) || new RegExp(/[#-]{1}\d{3}\*\d{1,}$/).test(semanticId)) {
|
|
17397
|
+
return getEquivalentEclassSemanticIds(keyValue).includes(semanticId);
|
|
17398
|
+
}
|
|
17399
|
+
// Eclass IRDI without version; like 0173-1#01-AHF578
|
|
17400
|
+
return (getEquivalentEclassSemanticIds(keyValue).findIndex((equivalentSemanticId) => {
|
|
17401
|
+
return equivalentSemanticId.startsWith(semanticId);
|
|
17402
|
+
}, semanticId) != -1);
|
|
17403
|
+
}
|
|
17404
|
+
else if (keyValue.startsWith('0173/1///')) {
|
|
17405
|
+
if (new RegExp(/[#-]{1}\d{3}$/).test(semanticId) || new RegExp(/[#-]{1}\d{3}\*\d{1,}$/).test(semanticId)) {
|
|
17406
|
+
// Eclass IRDI with version; like 0173/1///01#AHF578#001
|
|
17407
|
+
return getEquivalentEclassSemanticIds(keyValue).includes(semanticId);
|
|
17408
|
+
}
|
|
17409
|
+
// Eclass IRDI without version; like 0173/1///01#AHF578
|
|
17410
|
+
return (getEquivalentEclassSemanticIds(keyValue).findIndex((equivalentSemanticId) => {
|
|
17411
|
+
return equivalentSemanticId.startsWith(semanticId);
|
|
17412
|
+
}, semanticId) != -1);
|
|
17413
|
+
}
|
|
17414
|
+
return false;
|
|
17415
|
+
}
|
|
17416
|
+
/**
|
|
17417
|
+
* Checks whether a given EClass IRDI URL semantic ID matches an equivalent key value.
|
|
17418
|
+
* The function validates that both `keyValue` and `semanticId` are non-empty and that the `keyValue`
|
|
17419
|
+
* starts with the specified base URL. It then checks if the `semanticId` has a version and
|
|
17420
|
+
* compares it accordingly.
|
|
17421
|
+
*
|
|
17422
|
+
* @param {string} keyValue - The key value representing the original EClass IRDI URL to compare against.
|
|
17423
|
+
* @param {string} semanticId - The EClass semantic ID to be checked for equivalence.
|
|
17424
|
+
* @returns {boolean} Returns true if the `semanticId` matches the `keyValue`, false otherwise.
|
|
17425
|
+
*/
|
|
17426
|
+
function checkSemanticIdEclassIrdiUrl(keyValue, semanticId) {
|
|
17427
|
+
if (semanticId.trim() == '')
|
|
17428
|
+
return false;
|
|
17429
|
+
semanticId = semanticId.trim();
|
|
17430
|
+
if (!keyValue.startsWith('https://api.eclass-cdp.com/0173-1'))
|
|
17431
|
+
return false;
|
|
17432
|
+
// Eclass URL like https://api.eclass-cdp.com/0173-1-01-AHF578-001
|
|
17433
|
+
if (new RegExp(/[#-]{1}\d{3}$/).test(semanticId) || new RegExp(/[#-]{1}\d{3}~\d{1,}$/).test(semanticId)) {
|
|
17434
|
+
// Eclass URL with version (like https://api.eclass-cdp.com/0173-1-01-AHF578-001)
|
|
17435
|
+
return getEquivalentEclassSemanticIds(semanticId).includes(keyValue);
|
|
17436
|
+
}
|
|
17437
|
+
// Eclass URL without version (like https://api.eclass-cdp.com/0173-1-01-AHF578)
|
|
17438
|
+
return (getEquivalentEclassSemanticIds(keyValue).findIndex((equivalentSemanticId) => {
|
|
17439
|
+
return equivalentSemanticId.startsWith(semanticId);
|
|
17440
|
+
}, semanticId) != -1);
|
|
17441
|
+
}
|
|
17442
|
+
/**
|
|
17443
|
+
* Checks whether a given IEC CDD semantic ID matches the equivalent key value.
|
|
17444
|
+
* The function validates that both `keyValue` and `semanticId` are non-empty and start with "0112/".
|
|
17445
|
+
* It then determines if the two values are equivalent based on specific criteria for versioned and non-versioned IDs.
|
|
17446
|
+
*
|
|
17447
|
+
* @param {string} keyValue - The key value representing the original IEC CDD semantic ID to compare against.
|
|
17448
|
+
* @param {string} semanticId - The IEC CDD semantic ID to be checked for equivalence.
|
|
17449
|
+
* @returns {boolean} Returns true if the `semanticId` matches the `keyValue`, false otherwise.
|
|
17450
|
+
*/
|
|
17451
|
+
function checkSemanticIdIecCdd(keyValue, semanticId) {
|
|
17452
|
+
if (semanticId.trim() == '')
|
|
17453
|
+
return false;
|
|
17454
|
+
semanticId = semanticId.trim();
|
|
17455
|
+
if (!semanticId.startsWith('0112/'))
|
|
17456
|
+
return false;
|
|
17457
|
+
if (!keyValue.startsWith('0112/'))
|
|
17458
|
+
return false;
|
|
17459
|
+
// IEC CDD like 0112/2///61987#ABN590#002
|
|
17460
|
+
if (new RegExp(/[#-]{1}\d{3}$/).test(semanticId)) {
|
|
17461
|
+
// IEC CDD with version; like 0112/2///61987#ABN590#002
|
|
17462
|
+
if (keyValue === semanticId) {
|
|
17463
|
+
return true;
|
|
17464
|
+
}
|
|
17465
|
+
}
|
|
17466
|
+
// IEC CDD without version; like 0112/2///61987#ABN590
|
|
17467
|
+
return keyValue.startsWith(semanticId);
|
|
17468
|
+
}
|
|
17469
|
+
/**
|
|
17470
|
+
* Checks whether a given semantic ID matches the equivalent IRI derived from a key value.
|
|
17471
|
+
* The function verifies both the validity of the semantic ID and key value, and compares them.
|
|
17472
|
+
*
|
|
17473
|
+
* It considers:
|
|
17474
|
+
* - Validity checks for the `semanticId` and `keyValue` (they must be non-empty and start with http/https).
|
|
17475
|
+
* - Normalization of the `keyValue` and `semanticId` by removing any trailing slashes.
|
|
17476
|
+
* - Different comparison strategies depending on whether the `semanticId` indicates a versioned or non-versioned IRI.
|
|
17477
|
+
*
|
|
17478
|
+
* @param {string} keyValue - The key value representing the original IRI to compare against.
|
|
17479
|
+
* @param {string} semanticId - The semantic ID IRI to be checked for equivalence.
|
|
17480
|
+
* @returns {boolean} Returns true if the `semanticId` matches the equivalent IRI derived from `keyValue`, false otherwise.
|
|
17481
|
+
*/
|
|
17482
|
+
function checkSemanticIdIri(keyValue, semanticId) {
|
|
17483
|
+
if (semanticId.trim() == '')
|
|
17484
|
+
return false;
|
|
17485
|
+
semanticId = semanticId.trim();
|
|
17486
|
+
if (!semanticId.startsWith('http://') && !semanticId.startsWith('https://'))
|
|
17487
|
+
return false;
|
|
17488
|
+
if (!keyValue.startsWith('http://') && !keyValue.startsWith('https://'))
|
|
17489
|
+
return false;
|
|
17490
|
+
if (keyValue.endsWith('/'))
|
|
17491
|
+
keyValue = keyValue.substring(0, keyValue.length - 1);
|
|
17492
|
+
if (semanticId.endsWith('/'))
|
|
17493
|
+
semanticId = semanticId.substring(0, semanticId.length - 1);
|
|
17494
|
+
if (new RegExp(/\/\d{1,}\/\d{1,}\/{0,1}$/).test(semanticId) || new RegExp(/\/\d{1,}\/\d{1,}\//).test(semanticId)) {
|
|
17495
|
+
// IRI with version like https://admin-shell.io/idta/CarbonFootprint/ProductCarbonFootprint/0/9
|
|
17496
|
+
// IRI with version like https://admin-shell.io/zvei/nameplate/1/0/ContactInformations
|
|
17497
|
+
return (getEquivalentIriSemanticIds(keyValue).findIndex((equivalentSemanticId) => {
|
|
17498
|
+
return equivalentSemanticId.toLowerCase() === semanticId.toLowerCase();
|
|
17499
|
+
}, semanticId) != -1);
|
|
17500
|
+
}
|
|
17501
|
+
// IRI without version like https://admin-shell.io/idta/CarbonFootprint/ProductCarbonFootprint/
|
|
17502
|
+
return (getEquivalentIriSemanticIds(keyValue).findIndex((equivalentSemanticId) => {
|
|
17503
|
+
return equivalentSemanticId.toLowerCase().startsWith(semanticId.toLowerCase());
|
|
17504
|
+
}, semanticId) != -1);
|
|
17505
|
+
}
|
|
17506
|
+
/**
|
|
17507
|
+
* Generates an array of equivalent EClass semantic IDs based on the provided `semanticId`.
|
|
17508
|
+
* The function checks if the input `semanticId` is valid before generating its equivalents.
|
|
17509
|
+
* Valid formats are:
|
|
17510
|
+
* - "0173-1#..."
|
|
17511
|
+
* - "0173/1///..."
|
|
17512
|
+
* - "https://api.eclass-cdp.com/0173-1..."
|
|
17513
|
+
*
|
|
17514
|
+
* Returns the original `semanticId` and its variations based on specific rules depending on its format:
|
|
17515
|
+
* - Converts "0173-1#" to "0173/1///" and an API URL format.
|
|
17516
|
+
* - Converts "0173/1///" to "0173-1#" and the corresponding API URL format.
|
|
17517
|
+
* - Converts the API URL format back to "0173-1#" and "0173/1///".
|
|
17518
|
+
*
|
|
17519
|
+
* @param {string} semanticId - The EClass semantic ID to evaluate and convert.
|
|
17520
|
+
* @returns {any[]} An array of the original `semanticId` and its equivalent variations,
|
|
17521
|
+
* or an empty array if the input is invalid.
|
|
17522
|
+
*/
|
|
17523
|
+
function getEquivalentEclassSemanticIds(semanticId) {
|
|
17524
|
+
if (semanticId.trim() === '' ||
|
|
17525
|
+
(!semanticId.startsWith('0173-1#') &&
|
|
17526
|
+
!semanticId.startsWith('0173/1///') &&
|
|
17527
|
+
!semanticId.startsWith('https://api.eclass-cdp.com/0173-1'))) {
|
|
17528
|
+
return [];
|
|
17529
|
+
}
|
|
17530
|
+
semanticId = semanticId.trim();
|
|
17531
|
+
const semanticIds = [semanticId];
|
|
17532
|
+
if (semanticId.startsWith('0173-1#')) {
|
|
17533
|
+
// e.g. 0173-1#01-AHF578#001
|
|
17534
|
+
semanticIds.push(semanticId.replace(/-1#(\d{2})-/, '/1///$1#')); // 0173-1#01-AHF578#001 --> 0173/1///01#AHF578#001
|
|
17535
|
+
semanticIds.push('https://api.eclass-cdp.com/' + semanticId.replaceAll('#', '-')); // 0173-1#01-AHF578#001 --> https://api.eclass-cdp.com/0173-1-01-AHF578-001
|
|
17536
|
+
}
|
|
17537
|
+
else if (semanticId.startsWith('0173/1///')) {
|
|
17538
|
+
// e.g. 0173/1///01#AHF578#001
|
|
17539
|
+
semanticIds.push(semanticId.replace(/\/1\/\/\/(\d{2})#/, '-1#$1-')); // 0173/1///01#AHF578#001 --> 0173-1#01-AHF578#001
|
|
17540
|
+
semanticIds.push('https://api.eclass-cdp.com/' + semanticId.replace(/\/1\/\/\/(\d{2})#/, '-1-$1-').replaceAll('#', '-') // 0173/1///01#AHF578#001 --> https://api.eclass-cdp.com/0173-1-01-AHF578-001
|
|
17541
|
+
);
|
|
17542
|
+
}
|
|
17543
|
+
else if (semanticId.startsWith('https://api.eclass-cdp.com/0173-1')) {
|
|
17544
|
+
// e.g. https://api.eclass-cdp.com/0173-1-01-AHF578-001
|
|
17545
|
+
semanticIds.push(semanticId
|
|
17546
|
+
.replaceAll('https://api.eclass-cdp.com/', '')
|
|
17547
|
+
.replace(/-1-(\d{2})-/, '-1#$1-')
|
|
17548
|
+
.replace(/-(\d{3})$/, '#$1') // https://api.eclass-cdp.com/0173-1-01-AHF578-001 --> 0173-1#01-AHF578#001
|
|
17549
|
+
);
|
|
17550
|
+
semanticIds.push(semanticId
|
|
17551
|
+
.replaceAll('https://api.eclass-cdp.com/', '')
|
|
17552
|
+
.replace(/-1-(\d{2})-/, '/1///$1#')
|
|
17553
|
+
.replace(/-(\d{3})$/, '#$1') // https://api.eclass-cdp.com/0173-1-01-AHF578-001 --> 0173/1///01#AHF578#001
|
|
17554
|
+
);
|
|
17555
|
+
}
|
|
17556
|
+
return semanticIds;
|
|
17557
|
+
}
|
|
17558
|
+
/**
|
|
17559
|
+
* Generates an array of equivalent IRI (Internationalized Resource Identifier) semantic IDs
|
|
17560
|
+
* based on the given `semanticId`.
|
|
17561
|
+
*
|
|
17562
|
+
* The function checks if the `semanticId` is a valid IRI (i.e., it starts with "http://" or "https://").
|
|
17563
|
+
* It will return an empty array if the `semanticId` is invalid. If the `semanticId` is valid,
|
|
17564
|
+
* it will also include variations with a trailing slash or without one in the resultant array.
|
|
17565
|
+
*
|
|
17566
|
+
* @param {string} semanticId - The semantic ID to evaluate.
|
|
17567
|
+
* @returns {any[]} An array containing the original `semanticId` and its equivalent variations,
|
|
17568
|
+
* or an empty array if the input is invalid.
|
|
17569
|
+
*/
|
|
17570
|
+
function getEquivalentIriSemanticIds(semanticId) {
|
|
17571
|
+
if (semanticId.trim() === '' || !(semanticId.startsWith('http://') || semanticId.startsWith('https://'))) {
|
|
17572
|
+
return [];
|
|
17573
|
+
}
|
|
17574
|
+
semanticId = semanticId.trim();
|
|
17575
|
+
const semanticIds = [semanticId];
|
|
17576
|
+
// e.g. IRI
|
|
17577
|
+
if (semanticId.endsWith('/')) {
|
|
17578
|
+
semanticIds.push(semanticId.substring(0, semanticId.length - 1));
|
|
17579
|
+
}
|
|
17580
|
+
else {
|
|
17581
|
+
semanticIds.push(semanticId + '/');
|
|
17582
|
+
}
|
|
17583
|
+
return semanticIds;
|
|
17584
|
+
}
|
|
17585
|
+
/**
|
|
17586
|
+
* Retrieves a SubmodelElement (SME) by its `semanticId` from a given Submodel (SM) or SubmodelElement (SME).
|
|
17587
|
+
* If the `semanticId` is not found or if the input is invalid, an empty object is returned.
|
|
17588
|
+
*
|
|
17589
|
+
* The function supports the following types of elements:
|
|
17590
|
+
* - **Submodel (SM)**: Searches through `submodelElements`.
|
|
17591
|
+
* - **SubmodelElementCollection (SMC)** and **SubmodelElementList (SML)**: Searches through their `value` arrays.
|
|
17592
|
+
*
|
|
17593
|
+
* @param {string} semanticId - The `semanticId` of the SME to search for.
|
|
17594
|
+
* @param {Submodel | ISubmodelElement} submodelElement - The parent SM/SME to search within.
|
|
17595
|
+
* @returns {ISubmodelElement | undefined} The found SME or an empty object if not found or input is invalid.
|
|
17596
|
+
*/
|
|
17597
|
+
function getSubmodelElementBySemanticId(semanticId, submodelElement) {
|
|
17598
|
+
if (semanticId.trim() == '')
|
|
17599
|
+
return undefined;
|
|
17600
|
+
semanticId = semanticId.trim();
|
|
17601
|
+
if (!submodelElement?.modelType)
|
|
17602
|
+
return undefined;
|
|
17603
|
+
switch (submodelElement.modelType()) {
|
|
17604
|
+
case ModelType.Submodel: {
|
|
17605
|
+
const submodel = submodelElement;
|
|
17606
|
+
if (submodel.submodelElements && submodel.submodelElements.length > 0) {
|
|
17607
|
+
return submodel.submodelElements.find((sme) => {
|
|
17608
|
+
return checkSemanticId(sme, semanticId);
|
|
17609
|
+
});
|
|
17610
|
+
}
|
|
17611
|
+
break;
|
|
17612
|
+
}
|
|
17613
|
+
case ModelType.SubmodelElementCollection: {
|
|
17614
|
+
const collection = submodelElement;
|
|
17615
|
+
if (collection.value && collection.value.length > 0) {
|
|
17616
|
+
return collection.value.find((sme) => {
|
|
17617
|
+
return checkSemanticId(sme, semanticId);
|
|
17618
|
+
});
|
|
17619
|
+
}
|
|
17620
|
+
break;
|
|
17621
|
+
}
|
|
17622
|
+
case ModelType.SubmodelElementList: {
|
|
17623
|
+
const list = submodelElement;
|
|
17624
|
+
if (list.value && list.value.length > 0) {
|
|
17625
|
+
return list.value.find((sme) => {
|
|
17626
|
+
return checkSemanticId(sme, semanticId);
|
|
17627
|
+
});
|
|
17628
|
+
}
|
|
17629
|
+
break;
|
|
17630
|
+
}
|
|
17631
|
+
}
|
|
17632
|
+
return undefined;
|
|
17633
|
+
}
|
|
17634
|
+
/**
|
|
17635
|
+
* Retrieves an array of SubmodelElements (SMEs) by their `semanticId` from a given Submodel (SM) or SubmodelElement (SME).
|
|
17636
|
+
* If the `semanticId` is not found or if the input is invalid, an empty array is returned.
|
|
17637
|
+
*
|
|
17638
|
+
* The function supports the following types of elements:
|
|
17639
|
+
* - **Submodel (SM)**: Filters through `submodelElements`.
|
|
17640
|
+
* - **SubmodelElementCollection (SMC)** and **SubmodelElementList (SML)**: Filters through their `value` arrays.
|
|
17641
|
+
*
|
|
17642
|
+
* @param {string} semanticId - The `semanticId` of the SMEs to search for.
|
|
17643
|
+
* @param {Submodel | ISubmodelElement} submodelElement - The parent SM/SME to search within.
|
|
17644
|
+
* @returns {ISubmodelElement[]} An array of found SMEs matching the `idShort`, or an empty array if not found or input is invalid.
|
|
17645
|
+
*/
|
|
17646
|
+
function getSubmodelElementsBySemanticId(semanticId, submodelElement) {
|
|
17647
|
+
if (semanticId.trim() == '')
|
|
17648
|
+
return [];
|
|
17649
|
+
semanticId = semanticId.trim();
|
|
17650
|
+
if (!submodelElement?.modelType)
|
|
17651
|
+
return [];
|
|
17652
|
+
switch (submodelElement.modelType()) {
|
|
17653
|
+
case ModelType.Submodel: {
|
|
17654
|
+
const submodel = submodelElement;
|
|
17655
|
+
if (submodel.submodelElements && submodel.submodelElements.length > 0) {
|
|
17656
|
+
return submodel.submodelElements.filter((sme) => {
|
|
17657
|
+
return checkSemanticId(sme, semanticId);
|
|
17658
|
+
});
|
|
17659
|
+
}
|
|
17660
|
+
break;
|
|
17661
|
+
}
|
|
17662
|
+
case ModelType.SubmodelElementCollection: {
|
|
17663
|
+
const collection = submodelElement;
|
|
17664
|
+
if (collection.value && collection.value.length > 0) {
|
|
17665
|
+
return collection.value.filter((sme) => {
|
|
17666
|
+
return checkSemanticId(sme, semanticId);
|
|
17667
|
+
});
|
|
17668
|
+
}
|
|
17669
|
+
break;
|
|
17670
|
+
}
|
|
17671
|
+
case ModelType.SubmodelElementList: {
|
|
17672
|
+
const list = submodelElement;
|
|
17673
|
+
if (list.value && list.value.length > 0) {
|
|
17674
|
+
return list.value.filter((sme) => {
|
|
17675
|
+
return checkSemanticId(sme, semanticId);
|
|
17676
|
+
});
|
|
17677
|
+
}
|
|
17678
|
+
break;
|
|
17679
|
+
}
|
|
17680
|
+
}
|
|
17681
|
+
return [];
|
|
17682
|
+
}
|
|
17683
|
+
function extractVersionRevision(semanticId) {
|
|
17684
|
+
const failResponse = { version: '', revision: '' };
|
|
17685
|
+
if (semanticId.trim() == '')
|
|
17686
|
+
return failResponse;
|
|
17687
|
+
semanticId = semanticId.trim();
|
|
17688
|
+
const match = semanticId.match(versionRevisionRegex);
|
|
17689
|
+
if (match) {
|
|
17690
|
+
const response = {
|
|
17691
|
+
version: match && match[1] ? match[1] : '',
|
|
17692
|
+
revision: match && match[2] ? match[2] : '',
|
|
17693
|
+
};
|
|
17694
|
+
return response;
|
|
17695
|
+
}
|
|
17696
|
+
return failResponse;
|
|
17697
|
+
}
|
|
17698
|
+
|
|
17699
|
+
var SemanticIdUtils = /*#__PURE__*/Object.freeze({
|
|
17700
|
+
__proto__: null,
|
|
17701
|
+
checkSemanticId: checkSemanticId,
|
|
17702
|
+
checkSemanticIdEclassIrdi: checkSemanticIdEclassIrdi,
|
|
17703
|
+
checkSemanticIdEclassIrdiUrl: checkSemanticIdEclassIrdiUrl,
|
|
17704
|
+
checkSemanticIdIecCdd: checkSemanticIdIecCdd,
|
|
17705
|
+
checkSemanticIdIri: checkSemanticIdIri,
|
|
17706
|
+
extractVersionRevision: extractVersionRevision,
|
|
17707
|
+
getEquivalentEclassSemanticIds: getEquivalentEclassSemanticIds,
|
|
17708
|
+
getEquivalentIriSemanticIds: getEquivalentIriSemanticIds,
|
|
17709
|
+
getSubmodelElementBySemanticId: getSubmodelElementBySemanticId,
|
|
17710
|
+
getSubmodelElementsBySemanticId: getSubmodelElementsBySemanticId
|
|
17711
|
+
});
|
|
17712
|
+
|
|
17713
|
+
// Re-export all utilities as named exports for direct usage
|
|
17714
|
+
|
|
17715
|
+
var index = /*#__PURE__*/Object.freeze({
|
|
17716
|
+
__proto__: null,
|
|
17717
|
+
DescriptorUtils: DescriptorUtils,
|
|
17718
|
+
KeyTypesUtil: KeyTypesUtil,
|
|
17719
|
+
MultiLanguagePropertyUtils: MultiLanguagePropertyUtils,
|
|
17720
|
+
ReferableUtils: ReferableUtils,
|
|
17721
|
+
ReferenceUtil: ReferenceUtil,
|
|
17722
|
+
SemanticIdUtils: SemanticIdUtils,
|
|
17723
|
+
checkIdShort: checkIdShort,
|
|
17724
|
+
checkSemanticId: checkSemanticId,
|
|
17725
|
+
checkSemanticIdEclassIrdi: checkSemanticIdEclassIrdi,
|
|
17726
|
+
checkSemanticIdEclassIrdiUrl: checkSemanticIdEclassIrdiUrl,
|
|
17727
|
+
checkSemanticIdIecCdd: checkSemanticIdIecCdd,
|
|
17728
|
+
checkSemanticIdIri: checkSemanticIdIri,
|
|
17729
|
+
descriptionToDisplay: descriptionToDisplay,
|
|
17730
|
+
extractEndpointHref: extractEndpointHref,
|
|
17731
|
+
extractId: extractId,
|
|
17732
|
+
extractVersionRevision: extractVersionRevision,
|
|
17733
|
+
firstLangStringSetText: firstLangStringSetText,
|
|
17734
|
+
getEquivalentEclassSemanticIds: getEquivalentEclassSemanticIds,
|
|
17735
|
+
getEquivalentIriSemanticIds: getEquivalentIriSemanticIds,
|
|
17736
|
+
getKeyTypeAbbreviation: getKeyTypeAbbreviation,
|
|
17737
|
+
getSubmodelElementByIdShort: getSubmodelElementByIdShort,
|
|
17738
|
+
getSubmodelElementBySemanticId: getSubmodelElementBySemanticId,
|
|
17739
|
+
getSubmodelElementsByIdShort: getSubmodelElementsByIdShort,
|
|
17740
|
+
getSubmodelElementsBySemanticId: getSubmodelElementsBySemanticId,
|
|
17741
|
+
hasValue: hasValue,
|
|
17742
|
+
keyTypes: keyTypes,
|
|
17743
|
+
nameToDisplay: nameToDisplay,
|
|
17744
|
+
valueToDisplay: valueToDisplay
|
|
15643
17745
|
});
|
|
15644
17746
|
|
|
15645
17747
|
exports.AasDiscoveryClient = AasDiscoveryClient;
|
|
15646
|
-
exports.AasDiscoveryService = index$
|
|
17748
|
+
exports.AasDiscoveryService = index$3;
|
|
15647
17749
|
exports.AasRegistryClient = AasRegistryClient;
|
|
15648
|
-
exports.AasRegistryService = index$
|
|
17750
|
+
exports.AasRegistryService = index$5;
|
|
15649
17751
|
exports.AasRepositoryClient = AasRepositoryClient;
|
|
15650
|
-
exports.AasRepositoryService = index$
|
|
17752
|
+
exports.AasRepositoryService = index$8;
|
|
17753
|
+
exports.AasService = AasService;
|
|
15651
17754
|
exports.AasxFileClient = AasxFileClient;
|
|
15652
|
-
exports.AasxFileService = index$
|
|
17755
|
+
exports.AasxFileService = index$2;
|
|
17756
|
+
exports.AssetAdministrationShellDescriptor = AssetAdministrationShellDescriptor;
|
|
15653
17757
|
exports.BASE_PATH = BASE_PATH;
|
|
15654
17758
|
exports.BaseAPI = BaseAPI;
|
|
15655
17759
|
exports.BlobApiResponse = BlobApiResponse;
|
|
15656
17760
|
exports.COLLECTION_FORMATS = COLLECTION_FORMATS;
|
|
15657
17761
|
exports.ConceptDescriptionRepositoryClient = ConceptDescriptionRepositoryClient;
|
|
15658
|
-
exports.ConceptDescriptionRepositoryService = index$
|
|
17762
|
+
exports.ConceptDescriptionRepositoryService = index$6;
|
|
15659
17763
|
exports.Configuration = Configuration;
|
|
15660
17764
|
exports.DefaultConfig = DefaultConfig;
|
|
17765
|
+
exports.DescriptorUtils = DescriptorUtils;
|
|
15661
17766
|
exports.FetchError = FetchError;
|
|
15662
17767
|
exports.JSONApiResponse = JSONApiResponse;
|
|
15663
|
-
exports.
|
|
17768
|
+
exports.KeyTypesUtil = KeyTypesUtil;
|
|
17769
|
+
exports.Lib = index$1;
|
|
17770
|
+
exports.MultiLanguagePropertyUtils = MultiLanguagePropertyUtils;
|
|
17771
|
+
exports.ReferableUtils = ReferableUtils;
|
|
17772
|
+
exports.ReferenceUtil = ReferenceUtil;
|
|
15664
17773
|
exports.RequiredError = RequiredError;
|
|
15665
17774
|
exports.ResponseError = ResponseError;
|
|
17775
|
+
exports.SemanticIdUtils = SemanticIdUtils;
|
|
17776
|
+
exports.SubmodelDescriptor = SubmodelDescriptor;
|
|
15666
17777
|
exports.SubmodelRegistryClient = SubmodelRegistryClient;
|
|
15667
|
-
exports.SubmodelRegistryService = index$
|
|
17778
|
+
exports.SubmodelRegistryService = index$4;
|
|
15668
17779
|
exports.SubmodelRepositoryClient = SubmodelRepositoryClient;
|
|
15669
|
-
exports.SubmodelRepositoryService = index$
|
|
17780
|
+
exports.SubmodelRepositoryService = index$7;
|
|
17781
|
+
exports.SubmodelService = SubmodelService;
|
|
15670
17782
|
exports.TextApiResponse = TextApiResponse;
|
|
17783
|
+
exports.Utils = index;
|
|
15671
17784
|
exports.VoidApiResponse = VoidApiResponse;
|
|
17785
|
+
exports.applyDefaults = applyDefaults;
|
|
17786
|
+
exports.assetAdministrationShellDescriptorFromJsonable = assetAdministrationShellDescriptorFromJsonable;
|
|
17787
|
+
exports.base64Decode = base64Decode;
|
|
17788
|
+
exports.base64Encode = base64Encode$1;
|
|
15672
17789
|
exports.canConsumeForm = canConsumeForm;
|
|
17790
|
+
exports.checkIdShort = checkIdShort;
|
|
17791
|
+
exports.checkSemanticId = checkSemanticId;
|
|
17792
|
+
exports.checkSemanticIdEclassIrdi = checkSemanticIdEclassIrdi;
|
|
17793
|
+
exports.checkSemanticIdEclassIrdiUrl = checkSemanticIdEclassIrdiUrl;
|
|
17794
|
+
exports.checkSemanticIdIecCdd = checkSemanticIdIecCdd;
|
|
17795
|
+
exports.checkSemanticIdIri = checkSemanticIdIri;
|
|
17796
|
+
exports.convertApiAasDescriptorToCoreAasDescriptor = convertApiAasDescriptorToCoreAasDescriptor;
|
|
17797
|
+
exports.convertApiAasToCoreAas = convertApiAasToCoreAas;
|
|
17798
|
+
exports.convertApiAssetIdToCoreAssetId = convertApiAssetIdToCoreAssetId;
|
|
17799
|
+
exports.convertApiAssetInformationToCoreAssetInformation = convertApiAssetInformationToCoreAssetInformation;
|
|
17800
|
+
exports.convertApiCDToCoreCD = convertApiCDToCoreCD;
|
|
17801
|
+
exports.convertApiReferenceToCoreReference = convertApiReferenceToCoreReference;
|
|
17802
|
+
exports.convertApiSubmodelDescriptorToCoreSubmodelDescriptor = convertApiSubmodelDescriptorToCoreSubmodelDescriptor;
|
|
17803
|
+
exports.convertApiSubmodelElementToCoreSubmodelElement = convertApiSubmodelElementToCoreSubmodelElement;
|
|
17804
|
+
exports.convertApiSubmodelToCoreSubmodel = convertApiSubmodelToCoreSubmodel;
|
|
17805
|
+
exports.convertCoreAasDescriptorToApiAasDescriptor = convertCoreAasDescriptorToApiAasDescriptor;
|
|
17806
|
+
exports.convertCoreAasToApiAas = convertCoreAasToApiAas;
|
|
17807
|
+
exports.convertCoreAssetIdToApiAssetId = convertCoreAssetIdToApiAssetId;
|
|
17808
|
+
exports.convertCoreAssetInformationToApiAssetInformation = convertCoreAssetInformationToApiAssetInformation;
|
|
17809
|
+
exports.convertCoreCDToApiCD = convertCoreCDToApiCD;
|
|
17810
|
+
exports.convertCoreReferenceToApiReference = convertCoreReferenceToApiReference;
|
|
17811
|
+
exports.convertCoreSubmodelDescriptorToApiSubmodelDescriptor = convertCoreSubmodelDescriptorToApiSubmodelDescriptor;
|
|
17812
|
+
exports.convertCoreSubmodelElementToApiSubmodelElement = convertCoreSubmodelElementToApiSubmodelElement;
|
|
17813
|
+
exports.convertCoreSubmodelToApiSubmodel = convertCoreSubmodelToApiSubmodel;
|
|
17814
|
+
exports.descriptionToDisplay = descriptionToDisplay;
|
|
17815
|
+
exports.endpointFromJsonable = endpointFromJsonable;
|
|
15673
17816
|
exports.exists = exists;
|
|
17817
|
+
exports.extractEndpointHref = extractEndpointHref;
|
|
17818
|
+
exports.extractId = extractId;
|
|
17819
|
+
exports.extractVersionRevision = extractVersionRevision;
|
|
17820
|
+
exports.firstLangStringSetText = firstLangStringSetText;
|
|
17821
|
+
exports.getEquivalentEclassSemanticIds = getEquivalentEclassSemanticIds;
|
|
17822
|
+
exports.getEquivalentIriSemanticIds = getEquivalentIriSemanticIds;
|
|
17823
|
+
exports.getKeyTypeAbbreviation = getKeyTypeAbbreviation;
|
|
17824
|
+
exports.getSubmodelElementByIdShort = getSubmodelElementByIdShort;
|
|
17825
|
+
exports.getSubmodelElementBySemanticId = getSubmodelElementBySemanticId;
|
|
17826
|
+
exports.getSubmodelElementsByIdShort = getSubmodelElementsByIdShort;
|
|
17827
|
+
exports.getSubmodelElementsBySemanticId = getSubmodelElementsBySemanticId;
|
|
17828
|
+
exports.handleApiError = handleApiError;
|
|
17829
|
+
exports.hasValue = hasValue;
|
|
17830
|
+
exports.keyTypes = keyTypes;
|
|
17831
|
+
exports.nameToDisplay = nameToDisplay;
|
|
17832
|
+
exports.protocolInformationFromJsonable = protocolInformationFromJsonable;
|
|
15674
17833
|
exports.querystring = querystring;
|
|
17834
|
+
exports.submodelDescriptorFromJsonable = submodelDescriptorFromJsonable;
|
|
17835
|
+
exports.toJsonableAssetAdministrationShellDescriptor = toJsonableAssetAdministrationShellDescriptor;
|
|
17836
|
+
exports.toJsonableEndpoint = toJsonableEndpoint;
|
|
17837
|
+
exports.toJsonableProtocolInformation = toJsonableProtocolInformation;
|
|
17838
|
+
exports.toJsonableSecurityAttribute = toJsonableSecurityAttribute;
|
|
17839
|
+
exports.toJsonableSubmodelDescriptor = toJsonableSubmodelDescriptor;
|
|
17840
|
+
exports.valueToDisplay = valueToDisplay;
|
|
15675
17841
|
//# sourceMappingURL=index.cjs.map
|