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