basyx-typescript-sdk 0.1.10 → 0.2.0

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
@@ -25,10 +25,23 @@ Utility functions for working with AAS data:
25
25
 
26
26
  ```bash
27
27
  npm install basyx-typescript-sdk
28
+ # or
29
+ yarn add basyx-typescript-sdk
28
30
  ```
29
31
 
30
32
  > See https://www.npmjs.com/package/basyx-typescript-sdk
31
33
 
34
+ ---
35
+
36
+ > [!IMPORTANT]
37
+ > Make sure to install `@aas-core-works/aas-core3.0-typescript` in your project:
38
+
39
+ ```bash
40
+ npm install @aas-core-works/aas-core3.0-typescript
41
+ # or
42
+ yarn add @aas-core-works/aas-core3.0-typescript
43
+ ```
44
+
32
45
  ## Usage
33
46
 
34
47
  ```typescript
package/bundle/index.js CHANGED
@@ -1,6 +1,12 @@
1
1
  import { createClient, createConfig, formDataBodySerializer } from '@hey-api/client-fetch';
2
2
  import { jsonization } from '@aas-core-works/aas-core3.0-typescript';
3
3
 
4
+ // This file is auto-generated by @hey-api/openapi-ts
5
+
6
+ var types_gen = /*#__PURE__*/Object.freeze({
7
+ __proto__: null
8
+ });
9
+
4
10
  // This file is auto-generated by @hey-api/openapi-ts
5
11
  const client = createClient(createConfig());
6
12
  /**
@@ -133,6 +139,38 @@ const deleteSubmodelReferenceByIdAasRepository = (options) => {
133
139
  });
134
140
  };
135
141
 
142
+ /**
143
+ * Encodes a given string into Base64 format.
144
+ * Optionally transforms the output into a URL-safe Base64 string.
145
+ *
146
+ * The process includes:
147
+ * 1. Trimming the input string.
148
+ * 2. Percent-encoding the string.
149
+ * 3. Converting percent-encoded characters back to their raw representation.
150
+ * 4. Encoding the result into Base64.
151
+ * 5. Optionally making the Base64 string URL safe by replacing '+' with '-', '/' with '_' and removing trailing '='.
152
+ *
153
+ * @function base64Encode
154
+ * @param {string} string - The string to encode.
155
+ * @param {boolean} [urlSafe=true] - Whether to return a URL-safe encoded string. Defaults to true.
156
+ * @returns {string} The Base64 encoded string, converted to URL-safe format if requested.
157
+ */
158
+ function base64Encode(string, urlSafe = true) {
159
+ string = string.trim();
160
+ if (string === '')
161
+ return '';
162
+ const encodedUriComponent = encodeURIComponent(string);
163
+ const unescapedEncodedUriComponent = unescape(encodedUriComponent); // reverse percent-encoding
164
+ const base64String = btoa(unescapedEncodedUriComponent);
165
+ if (!urlSafe)
166
+ return base64String;
167
+ const urlSafeBase64String = base64String
168
+ .replace(/\+/g, '-') // Replace + with -
169
+ .replace(/\//g, '_') // Replace / with _
170
+ .replace(/=+$/, ''); // Remove padding (=)
171
+ return urlSafeBase64String;
172
+ }
173
+
136
174
  /**
137
175
  * Provide an implementation of the Asset Administration Shell (AAS) V3.0.
138
176
  *
@@ -612,27 +650,22 @@ class AasRepositoryClient {
612
650
  /**
613
651
  * Returns all Asset Administration Shells
614
652
  *
615
- * @async
616
653
  * @function getAllAssetAdministrationShells
617
- * @param baseURL The API base URL
618
- * @param headers Request headers
619
- * @param assetIds A list of specific Asset identifiers. Every single value asset identifier is a base64-url-encoded
620
- * @param idShort The Asset Administration Shell’s IdShort
621
- * @param limit The maximum number of elements in the response array
622
- * @param cursor A server-generated identifier retrieved from pagingMetadata that specifies from which position the result listing should continue
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
623
661
  * @returns {Promise<GetAllAssetAdministrationShellsResponse>} Requested Asset Administration Shells
624
662
  */
625
- async getAllAssetAdministrationShells(baseURL, headers, assetIds, idShort, limit, cursor) {
663
+ async getAllAssetAdministrationShells({ baseUrl, headers, assetIds, idShort, limit, cursor, }) {
626
664
  try {
627
- const client = createCustomClient(baseURL, headers);
665
+ const client = createCustomClient(baseUrl, headers);
628
666
  const { data, error } = await getAllAssetAdministrationShells({
629
667
  client,
630
- query: {
631
- assetIds,
632
- idShort,
633
- limit,
634
- cursor,
635
- },
668
+ query: { assetIds, idShort, limit, cursor },
636
669
  });
637
670
  if (error) {
638
671
  console.error('Error from server:', error);
@@ -652,16 +685,16 @@ class AasRepositoryClient {
652
685
  /**
653
686
  * Creates a new Asset Administration Shell
654
687
  *
655
- * @async
656
688
  * @function postAssetAdministrationShell
657
- * @param baseURL The API base URL
658
- * @param assetAdministrationShell Asset Administration Shell object
659
- * @param headers Request headers
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
660
693
  * @returns {Promise<AssetAdministrationShell>} Asset Administration Shell created successfully
661
694
  */
662
- async postAssetAdministrationShell(baseURL, assetAdministrationShell, headers) {
695
+ async postAssetAdministrationShell({ baseUrl, assetAdministrationShell, headers, }) {
663
696
  try {
664
- const client = createCustomClient(baseURL, headers);
697
+ const client = createCustomClient(baseUrl, headers);
665
698
  const { data, error } = await postAssetAdministrationShell({
666
699
  client,
667
700
  body: convertCoreAasToApiAas(assetAdministrationShell),
@@ -680,19 +713,20 @@ class AasRepositoryClient {
680
713
  /**
681
714
  * Deletes an Asset Administration Shell
682
715
  *
683
- * @async
684
716
  * @function deleteAssetAdministrationShellById
685
- * @param baseURL The API base URL
686
- * @param aasIdentifier The Asset Administration Shell’s unique id (UTF8-BASE64-URL-encoded)
687
- * @param headers Request headers
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
688
721
  * @returns {Promise<void>} Asset Administration Shell deleted successfully
689
722
  */
690
- async deleteAssetAdministrationShellById(baseURL, aasIdentifier, headers) {
723
+ async deleteAssetAdministrationShellById({ baseUrl, aasIdentifier, headers }) {
691
724
  try {
692
- const client = createCustomClient(baseURL, headers);
725
+ const client = createCustomClient(baseUrl, headers);
726
+ const encodedAasIdentifier = base64Encode(aasIdentifier);
693
727
  const { error } = await deleteAssetAdministrationShellById({
694
728
  client,
695
- path: { aasIdentifier },
729
+ path: { aasIdentifier: encodedAasIdentifier },
696
730
  });
697
731
  if (error) {
698
732
  console.error('Error from server:', error);
@@ -708,19 +742,20 @@ class AasRepositoryClient {
708
742
  /**
709
743
  * Returns a specific Asset Administration Shell
710
744
  *
711
- * @async
712
745
  * @function getAssetAdministrationShellById
713
- * @param baseURL The API base URL
714
- * @param aasIdentifier The Asset Administration Shell’s unique id (UTF8-BASE64-URL-encoded)
715
- * @param headers Request headers
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
716
750
  * @returns {Promise<AssetAdministrationShell>} Requested Asset Administration Shell
717
751
  */
718
- async getAssetAdministrationShellById(baseURL, aasIdentifier, headers) {
752
+ async getAssetAdministrationShellById({ baseUrl, aasIdentifier, headers, }) {
719
753
  try {
720
- const client = createCustomClient(baseURL, headers);
754
+ const client = createCustomClient(baseUrl, headers);
755
+ const encodedAasIdentifier = base64Encode(aasIdentifier);
721
756
  const { data, error } = await getAssetAdministrationShellById({
722
757
  client,
723
- path: { aasIdentifier },
758
+ path: { aasIdentifier: encodedAasIdentifier },
724
759
  });
725
760
  if (error) {
726
761
  console.error('Error from server:', error);
@@ -736,20 +771,21 @@ class AasRepositoryClient {
736
771
  /**
737
772
  * Updates an existing Asset Administration Shell
738
773
  *
739
- * @async
740
774
  * @function putAssetAdministrationShellById
741
- * @param baseURL The API base URL
742
- * @param aasIdentifier The Asset Administration Shell’s unique id (UTF8-BASE64-URL-encoded)
743
- * @param assetAdministrationShell Asset Administration Shell object
744
- * @param headers Request headers
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
745
780
  * @returns {Promise<void>} Asset Administration Shell updated successfully
746
781
  */
747
- async putAssetAdministrationShellById(baseURL, aasIdentifier, assetAdministrationShell, headers) {
782
+ async putAssetAdministrationShellById({ baseUrl, aasIdentifier, assetAdministrationShell, headers, }) {
748
783
  try {
749
- const client = createCustomClient(baseURL, headers);
784
+ const client = createCustomClient(baseUrl, headers);
785
+ const encodedAasIdentifier = base64Encode(aasIdentifier);
750
786
  const { error } = await putAssetAdministrationShellById({
751
787
  client,
752
- path: { aasIdentifier },
788
+ path: { aasIdentifier: encodedAasIdentifier },
753
789
  body: convertCoreAasToApiAas(assetAdministrationShell),
754
790
  });
755
791
  if (error) {
@@ -766,19 +802,20 @@ class AasRepositoryClient {
766
802
  /**
767
803
  * Returns the Asset Information
768
804
  *
769
- * @async
770
805
  * @function getAssetInformation
771
- * @param baseURL The API base URL
772
- * @param aasIdentifier The Asset Administration Shell’s unique id (UTF8-BASE64-URL-encoded)
773
- * @param headers Request headers
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
774
810
  * @returns {Promise<AssetInformation>} Requested Asset Information
775
811
  */
776
- async getAssetInformation(baseURL, aasIdentifier, headers) {
812
+ async getAssetInformation({ baseUrl, aasIdentifier, headers }) {
777
813
  try {
778
- const client = createCustomClient(baseURL, headers);
814
+ const client = createCustomClient(baseUrl, headers);
815
+ const encodedAasIdentifier = base64Encode(aasIdentifier);
779
816
  const { data, error } = await getAssetInformationAasRepository({
780
817
  client,
781
- path: { aasIdentifier },
818
+ path: { aasIdentifier: encodedAasIdentifier },
782
819
  });
783
820
  if (error) {
784
821
  console.error('Error from server:', error);
@@ -794,20 +831,21 @@ class AasRepositoryClient {
794
831
  /**
795
832
  * Updates the Asset Information
796
833
  *
797
- * @async
798
834
  * @function putAssetInformation
799
- * @param baseURL The API base URL
800
- * @param aasIdentifier The Asset Administration Shell’s unique id (UTF8-BASE64-URL-encoded)
801
- * @param assetInformation Asset Information object
802
- * @param headers Request headers
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
803
840
  * @returns {Promise<void>} Asset Information updated successfully
804
841
  */
805
- async putAssetInformation(baseURL, aasIdentifier, assetInformation, headers) {
842
+ async putAssetInformation({ baseUrl, aasIdentifier, assetInformation, headers, }) {
806
843
  try {
807
- const client = createCustomClient(baseURL, headers);
844
+ const client = createCustomClient(baseUrl, headers);
845
+ const encodedAasIdentifier = base64Encode(aasIdentifier);
808
846
  const { error } = await putAssetInformationAasRepository({
809
847
  client,
810
- path: { aasIdentifier },
848
+ path: { aasIdentifier: encodedAasIdentifier },
811
849
  body: convertCoreAssetInformationToApiAssetInformation(assetInformation),
812
850
  });
813
851
  if (error) {
@@ -824,19 +862,20 @@ class AasRepositoryClient {
824
862
  /**
825
863
  * Deletes the Thumbnail
826
864
  *
827
- * @async
828
865
  * @function deleteThumbnail
829
- * @param baseURL The API base URL
830
- * @param aasIdentifier The Asset Administration Shell’s unique id (UTF8-BASE64-URL-encoded)
831
- * @param headers Request headers
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
832
870
  * @returns {Promise<void>} Thumbnail deletion successful
833
871
  */
834
- async deleteThumbnail(baseURL, aasIdentifier, headers) {
872
+ async deleteThumbnail({ baseUrl, aasIdentifier, headers }) {
835
873
  try {
836
- const client = createCustomClient(baseURL, headers);
874
+ const client = createCustomClient(baseUrl, headers);
875
+ const encodedAasIdentifier = base64Encode(aasIdentifier);
837
876
  const { error } = await deleteThumbnailAasRepository({
838
877
  client,
839
- path: { aasIdentifier },
878
+ path: { aasIdentifier: encodedAasIdentifier },
840
879
  });
841
880
  if (error) {
842
881
  console.error('Error from server:', error);
@@ -852,19 +891,20 @@ class AasRepositoryClient {
852
891
  /**
853
892
  * Returns the Thumbnail
854
893
  *
855
- * @async
856
894
  * @function getThumbnail
857
- * @param baseURL The API base URL
858
- * @param aasIdentifier The Asset Administration Shell’s unique id (UTF8-BASE64-URL-encoded)
859
- * @param headers Request headers
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
860
899
  * @returns {Promise<Blob | File>} The thumbnail of the Asset Information.
861
900
  */
862
- async getThumbnail(baseURL, aasIdentifier, headers) {
901
+ async getThumbnail({ baseUrl, aasIdentifier, headers }) {
863
902
  try {
864
- const client = createCustomClient(baseURL, headers);
903
+ const client = createCustomClient(baseUrl, headers);
904
+ const encodedAasIdentifier = base64Encode(aasIdentifier);
865
905
  const { data, error } = await getThumbnailAasRepository({
866
906
  client,
867
- path: { aasIdentifier },
907
+ path: { aasIdentifier: encodedAasIdentifier },
868
908
  });
869
909
  if (error) {
870
910
  console.error('Error from server:', error);
@@ -880,20 +920,21 @@ class AasRepositoryClient {
880
920
  /**
881
921
  * Updates the Thumbnail
882
922
  *
883
- * @async
884
923
  * @function putThumbnail
885
- * @param baseURL The API base URL
886
- * @param aasIdentifier The Asset Administration Shell’s unique id (UTF8-BASE64-URL-encoded)
887
- * @param thumbnail Thumbnail to upload
888
- * @param headers Request headers
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
889
929
  * @returns {Promise<void>} Thumbnail updated successfully
890
930
  */
891
- async putThumbnail(baseURL, aasIdentifier, thumbnail, headers) {
931
+ async putThumbnail({ baseUrl, aasIdentifier, thumbnail, headers }) {
892
932
  try {
893
- const client = createCustomClient(baseURL, headers);
933
+ const client = createCustomClient(baseUrl, headers);
934
+ const encodedAasIdentifier = base64Encode(aasIdentifier);
894
935
  const { error } = await putThumbnailAasRepository({
895
936
  client,
896
- path: { aasIdentifier },
937
+ path: { aasIdentifier: encodedAasIdentifier },
897
938
  body: thumbnail,
898
939
  });
899
940
  if (error) {
@@ -910,21 +951,22 @@ class AasRepositoryClient {
910
951
  /**
911
952
  * Returns all submodel references
912
953
  *
913
- * @async
914
954
  * @function getAllSubmodelReferences
915
- * @param baseURL The API base URL
916
- * @param aasIdentifier The Asset Administration Shell’s unique id (UTF8-BASE64-URL-encoded)
917
- * @param headers Request headers
918
- * @param limit The maximum number of elements in the response array
919
- * @param cursor A server-generated identifier retrieved from pagingMetadata that specifies from which position the result listing should continue
920
- * @returns {Promise<getAllSubmodelReferencesResponse>} Requested submodel references
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
921
962
  */
922
- async getAllSubmodelReferences(baseURL, aasIdentifier, headers, limit, cursor) {
963
+ async getAllSubmodelReferences({ baseUrl, aasIdentifier, headers, limit, cursor, }) {
923
964
  try {
924
- const client = createCustomClient(baseURL, headers);
965
+ const client = createCustomClient(baseUrl, headers);
966
+ const encodedAasIdentifier = base64Encode(aasIdentifier);
925
967
  const { data, error } = await getAllSubmodelReferencesAasRepository({
926
968
  client,
927
- path: { aasIdentifier },
969
+ path: { aasIdentifier: encodedAasIdentifier },
928
970
  query: {
929
971
  limit,
930
972
  cursor,
@@ -948,20 +990,21 @@ class AasRepositoryClient {
948
990
  /**
949
991
  * Creates a submodel reference at the Asset Administration Shell
950
992
  *
951
- * @async
952
993
  * @function postSubmodelReference
953
- * @param baseURL The API base URL
954
- * @param aasIdentifier The Asset Administration Shell’s unique id (UTF8-BASE64-URL-encoded)
955
- * @param submodelReference Reference to the Submodel
956
- * @param headers Request headers
957
- * @returns {promise<Reference>} Submodel reference created successfully
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
958
1000
  */
959
- async postSubmodelReference(baseURL, aasIdentifier, submodelReference, headers) {
1001
+ async postSubmodelReference({ baseUrl, aasIdentifier, submodelReference, headers, }) {
960
1002
  try {
961
- const client = createCustomClient(baseURL, headers);
1003
+ const client = createCustomClient(baseUrl, headers);
1004
+ const encodedAasIdentifier = base64Encode(aasIdentifier);
962
1005
  const { data, error } = await postSubmodelReferenceAasRepository({
963
1006
  client,
964
- path: { aasIdentifier },
1007
+ path: { aasIdentifier: encodedAasIdentifier },
965
1008
  body: convertCoreReferenceToApiReference(submodelReference),
966
1009
  });
967
1010
  if (error) {
@@ -978,20 +1021,22 @@ class AasRepositoryClient {
978
1021
  /**
979
1022
  * Deletes the submodel reference from the Asset Administration Shell. Does not delete the submodel itself!
980
1023
  *
981
- * @async
982
1024
  * @function deleteSubmodelReferenceById
983
- * @param baseURL The API base URL
984
- * @param aasIdentifier The Asset Administration Shell’s unique id (UTF8-BASE64-URL-encoded)
985
- * @param submodelIdentifier The Submodel’s unique id (UTF8-BASE64-URL-encoded)
986
- * @param headers Request headers
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
987
1030
  * @returns {Promise<void>} Submodel reference deleted successfully
988
1031
  */
989
- async deleteSubmodelReferenceById(baseURL, aasIdentifier, submodelIdentifier, headers) {
1032
+ async deleteSubmodelReferenceById({ baseUrl, aasIdentifier, submodelIdentifier, headers, }) {
990
1033
  try {
991
- const client = createCustomClient(baseURL, headers);
1034
+ const client = createCustomClient(baseUrl, headers);
1035
+ const encodedAasIdentifier = base64Encode(aasIdentifier);
1036
+ const encodedSubmodelIdentifier = base64Encode(submodelIdentifier);
992
1037
  const { error } = await deleteSubmodelReferenceByIdAasRepository({
993
1038
  client,
994
- path: { aasIdentifier, submodelIdentifier },
1039
+ path: { aasIdentifier: encodedAasIdentifier, submodelIdentifier: encodedSubmodelIdentifier },
995
1040
  });
996
1041
  if (error) {
997
1042
  console.error('Error from server:', error);
@@ -1006,5 +1051,9 @@ class AasRepositoryClient {
1006
1051
  }
1007
1052
  }
1008
1053
 
1009
- export { AasRepositoryClient };
1054
+ var aasRepository = /*#__PURE__*/Object.freeze({
1055
+ __proto__: null
1056
+ });
1057
+
1058
+ export { AasRepositoryClient, aasRepository as AasRepositoryModels, types_gen as AasTypes };
1010
1059
  //# sourceMappingURL=index.js.map