basyx-typescript-sdk 2.2.4 → 2.3.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.
Files changed (62) hide show
  1. package/README.md +169 -0
  2. package/bundle/index.cjs +3484 -2149
  3. package/bundle/index.cjs.map +1 -1
  4. package/bundle/index.mjs +3484 -2149
  5. package/bundle/index.mjs.map +1 -1
  6. package/dist/clients/AasDiscoveryClient.d.ts +12 -5
  7. package/dist/clients/AasDiscoveryClient.js +104 -27
  8. package/dist/clients/AasRegistryClient.d.ts +32 -10
  9. package/dist/clients/AasRegistryClient.js +211 -61
  10. package/dist/clients/AasRepositoryClient.d.ts +231 -60
  11. package/dist/clients/AasRepositoryClient.js +1021 -353
  12. package/dist/clients/AasxFileClient.d.ts +29 -3
  13. package/dist/clients/AasxFileClient.js +122 -31
  14. package/dist/clients/ConceptDescriptionRepositoryClient.d.ts +14 -4
  15. package/dist/clients/ConceptDescriptionRepositoryClient.js +127 -35
  16. package/dist/clients/SubmodelRegistryClient.d.ts +14 -4
  17. package/dist/clients/SubmodelRegistryClient.js +117 -27
  18. package/dist/clients/SubmodelRepositoryClient.d.ts +339 -58
  19. package/dist/clients/SubmodelRepositoryClient.js +913 -269
  20. package/dist/generated/AasDiscoveryService/models/index.d.ts +2 -2
  21. package/dist/generated/AasRegistryService/apis/AssetAdministrationShellRegistryAPIApi.d.ts +1 -1
  22. package/dist/generated/AasRegistryService/apis/AssetAdministrationShellRegistryAPIApi.js +1 -1
  23. package/dist/generated/AasRegistryService/apis/DescriptionAPIApi.d.ts +1 -1
  24. package/dist/generated/AasRegistryService/apis/DescriptionAPIApi.js +1 -1
  25. package/dist/generated/AasRegistryService/index.d.ts +1 -1
  26. package/dist/generated/AasRegistryService/index.js +1 -1
  27. package/dist/generated/AasRegistryService/models/index.d.ts +3 -3
  28. package/dist/generated/AasRepositoryService/apis/AssetAdministrationShellRepositoryAPIApi.d.ts +3 -3
  29. package/dist/generated/AasRepositoryService/apis/AssetAdministrationShellRepositoryAPIApi.js +1 -1
  30. package/dist/generated/AasRepositoryService/apis/DescriptionAPIApi.d.ts +1 -1
  31. package/dist/generated/AasRepositoryService/apis/DescriptionAPIApi.js +1 -1
  32. package/dist/generated/AasRepositoryService/apis/SerializationAPIApi.d.ts +1 -1
  33. package/dist/generated/AasRepositoryService/apis/SerializationAPIApi.js +1 -1
  34. package/dist/generated/AasRepositoryService/index.d.ts +1 -1
  35. package/dist/generated/AasRepositoryService/index.js +1 -1
  36. package/dist/generated/AasRepositoryService/models/index.d.ts +7 -7
  37. package/dist/generated/AasxFileService/apis/AASXFileServerAPIApi.d.ts +5 -3
  38. package/dist/generated/AasxFileService/apis/AASXFileServerAPIApi.js +6 -0
  39. package/dist/generated/AasxFileService/apis/DescriptionAPIApi.d.ts +26 -0
  40. package/dist/generated/AasxFileService/apis/DescriptionAPIApi.js +40 -0
  41. package/dist/generated/AasxFileService/apis/index.d.ts +1 -0
  42. package/dist/generated/AasxFileService/apis/index.js +1 -0
  43. package/dist/generated/AasxFileService/models/index.d.ts +45 -0
  44. package/dist/generated/ConceptDescriptionRepositoryService/models/index.d.ts +2 -2
  45. package/dist/generated/SubmodelRegistryService/models/index.d.ts +2 -2
  46. package/dist/generated/SubmodelRepositoryService/models/index.d.ts +9 -9
  47. package/dist/generated/runtime.js +7 -0
  48. package/dist/lib/apiConfig.d.ts +2 -1
  49. package/dist/lib/apiConfig.js +27 -2
  50. package/dist/lib/conditionalRequests.d.ts +28 -0
  51. package/dist/lib/conditionalRequests.js +55 -0
  52. package/dist/lib/errorHandler.js +13 -2
  53. package/dist/models/api.d.ts +40 -2
  54. package/dist/services/AasService.d.ts +34 -4
  55. package/dist/services/AasService.js +159 -33
  56. package/dist/services/SubmodelService.d.ts +34 -4
  57. package/dist/services/SubmodelService.js +168 -28
  58. package/package.json +14 -3
  59. package/dist/generated/AasRegistryService/runtime.d.ts +0 -181
  60. package/dist/generated/AasRegistryService/runtime.js +0 -326
  61. package/dist/generated/AasRepositoryService/runtime.d.ts +0 -181
  62. package/dist/generated/AasRepositoryService/runtime.js +0 -326
