basyx-typescript-sdk 0.0.1

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