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/README.md +1 -1
- package/bundle/index.js +237 -230
- package/bundle/index.js.map +1 -1
- package/dist/clients/AasRepositoryClient.d.ts +198 -128
- package/dist/clients/AasRepositoryClient.js +235 -228
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/models/AssetId.d.ts +11 -0
- package/dist/models/AssetId.js +1 -0
- package/dist/models/api.d.ts +12 -0
- package/dist/models/api.js +1 -0
- package/dist/models/index.d.ts +3 -0
- package/dist/models/index.js +3 -0
- package/package.json +1 -1
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
|
-
* @
|
|
654
|
-
*
|
|
655
|
-
*
|
|
656
|
-
*
|
|
657
|
-
*
|
|
658
|
-
*
|
|
659
|
-
*
|
|
660
|
-
*
|
|
661
|
-
* @returns {
|
|
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(
|
|
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
|
|
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
|
-
|
|
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
|
-
|
|
677
|
-
|
|
677
|
+
success: true,
|
|
678
|
+
data: {
|
|
679
|
+
pagedResult: result.data.paging_metadata,
|
|
680
|
+
result: shells,
|
|
681
|
+
},
|
|
678
682
|
};
|
|
679
683
|
}
|
|
680
|
-
catch (
|
|
681
|
-
|
|
682
|
-
|
|
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
|
-
* @
|
|
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(
|
|
701
|
+
async postAssetAdministrationShell(options) {
|
|
702
|
+
const { baseUrl, assetAdministrationShell, headers } = options;
|
|
696
703
|
try {
|
|
697
704
|
const client = createCustomClient(baseUrl, headers);
|
|
698
|
-
const
|
|
705
|
+
const result = await postAssetAdministrationShell({
|
|
699
706
|
client,
|
|
700
707
|
body: convertCoreAasToApiAas(assetAdministrationShell),
|
|
701
708
|
});
|
|
702
|
-
if (error) {
|
|
703
|
-
|
|
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 (
|
|
709
|
-
|
|
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
|
-
* @
|
|
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(
|
|
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
|
|
733
|
+
const result = await deleteAssetAdministrationShellById({
|
|
728
734
|
client,
|
|
729
735
|
path: { aasIdentifier: encodedAasIdentifier },
|
|
730
736
|
});
|
|
731
|
-
if (error) {
|
|
732
|
-
|
|
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 (
|
|
738
|
-
|
|
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
|
-
* @
|
|
746
|
-
*
|
|
747
|
-
*
|
|
748
|
-
*
|
|
749
|
-
*
|
|
750
|
-
* @returns {
|
|
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(
|
|
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
|
|
761
|
+
const result = await getAssetAdministrationShellById({
|
|
757
762
|
client,
|
|
758
763
|
path: { aasIdentifier: encodedAasIdentifier },
|
|
759
764
|
});
|
|
760
|
-
if (error) {
|
|
761
|
-
|
|
762
|
-
|
|
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 (
|
|
767
|
-
|
|
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
|
-
* @
|
|
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(
|
|
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
|
|
794
|
+
const result = await putAssetAdministrationShellById({
|
|
787
795
|
client,
|
|
788
796
|
path: { aasIdentifier: encodedAasIdentifier },
|
|
789
797
|
body: convertCoreAasToApiAas(assetAdministrationShell),
|
|
790
798
|
});
|
|
791
|
-
if (error) {
|
|
792
|
-
|
|
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 (
|
|
798
|
-
|
|
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
|
|
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
|
-
* @
|
|
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(
|
|
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
|
|
823
|
+
const result = await getAssetInformationAasRepository({
|
|
817
824
|
client,
|
|
818
825
|
path: { aasIdentifier: encodedAasIdentifier },
|
|
819
826
|
});
|
|
820
|
-
if (error) {
|
|
821
|
-
|
|
822
|
-
throw new Error(JSON.stringify(error.messages));
|
|
827
|
+
if (result.error) {
|
|
828
|
+
return { success: false, error: result.error };
|
|
823
829
|
}
|
|
824
|
-
return
|
|
830
|
+
return {
|
|
831
|
+
success: true,
|
|
832
|
+
data: convertApiAssetInformationToCoreAssetInformation(result.data),
|
|
833
|
+
};
|
|
825
834
|
}
|
|
826
|
-
catch (
|
|
827
|
-
|
|
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
|
|
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
|
-
* @
|
|
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(
|
|
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
|
|
855
|
+
const result = await putAssetInformationAasRepository({
|
|
847
856
|
client,
|
|
848
857
|
path: { aasIdentifier: encodedAasIdentifier },
|
|
849
858
|
body: convertCoreAssetInformationToApiAssetInformation(assetInformation),
|
|
850
859
|
});
|
|
851
|
-
if (error) {
|
|
852
|
-
|
|
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 (
|
|
858
|
-
|
|
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
|
-
* @
|
|
866
|
-
*
|
|
867
|
-
*
|
|
868
|
-
*
|
|
869
|
-
*
|
|
870
|
-
* @returns {
|
|
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(
|
|
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
|
|
884
|
+
const result = await deleteThumbnailAasRepository({
|
|
877
885
|
client,
|
|
878
886
|
path: { aasIdentifier: encodedAasIdentifier },
|
|
879
887
|
});
|
|
880
|
-
if (error) {
|
|
881
|
-
|
|
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 (
|
|
887
|
-
|
|
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
|
-
* @
|
|
895
|
-
*
|
|
896
|
-
*
|
|
897
|
-
*
|
|
898
|
-
*
|
|
899
|
-
* @returns {
|
|
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(
|
|
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
|
|
915
|
+
const result = await getThumbnailAasRepository({
|
|
906
916
|
client,
|
|
907
917
|
path: { aasIdentifier: encodedAasIdentifier },
|
|
908
918
|
});
|
|
909
|
-
if (error) {
|
|
910
|
-
|
|
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 (
|
|
916
|
-
|
|
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
|
-
* @
|
|
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(
|
|
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
|
|
944
|
+
const result = await putThumbnailAasRepository({
|
|
936
945
|
client,
|
|
937
946
|
path: { aasIdentifier: encodedAasIdentifier },
|
|
938
947
|
body: thumbnail,
|
|
939
948
|
});
|
|
940
|
-
if (error) {
|
|
941
|
-
|
|
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 (
|
|
947
|
-
|
|
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
|
-
* @
|
|
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(
|
|
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
|
|
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
|
-
|
|
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
|
-
|
|
982
|
-
|
|
985
|
+
success: true,
|
|
986
|
+
data: {
|
|
987
|
+
pagedResult: result.data.paging_metadata,
|
|
988
|
+
result: submodelReferences,
|
|
989
|
+
},
|
|
983
990
|
};
|
|
984
991
|
}
|
|
985
|
-
catch (
|
|
986
|
-
|
|
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
|
|
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
|
-
* @
|
|
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(
|
|
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
|
|
1012
|
+
const result = await postSubmodelReferenceAasRepository({
|
|
1006
1013
|
client,
|
|
1007
1014
|
path: { aasIdentifier: encodedAasIdentifier },
|
|
1008
1015
|
body: convertCoreReferenceToApiReference(submodelReference),
|
|
1009
1016
|
});
|
|
1010
|
-
if (error) {
|
|
1011
|
-
|
|
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 (
|
|
1017
|
-
|
|
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
|
|
1027
|
+
* Deletes a submodel reference from the given AAS (does not delete the submodel itself).
|
|
1023
1028
|
*
|
|
1024
|
-
* @
|
|
1025
|
-
*
|
|
1026
|
-
*
|
|
1027
|
-
*
|
|
1028
|
-
*
|
|
1029
|
-
*
|
|
1030
|
-
* @returns {
|
|
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(
|
|
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
|
|
1043
|
+
const result = await deleteSubmodelReferenceByIdAasRepository({
|
|
1038
1044
|
client,
|
|
1039
|
-
path: {
|
|
1045
|
+
path: {
|
|
1046
|
+
aasIdentifier: encodedAasIdentifier,
|
|
1047
|
+
submodelIdentifier: encodedSubmodelIdentifier,
|
|
1048
|
+
},
|
|
1040
1049
|
});
|
|
1041
|
-
if (error) {
|
|
1042
|
-
|
|
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 (
|
|
1048
|
-
|
|
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
|
|
1061
|
+
var index = /*#__PURE__*/Object.freeze({
|
|
1055
1062
|
__proto__: null
|
|
1056
1063
|
});
|
|
1057
1064
|
|
|
1058
|
-
export { AasRepositoryClient,
|
|
1065
|
+
export { AasRepositoryClient, types_gen as AasTypes, index as Models };
|
|
1059
1066
|
//# sourceMappingURL=index.js.map
|