basyx-typescript-sdk 0.2.0 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -52,7 +52,7 @@ async function getAllShells() {
52
52
  const client = new AasRepositoryClient();
53
53
 
54
54
  try {
55
- const response = await client.getAllAssetAdministrationShells(baseURL);
55
+ const response = await client.getAllAssetAdministrationShells({ baseUrl: baseURL });
56
56
  console.log('Asset Administration Shells fetched successfully:', response);
57
57
  // You can now use the response as needed
58
58
  } catch (error) {
package/bundle/index.js CHANGED
@@ -648,51 +648,58 @@ function createCustomClient(baseURL, headers = new Headers()) {
648
648
 
649
649
  class AasRepositoryClient {
650
650
  /**
651
- * Returns all Asset Administration Shells
651
+ * Returns all Asset Administration Shells.
652
652
  *
653
- * @function getAllAssetAdministrationShells
654
- * @param {GetAllAssetAdministrationShellsOptions} options - Options object.
655
- * @param {string} options.baseUrl - The API base URL
656
- * @param {Headers} [options.headers] - Request headers
657
- * @param {string[]} [options.assetIds] - A list of specific Asset identifiers. Every single value asset identifier is a base64-url-encoded
658
- * @param {string} [options.idShort] - The Asset Administration Shell's IdShort
659
- * @param {number} [options.limit] - The maximum number of elements in the response array
660
- * @param {string} [options.cursor] - A server-generated identifier retrieved from pagingMetadata that specifies from which position the result listing should continue
661
- * @returns {Promise<GetAllAssetAdministrationShellsResponse>} Requested Asset Administration Shells
653
+ * @param options Object containing:
654
+ * - baseUrl: The API base URL
655
+ * - headers?: Optional Request headers
656
+ * - assetIds?: A list of asset identifiers
657
+ * - idShort?: The AAS's idShort
658
+ * - limit?: Max number of elements to return
659
+ * - cursor?: A paging cursor from previous responses
660
+ *
661
+ * @returns Either `{ success: true; data: ... }` or `{ success: false; error: ... }`.
662
662
  */
663
- async getAllAssetAdministrationShells({ baseUrl, headers, assetIds, idShort, limit, cursor, }) {
663
+ async getAllAssetAdministrationShells(options) {
664
+ const { baseUrl, headers, assetIds, idShort, limit, cursor } = options;
664
665
  try {
665
666
  const client = createCustomClient(baseUrl, headers);
667
+ const encodedAssetIds = assetIds?.map((id) => base64Encode(JSON.stringify(id)));
666
668
  const { data, error } = await getAllAssetAdministrationShells({
667
669
  client,
668
- query: { assetIds, idShort, limit, cursor },
670
+ query: { assetIds: encodedAssetIds, idShort, limit, cursor },
669
671
  });
670
672
  if (error) {
671
- console.error('Error from server:', error);
672
- throw new Error(JSON.stringify(error.messages));
673
+ return { success: false, error };
673
674
  }
674
675
  const shells = (data.result ?? []).map(convertApiAasToCoreAas);
675
676
  return {
676
- pagedResult: data.paging_metadata,
677
- result: shells,
677
+ success: true,
678
+ data: {
679
+ pagedResult: data.paging_metadata,
680
+ result: shells,
681
+ },
678
682
  };
679
683
  }
680
- catch (error) {
681
- console.error('Error fetching Asset Administration Shells:', error);
682
- throw error;
684
+ catch (err) {
685
+ return {
686
+ success: false,
687
+ error: err instanceof Error ? err : new Error(String(err)),
688
+ };
683
689
  }
684
690
  }
685
691
  /**
686
- * Creates a new Asset Administration Shell
692
+ * Creates a new Asset Administration Shell.
693
+ *
694
+ * @param options Object containing:
695
+ * - baseUrl: The API base URL
696
+ * - assetAdministrationShell: The AAS to create
697
+ * - headers?: Optional request headers
687
698
  *
688
- * @function postAssetAdministrationShell
689
- * @param {PostAssetAdministrationShellOptions} options - Options object.
690
- * @param {string} options.baseUrl - The API base URL
691
- * @param {AssetAdministrationShell} options.assetAdministrationShell - Asset Administration Shell object
692
- * @param {Headers} [options.headers] - Request headers
693
- * @returns {Promise<AssetAdministrationShell>} Asset Administration Shell created successfully
699
+ * @returns Either `{ success: true; data: ... }` or `{ success: false; error: ... }`.
694
700
  */
695
- async postAssetAdministrationShell({ baseUrl, assetAdministrationShell, headers, }) {
701
+ async postAssetAdministrationShell(options) {
702
+ const { baseUrl, assetAdministrationShell, headers } = options;
696
703
  try {
697
704
  const client = createCustomClient(baseUrl, headers);
698
705
  const { data, error } = await postAssetAdministrationShell({
@@ -700,56 +707,54 @@ class AasRepositoryClient {
700
707
  body: convertCoreAasToApiAas(assetAdministrationShell),
701
708
  });
702
709
  if (error) {
703
- console.error('Error from server:', error);
704
- throw new Error(JSON.stringify(error.messages));
710
+ return { success: false, error };
705
711
  }
706
- return convertApiAasToCoreAas(data);
712
+ return { success: true, data: convertApiAasToCoreAas(data) };
707
713
  }
708
- catch (error) {
709
- console.error('Error creating Asset Administration Shell:', error);
710
- throw error;
714
+ catch (err) {
715
+ return { success: false, error: err instanceof Error ? err : new Error(String(err)) };
711
716
  }
712
717
  }
713
718
  /**
714
- * Deletes an Asset Administration Shell
719
+ * Deletes an Asset Administration Shell by its unique identifier.
720
+ *
721
+ * @param options Object containing:
722
+ * - baseUrl: The API base URL
723
+ * - aasIdentifier: The unique ID for the AAS
724
+ * - headers?: Optional request headers
715
725
  *
716
- * @function deleteAssetAdministrationShellById
717
- * @param {AasIdentifierOptions} options - Options object.
718
- * @param {string} options.baseUrl - The API base URL
719
- * @param {string} options.aasIdentifier - The Asset Administration Shell's unique id
720
- * @param {Headers} [options.headers] - Request headers
721
- * @returns {Promise<void>} Asset Administration Shell deleted successfully
726
+ * @returns Either `{ success: true; data: ... }` or `{ success: false; error: ... }`.
722
727
  */
723
- async deleteAssetAdministrationShellById({ baseUrl, aasIdentifier, headers }) {
728
+ async deleteAssetAdministrationShellById(options) {
729
+ const { baseUrl, aasIdentifier, headers } = options;
724
730
  try {
725
731
  const client = createCustomClient(baseUrl, headers);
726
732
  const encodedAasIdentifier = base64Encode(aasIdentifier);
727
- const { error } = await deleteAssetAdministrationShellById({
733
+ const { data, error } = await deleteAssetAdministrationShellById({
728
734
  client,
729
735
  path: { aasIdentifier: encodedAasIdentifier },
730
736
  });
731
737
  if (error) {
732
- console.error('Error from server:', error);
733
- throw new Error(JSON.stringify(error.messages));
738
+ return { success: false, error };
734
739
  }
735
- return;
740
+ return { success: true, data };
736
741
  }
737
- catch (error) {
738
- console.error('Error deleting Asset Administration Shell:', error);
739
- throw error;
742
+ catch (err) {
743
+ return { success: false, error: err instanceof Error ? err : new Error(String(err)) };
740
744
  }
741
745
  }
742
746
  /**
743
- * Returns a specific Asset Administration Shell
747
+ * Returns a specific Asset Administration Shell by its unique identifier.
744
748
  *
745
- * @function getAssetAdministrationShellById
746
- * @param {AasIdentifierOptions} options - Options object.
747
- * @param {string} options.baseUrl - The API base URL
748
- * @param {string} options.aasIdentifier - The Asset Administration Shell's unique id
749
- * @param {Headers} [options.headers] - Request headers
750
- * @returns {Promise<AssetAdministrationShell>} Requested Asset Administration Shell
749
+ * @param options Object containing:
750
+ * - baseUrl: The API base URL
751
+ * - aasIdentifier: The unique ID
752
+ * - headers?: Optional request headers
753
+ *
754
+ * @returns Either `{ success: true; data: ... }` or `{ success: false; error: ... }`.
751
755
  */
752
- async getAssetAdministrationShellById({ baseUrl, aasIdentifier, headers, }) {
756
+ async getAssetAdministrationShellById(options) {
757
+ const { baseUrl, aasIdentifier, headers } = options;
753
758
  try {
754
759
  const client = createCustomClient(baseUrl, headers);
755
760
  const encodedAasIdentifier = base64Encode(aasIdentifier);
@@ -758,58 +763,56 @@ class AasRepositoryClient {
758
763
  path: { aasIdentifier: encodedAasIdentifier },
759
764
  });
760
765
  if (error) {
761
- console.error('Error from server:', error);
762
- throw new Error(JSON.stringify(error.messages));
766
+ return { success: false, error };
763
767
  }
764
- return convertApiAasToCoreAas(data);
768
+ return { success: true, data: convertApiAasToCoreAas(data) };
765
769
  }
766
- catch (error) {
767
- console.error('Error fetching Asset Administration Shell:', error);
768
- throw error;
770
+ catch (err) {
771
+ return { success: false, error: err instanceof Error ? err : new Error(String(err)) };
769
772
  }
770
773
  }
771
774
  /**
772
- * Updates an existing Asset Administration Shell
775
+ * Updates an existing Asset Administration Shell by ID (PUT).
776
+ *
777
+ * @param options Object containing:
778
+ * - baseUrl: The API base URL
779
+ * - aasIdentifier: The unique ID
780
+ * - assetAdministrationShell: The updated AAS object
781
+ * - headers?: Optional request headers
773
782
  *
774
- * @function putAssetAdministrationShellById
775
- * @param {PutAssetAdministrationShellOptions} options - Options object.
776
- * @param {string} options.baseUrl - The API base URL
777
- * @param {string} options.aasIdentifier - The Asset Administration Shell's unique id
778
- * @param {AssetAdministrationShell} options.assetAdministrationShell - Asset Administration Shell object
779
- * @param {Headers} [options.headers] - Request headers
780
- * @returns {Promise<void>} Asset Administration Shell updated successfully
783
+ * @returns Either `{ success: true; data: ... }` or `{ success: false; error: ... }`.
781
784
  */
782
- async putAssetAdministrationShellById({ baseUrl, aasIdentifier, assetAdministrationShell, headers, }) {
785
+ async putAssetAdministrationShellById(options) {
786
+ const { baseUrl, aasIdentifier, assetAdministrationShell, headers } = options;
783
787
  try {
784
788
  const client = createCustomClient(baseUrl, headers);
785
789
  const encodedAasIdentifier = base64Encode(aasIdentifier);
786
- const { error } = await putAssetAdministrationShellById({
790
+ const { data, error } = await putAssetAdministrationShellById({
787
791
  client,
788
792
  path: { aasIdentifier: encodedAasIdentifier },
789
793
  body: convertCoreAasToApiAas(assetAdministrationShell),
790
794
  });
791
795
  if (error) {
792
- console.error('Error from server:', error);
793
- throw new Error(JSON.stringify(error.messages));
796
+ return { success: false, error };
794
797
  }
795
- return;
798
+ return { success: true, data };
796
799
  }
797
- catch (error) {
798
- console.error('Error updating Asset Administration Shell:', error);
799
- throw error;
800
+ catch (err) {
801
+ return { success: false, error: err instanceof Error ? err : new Error(String(err)) };
800
802
  }
801
803
  }
802
804
  /**
803
- * Returns the Asset Information
805
+ * Returns the AssetInformation for the given AAS.
806
+ *
807
+ * @param options Object containing:
808
+ * - baseUrl: The API base URL
809
+ * - aasIdentifier: The unique ID
810
+ * - headers?: Optional request headers
804
811
  *
805
- * @function getAssetInformation
806
- * @param {AasIdentifierOptions} options - Options object.
807
- * @param {string} options.baseUrl - The API base URL
808
- * @param {string} options.aasIdentifier - The Asset Administration Shell's unique id
809
- * @param {Headers} [options.headers] - Request headers
810
- * @returns {Promise<AssetInformation>} Requested Asset Information
812
+ * @returns Either `{ success: true; data: ... }` or `{ success: false; error: ... }`.
811
813
  */
812
- async getAssetInformation({ baseUrl, aasIdentifier, headers }) {
814
+ async getAssetInformation(options) {
815
+ const { baseUrl, aasIdentifier, headers } = options;
813
816
  try {
814
817
  const client = createCustomClient(baseUrl, headers);
815
818
  const encodedAasIdentifier = base64Encode(aasIdentifier);
@@ -818,87 +821,90 @@ class AasRepositoryClient {
818
821
  path: { aasIdentifier: encodedAasIdentifier },
819
822
  });
820
823
  if (error) {
821
- console.error('Error from server:', error);
822
- throw new Error(JSON.stringify(error.messages));
824
+ return { success: false, error };
823
825
  }
824
- return convertApiAssetInformationToCoreAssetInformation(data);
826
+ return {
827
+ success: true,
828
+ data: convertApiAssetInformationToCoreAssetInformation(data),
829
+ };
825
830
  }
826
- catch (error) {
827
- console.error('Error fetching Asset Information:', error);
828
- throw error;
831
+ catch (err) {
832
+ return { success: false, error: err instanceof Error ? err : new Error(String(err)) };
829
833
  }
830
834
  }
831
835
  /**
832
- * Updates the Asset Information
836
+ * Updates the AssetInformation for the given AAS.
837
+ *
838
+ * @param options Object containing:
839
+ * - baseUrl: The API base URL
840
+ * - aasIdentifier: The unique ID
841
+ * - assetInformation: The updated AssetInformation object
842
+ * - headers?: Optional request headers
833
843
  *
834
- * @function putAssetInformation
835
- * @param {PutAssetInformationOptions} options - Options object.
836
- * @param {string} options.baseUrl - The API base URL
837
- * @param {string} options.aasIdentifier - The Asset Administration Shell's unique id
838
- * @param {AssetInformation} options.assetInformation - Asset Information object
839
- * @param {Headers} [options.headers] - Request headers
840
- * @returns {Promise<void>} Asset Information updated successfully
844
+ * @returns Either `{ success: true; data: ... }` or `{ success: false; error: ... }`.
841
845
  */
842
- async putAssetInformation({ baseUrl, aasIdentifier, assetInformation, headers, }) {
846
+ async putAssetInformation(options) {
847
+ const { baseUrl, aasIdentifier, assetInformation, headers } = options;
843
848
  try {
844
849
  const client = createCustomClient(baseUrl, headers);
845
850
  const encodedAasIdentifier = base64Encode(aasIdentifier);
846
- const { error } = await putAssetInformationAasRepository({
851
+ const { data, error } = await putAssetInformationAasRepository({
847
852
  client,
848
853
  path: { aasIdentifier: encodedAasIdentifier },
849
854
  body: convertCoreAssetInformationToApiAssetInformation(assetInformation),
850
855
  });
851
856
  if (error) {
852
- console.error('Error from server:', error);
853
- throw new Error(JSON.stringify(error.messages));
857
+ return { success: false, error };
854
858
  }
855
- return;
859
+ return { success: true, data };
856
860
  }
857
- catch (error) {
858
- console.error('Error updating Asset Information:', error);
859
- throw error;
861
+ catch (err) {
862
+ return { success: false, error: err instanceof Error ? err : new Error(String(err)) };
860
863
  }
861
864
  }
862
865
  /**
863
- * Deletes the Thumbnail
866
+ * Deletes the Thumbnail associated with the given AAS.
864
867
  *
865
- * @function deleteThumbnail
866
- * @param {AasIdentifierOptions} options - Options object.
867
- * @param {string} options.baseUrl - The API base URL
868
- * @param {string} options.aasIdentifier - The Asset Administration Shell's unique id
869
- * @param {Headers} [options.headers] - Request headers
870
- * @returns {Promise<void>} Thumbnail deletion successful
868
+ * @param options Object containing:
869
+ * - baseUrl: The API base URL
870
+ * - aasIdentifier: The unique ID
871
+ * - headers?: Optional request headers
872
+ *
873
+ * @returns Either `{ success: true; data: ... }` or `{ success: false; error: ... }`.
871
874
  */
872
- async deleteThumbnail({ baseUrl, aasIdentifier, headers }) {
875
+ async deleteThumbnail(options) {
876
+ const { baseUrl, aasIdentifier, headers } = options;
873
877
  try {
874
878
  const client = createCustomClient(baseUrl, headers);
875
879
  const encodedAasIdentifier = base64Encode(aasIdentifier);
876
- const { error } = await deleteThumbnailAasRepository({
880
+ const { data, error } = await deleteThumbnailAasRepository({
877
881
  client,
878
882
  path: { aasIdentifier: encodedAasIdentifier },
879
883
  });
880
884
  if (error) {
881
- console.error('Error from server:', error);
882
- throw new Error(JSON.stringify(error.messages));
885
+ return { success: false, error };
883
886
  }
884
- return;
887
+ return {
888
+ success: true,
889
+ data: data,
890
+ };
885
891
  }
886
- catch (error) {
887
- console.error('Error deleting Thumbnail:', error);
888
- throw error;
892
+ catch (err) {
893
+ return { success: false, error: err instanceof Error ? err : new Error(String(err)) };
889
894
  }
890
895
  }
891
896
  /**
892
- * Returns the Thumbnail
897
+ * Returns the Thumbnail associated with an AAS, if any.
893
898
  *
894
- * @function getThumbnail
895
- * @param {AasIdentifierOptions} options - Options object.
896
- * @param {string} options.baseUrl - The API base URL
897
- * @param {string} options.aasIdentifier - The Asset Administration Shell's unique id
898
- * @param {Headers} [options.headers] - Request headers
899
- * @returns {Promise<Blob | File>} The thumbnail of the Asset Information.
899
+ * @param options Object containing:
900
+ * - baseUrl: The API base URL
901
+ * - aasIdentifier: The unique ID
902
+ * - headers?: Optional request headers
903
+ *
904
+ * @returns Either `{ success: true; data: ... }` or `{ success: false; error: ... }`.
900
905
  */
901
- async getThumbnail({ baseUrl, aasIdentifier, headers }) {
906
+ async getThumbnail(options) {
907
+ const { baseUrl, aasIdentifier, headers } = options;
902
908
  try {
903
909
  const client = createCustomClient(baseUrl, headers);
904
910
  const encodedAasIdentifier = base64Encode(aasIdentifier);
@@ -907,98 +913,95 @@ class AasRepositoryClient {
907
913
  path: { aasIdentifier: encodedAasIdentifier },
908
914
  });
909
915
  if (error) {
910
- console.error('Error from server:', error);
911
- throw new Error(JSON.stringify(error.messages));
916
+ return { success: false, error };
912
917
  }
913
- return data;
918
+ return { success: true, data };
914
919
  }
915
- catch (error) {
916
- console.error('Error fetching Thumbnail:', error);
917
- throw error;
920
+ catch (err) {
921
+ return { success: false, error: err instanceof Error ? err : new Error(String(err)) };
918
922
  }
919
923
  }
920
924
  /**
921
- * Updates the Thumbnail
925
+ * Updates (or creates) the Thumbnail for the given AAS.
926
+ *
927
+ * @param options Object containing:
928
+ * - baseUrl: The API base URL
929
+ * - aasIdentifier: The unique ID
930
+ * - thumbnail: The thumbnail data to upload
931
+ * - headers?: Optional request headers
922
932
  *
923
- * @function putThumbnail
924
- * @param {PutThumbnailOptions} options - Options object.
925
- * @param {string} options.baseUrl - The API base URL
926
- * @param {string} options.aasIdentifier - The Asset Administration Shell's unique id
927
- * @param {AssetinformationThumbnailBody} options.thumbnail - Thumbnail to upload
928
- * @param {Headers} [options.headers] - Request headers
929
- * @returns {Promise<void>} Thumbnail updated successfully
933
+ * @returns Either `{ success: true; data: ... }` or `{ success: false; error: ... }`.
930
934
  */
931
- async putThumbnail({ baseUrl, aasIdentifier, thumbnail, headers }) {
935
+ async putThumbnail(options) {
936
+ const { baseUrl, aasIdentifier, thumbnail, headers } = options;
932
937
  try {
933
938
  const client = createCustomClient(baseUrl, headers);
934
939
  const encodedAasIdentifier = base64Encode(aasIdentifier);
935
- const { error } = await putThumbnailAasRepository({
940
+ const { data, error } = await putThumbnailAasRepository({
936
941
  client,
937
942
  path: { aasIdentifier: encodedAasIdentifier },
938
943
  body: thumbnail,
939
944
  });
940
945
  if (error) {
941
- console.error('Error from server:', error);
942
- throw new Error(JSON.stringify(error.messages));
946
+ return { success: false, error };
943
947
  }
944
- return;
948
+ return { success: true, data };
945
949
  }
946
- catch (error) {
947
- console.error('Error updating Thumbnail:', error);
948
- throw error;
950
+ catch (err) {
951
+ return { success: false, error: err instanceof Error ? err : new Error(String(err)) };
949
952
  }
950
953
  }
951
954
  /**
952
- * Returns all submodel references
955
+ * Returns all submodel references for the given AAS.
956
+ *
957
+ * @param options Object containing:
958
+ * - baseUrl: The API base URL
959
+ * - aasIdentifier: The unique ID
960
+ * - headers?: Optional request headers
961
+ * - limit?: Max number of elements
962
+ * - cursor?: Paging cursor
953
963
  *
954
- * @function getAllSubmodelReferences
955
- * @param {GetAllSubmodelReferencesOptions} options - Options object.
956
- * @param {string} options.baseUrl - The API base URL
957
- * @param {string} options.aasIdentifier - The Asset Administration Shell's unique id
958
- * @param {Headers} [options.headers] - Request headers
959
- * @param {number} [options.limit] - The maximum number of elements in the response array
960
- * @param {string} [options.cursor] - A server-generated identifier retrieved from pagingMetadata that specifies from which position the result listing should continue
961
- * @returns {Promise<GetAllSubmodelReferencesResponse>} Requested submodel references
964
+ * @returns Either `{ success: true; data: ... }` or `{ success: false; error: ... }`.
962
965
  */
963
- async getAllSubmodelReferences({ baseUrl, aasIdentifier, headers, limit, cursor, }) {
966
+ async getAllSubmodelReferences(options) {
967
+ const { baseUrl, aasIdentifier, headers, limit, cursor } = options;
964
968
  try {
965
969
  const client = createCustomClient(baseUrl, headers);
966
970
  const encodedAasIdentifier = base64Encode(aasIdentifier);
967
971
  const { data, error } = await getAllSubmodelReferencesAasRepository({
968
972
  client,
969
973
  path: { aasIdentifier: encodedAasIdentifier },
970
- query: {
971
- limit,
972
- cursor,
973
- },
974
+ query: { limit, cursor },
974
975
  });
975
976
  if (error) {
976
- console.error('Error from server:', error);
977
- throw new Error(JSON.stringify(error.messages));
977
+ return { success: false, error };
978
978
  }
979
979
  const submodelReferences = (data.result ?? []).map(convertApiReferenceToCoreReference);
980
980
  return {
981
- pagedResult: data.paging_metadata,
982
- result: submodelReferences,
981
+ success: true,
982
+ data: {
983
+ pagedResult: data.paging_metadata,
984
+ result: submodelReferences,
985
+ },
983
986
  };
984
987
  }
985
- catch (error) {
986
- console.error('Error fetching Submodel References:', error);
987
- throw error;
988
+ catch (err) {
989
+ return { success: false, error: err instanceof Error ? err : new Error(String(err)) };
988
990
  }
989
991
  }
990
992
  /**
991
- * Creates a submodel reference at the Asset Administration Shell
993
+ * Creates a submodel reference at the given AAS.
994
+ *
995
+ * @param options Object containing:
996
+ * - baseUrl: The API base URL
997
+ * - aasIdentifier: The unique ID of the AAS
998
+ * - submodelReference: The Reference to the submodel
999
+ * - headers?: Optional request headers
992
1000
  *
993
- * @function postSubmodelReference
994
- * @param {PostSubmodelReferenceOptions} options - Options object.
995
- * @param {string} options.baseUrl - The API base URL
996
- * @param {string} options.aasIdentifier - The Asset Administration Shell's unique id
997
- * @param {Reference} options.submodelReference - Reference to the Submodel
998
- * @param {Headers} [options.headers] - Request headers
999
- * @returns {Promise<Reference>} Submodel reference created successfully
1001
+ * @returns Either `{ success: true; data: ... }` or `{ success: false; error: ... }`.
1000
1002
  */
1001
- async postSubmodelReference({ baseUrl, aasIdentifier, submodelReference, headers, }) {
1003
+ async postSubmodelReference(options) {
1004
+ const { baseUrl, aasIdentifier, submodelReference, headers } = options;
1002
1005
  try {
1003
1006
  const client = createCustomClient(baseUrl, headers);
1004
1007
  const encodedAasIdentifier = base64Encode(aasIdentifier);
@@ -1008,52 +1011,52 @@ class AasRepositoryClient {
1008
1011
  body: convertCoreReferenceToApiReference(submodelReference),
1009
1012
  });
1010
1013
  if (error) {
1011
- console.error('Error from server:', error);
1012
- throw new Error(JSON.stringify(error.messages));
1014
+ return { success: false, error };
1013
1015
  }
1014
- return convertApiReferenceToCoreReference(data);
1016
+ return { success: true, data: convertApiReferenceToCoreReference(data) };
1015
1017
  }
1016
- catch (error) {
1017
- console.error('Error creating Submodel Reference:', error);
1018
- throw error;
1018
+ catch (err) {
1019
+ return { success: false, error: err instanceof Error ? err : new Error(String(err)) };
1019
1020
  }
1020
1021
  }
1021
1022
  /**
1022
- * Deletes the submodel reference from the Asset Administration Shell. Does not delete the submodel itself!
1023
+ * Deletes a submodel reference from the given AAS (does not delete the submodel itself).
1023
1024
  *
1024
- * @function deleteSubmodelReferenceById
1025
- * @param {DeleteSubmodelReferenceByIdOptions} options - Options object.
1026
- * @param {string} options.baseUrl - The API base URL
1027
- * @param {string} options.aasIdentifier - The Asset Administration Shell's unique id
1028
- * @param {string} options.submodelIdentifier - The Submodel's unique id
1029
- * @param {Headers} [options.headers] - Request headers
1030
- * @returns {Promise<void>} Submodel reference deleted successfully
1025
+ * @param options Object containing:
1026
+ * - baseUrl: The API base URL
1027
+ * - aasIdentifier: Unique ID of the AAS
1028
+ * - submodelIdentifier: The submodel's unique ID
1029
+ * - headers?: Optional request headers
1030
+ *
1031
+ * @returns Either `{ success: true; data: ... }` or `{ success: false; error: ... }`.
1031
1032
  */
1032
- async deleteSubmodelReferenceById({ baseUrl, aasIdentifier, submodelIdentifier, headers, }) {
1033
+ async deleteSubmodelReferenceById(options) {
1034
+ const { baseUrl, aasIdentifier, submodelIdentifier, headers } = options;
1033
1035
  try {
1034
1036
  const client = createCustomClient(baseUrl, headers);
1035
1037
  const encodedAasIdentifier = base64Encode(aasIdentifier);
1036
1038
  const encodedSubmodelIdentifier = base64Encode(submodelIdentifier);
1037
- const { error } = await deleteSubmodelReferenceByIdAasRepository({
1039
+ const { data, error } = await deleteSubmodelReferenceByIdAasRepository({
1038
1040
  client,
1039
- path: { aasIdentifier: encodedAasIdentifier, submodelIdentifier: encodedSubmodelIdentifier },
1041
+ path: {
1042
+ aasIdentifier: encodedAasIdentifier,
1043
+ submodelIdentifier: encodedSubmodelIdentifier,
1044
+ },
1040
1045
  });
1041
1046
  if (error) {
1042
- console.error('Error from server:', error);
1043
- throw new Error(JSON.stringify(error.messages));
1047
+ return { success: false, error };
1044
1048
  }
1045
- return;
1049
+ return { success: true, data };
1046
1050
  }
1047
- catch (error) {
1048
- console.error('Error deleting Submodel Reference:', error);
1049
- throw error;
1051
+ catch (err) {
1052
+ return { success: false, error: err instanceof Error ? err : new Error(String(err)) };
1050
1053
  }
1051
1054
  }
1052
1055
  }
1053
1056
 
1054
- var aasRepository = /*#__PURE__*/Object.freeze({
1057
+ var index = /*#__PURE__*/Object.freeze({
1055
1058
  __proto__: null
1056
1059
  });
1057
1060
 
1058
- export { AasRepositoryClient, aasRepository as AasRepositoryModels, types_gen as AasTypes };
1061
+ export { AasRepositoryClient, types_gen as AasTypes, index as Models };
1059
1062
  //# sourceMappingURL=index.js.map