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 +13 -0
- package/bundle/index.js +157 -108
- package/bundle/index.js.map +1 -1
- package/dist/clients/AasRepositoryClient.d.ts +157 -0
- package/dist/clients/AasRepositoryClient.js +408 -0
- package/dist/clients/index.d.ts +1 -0
- package/dist/clients/index.js +1 -0
- package/dist/generated/index.d.ts +2 -0
- package/dist/generated/index.js +3 -0
- package/dist/generated/schemas.gen.d.ts +2357 -0
- package/dist/generated/schemas.gen.js +2789 -0
- package/dist/generated/sdk.gen.d.ts +822 -0
- package/dist/generated/sdk.gen.js +2225 -0
- package/dist/generated/types.gen.d.ts +10829 -0
- package/dist/generated/types.gen.js +2 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +3 -0
- package/dist/lib/base64Url.d.ts +32 -0
- package/dist/lib/base64Url.js +62 -0
- package/dist/lib/convertAasTypes.d.ts +50 -0
- package/dist/lib/convertAasTypes.js +113 -0
- package/dist/lib/createAasRepoClient.d.ts +9 -0
- package/dist/lib/createAasRepoClient.js +15 -0
- package/dist/models/aas-repository.d.ts +65 -0
- package/dist/models/aas-repository.js +1 -0
- package/package.json +4 -3
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
import type { AssetAdministrationShell, AssetInformation, Reference } from '@aas-core-works/aas-core3.0-typescript/types';
|
|
2
|
+
import { AasIdentifierOptions, DeleteSubmodelReferenceByIdOptions, GetAllAssetAdministrationShellsOptions, GetAllAssetAdministrationShellsResponse, GetAllSubmodelReferencesOptions, GetAllSubmodelReferencesResponse, PostAssetAdministrationShellOptions, PostSubmodelReferenceOptions, PutAssetAdministrationShellOptions, PutAssetInformationOptions, PutThumbnailOptions } from '../models/aas-repository';
|
|
3
|
+
export declare class AasRepositoryClient {
|
|
4
|
+
/**
|
|
5
|
+
* Returns all Asset Administration Shells
|
|
6
|
+
*
|
|
7
|
+
* @function getAllAssetAdministrationShells
|
|
8
|
+
* @param {GetAllAssetAdministrationShellsOptions} options - Options object.
|
|
9
|
+
* @param {string} options.baseUrl - The API base URL
|
|
10
|
+
* @param {Headers} [options.headers] - Request headers
|
|
11
|
+
* @param {string[]} [options.assetIds] - A list of specific Asset identifiers. Every single value asset identifier is a base64-url-encoded
|
|
12
|
+
* @param {string} [options.idShort] - The Asset Administration Shell's IdShort
|
|
13
|
+
* @param {number} [options.limit] - The maximum number of elements in the response array
|
|
14
|
+
* @param {string} [options.cursor] - A server-generated identifier retrieved from pagingMetadata that specifies from which position the result listing should continue
|
|
15
|
+
* @returns {Promise<GetAllAssetAdministrationShellsResponse>} Requested Asset Administration Shells
|
|
16
|
+
*/
|
|
17
|
+
getAllAssetAdministrationShells({ baseUrl, headers, assetIds, idShort, limit, cursor, }: GetAllAssetAdministrationShellsOptions): Promise<GetAllAssetAdministrationShellsResponse>;
|
|
18
|
+
/**
|
|
19
|
+
* Creates a new Asset Administration Shell
|
|
20
|
+
*
|
|
21
|
+
* @function postAssetAdministrationShell
|
|
22
|
+
* @param {PostAssetAdministrationShellOptions} options - Options object.
|
|
23
|
+
* @param {string} options.baseUrl - The API base URL
|
|
24
|
+
* @param {AssetAdministrationShell} options.assetAdministrationShell - Asset Administration Shell object
|
|
25
|
+
* @param {Headers} [options.headers] - Request headers
|
|
26
|
+
* @returns {Promise<AssetAdministrationShell>} Asset Administration Shell created successfully
|
|
27
|
+
*/
|
|
28
|
+
postAssetAdministrationShell({ baseUrl, assetAdministrationShell, headers, }: PostAssetAdministrationShellOptions): Promise<AssetAdministrationShell>;
|
|
29
|
+
/**
|
|
30
|
+
* Deletes an Asset Administration Shell
|
|
31
|
+
*
|
|
32
|
+
* @function deleteAssetAdministrationShellById
|
|
33
|
+
* @param {AasIdentifierOptions} options - Options object.
|
|
34
|
+
* @param {string} options.baseUrl - The API base URL
|
|
35
|
+
* @param {string} options.aasIdentifier - The Asset Administration Shell's unique id
|
|
36
|
+
* @param {Headers} [options.headers] - Request headers
|
|
37
|
+
* @returns {Promise<void>} Asset Administration Shell deleted successfully
|
|
38
|
+
*/
|
|
39
|
+
deleteAssetAdministrationShellById({ baseUrl, aasIdentifier, headers }: AasIdentifierOptions): Promise<void>;
|
|
40
|
+
/**
|
|
41
|
+
* Returns a specific Asset Administration Shell
|
|
42
|
+
*
|
|
43
|
+
* @function getAssetAdministrationShellById
|
|
44
|
+
* @param {AasIdentifierOptions} options - Options object.
|
|
45
|
+
* @param {string} options.baseUrl - The API base URL
|
|
46
|
+
* @param {string} options.aasIdentifier - The Asset Administration Shell's unique id
|
|
47
|
+
* @param {Headers} [options.headers] - Request headers
|
|
48
|
+
* @returns {Promise<AssetAdministrationShell>} Requested Asset Administration Shell
|
|
49
|
+
*/
|
|
50
|
+
getAssetAdministrationShellById({ baseUrl, aasIdentifier, headers, }: AasIdentifierOptions): Promise<AssetAdministrationShell>;
|
|
51
|
+
/**
|
|
52
|
+
* Updates an existing Asset Administration Shell
|
|
53
|
+
*
|
|
54
|
+
* @function putAssetAdministrationShellById
|
|
55
|
+
* @param {PutAssetAdministrationShellOptions} options - Options object.
|
|
56
|
+
* @param {string} options.baseUrl - The API base URL
|
|
57
|
+
* @param {string} options.aasIdentifier - The Asset Administration Shell's unique id
|
|
58
|
+
* @param {AssetAdministrationShell} options.assetAdministrationShell - Asset Administration Shell object
|
|
59
|
+
* @param {Headers} [options.headers] - Request headers
|
|
60
|
+
* @returns {Promise<void>} Asset Administration Shell updated successfully
|
|
61
|
+
*/
|
|
62
|
+
putAssetAdministrationShellById({ baseUrl, aasIdentifier, assetAdministrationShell, headers, }: PutAssetAdministrationShellOptions): Promise<void>;
|
|
63
|
+
/**
|
|
64
|
+
* Returns the Asset Information
|
|
65
|
+
*
|
|
66
|
+
* @function getAssetInformation
|
|
67
|
+
* @param {AasIdentifierOptions} options - Options object.
|
|
68
|
+
* @param {string} options.baseUrl - The API base URL
|
|
69
|
+
* @param {string} options.aasIdentifier - The Asset Administration Shell's unique id
|
|
70
|
+
* @param {Headers} [options.headers] - Request headers
|
|
71
|
+
* @returns {Promise<AssetInformation>} Requested Asset Information
|
|
72
|
+
*/
|
|
73
|
+
getAssetInformation({ baseUrl, aasIdentifier, headers }: AasIdentifierOptions): Promise<AssetInformation>;
|
|
74
|
+
/**
|
|
75
|
+
* Updates the Asset Information
|
|
76
|
+
*
|
|
77
|
+
* @function putAssetInformation
|
|
78
|
+
* @param {PutAssetInformationOptions} options - Options object.
|
|
79
|
+
* @param {string} options.baseUrl - The API base URL
|
|
80
|
+
* @param {string} options.aasIdentifier - The Asset Administration Shell's unique id
|
|
81
|
+
* @param {AssetInformation} options.assetInformation - Asset Information object
|
|
82
|
+
* @param {Headers} [options.headers] - Request headers
|
|
83
|
+
* @returns {Promise<void>} Asset Information updated successfully
|
|
84
|
+
*/
|
|
85
|
+
putAssetInformation({ baseUrl, aasIdentifier, assetInformation, headers, }: PutAssetInformationOptions): Promise<void>;
|
|
86
|
+
/**
|
|
87
|
+
* Deletes the Thumbnail
|
|
88
|
+
*
|
|
89
|
+
* @function deleteThumbnail
|
|
90
|
+
* @param {AasIdentifierOptions} options - Options object.
|
|
91
|
+
* @param {string} options.baseUrl - The API base URL
|
|
92
|
+
* @param {string} options.aasIdentifier - The Asset Administration Shell's unique id
|
|
93
|
+
* @param {Headers} [options.headers] - Request headers
|
|
94
|
+
* @returns {Promise<void>} Thumbnail deletion successful
|
|
95
|
+
*/
|
|
96
|
+
deleteThumbnail({ baseUrl, aasIdentifier, headers }: AasIdentifierOptions): Promise<void>;
|
|
97
|
+
/**
|
|
98
|
+
* Returns the Thumbnail
|
|
99
|
+
*
|
|
100
|
+
* @function getThumbnail
|
|
101
|
+
* @param {AasIdentifierOptions} options - Options object.
|
|
102
|
+
* @param {string} options.baseUrl - The API base URL
|
|
103
|
+
* @param {string} options.aasIdentifier - The Asset Administration Shell's unique id
|
|
104
|
+
* @param {Headers} [options.headers] - Request headers
|
|
105
|
+
* @returns {Promise<Blob | File>} The thumbnail of the Asset Information.
|
|
106
|
+
*/
|
|
107
|
+
getThumbnail({ baseUrl, aasIdentifier, headers }: AasIdentifierOptions): Promise<Blob | File>;
|
|
108
|
+
/**
|
|
109
|
+
* Updates the Thumbnail
|
|
110
|
+
*
|
|
111
|
+
* @function putThumbnail
|
|
112
|
+
* @param {PutThumbnailOptions} options - Options object.
|
|
113
|
+
* @param {string} options.baseUrl - The API base URL
|
|
114
|
+
* @param {string} options.aasIdentifier - The Asset Administration Shell's unique id
|
|
115
|
+
* @param {AssetinformationThumbnailBody} options.thumbnail - Thumbnail to upload
|
|
116
|
+
* @param {Headers} [options.headers] - Request headers
|
|
117
|
+
* @returns {Promise<void>} Thumbnail updated successfully
|
|
118
|
+
*/
|
|
119
|
+
putThumbnail({ baseUrl, aasIdentifier, thumbnail, headers }: PutThumbnailOptions): Promise<void>;
|
|
120
|
+
/**
|
|
121
|
+
* Returns all submodel references
|
|
122
|
+
*
|
|
123
|
+
* @function getAllSubmodelReferences
|
|
124
|
+
* @param {GetAllSubmodelReferencesOptions} options - Options object.
|
|
125
|
+
* @param {string} options.baseUrl - The API base URL
|
|
126
|
+
* @param {string} options.aasIdentifier - The Asset Administration Shell's unique id
|
|
127
|
+
* @param {Headers} [options.headers] - Request headers
|
|
128
|
+
* @param {number} [options.limit] - The maximum number of elements in the response array
|
|
129
|
+
* @param {string} [options.cursor] - A server-generated identifier retrieved from pagingMetadata that specifies from which position the result listing should continue
|
|
130
|
+
* @returns {Promise<GetAllSubmodelReferencesResponse>} Requested submodel references
|
|
131
|
+
*/
|
|
132
|
+
getAllSubmodelReferences({ baseUrl, aasIdentifier, headers, limit, cursor, }: GetAllSubmodelReferencesOptions): Promise<GetAllSubmodelReferencesResponse>;
|
|
133
|
+
/**
|
|
134
|
+
* Creates a submodel reference at the Asset Administration Shell
|
|
135
|
+
*
|
|
136
|
+
* @function postSubmodelReference
|
|
137
|
+
* @param {PostSubmodelReferenceOptions} options - Options object.
|
|
138
|
+
* @param {string} options.baseUrl - The API base URL
|
|
139
|
+
* @param {string} options.aasIdentifier - The Asset Administration Shell's unique id
|
|
140
|
+
* @param {Reference} options.submodelReference - Reference to the Submodel
|
|
141
|
+
* @param {Headers} [options.headers] - Request headers
|
|
142
|
+
* @returns {Promise<Reference>} Submodel reference created successfully
|
|
143
|
+
*/
|
|
144
|
+
postSubmodelReference({ baseUrl, aasIdentifier, submodelReference, headers, }: PostSubmodelReferenceOptions): Promise<Reference>;
|
|
145
|
+
/**
|
|
146
|
+
* Deletes the submodel reference from the Asset Administration Shell. Does not delete the submodel itself!
|
|
147
|
+
*
|
|
148
|
+
* @function deleteSubmodelReferenceById
|
|
149
|
+
* @param {DeleteSubmodelReferenceByIdOptions} options - Options object.
|
|
150
|
+
* @param {string} options.baseUrl - The API base URL
|
|
151
|
+
* @param {string} options.aasIdentifier - The Asset Administration Shell's unique id
|
|
152
|
+
* @param {string} options.submodelIdentifier - The Submodel's unique id
|
|
153
|
+
* @param {Headers} [options.headers] - Request headers
|
|
154
|
+
* @returns {Promise<void>} Submodel reference deleted successfully
|
|
155
|
+
*/
|
|
156
|
+
deleteSubmodelReferenceById({ baseUrl, aasIdentifier, submodelIdentifier, headers, }: DeleteSubmodelReferenceByIdOptions): Promise<void>;
|
|
157
|
+
}
|
|
@@ -0,0 +1,408 @@
|
|
|
1
|
+
import * as AasRepository from '../generated';
|
|
2
|
+
import { base64Encode } from '../lib/base64Url';
|
|
3
|
+
import { convertApiAasToCoreAas, convertApiAssetInformationToCoreAssetInformation, convertApiReferenceToCoreReference, convertCoreAasToApiAas, convertCoreAssetInformationToApiAssetInformation, convertCoreReferenceToApiReference, } from '../lib/convertAasTypes';
|
|
4
|
+
import { createCustomClient } from '../lib/createAasRepoClient';
|
|
5
|
+
export class AasRepositoryClient {
|
|
6
|
+
/**
|
|
7
|
+
* Returns all Asset Administration Shells
|
|
8
|
+
*
|
|
9
|
+
* @function getAllAssetAdministrationShells
|
|
10
|
+
* @param {GetAllAssetAdministrationShellsOptions} options - Options object.
|
|
11
|
+
* @param {string} options.baseUrl - The API base URL
|
|
12
|
+
* @param {Headers} [options.headers] - Request headers
|
|
13
|
+
* @param {string[]} [options.assetIds] - A list of specific Asset identifiers. Every single value asset identifier is a base64-url-encoded
|
|
14
|
+
* @param {string} [options.idShort] - The Asset Administration Shell's IdShort
|
|
15
|
+
* @param {number} [options.limit] - The maximum number of elements in the response array
|
|
16
|
+
* @param {string} [options.cursor] - A server-generated identifier retrieved from pagingMetadata that specifies from which position the result listing should continue
|
|
17
|
+
* @returns {Promise<GetAllAssetAdministrationShellsResponse>} Requested Asset Administration Shells
|
|
18
|
+
*/
|
|
19
|
+
async getAllAssetAdministrationShells({ baseUrl, headers, assetIds, idShort, limit, cursor, }) {
|
|
20
|
+
try {
|
|
21
|
+
const client = createCustomClient(baseUrl, headers);
|
|
22
|
+
const { data, error } = await AasRepository.getAllAssetAdministrationShells({
|
|
23
|
+
client,
|
|
24
|
+
query: { assetIds, idShort, limit, cursor },
|
|
25
|
+
});
|
|
26
|
+
if (error) {
|
|
27
|
+
console.error('Error from server:', error);
|
|
28
|
+
throw new Error(JSON.stringify(error.messages));
|
|
29
|
+
}
|
|
30
|
+
const shells = (data.result ?? []).map(convertApiAasToCoreAas);
|
|
31
|
+
return {
|
|
32
|
+
pagedResult: data.paging_metadata,
|
|
33
|
+
result: shells,
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
catch (error) {
|
|
37
|
+
console.error('Error fetching Asset Administration Shells:', error);
|
|
38
|
+
throw error;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Creates a new Asset Administration Shell
|
|
43
|
+
*
|
|
44
|
+
* @function postAssetAdministrationShell
|
|
45
|
+
* @param {PostAssetAdministrationShellOptions} options - Options object.
|
|
46
|
+
* @param {string} options.baseUrl - The API base URL
|
|
47
|
+
* @param {AssetAdministrationShell} options.assetAdministrationShell - Asset Administration Shell object
|
|
48
|
+
* @param {Headers} [options.headers] - Request headers
|
|
49
|
+
* @returns {Promise<AssetAdministrationShell>} Asset Administration Shell created successfully
|
|
50
|
+
*/
|
|
51
|
+
async postAssetAdministrationShell({ baseUrl, assetAdministrationShell, headers, }) {
|
|
52
|
+
try {
|
|
53
|
+
const client = createCustomClient(baseUrl, headers);
|
|
54
|
+
const { data, error } = await AasRepository.postAssetAdministrationShell({
|
|
55
|
+
client,
|
|
56
|
+
body: convertCoreAasToApiAas(assetAdministrationShell),
|
|
57
|
+
});
|
|
58
|
+
if (error) {
|
|
59
|
+
console.error('Error from server:', error);
|
|
60
|
+
throw new Error(JSON.stringify(error.messages));
|
|
61
|
+
}
|
|
62
|
+
return convertApiAasToCoreAas(data);
|
|
63
|
+
}
|
|
64
|
+
catch (error) {
|
|
65
|
+
console.error('Error creating Asset Administration Shell:', error);
|
|
66
|
+
throw error;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Deletes an Asset Administration Shell
|
|
71
|
+
*
|
|
72
|
+
* @function deleteAssetAdministrationShellById
|
|
73
|
+
* @param {AasIdentifierOptions} options - Options object.
|
|
74
|
+
* @param {string} options.baseUrl - The API base URL
|
|
75
|
+
* @param {string} options.aasIdentifier - The Asset Administration Shell's unique id
|
|
76
|
+
* @param {Headers} [options.headers] - Request headers
|
|
77
|
+
* @returns {Promise<void>} Asset Administration Shell deleted successfully
|
|
78
|
+
*/
|
|
79
|
+
async deleteAssetAdministrationShellById({ baseUrl, aasIdentifier, headers }) {
|
|
80
|
+
try {
|
|
81
|
+
const client = createCustomClient(baseUrl, headers);
|
|
82
|
+
const encodedAasIdentifier = base64Encode(aasIdentifier);
|
|
83
|
+
const { error } = await AasRepository.deleteAssetAdministrationShellById({
|
|
84
|
+
client,
|
|
85
|
+
path: { aasIdentifier: encodedAasIdentifier },
|
|
86
|
+
});
|
|
87
|
+
if (error) {
|
|
88
|
+
console.error('Error from server:', error);
|
|
89
|
+
throw new Error(JSON.stringify(error.messages));
|
|
90
|
+
}
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
catch (error) {
|
|
94
|
+
console.error('Error deleting Asset Administration Shell:', error);
|
|
95
|
+
throw error;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Returns a specific Asset Administration Shell
|
|
100
|
+
*
|
|
101
|
+
* @function getAssetAdministrationShellById
|
|
102
|
+
* @param {AasIdentifierOptions} options - Options object.
|
|
103
|
+
* @param {string} options.baseUrl - The API base URL
|
|
104
|
+
* @param {string} options.aasIdentifier - The Asset Administration Shell's unique id
|
|
105
|
+
* @param {Headers} [options.headers] - Request headers
|
|
106
|
+
* @returns {Promise<AssetAdministrationShell>} Requested Asset Administration Shell
|
|
107
|
+
*/
|
|
108
|
+
async getAssetAdministrationShellById({ baseUrl, aasIdentifier, headers, }) {
|
|
109
|
+
try {
|
|
110
|
+
const client = createCustomClient(baseUrl, headers);
|
|
111
|
+
const encodedAasIdentifier = base64Encode(aasIdentifier);
|
|
112
|
+
const { data, error } = await AasRepository.getAssetAdministrationShellById({
|
|
113
|
+
client,
|
|
114
|
+
path: { aasIdentifier: encodedAasIdentifier },
|
|
115
|
+
});
|
|
116
|
+
if (error) {
|
|
117
|
+
console.error('Error from server:', error);
|
|
118
|
+
throw new Error(JSON.stringify(error.messages));
|
|
119
|
+
}
|
|
120
|
+
return convertApiAasToCoreAas(data);
|
|
121
|
+
}
|
|
122
|
+
catch (error) {
|
|
123
|
+
console.error('Error fetching Asset Administration Shell:', error);
|
|
124
|
+
throw error;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* Updates an existing Asset Administration Shell
|
|
129
|
+
*
|
|
130
|
+
* @function putAssetAdministrationShellById
|
|
131
|
+
* @param {PutAssetAdministrationShellOptions} options - Options object.
|
|
132
|
+
* @param {string} options.baseUrl - The API base URL
|
|
133
|
+
* @param {string} options.aasIdentifier - The Asset Administration Shell's unique id
|
|
134
|
+
* @param {AssetAdministrationShell} options.assetAdministrationShell - Asset Administration Shell object
|
|
135
|
+
* @param {Headers} [options.headers] - Request headers
|
|
136
|
+
* @returns {Promise<void>} Asset Administration Shell updated successfully
|
|
137
|
+
*/
|
|
138
|
+
async putAssetAdministrationShellById({ baseUrl, aasIdentifier, assetAdministrationShell, headers, }) {
|
|
139
|
+
try {
|
|
140
|
+
const client = createCustomClient(baseUrl, headers);
|
|
141
|
+
const encodedAasIdentifier = base64Encode(aasIdentifier);
|
|
142
|
+
const { error } = await AasRepository.putAssetAdministrationShellById({
|
|
143
|
+
client,
|
|
144
|
+
path: { aasIdentifier: encodedAasIdentifier },
|
|
145
|
+
body: convertCoreAasToApiAas(assetAdministrationShell),
|
|
146
|
+
});
|
|
147
|
+
if (error) {
|
|
148
|
+
console.error('Error from server:', error);
|
|
149
|
+
throw new Error(JSON.stringify(error.messages));
|
|
150
|
+
}
|
|
151
|
+
return;
|
|
152
|
+
}
|
|
153
|
+
catch (error) {
|
|
154
|
+
console.error('Error updating Asset Administration Shell:', error);
|
|
155
|
+
throw error;
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
/**
|
|
159
|
+
* Returns the Asset Information
|
|
160
|
+
*
|
|
161
|
+
* @function getAssetInformation
|
|
162
|
+
* @param {AasIdentifierOptions} options - Options object.
|
|
163
|
+
* @param {string} options.baseUrl - The API base URL
|
|
164
|
+
* @param {string} options.aasIdentifier - The Asset Administration Shell's unique id
|
|
165
|
+
* @param {Headers} [options.headers] - Request headers
|
|
166
|
+
* @returns {Promise<AssetInformation>} Requested Asset Information
|
|
167
|
+
*/
|
|
168
|
+
async getAssetInformation({ baseUrl, aasIdentifier, headers }) {
|
|
169
|
+
try {
|
|
170
|
+
const client = createCustomClient(baseUrl, headers);
|
|
171
|
+
const encodedAasIdentifier = base64Encode(aasIdentifier);
|
|
172
|
+
const { data, error } = await AasRepository.getAssetInformationAasRepository({
|
|
173
|
+
client,
|
|
174
|
+
path: { aasIdentifier: encodedAasIdentifier },
|
|
175
|
+
});
|
|
176
|
+
if (error) {
|
|
177
|
+
console.error('Error from server:', error);
|
|
178
|
+
throw new Error(JSON.stringify(error.messages));
|
|
179
|
+
}
|
|
180
|
+
return convertApiAssetInformationToCoreAssetInformation(data);
|
|
181
|
+
}
|
|
182
|
+
catch (error) {
|
|
183
|
+
console.error('Error fetching Asset Information:', error);
|
|
184
|
+
throw error;
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
/**
|
|
188
|
+
* Updates the Asset Information
|
|
189
|
+
*
|
|
190
|
+
* @function putAssetInformation
|
|
191
|
+
* @param {PutAssetInformationOptions} options - Options object.
|
|
192
|
+
* @param {string} options.baseUrl - The API base URL
|
|
193
|
+
* @param {string} options.aasIdentifier - The Asset Administration Shell's unique id
|
|
194
|
+
* @param {AssetInformation} options.assetInformation - Asset Information object
|
|
195
|
+
* @param {Headers} [options.headers] - Request headers
|
|
196
|
+
* @returns {Promise<void>} Asset Information updated successfully
|
|
197
|
+
*/
|
|
198
|
+
async putAssetInformation({ baseUrl, aasIdentifier, assetInformation, headers, }) {
|
|
199
|
+
try {
|
|
200
|
+
const client = createCustomClient(baseUrl, headers);
|
|
201
|
+
const encodedAasIdentifier = base64Encode(aasIdentifier);
|
|
202
|
+
const { error } = await AasRepository.putAssetInformationAasRepository({
|
|
203
|
+
client,
|
|
204
|
+
path: { aasIdentifier: encodedAasIdentifier },
|
|
205
|
+
body: convertCoreAssetInformationToApiAssetInformation(assetInformation),
|
|
206
|
+
});
|
|
207
|
+
if (error) {
|
|
208
|
+
console.error('Error from server:', error);
|
|
209
|
+
throw new Error(JSON.stringify(error.messages));
|
|
210
|
+
}
|
|
211
|
+
return;
|
|
212
|
+
}
|
|
213
|
+
catch (error) {
|
|
214
|
+
console.error('Error updating Asset Information:', error);
|
|
215
|
+
throw error;
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
/**
|
|
219
|
+
* Deletes the Thumbnail
|
|
220
|
+
*
|
|
221
|
+
* @function deleteThumbnail
|
|
222
|
+
* @param {AasIdentifierOptions} options - Options object.
|
|
223
|
+
* @param {string} options.baseUrl - The API base URL
|
|
224
|
+
* @param {string} options.aasIdentifier - The Asset Administration Shell's unique id
|
|
225
|
+
* @param {Headers} [options.headers] - Request headers
|
|
226
|
+
* @returns {Promise<void>} Thumbnail deletion successful
|
|
227
|
+
*/
|
|
228
|
+
async deleteThumbnail({ baseUrl, aasIdentifier, headers }) {
|
|
229
|
+
try {
|
|
230
|
+
const client = createCustomClient(baseUrl, headers);
|
|
231
|
+
const encodedAasIdentifier = base64Encode(aasIdentifier);
|
|
232
|
+
const { error } = await AasRepository.deleteThumbnailAasRepository({
|
|
233
|
+
client,
|
|
234
|
+
path: { aasIdentifier: encodedAasIdentifier },
|
|
235
|
+
});
|
|
236
|
+
if (error) {
|
|
237
|
+
console.error('Error from server:', error);
|
|
238
|
+
throw new Error(JSON.stringify(error.messages));
|
|
239
|
+
}
|
|
240
|
+
return;
|
|
241
|
+
}
|
|
242
|
+
catch (error) {
|
|
243
|
+
console.error('Error deleting Thumbnail:', error);
|
|
244
|
+
throw error;
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
/**
|
|
248
|
+
* Returns the Thumbnail
|
|
249
|
+
*
|
|
250
|
+
* @function getThumbnail
|
|
251
|
+
* @param {AasIdentifierOptions} options - Options object.
|
|
252
|
+
* @param {string} options.baseUrl - The API base URL
|
|
253
|
+
* @param {string} options.aasIdentifier - The Asset Administration Shell's unique id
|
|
254
|
+
* @param {Headers} [options.headers] - Request headers
|
|
255
|
+
* @returns {Promise<Blob | File>} The thumbnail of the Asset Information.
|
|
256
|
+
*/
|
|
257
|
+
async getThumbnail({ baseUrl, aasIdentifier, headers }) {
|
|
258
|
+
try {
|
|
259
|
+
const client = createCustomClient(baseUrl, headers);
|
|
260
|
+
const encodedAasIdentifier = base64Encode(aasIdentifier);
|
|
261
|
+
const { data, error } = await AasRepository.getThumbnailAasRepository({
|
|
262
|
+
client,
|
|
263
|
+
path: { aasIdentifier: encodedAasIdentifier },
|
|
264
|
+
});
|
|
265
|
+
if (error) {
|
|
266
|
+
console.error('Error from server:', error);
|
|
267
|
+
throw new Error(JSON.stringify(error.messages));
|
|
268
|
+
}
|
|
269
|
+
return data;
|
|
270
|
+
}
|
|
271
|
+
catch (error) {
|
|
272
|
+
console.error('Error fetching Thumbnail:', error);
|
|
273
|
+
throw error;
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
/**
|
|
277
|
+
* Updates the Thumbnail
|
|
278
|
+
*
|
|
279
|
+
* @function putThumbnail
|
|
280
|
+
* @param {PutThumbnailOptions} options - Options object.
|
|
281
|
+
* @param {string} options.baseUrl - The API base URL
|
|
282
|
+
* @param {string} options.aasIdentifier - The Asset Administration Shell's unique id
|
|
283
|
+
* @param {AssetinformationThumbnailBody} options.thumbnail - Thumbnail to upload
|
|
284
|
+
* @param {Headers} [options.headers] - Request headers
|
|
285
|
+
* @returns {Promise<void>} Thumbnail updated successfully
|
|
286
|
+
*/
|
|
287
|
+
async putThumbnail({ baseUrl, aasIdentifier, thumbnail, headers }) {
|
|
288
|
+
try {
|
|
289
|
+
const client = createCustomClient(baseUrl, headers);
|
|
290
|
+
const encodedAasIdentifier = base64Encode(aasIdentifier);
|
|
291
|
+
const { error } = await AasRepository.putThumbnailAasRepository({
|
|
292
|
+
client,
|
|
293
|
+
path: { aasIdentifier: encodedAasIdentifier },
|
|
294
|
+
body: thumbnail,
|
|
295
|
+
});
|
|
296
|
+
if (error) {
|
|
297
|
+
console.error('Error from server:', error);
|
|
298
|
+
throw new Error(JSON.stringify(error.messages));
|
|
299
|
+
}
|
|
300
|
+
return;
|
|
301
|
+
}
|
|
302
|
+
catch (error) {
|
|
303
|
+
console.error('Error updating Thumbnail:', error);
|
|
304
|
+
throw error;
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
/**
|
|
308
|
+
* Returns all submodel references
|
|
309
|
+
*
|
|
310
|
+
* @function getAllSubmodelReferences
|
|
311
|
+
* @param {GetAllSubmodelReferencesOptions} options - Options object.
|
|
312
|
+
* @param {string} options.baseUrl - The API base URL
|
|
313
|
+
* @param {string} options.aasIdentifier - The Asset Administration Shell's unique id
|
|
314
|
+
* @param {Headers} [options.headers] - Request headers
|
|
315
|
+
* @param {number} [options.limit] - The maximum number of elements in the response array
|
|
316
|
+
* @param {string} [options.cursor] - A server-generated identifier retrieved from pagingMetadata that specifies from which position the result listing should continue
|
|
317
|
+
* @returns {Promise<GetAllSubmodelReferencesResponse>} Requested submodel references
|
|
318
|
+
*/
|
|
319
|
+
async getAllSubmodelReferences({ baseUrl, aasIdentifier, headers, limit, cursor, }) {
|
|
320
|
+
try {
|
|
321
|
+
const client = createCustomClient(baseUrl, headers);
|
|
322
|
+
const encodedAasIdentifier = base64Encode(aasIdentifier);
|
|
323
|
+
const { data, error } = await AasRepository.getAllSubmodelReferencesAasRepository({
|
|
324
|
+
client,
|
|
325
|
+
path: { aasIdentifier: encodedAasIdentifier },
|
|
326
|
+
query: {
|
|
327
|
+
limit,
|
|
328
|
+
cursor,
|
|
329
|
+
},
|
|
330
|
+
});
|
|
331
|
+
if (error) {
|
|
332
|
+
console.error('Error from server:', error);
|
|
333
|
+
throw new Error(JSON.stringify(error.messages));
|
|
334
|
+
}
|
|
335
|
+
const submodelReferences = (data.result ?? []).map(convertApiReferenceToCoreReference);
|
|
336
|
+
return {
|
|
337
|
+
pagedResult: data.paging_metadata,
|
|
338
|
+
result: submodelReferences,
|
|
339
|
+
};
|
|
340
|
+
}
|
|
341
|
+
catch (error) {
|
|
342
|
+
console.error('Error fetching Submodel References:', error);
|
|
343
|
+
throw error;
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
/**
|
|
347
|
+
* Creates a submodel reference at the Asset Administration Shell
|
|
348
|
+
*
|
|
349
|
+
* @function postSubmodelReference
|
|
350
|
+
* @param {PostSubmodelReferenceOptions} options - Options object.
|
|
351
|
+
* @param {string} options.baseUrl - The API base URL
|
|
352
|
+
* @param {string} options.aasIdentifier - The Asset Administration Shell's unique id
|
|
353
|
+
* @param {Reference} options.submodelReference - Reference to the Submodel
|
|
354
|
+
* @param {Headers} [options.headers] - Request headers
|
|
355
|
+
* @returns {Promise<Reference>} Submodel reference created successfully
|
|
356
|
+
*/
|
|
357
|
+
async postSubmodelReference({ baseUrl, aasIdentifier, submodelReference, headers, }) {
|
|
358
|
+
try {
|
|
359
|
+
const client = createCustomClient(baseUrl, headers);
|
|
360
|
+
const encodedAasIdentifier = base64Encode(aasIdentifier);
|
|
361
|
+
const { data, error } = await AasRepository.postSubmodelReferenceAasRepository({
|
|
362
|
+
client,
|
|
363
|
+
path: { aasIdentifier: encodedAasIdentifier },
|
|
364
|
+
body: convertCoreReferenceToApiReference(submodelReference),
|
|
365
|
+
});
|
|
366
|
+
if (error) {
|
|
367
|
+
console.error('Error from server:', error);
|
|
368
|
+
throw new Error(JSON.stringify(error.messages));
|
|
369
|
+
}
|
|
370
|
+
return convertApiReferenceToCoreReference(data);
|
|
371
|
+
}
|
|
372
|
+
catch (error) {
|
|
373
|
+
console.error('Error creating Submodel Reference:', error);
|
|
374
|
+
throw error;
|
|
375
|
+
}
|
|
376
|
+
}
|
|
377
|
+
/**
|
|
378
|
+
* Deletes the submodel reference from the Asset Administration Shell. Does not delete the submodel itself!
|
|
379
|
+
*
|
|
380
|
+
* @function deleteSubmodelReferenceById
|
|
381
|
+
* @param {DeleteSubmodelReferenceByIdOptions} options - Options object.
|
|
382
|
+
* @param {string} options.baseUrl - The API base URL
|
|
383
|
+
* @param {string} options.aasIdentifier - The Asset Administration Shell's unique id
|
|
384
|
+
* @param {string} options.submodelIdentifier - The Submodel's unique id
|
|
385
|
+
* @param {Headers} [options.headers] - Request headers
|
|
386
|
+
* @returns {Promise<void>} Submodel reference deleted successfully
|
|
387
|
+
*/
|
|
388
|
+
async deleteSubmodelReferenceById({ baseUrl, aasIdentifier, submodelIdentifier, headers, }) {
|
|
389
|
+
try {
|
|
390
|
+
const client = createCustomClient(baseUrl, headers);
|
|
391
|
+
const encodedAasIdentifier = base64Encode(aasIdentifier);
|
|
392
|
+
const encodedSubmodelIdentifier = base64Encode(submodelIdentifier);
|
|
393
|
+
const { error } = await AasRepository.deleteSubmodelReferenceByIdAasRepository({
|
|
394
|
+
client,
|
|
395
|
+
path: { aasIdentifier: encodedAasIdentifier, submodelIdentifier: encodedSubmodelIdentifier },
|
|
396
|
+
});
|
|
397
|
+
if (error) {
|
|
398
|
+
console.error('Error from server:', error);
|
|
399
|
+
throw new Error(JSON.stringify(error.messages));
|
|
400
|
+
}
|
|
401
|
+
return;
|
|
402
|
+
}
|
|
403
|
+
catch (error) {
|
|
404
|
+
console.error('Error deleting Submodel Reference:', error);
|
|
405
|
+
throw error;
|
|
406
|
+
}
|
|
407
|
+
}
|
|
408
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { AasRepositoryClient } from './AasRepositoryClient';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { AasRepositoryClient } from './AasRepositoryClient';
|