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