basyx-typescript-sdk 0.2.0 → 0.2.2

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.js CHANGED
@@ -648,412 +648,419 @@ 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);
666
- const { data, error } = await getAllAssetAdministrationShells({
667
+ const encodedAssetIds = assetIds?.map((id) => base64Encode(JSON.stringify(id)));
668
+ const result = await getAllAssetAdministrationShells({
667
669
  client,
668
- query: { assetIds, idShort, limit, cursor },
670
+ query: { assetIds: encodedAssetIds, idShort, limit, cursor },
669
671
  });
670
- if (error) {
671
- console.error('Error from server:', error);
672
- throw new Error(JSON.stringify(error.messages));
672
+ if (result.error) {
673
+ return { success: false, error: result.error };
673
674
  }
674
- const shells = (data.result ?? []).map(convertApiAasToCoreAas);
675
+ const shells = (result.data.result ?? []).map(convertApiAasToCoreAas);
675
676
  return {
676
- pagedResult: data.paging_metadata,
677
- result: shells,
677
+ success: true,
678
+ data: {
679
+ pagedResult: result.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
- const { data, error } = await postAssetAdministrationShell({
705
+ const result = await postAssetAdministrationShell({
699
706
  client,
700
707
  body: convertCoreAasToApiAas(assetAdministrationShell),
701
708
  });
702
- if (error) {
703
- console.error('Error from server:', error);
704
- throw new Error(JSON.stringify(error.messages));
709
+ if (result.error) {
710
+ return { success: false, error: result.error };
705
711
  }
706
- return convertApiAasToCoreAas(data);
712
+ return { success: true, data: convertApiAasToCoreAas(result.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 result = await deleteAssetAdministrationShellById({
728
734
  client,
729
735
  path: { aasIdentifier: encodedAasIdentifier },
730
736
  });
731
- if (error) {
732
- console.error('Error from server:', error);
733
- throw new Error(JSON.stringify(error.messages));
737
+ if (result.error) {
738
+ return { success: false, error: result.error };
734
739
  }
735
- return;
740
+ return { success: true, data: result.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);
756
- const { data, error } = await getAssetAdministrationShellById({
761
+ const result = await getAssetAdministrationShellById({
757
762
  client,
758
763
  path: { aasIdentifier: encodedAasIdentifier },
759
764
  });
760
- if (error) {
761
- console.error('Error from server:', error);
762
- throw new Error(JSON.stringify(error.messages));
765
+ if (result.error) {
766
+ // Return the complete error object with status code
767
+ return {
768
+ success: false,
769
+ error: result.error,
770
+ };
763
771
  }
764
- return convertApiAasToCoreAas(data);
772
+ return { success: true, data: convertApiAasToCoreAas(result.data) };
765
773
  }
766
- catch (error) {
767
- console.error('Error fetching Asset Administration Shell:', error);
768
- throw error;
774
+ catch (err) {
775
+ return { success: false, error: err instanceof Error ? err : new Error(String(err)) };
769
776
  }
770
777
  }
771
778
  /**
772
- * Updates an existing Asset Administration Shell
779
+ * Updates an existing Asset Administration Shell by ID (PUT).
780
+ *
781
+ * @param options Object containing:
782
+ * - baseUrl: The API base URL
783
+ * - aasIdentifier: The unique ID
784
+ * - assetAdministrationShell: The updated AAS object
785
+ * - headers?: Optional request headers
773
786
  *
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
787
+ * @returns Either `{ success: true; data: ... }` or `{ success: false; error: ... }`.
781
788
  */
782
- async putAssetAdministrationShellById({ baseUrl, aasIdentifier, assetAdministrationShell, headers, }) {
789
+ async putAssetAdministrationShellById(options) {
790
+ const { baseUrl, aasIdentifier, assetAdministrationShell, headers } = options;
783
791
  try {
784
792
  const client = createCustomClient(baseUrl, headers);
785
793
  const encodedAasIdentifier = base64Encode(aasIdentifier);
786
- const { error } = await putAssetAdministrationShellById({
794
+ const result = await putAssetAdministrationShellById({
787
795
  client,
788
796
  path: { aasIdentifier: encodedAasIdentifier },
789
797
  body: convertCoreAasToApiAas(assetAdministrationShell),
790
798
  });
791
- if (error) {
792
- console.error('Error from server:', error);
793
- throw new Error(JSON.stringify(error.messages));
799
+ if (result.error) {
800
+ return { success: false, error: result.error };
794
801
  }
795
- return;
802
+ return { success: true, data: result.data };
796
803
  }
797
- catch (error) {
798
- console.error('Error updating Asset Administration Shell:', error);
799
- throw error;
804
+ catch (err) {
805
+ return { success: false, error: err instanceof Error ? err : new Error(String(err)) };
800
806
  }
801
807
  }
802
808
  /**
803
- * Returns the Asset Information
809
+ * Returns the AssetInformation for the given AAS.
810
+ *
811
+ * @param options Object containing:
812
+ * - baseUrl: The API base URL
813
+ * - aasIdentifier: The unique ID
814
+ * - headers?: Optional request headers
804
815
  *
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
816
+ * @returns Either `{ success: true; data: ... }` or `{ success: false; error: ... }`.
811
817
  */
812
- async getAssetInformation({ baseUrl, aasIdentifier, headers }) {
818
+ async getAssetInformation(options) {
819
+ const { baseUrl, aasIdentifier, headers } = options;
813
820
  try {
814
821
  const client = createCustomClient(baseUrl, headers);
815
822
  const encodedAasIdentifier = base64Encode(aasIdentifier);
816
- const { data, error } = await getAssetInformationAasRepository({
823
+ const result = await getAssetInformationAasRepository({
817
824
  client,
818
825
  path: { aasIdentifier: encodedAasIdentifier },
819
826
  });
820
- if (error) {
821
- console.error('Error from server:', error);
822
- throw new Error(JSON.stringify(error.messages));
827
+ if (result.error) {
828
+ return { success: false, error: result.error };
823
829
  }
824
- return convertApiAssetInformationToCoreAssetInformation(data);
830
+ return {
831
+ success: true,
832
+ data: convertApiAssetInformationToCoreAssetInformation(result.data),
833
+ };
825
834
  }
826
- catch (error) {
827
- console.error('Error fetching Asset Information:', error);
828
- throw error;
835
+ catch (err) {
836
+ return { success: false, error: err instanceof Error ? err : new Error(String(err)) };
829
837
  }
830
838
  }
831
839
  /**
832
- * Updates the Asset Information
840
+ * Updates the AssetInformation for the given AAS.
841
+ *
842
+ * @param options Object containing:
843
+ * - baseUrl: The API base URL
844
+ * - aasIdentifier: The unique ID
845
+ * - assetInformation: The updated AssetInformation object
846
+ * - headers?: Optional request headers
833
847
  *
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
848
+ * @returns Either `{ success: true; data: ... }` or `{ success: false; error: ... }`.
841
849
  */
842
- async putAssetInformation({ baseUrl, aasIdentifier, assetInformation, headers, }) {
850
+ async putAssetInformation(options) {
851
+ const { baseUrl, aasIdentifier, assetInformation, headers } = options;
843
852
  try {
844
853
  const client = createCustomClient(baseUrl, headers);
845
854
  const encodedAasIdentifier = base64Encode(aasIdentifier);
846
- const { error } = await putAssetInformationAasRepository({
855
+ const result = await putAssetInformationAasRepository({
847
856
  client,
848
857
  path: { aasIdentifier: encodedAasIdentifier },
849
858
  body: convertCoreAssetInformationToApiAssetInformation(assetInformation),
850
859
  });
851
- if (error) {
852
- console.error('Error from server:', error);
853
- throw new Error(JSON.stringify(error.messages));
860
+ if (result.error) {
861
+ return { success: false, error: result.error };
854
862
  }
855
- return;
863
+ return { success: true, data: result.data };
856
864
  }
857
- catch (error) {
858
- console.error('Error updating Asset Information:', error);
859
- throw error;
865
+ catch (err) {
866
+ return { success: false, error: err instanceof Error ? err : new Error(String(err)) };
860
867
  }
861
868
  }
862
869
  /**
863
- * Deletes the Thumbnail
870
+ * Deletes the Thumbnail associated with the given AAS.
864
871
  *
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
872
+ * @param options Object containing:
873
+ * - baseUrl: The API base URL
874
+ * - aasIdentifier: The unique ID
875
+ * - headers?: Optional request headers
876
+ *
877
+ * @returns Either `{ success: true; data: ... }` or `{ success: false; error: ... }`.
871
878
  */
872
- async deleteThumbnail({ baseUrl, aasIdentifier, headers }) {
879
+ async deleteThumbnail(options) {
880
+ const { baseUrl, aasIdentifier, headers } = options;
873
881
  try {
874
882
  const client = createCustomClient(baseUrl, headers);
875
883
  const encodedAasIdentifier = base64Encode(aasIdentifier);
876
- const { error } = await deleteThumbnailAasRepository({
884
+ const result = await deleteThumbnailAasRepository({
877
885
  client,
878
886
  path: { aasIdentifier: encodedAasIdentifier },
879
887
  });
880
- if (error) {
881
- console.error('Error from server:', error);
882
- throw new Error(JSON.stringify(error.messages));
888
+ if (result.error) {
889
+ return { success: false, error: result.error };
883
890
  }
884
- return;
891
+ return {
892
+ success: true,
893
+ data: result.data,
894
+ };
885
895
  }
886
- catch (error) {
887
- console.error('Error deleting Thumbnail:', error);
888
- throw error;
896
+ catch (err) {
897
+ return { success: false, error: err instanceof Error ? err : new Error(String(err)) };
889
898
  }
890
899
  }
891
900
  /**
892
- * Returns the Thumbnail
901
+ * Returns the Thumbnail associated with an AAS, if any.
893
902
  *
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.
903
+ * @param options Object containing:
904
+ * - baseUrl: The API base URL
905
+ * - aasIdentifier: The unique ID
906
+ * - headers?: Optional request headers
907
+ *
908
+ * @returns Either `{ success: true; data: ... }` or `{ success: false; error: ... }`.
900
909
  */
901
- async getThumbnail({ baseUrl, aasIdentifier, headers }) {
910
+ async getThumbnail(options) {
911
+ const { baseUrl, aasIdentifier, headers } = options;
902
912
  try {
903
913
  const client = createCustomClient(baseUrl, headers);
904
914
  const encodedAasIdentifier = base64Encode(aasIdentifier);
905
- const { data, error } = await getThumbnailAasRepository({
915
+ const result = await getThumbnailAasRepository({
906
916
  client,
907
917
  path: { aasIdentifier: encodedAasIdentifier },
908
918
  });
909
- if (error) {
910
- console.error('Error from server:', error);
911
- throw new Error(JSON.stringify(error.messages));
919
+ if (result.error) {
920
+ return { success: false, error: result.error };
912
921
  }
913
- return data;
922
+ return { success: true, data: result.data };
914
923
  }
915
- catch (error) {
916
- console.error('Error fetching Thumbnail:', error);
917
- throw error;
924
+ catch (err) {
925
+ return { success: false, error: err instanceof Error ? err : new Error(String(err)) };
918
926
  }
919
927
  }
920
928
  /**
921
- * Updates the Thumbnail
929
+ * Updates (or creates) the Thumbnail for the given AAS.
930
+ *
931
+ * @param options Object containing:
932
+ * - baseUrl: The API base URL
933
+ * - aasIdentifier: The unique ID
934
+ * - thumbnail: The thumbnail data to upload
935
+ * - headers?: Optional request headers
922
936
  *
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
937
+ * @returns Either `{ success: true; data: ... }` or `{ success: false; error: ... }`.
930
938
  */
931
- async putThumbnail({ baseUrl, aasIdentifier, thumbnail, headers }) {
939
+ async putThumbnail(options) {
940
+ const { baseUrl, aasIdentifier, thumbnail, headers } = options;
932
941
  try {
933
942
  const client = createCustomClient(baseUrl, headers);
934
943
  const encodedAasIdentifier = base64Encode(aasIdentifier);
935
- const { error } = await putThumbnailAasRepository({
944
+ const result = await putThumbnailAasRepository({
936
945
  client,
937
946
  path: { aasIdentifier: encodedAasIdentifier },
938
947
  body: thumbnail,
939
948
  });
940
- if (error) {
941
- console.error('Error from server:', error);
942
- throw new Error(JSON.stringify(error.messages));
949
+ if (result.error) {
950
+ return { success: false, error: result.error };
943
951
  }
944
- return;
952
+ return { success: true, data: result.data };
945
953
  }
946
- catch (error) {
947
- console.error('Error updating Thumbnail:', error);
948
- throw error;
954
+ catch (err) {
955
+ return { success: false, error: err instanceof Error ? err : new Error(String(err)) };
949
956
  }
950
957
  }
951
958
  /**
952
- * Returns all submodel references
959
+ * Returns all submodel references for the given AAS.
960
+ *
961
+ * @param options Object containing:
962
+ * - baseUrl: The API base URL
963
+ * - aasIdentifier: The unique ID
964
+ * - headers?: Optional request headers
965
+ * - limit?: Max number of elements
966
+ * - cursor?: Paging cursor
953
967
  *
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
968
+ * @returns Either `{ success: true; data: ... }` or `{ success: false; error: ... }`.
962
969
  */
963
- async getAllSubmodelReferences({ baseUrl, aasIdentifier, headers, limit, cursor, }) {
970
+ async getAllSubmodelReferences(options) {
971
+ const { baseUrl, aasIdentifier, headers, limit, cursor } = options;
964
972
  try {
965
973
  const client = createCustomClient(baseUrl, headers);
966
974
  const encodedAasIdentifier = base64Encode(aasIdentifier);
967
- const { data, error } = await getAllSubmodelReferencesAasRepository({
975
+ const result = await getAllSubmodelReferencesAasRepository({
968
976
  client,
969
977
  path: { aasIdentifier: encodedAasIdentifier },
970
- query: {
971
- limit,
972
- cursor,
973
- },
978
+ query: { limit, cursor },
974
979
  });
975
- if (error) {
976
- console.error('Error from server:', error);
977
- throw new Error(JSON.stringify(error.messages));
980
+ if (result.error) {
981
+ return { success: false, error: result.error };
978
982
  }
979
- const submodelReferences = (data.result ?? []).map(convertApiReferenceToCoreReference);
983
+ const submodelReferences = (result.data.result ?? []).map(convertApiReferenceToCoreReference);
980
984
  return {
981
- pagedResult: data.paging_metadata,
982
- result: submodelReferences,
985
+ success: true,
986
+ data: {
987
+ pagedResult: result.data.paging_metadata,
988
+ result: submodelReferences,
989
+ },
983
990
  };
984
991
  }
985
- catch (error) {
986
- console.error('Error fetching Submodel References:', error);
987
- throw error;
992
+ catch (err) {
993
+ return { success: false, error: err instanceof Error ? err : new Error(String(err)) };
988
994
  }
989
995
  }
990
996
  /**
991
- * Creates a submodel reference at the Asset Administration Shell
997
+ * Creates a submodel reference at the given AAS.
998
+ *
999
+ * @param options Object containing:
1000
+ * - baseUrl: The API base URL
1001
+ * - aasIdentifier: The unique ID of the AAS
1002
+ * - submodelReference: The Reference to the submodel
1003
+ * - headers?: Optional request headers
992
1004
  *
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
1005
+ * @returns Either `{ success: true; data: ... }` or `{ success: false; error: ... }`.
1000
1006
  */
1001
- async postSubmodelReference({ baseUrl, aasIdentifier, submodelReference, headers, }) {
1007
+ async postSubmodelReference(options) {
1008
+ const { baseUrl, aasIdentifier, submodelReference, headers } = options;
1002
1009
  try {
1003
1010
  const client = createCustomClient(baseUrl, headers);
1004
1011
  const encodedAasIdentifier = base64Encode(aasIdentifier);
1005
- const { data, error } = await postSubmodelReferenceAasRepository({
1012
+ const result = await postSubmodelReferenceAasRepository({
1006
1013
  client,
1007
1014
  path: { aasIdentifier: encodedAasIdentifier },
1008
1015
  body: convertCoreReferenceToApiReference(submodelReference),
1009
1016
  });
1010
- if (error) {
1011
- console.error('Error from server:', error);
1012
- throw new Error(JSON.stringify(error.messages));
1017
+ if (result.error) {
1018
+ return { success: false, error: result.error };
1013
1019
  }
1014
- return convertApiReferenceToCoreReference(data);
1020
+ return { success: true, data: convertApiReferenceToCoreReference(result.data) };
1015
1021
  }
1016
- catch (error) {
1017
- console.error('Error creating Submodel Reference:', error);
1018
- throw error;
1022
+ catch (err) {
1023
+ return { success: false, error: err instanceof Error ? err : new Error(String(err)) };
1019
1024
  }
1020
1025
  }
1021
1026
  /**
1022
- * Deletes the submodel reference from the Asset Administration Shell. Does not delete the submodel itself!
1027
+ * Deletes a submodel reference from the given AAS (does not delete the submodel itself).
1023
1028
  *
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
1029
+ * @param options Object containing:
1030
+ * - baseUrl: The API base URL
1031
+ * - aasIdentifier: Unique ID of the AAS
1032
+ * - submodelIdentifier: The submodel's unique ID
1033
+ * - headers?: Optional request headers
1034
+ *
1035
+ * @returns Either `{ success: true; data: ... }` or `{ success: false; error: ... }`.
1031
1036
  */
1032
- async deleteSubmodelReferenceById({ baseUrl, aasIdentifier, submodelIdentifier, headers, }) {
1037
+ async deleteSubmodelReferenceById(options) {
1038
+ const { baseUrl, aasIdentifier, submodelIdentifier, headers } = options;
1033
1039
  try {
1034
1040
  const client = createCustomClient(baseUrl, headers);
1035
1041
  const encodedAasIdentifier = base64Encode(aasIdentifier);
1036
1042
  const encodedSubmodelIdentifier = base64Encode(submodelIdentifier);
1037
- const { error } = await deleteSubmodelReferenceByIdAasRepository({
1043
+ const result = await deleteSubmodelReferenceByIdAasRepository({
1038
1044
  client,
1039
- path: { aasIdentifier: encodedAasIdentifier, submodelIdentifier: encodedSubmodelIdentifier },
1045
+ path: {
1046
+ aasIdentifier: encodedAasIdentifier,
1047
+ submodelIdentifier: encodedSubmodelIdentifier,
1048
+ },
1040
1049
  });
1041
- if (error) {
1042
- console.error('Error from server:', error);
1043
- throw new Error(JSON.stringify(error.messages));
1050
+ if (result.error) {
1051
+ return { success: false, error: result.error };
1044
1052
  }
1045
- return;
1053
+ return { success: true, data: result.data };
1046
1054
  }
1047
- catch (error) {
1048
- console.error('Error deleting Submodel Reference:', error);
1049
- throw error;
1055
+ catch (err) {
1056
+ return { success: false, error: err instanceof Error ? err : new Error(String(err)) };
1050
1057
  }
1051
1058
  }
1052
1059
  }
1053
1060
 
1054
- var aasRepository = /*#__PURE__*/Object.freeze({
1061
+ var index = /*#__PURE__*/Object.freeze({
1055
1062
  __proto__: null
1056
1063
  });
1057
1064
 
1058
- export { AasRepositoryClient, aasRepository as AasRepositoryModels, types_gen as AasTypes };
1065
+ export { AasRepositoryClient, types_gen as AasTypes, index as Models };
1059
1066
  //# sourceMappingURL=index.js.map