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