@@ -1,16 +1,39 @@
1
1
  import { AasRegistryService } from '../generated';
2
+ import { RequiredError } from '../generated/runtime';
2
3
  import { applyDefaults } from '../lib/apiConfig';
3
4
  import { base64Encode } from '../lib/base64Url';
5
+ import { getConditionalErrorFields, getEtag, getNotModifiedResult } from '../lib/conditionalRequests';
4
6
  import { convertApiAasDescriptorToCoreAasDescriptor, convertApiSubmodelDescriptorToCoreSubmodelDescriptor, convertCoreAasDescriptorToApiAasDescriptor, convertCoreSubmodelDescriptorToApiSubmodelDescriptor, } from '../lib/convertAasDescriptorTypes';
5
7
  import { handleApiError } from '../lib/errorHandler';
6
8
  export class AasRegistryClient {
9
+ static requireIdentifier(value, field) {
10
+ if (value === null || value === undefined || value.trim() === '') {
11
+ throw new RequiredError(field, `Required parameter "${field}" was null, undefined, or empty.`);
12
+ }
13
+ return value;
14
+ }
15
+ static extractStatusCode(err, parsedError) {
16
+ const responseStatus = err?.response?.status;
17
+ if (typeof responseStatus === 'number') {
18
+ return responseStatus;
19
+ }
20
+ if (err instanceof RequiredError || err?.name === 'RequiredError') {
21
+ return 400;
22
+ }
23
+ const code = parsedError?.messages?.[0]?.code;
24
+ if (!code) {
25
+ return undefined;
26
+ }
27
+ const parsedCode = Number.parseInt(code, 10);
28
+ return Number.isNaN(parsedCode) ? undefined : parsedCode;
29
+ }
7
30
  /**
8
31
  * Returns all Asset Administration Shell Descriptors
9
32
  *
10
33
  * @param options Object containing:
11
34
  * - configuration: The http request options
12
35
  * - limit?: The maximum number of elements in the response array
13
- * - cursor?: A server-generated identifier retrieved from pagingMetadata that specifies from which position the result listing should continue
36
+ * - cursor?: A server-generated identifier retrieved from paging_metadata that specifies from which position the result listing should continue
14
37
  * - assetKind?: The Asset's kind (Instance or Type)
15
38
  * - assetType?: The Asset's type (UTF8-BASE64-URL-encoded)
16
39
  *
@@ -21,21 +44,30 @@ export class AasRegistryClient {
21
44
  try {
22
45
  const apiInstance = new AasRegistryService.AssetAdministrationShellRegistryAPIApi(applyDefaults(configuration));
23
46
  const encodedAssetType = assetType ? base64Encode(assetType) : undefined;
24
- const result = await apiInstance.getAllAssetAdministrationShellDescriptors({
47
+ const response = await apiInstance.getAllAssetAdministrationShellDescriptorsRaw({
25
48
  limit: limit,
26
49
  cursor: cursor,
27
50
  assetKind: assetKind,
28
51
  assetType: encodedAssetType,
29
52
  });
53
+ const result = await response.value();
30
54
  const aasDescriptors = (result.result ?? []).map(convertApiAasDescriptorToCoreAasDescriptor);
55
+ const pagedResult = result.paging_metadata;
31
56
  return {
32
57
  success: true,
33
- data: { pagedResult: result.pagingMetadata, result: aasDescriptors },
58
+ data: { pagedResult, result: aasDescriptors },
59
+ statusCode: response.raw.status,
60
+ etag: getEtag(response.raw),
34
61
  };
35
62
  }
36
63
  catch (err) {
37
64
  const customError = await handleApiError(err);
38
- return { success: false, error: customError };
65
+ return {
66
+ success: false,
67
+ error: customError,
68
+ statusCode: AasRegistryClient.extractStatusCode(err, customError),
69
+ ...getConditionalErrorFields(err),
70
+ };
39
71
  }
40
72
  }
41
73
  /**
@@ -51,14 +83,25 @@ export class AasRegistryClient {
51
83
  const { configuration, assetAdministrationShellDescriptor } = options;
52
84
  try {
53
85
  const apiInstance = new AasRegistryService.AssetAdministrationShellRegistryAPIApi(applyDefaults(configuration));
54
- const result = await apiInstance.postAssetAdministrationShellDescriptor({
86
+ const response = await apiInstance.postAssetAdministrationShellDescriptorRaw({
55
87
  assetAdministrationShellDescriptor: convertCoreAasDescriptorToApiAasDescriptor(assetAdministrationShellDescriptor),
56
88
  });
57
- return { success: true, data: convertApiAasDescriptorToCoreAasDescriptor(result) };
89
+ const result = await response.value();
90
+ return {
91
+ success: true,
92
+ data: convertApiAasDescriptorToCoreAasDescriptor(result),
93
+ statusCode: response.raw.status,
94
+ etag: getEtag(response.raw),
95
+ };
58
96
  }
59
97
  catch (err) {
60
98
  const customError = await handleApiError(err);
61
- return { success: false, error: customError };
99
+ return {
100
+ success: false,
101
+ error: customError,
102
+ statusCode: AasRegistryClient.extractStatusCode(err, customError),
103
+ ...getConditionalErrorFields(err),
104
+ };
62
105
  }
63
106
  }
64
107
  /**
@@ -67,22 +110,29 @@ export class AasRegistryClient {
67
110
  * @param options Object containing:
68
111
  * - configuration: The http request options
69
112
  * - aasIdentifier: The Asset Administration Shell’s unique id (UTF8-BASE64-URL-encoded)
113
+ * - ifMatch?: Sent as `If-Match` header; the request fails with `preconditionFailed` if the resource has changed since the `etag` was issued
70
114
  *
71
115
  * @returns Either `{ success: true; data: ... }` or `{ success: false; error: ... }`.
72
116
  */
73
117
  async deleteAssetAdministrationShellDescriptorById(options) {
74
- const { configuration, aasIdentifier } = options;
118
+ const { configuration, aasIdentifier, ifMatch } = options;
75
119
  try {
76
- const apiInstance = new AasRegistryService.AssetAdministrationShellRegistryAPIApi(applyDefaults(configuration));
77
- const encodedAasIdentifier = base64Encode(aasIdentifier);
78
- const result = await apiInstance.deleteAssetAdministrationShellDescriptorById({
120
+ const apiInstance = new AasRegistryService.AssetAdministrationShellRegistryAPIApi(applyDefaults(configuration, { ifMatch }));
121
+ const encodedAasIdentifier = base64Encode(AasRegistryClient.requireIdentifier(aasIdentifier, 'aasIdentifier'));
122
+ const response = await apiInstance.deleteAssetAdministrationShellDescriptorByIdRaw({
79
123
  aasIdentifier: encodedAasIdentifier,
80
124
  });
81
- return { success: true, data: result };
125
+ const result = await response.value();
126
+ return { success: true, data: result, statusCode: response.raw.status, etag: getEtag(response.raw) };
82
127
  }
83
128
  catch (err) {
84
129
  const customError = await handleApiError(err);
85
- return { success: false, error: customError };
130
+ return {
131
+ success: false,
132
+ error: customError,
133
+ statusCode: AasRegistryClient.extractStatusCode(err, customError),
134
+ ...getConditionalErrorFields(err),
135
+ };
86
136
  }
87
137
  }
88
138
  /**
@@ -91,22 +141,38 @@ export class AasRegistryClient {
91
141
  * @param options Object containing:
92
142
  * - configuration: The http request options
93
143
  * - aasIdentifier: The Asset Administration Shell’s unique id (UTF8-BASE64-URL-encoded)
144
+ * - ifNoneMatch?: Sent as `If-None-Match` header; returns `{ success: true; notModified: true }` without data if the representation still has this `etag`
94
145
  *
95
146
  * @returns Either `{ success: true; data: ... }` or `{ success: false; error: ... }`.
96
147
  */
97
148
  async getAssetAdministrationShellDescriptorById(options) {
98
- const { configuration, aasIdentifier } = options;
149
+ const { configuration, aasIdentifier, ifNoneMatch } = options;
99
150
  try {
100
- const apiInstance = new AasRegistryService.AssetAdministrationShellRegistryAPIApi(applyDefaults(configuration));
101
- const encodedAasIdentifier = base64Encode(aasIdentifier);
102
- const result = await apiInstance.getAssetAdministrationShellDescriptorById({
151
+ const apiInstance = new AasRegistryService.AssetAdministrationShellRegistryAPIApi(applyDefaults(configuration, { ifNoneMatch }));
152
+ const encodedAasIdentifier = base64Encode(AasRegistryClient.requireIdentifier(aasIdentifier, 'aasIdentifier'));
153
+ const response = await apiInstance.getAssetAdministrationShellDescriptorByIdRaw({
103
154
  aasIdentifier: encodedAasIdentifier,
104
155
  });
105
- return { success: true, data: convertApiAasDescriptorToCoreAasDescriptor(result) };
156
+ const result = await response.value();
157
+ return {
158
+ success: true,
159
+ data: convertApiAasDescriptorToCoreAasDescriptor(result),
160
+ statusCode: response.raw.status,
161
+ etag: getEtag(response.raw),
162
+ };
106
163
  }
107
164
  catch (err) {
165
+ const notModified = getNotModifiedResult(err, ifNoneMatch);
166
+ if (notModified) {
167
+ return notModified;
168
+ }
108
169
  const customError = await handleApiError(err);
109
- return { success: false, error: customError };
170
+ return {
171
+ success: false,
172
+ error: customError,
173
+ statusCode: AasRegistryClient.extractStatusCode(err, customError),
174
+ ...getConditionalErrorFields(err),
175
+ };
110
176
  }
111
177
  }
112
178
  /**
@@ -116,23 +182,39 @@ export class AasRegistryClient {
116
182
  * - configuration: The http request options
117
183
  * - aasIdentifier: The Asset Administration Shell’s unique id (UTF8-BASE64-URL-encoded)
118
184
  * - assetAdministrationShellDescriptor: Asset Administration Shell Descriptor object
185
+ * - ifMatch?: Sent as `If-Match` header; the request fails with `preconditionFailed` if the resource has changed since the `etag` was issued
186
+ * - ifNoneMatch?: Sent as `If-None-Match` header; use `*` to only create the resource (fails with `preconditionFailed` if it exists)
119
187
  *
120
188
  * @returns Either `{ success: true; data: ... }` or `{ success: false; error: ... }`.
121
189
  */
122
190
  async putAssetAdministrationShellDescriptorById(options) {
123
- const { configuration, aasIdentifier, assetAdministrationShellDescriptor } = options;
191
+ const { configuration, aasIdentifier, assetAdministrationShellDescriptor, ifMatch, ifNoneMatch } = options;
124
192
  try {
125
- const apiInstance = new AasRegistryService.AssetAdministrationShellRegistryAPIApi(applyDefaults(configuration));
126
- const encodedAasIdentifier = base64Encode(aasIdentifier);
127
- const result = await apiInstance.putAssetAdministrationShellDescriptorById({
193
+ const apiInstance = new AasRegistryService.AssetAdministrationShellRegistryAPIApi(applyDefaults(configuration, { ifMatch, ifNoneMatch }));
194
+ const encodedAasIdentifier = base64Encode(AasRegistryClient.requireIdentifier(aasIdentifier, 'aasIdentifier'));
195
+ const response = await apiInstance.putAssetAdministrationShellDescriptorByIdRaw({
128
196
  aasIdentifier: encodedAasIdentifier,
129
197
  assetAdministrationShellDescriptor: convertCoreAasDescriptorToApiAasDescriptor(assetAdministrationShellDescriptor),
130
198
  });
131
- return { success: true, data: result ? convertApiAasDescriptorToCoreAasDescriptor(result) : undefined };
199
+ if (response.raw.status === 204) {
200
+ return { success: true, data: undefined, statusCode: response.raw.status, etag: getEtag(response.raw) };
201
+ }
202
+ const result = await response.value();
203
+ return {
204
+ success: true,
205
+ data: result ? convertApiAasDescriptorToCoreAasDescriptor(result) : undefined,
206
+ statusCode: response.raw.status,
207
+ etag: getEtag(response.raw),
208
+ };
132
209
  }
133
210
  catch (err) {
134
211
  const customError = await handleApiError(err);
135
- return { success: false, error: customError };
212
+ return {
213
+ success: false,
214
+ error: customError,
215
+ statusCode: AasRegistryClient.extractStatusCode(err, customError),
216
+ ...getConditionalErrorFields(err),
217
+ };
136
218
  }
137
219
  }
138
220
  /**
@@ -142,29 +224,43 @@ export class AasRegistryClient {
142
224
  * - configuration: The http request options
143
225
  * - aasIdentifier: The Asset Administration Shell’s unique id (UTF8-BASE64-URL-encoded)
144
226
  * - limit?: The maximum number of elements in the response array
145
- * - cursor?: A server-generated identifier retrieved from pagingMetadata that specifies from which position the result listing should continue
227
+ * - cursor?: A server-generated identifier retrieved from paging_metadata that specifies from which position the result listing should continue
228
+ * - ifNoneMatch?: Sent as `If-None-Match` header; returns `{ success: true; notModified: true }` without data if the representation still has this `etag`
146
229
  *
147
230
  * @returns Either `{ success: true; data: ... }` or `{ success: false; error: ... }`.
148
231
  */
149
232
  async getAllSubmodelDescriptorsThroughSuperpath(options) {
150
- const { configuration, aasIdentifier, limit, cursor } = options;
233
+ const { configuration, aasIdentifier, limit, cursor, ifNoneMatch } = options;
151
234
  try {
152
- const apiInstance = new AasRegistryService.AssetAdministrationShellRegistryAPIApi(applyDefaults(configuration));
153
- const encodedAasIdentifier = base64Encode(aasIdentifier);
154
- const result = await apiInstance.getAllSubmodelDescriptorsThroughSuperpath({
235
+ const apiInstance = new AasRegistryService.AssetAdministrationShellRegistryAPIApi(applyDefaults(configuration, { ifNoneMatch }));
236
+ const encodedAasIdentifier = base64Encode(AasRegistryClient.requireIdentifier(aasIdentifier, 'aasIdentifier'));
237
+ const response = await apiInstance.getAllSubmodelDescriptorsThroughSuperpathRaw({
155
238
  aasIdentifier: encodedAasIdentifier,
156
239
  limit: limit,
157
240
  cursor: cursor,
158
241
  });
242
+ const result = await response.value();
159
243
  const submodelDescriptors = (result.result ?? []).map(convertApiSubmodelDescriptorToCoreSubmodelDescriptor);
244
+ const pagedResult = result.paging_metadata;
160
245
  return {
161
246
  success: true,
162
- data: { pagedResult: result.pagingMetadata, result: submodelDescriptors },
247
+ data: { pagedResult, result: submodelDescriptors },
248
+ statusCode: response.raw.status,
249
+ etag: getEtag(response.raw),
163
250
  };
164
251
  }
165
252
  catch (err) {
253
+ const notModified = getNotModifiedResult(err, ifNoneMatch);
254
+ if (notModified) {
255
+ return notModified;
256
+ }
166
257
  const customError = await handleApiError(err);
167
- return { success: false, error: customError };
258
+ return {
259
+ success: false,
260
+ error: customError,
261
+ statusCode: AasRegistryClient.extractStatusCode(err, customError),
262
+ ...getConditionalErrorFields(err),
263
+ };
168
264
  }
169
265
  }
170
266
  /**
@@ -174,23 +270,35 @@ export class AasRegistryClient {
174
270
  * - configuration: The http request options.
175
271
  * - aasIdentifier: The Asset Administration Shell’s unique id (UTF8-BASE64-URL-encoded)
176
272
  * - submodelDescriptor: Submodel Descriptor object
273
+ * - ifMatch?: Sent as `If-Match` header; the request fails with `preconditionFailed` if the resource has changed since the `etag` was issued
177
274
  *
178
275
  * @returns Either `{ success: true; data: ... }` or `{ success: false; error: ... }`.
179
276
  */
180
277
  async postSubmodelDescriptorThroughSuperpath(options) {
181
- const { configuration, aasIdentifier, submodelDescriptor } = options;
278
+ const { configuration, aasIdentifier, submodelDescriptor, ifMatch } = options;
182
279
  try {
183
- const apiInstance = new AasRegistryService.AssetAdministrationShellRegistryAPIApi(applyDefaults(configuration));
184
- const encodedAasIdentifier = base64Encode(aasIdentifier);
185
- const result = await apiInstance.postSubmodelDescriptorThroughSuperpath({
280
+ const apiInstance = new AasRegistryService.AssetAdministrationShellRegistryAPIApi(applyDefaults(configuration, { ifMatch }));
281
+ const encodedAasIdentifier = base64Encode(AasRegistryClient.requireIdentifier(aasIdentifier, 'aasIdentifier'));
282
+ const response = await apiInstance.postSubmodelDescriptorThroughSuperpathRaw({
186
283
  aasIdentifier: encodedAasIdentifier,
187
284
  submodelDescriptor: convertCoreSubmodelDescriptorToApiSubmodelDescriptor(submodelDescriptor),
188
285
  });
189
- return { success: true, data: convertApiSubmodelDescriptorToCoreSubmodelDescriptor(result) };
286
+ const result = await response.value();
287
+ return {
288
+ success: true,
289
+ data: convertApiSubmodelDescriptorToCoreSubmodelDescriptor(result),
290
+ statusCode: response.raw.status,
291
+ etag: getEtag(response.raw),
292
+ };
190
293
  }
191
294
  catch (err) {
192
295
  const customError = await handleApiError(err);
193
- return { success: false, error: customError };
296
+ return {
297
+ success: false,
298
+ error: customError,
299
+ statusCode: AasRegistryClient.extractStatusCode(err, customError),
300
+ ...getConditionalErrorFields(err),
301
+ };
194
302
  }
195
303
  }
196
304
  /**
@@ -200,24 +308,40 @@ export class AasRegistryClient {
200
308
  * - configuration: The http request options
201
309
  * - aasIdentifier: The Asset Administration Shell’s unique id (UTF8-BASE64-URL-encoded)
202
310
  * - submodelIdentifier: The Submodel’s unique id (UTF8-BASE64-URL-encoded)
311
+ * - ifNoneMatch?: Sent as `If-None-Match` header; returns `{ success: true; notModified: true }` without data if the representation still has this `etag`
203
312
  *
204
313
  * @returns Either `{ success: true; data: ... }` or `{ success: false; error: ... }`.
205
314
  */
206
315
  async getSubmodelDescriptorByIdThroughSuperpath(options) {
207
- const { configuration, aasIdentifier, submodelIdentifier } = options;
316
+ const { configuration, aasIdentifier, submodelIdentifier, ifNoneMatch } = options;
208
317
  try {
209
- const apiInstance = new AasRegistryService.AssetAdministrationShellRegistryAPIApi(applyDefaults(configuration));
210
- const encodedAasIdentifier = base64Encode(aasIdentifier);
211
- const encodedSubmodelIdentifier = base64Encode(submodelIdentifier);
212
- const result = await apiInstance.getSubmodelDescriptorByIdThroughSuperpath({
318
+ const apiInstance = new AasRegistryService.AssetAdministrationShellRegistryAPIApi(applyDefaults(configuration, { ifNoneMatch }));
319
+ const encodedAasIdentifier = base64Encode(AasRegistryClient.requireIdentifier(aasIdentifier, 'aasIdentifier'));
320
+ const encodedSubmodelIdentifier = base64Encode(AasRegistryClient.requireIdentifier(submodelIdentifier, 'submodelIdentifier'));
321
+ const response = await apiInstance.getSubmodelDescriptorByIdThroughSuperpathRaw({
213
322
  aasIdentifier: encodedAasIdentifier,
214
323
  submodelIdentifier: encodedSubmodelIdentifier,
215
324
  });
216
- return { success: true, data: convertApiSubmodelDescriptorToCoreSubmodelDescriptor(result) };
325
+ const result = await response.value();
326
+ return {
327
+ success: true,
328
+ data: convertApiSubmodelDescriptorToCoreSubmodelDescriptor(result),
329
+ statusCode: response.raw.status,
330
+ etag: getEtag(response.raw),
331
+ };
217
332
  }
218
333
  catch (err) {
334
+ const notModified = getNotModifiedResult(err, ifNoneMatch);
335
+ if (notModified) {
336
+ return notModified;
337
+ }
219
338
  const customError = await handleApiError(err);
220
- return { success: false, error: customError };
339
+ return {
340
+ success: false,
341
+ error: customError,
342
+ statusCode: AasRegistryClient.extractStatusCode(err, customError),
343
+ ...getConditionalErrorFields(err),
344
+ };
221
345
  }
222
346
  }
223
347
  /**
@@ -227,24 +351,31 @@ export class AasRegistryClient {
227
351
  * - configuration: The http request options
228
352
  * - aasIdentifier: The Asset Administration Shell’s unique id (UTF8-BASE64-URL-encoded)
229
353
  * - submodelIdentifier: The Submodel’s unique id (UTF8-BASE64-URL-encoded)
354
+ * - ifMatch?: Sent as `If-Match` header; the request fails with `preconditionFailed` if the resource has changed since the `etag` was issued
230
355
  *
231
356
  * @returns Either `{ success: true; data: ... }` or `{ success: false; error: ... }`.
232
357
  */
233
358
  async deleteSubmodelDescriptorByIdThroughSuperpath(options) {
234
- const { configuration, aasIdentifier, submodelIdentifier } = options;
359
+ const { configuration, aasIdentifier, submodelIdentifier, ifMatch } = options;
235
360
  try {
236
- const apiInstance = new AasRegistryService.AssetAdministrationShellRegistryAPIApi(applyDefaults(configuration));
237
- const encodedAasIdentifier = base64Encode(aasIdentifier);
238
- const encodedSubmodelIdentifier = base64Encode(submodelIdentifier);
239
- const result = await apiInstance.deleteSubmodelDescriptorByIdThroughSuperpath({
361
+ const apiInstance = new AasRegistryService.AssetAdministrationShellRegistryAPIApi(applyDefaults(configuration, { ifMatch }));
362
+ const encodedAasIdentifier = base64Encode(AasRegistryClient.requireIdentifier(aasIdentifier, 'aasIdentifier'));
363
+ const encodedSubmodelIdentifier = base64Encode(AasRegistryClient.requireIdentifier(submodelIdentifier, 'submodelIdentifier'));
364
+ const response = await apiInstance.deleteSubmodelDescriptorByIdThroughSuperpathRaw({
240
365
  aasIdentifier: encodedAasIdentifier,
241
366
  submodelIdentifier: encodedSubmodelIdentifier,
242
367
  });
243
- return { success: true, data: result };
368
+ const result = await response.value();
369
+ return { success: true, data: result, statusCode: response.raw.status, etag: getEtag(response.raw) };
244
370
  }
245
371
  catch (err) {
246
372
  const customError = await handleApiError(err);
247
- return { success: false, error: customError };
373
+ return {
374
+ success: false,
375
+ error: customError,
376
+ statusCode: AasRegistryClient.extractStatusCode(err, customError),
377
+ ...getConditionalErrorFields(err),
378
+ };
248
379
  }
249
380
  }
250
381
  /**
@@ -255,28 +386,41 @@ export class AasRegistryClient {
255
386
  * - aasIdentifier: The Asset Administration Shell’s unique id (UTF8-BASE64-URL-encoded)
256
387
  * - submodelIdentifier: The Submodel’s unique id (UTF8-BASE64-URL-encoded)
257
388
  * - submodelDescriptor: Submodel Descriptor object
389
+ * - ifMatch?: Sent as `If-Match` header; the request fails with `preconditionFailed` if the resource has changed since the `etag` was issued
390
+ * - ifNoneMatch?: Sent as `If-None-Match` header; use `*` to only create the resource (fails with `preconditionFailed` if it exists)
258
391
  *
259
392
  * @returns Either `{ success: true; data: ... }` or `{ success: false; error: ... }`.
260
393
  */
261
394
  async putSubmodelDescriptorByIdThroughSuperpath(options) {
262
- const { configuration, aasIdentifier, submodelIdentifier, submodelDescriptor } = options;
395
+ const { configuration, aasIdentifier, submodelIdentifier, submodelDescriptor, ifMatch, ifNoneMatch } = options;
263
396
  try {
264
- const apiInstance = new AasRegistryService.AssetAdministrationShellRegistryAPIApi(applyDefaults(configuration));
265
- const encodedAasIdentifier = base64Encode(aasIdentifier);
266
- const encodedSubmodelIdentifier = base64Encode(submodelIdentifier);
267
- const result = await apiInstance.putSubmodelDescriptorByIdThroughSuperpath({
397
+ const apiInstance = new AasRegistryService.AssetAdministrationShellRegistryAPIApi(applyDefaults(configuration, { ifMatch, ifNoneMatch }));
398
+ const encodedAasIdentifier = base64Encode(AasRegistryClient.requireIdentifier(aasIdentifier, 'aasIdentifier'));
399
+ const encodedSubmodelIdentifier = base64Encode(AasRegistryClient.requireIdentifier(submodelIdentifier, 'submodelIdentifier'));
400
+ const response = await apiInstance.putSubmodelDescriptorByIdThroughSuperpathRaw({
268
401
  aasIdentifier: encodedAasIdentifier,
269
402
  submodelIdentifier: encodedSubmodelIdentifier,
270
403
  submodelDescriptor: convertCoreSubmodelDescriptorToApiSubmodelDescriptor(submodelDescriptor),
271
404
  });
405
+ if (response.raw.status === 204) {
406
+ return { success: true, data: undefined, statusCode: response.raw.status, etag: getEtag(response.raw) };
407
+ }
408
+ const result = await response.value();
272
409
  return {
273
410
  success: true,
274
411
  data: result ? convertApiSubmodelDescriptorToCoreSubmodelDescriptor(result) : undefined,
412
+ statusCode: response.raw.status,
413
+ etag: getEtag(response.raw),
275
414
  };
276
415
  }
277
416
  catch (err) {
278
417
  const customError = await handleApiError(err);
279
- return { success: false, error: customError };
418
+ return {
419
+ success: false,
420
+ error: customError,
421
+ statusCode: AasRegistryClient.extractStatusCode(err, customError),
422
+ ...getConditionalErrorFields(err),
423
+ };
280
424
  }
281
425
  }
282
426
  /**
@@ -291,12 +435,18 @@ export class AasRegistryClient {
291
435
  const { configuration } = options;
292
436
  try {
293
437
  const apiInstance = new AasRegistryService.DescriptionAPIApi(applyDefaults(configuration));
294
- const result = await apiInstance.getSelfDescription();
295
- return { success: true, data: result };
438
+ const response = await apiInstance.getSelfDescriptionRaw();
439
+ const result = await response.value();
440
+ return { success: true, data: result, statusCode: response.raw.status, etag: getEtag(response.raw) };
296
441
  }
297
442
  catch (err) {
298
443
  const customError = await handleApiError(err);
299
- return { success: false, error: customError };
444
+ return {
445
+ success: false,
446
+ error: customError,
447
+ statusCode: AasRegistryClient.extractStatusCode(err, customError),
448
+ ...getConditionalErrorFields(err),
449
+ };
300
450
  }
301
451
  }
302
452
  }