basyx-typescript-sdk 2.2.5 → 2.3.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.
@@ -1,5 +1,5 @@
1
1
  import type { SpecificAssetId } from '@aas-core-works/aas-core3.1-typescript/types';
2
- import type { ApiResult } from '../models/api';
2
+ import type { ApiResult, ConditionalApiResult } from '../models/api';
3
3
  import type { AssetId } from '../models/AssetId';
4
4
  import { AasDiscoveryService } from '../generated';
5
5
  import { Configuration } from '../generated/runtime';
@@ -32,6 +32,7 @@ export declare class AasDiscoveryClient {
32
32
  * - configuration: The http request options.
33
33
  * - aasIdentifier: The Asset Administration Shell’s unique id
34
34
  * - specificAssetId: A set of specific asset identifiers
35
+ * - ifMatch?: Sent as `If-Match` header; the request fails with `preconditionFailed` if the resource has changed since the `etag` was issued
35
36
  *
36
37
  * @returns Either `{ success: true; data: ... }` or `{ success: false; error: ... }`.
37
38
  */
@@ -39,6 +40,7 @@ export declare class AasDiscoveryClient {
39
40
  configuration: Configuration;
40
41
  aasIdentifier: string;
41
42
  specificAssetId: Array<SpecificAssetId>;
43
+ ifMatch?: string;
42
44
  }): Promise<ApiResult<Array<SpecificAssetId>, AasDiscoveryService.Result>>;
43
45
  /**
44
46
  * Deletes specified specific asset identifiers linked to an Asset Administration Shell
@@ -46,12 +48,14 @@ export declare class AasDiscoveryClient {
46
48
  * @param options Object containing:
47
49
  * - configuration: The http request options
48
50
  * - aasIdentifier: The Asset Administration Shell’s unique id
51
+ * - ifMatch?: Sent as `If-Match` header; the request fails with `preconditionFailed` if the resource has changed since the `etag` was issued
49
52
  *
50
53
  * @returns Either `{ success: true; data: ... }` or `{ success: false; error: ... }`.
51
54
  */
52
55
  deleteAllAssetLinksById(options: {
53
56
  configuration: Configuration;
54
57
  aasIdentifier: string;
58
+ ifMatch?: string;
55
59
  }): Promise<ApiResult<void, AasDiscoveryService.Result>>;
56
60
  /**
57
61
  * Returns a list of specific asset identifiers based on an Asset Administration Shell ID to edit discoverable content.
@@ -59,13 +63,15 @@ export declare class AasDiscoveryClient {
59
63
  * @param options Object containing:
60
64
  * - configuration: The http request options
61
65
  * - aasIdentifier: The Asset Administration Shell’s unique id
66
+ * - ifNoneMatch?: Sent as `If-None-Match` header; returns `{ success: true; notModified: true }` without data if the representation still has this `etag`
62
67
  *
63
68
  * @returns Either `{ success: true; data: ... }` or `{ success: false; error: ... }`.
64
69
  */
65
- getAllAssetLinksById(options: {
70
+ getAllAssetLinksById<IfNoneMatch extends string | undefined = undefined>(options: {
66
71
  configuration: Configuration;
67
72
  aasIdentifier: string;
68
- }): Promise<ApiResult<Array<SpecificAssetId>, AasDiscoveryService.Result>>;
73
+ ifNoneMatch?: IfNoneMatch;
74
+ }): Promise<ConditionalApiResult<Array<SpecificAssetId>, AasDiscoveryService.Result, IfNoneMatch>>;
69
75
  /**
70
76
  * Returns a list of Asset Administration Shell IDs linked to specific asset identifiers or the global asset ID
71
77
  *
@@ -2,6 +2,7 @@ import { AasDiscoveryService } from '../generated';
2
2
  import { RequiredError } from '../generated/runtime';
3
3
  import { applyDefaults } from '../lib/apiConfig';
4
4
  import { base64Encode } from '../lib/base64Url';
5
+ import { getConditionalErrorFields, getEtag, getNotModifiedResult } from '../lib/conditionalRequests';
5
6
  import { convertApiAssetIdToCoreAssetId, convertCoreAssetIdToApiAssetId } from '../lib/convertAasDiscoveryTypes';
6
7
  import { handleApiError } from '../lib/errorHandler';
7
8
  export class AasDiscoveryClient {
@@ -35,7 +36,8 @@ export class AasDiscoveryClient {
35
36
  const { configuration, assetIds, limit, cursor } = options;
36
37
  try {
37
38
  const apiInstance = new AasDiscoveryService.AssetAdministrationShellBasicDiscoveryAPIApi(applyDefaults(configuration));
38
- const encodedAssetIds = assetIds?.map((id) => base64Encode(JSON.stringify(id)));
39
+ // Only name and value: objects such as core SpecificAssetIds carry further fields that may be null
40
+ const encodedAssetIds = assetIds?.map((id) => base64Encode(JSON.stringify({ name: id.name, value: id.value })));
39
41
  const response = await apiInstance.getAllAssetAdministrationShellIdsByAssetLinkRaw({
40
42
  assetIds: encodedAssetIds,
41
43
  limit: limit,
@@ -48,6 +50,7 @@ export class AasDiscoveryClient {
48
50
  success: true,
49
51
  data: { pagedResult, result: shellIds },
50
52
  statusCode: response.raw.status,
53
+ etag: getEtag(response.raw),
51
54
  };
52
55
  }
53
56
  catch (err) {
@@ -56,6 +59,7 @@ export class AasDiscoveryClient {
56
59
  success: false,
57
60
  error: customError,
58
61
  statusCode: AasDiscoveryClient.extractStatusCode(err, customError),
62
+ ...getConditionalErrorFields(err),
59
63
  };
60
64
  }
61
65
  }
@@ -66,13 +70,14 @@ export class AasDiscoveryClient {
66
70
  * - configuration: The http request options.
67
71
  * - aasIdentifier: The Asset Administration Shell’s unique id
68
72
  * - specificAssetId: A set of specific asset identifiers
73
+ * - ifMatch?: Sent as `If-Match` header; the request fails with `preconditionFailed` if the resource has changed since the `etag` was issued
69
74
  *
70
75
  * @returns Either `{ success: true; data: ... }` or `{ success: false; error: ... }`.
71
76
  */
72
77
  async postAllAssetLinksById(options) {
73
- const { configuration, aasIdentifier, specificAssetId } = options;
78
+ const { configuration, aasIdentifier, specificAssetId, ifMatch } = options;
74
79
  try {
75
- const apiInstance = new AasDiscoveryService.AssetAdministrationShellBasicDiscoveryAPIApi(applyDefaults(configuration));
80
+ const apiInstance = new AasDiscoveryService.AssetAdministrationShellBasicDiscoveryAPIApi(applyDefaults(configuration, { ifMatch }));
76
81
  const encodedAasIdentifier = base64Encode(aasIdentifier);
77
82
  const response = await apiInstance.postAllAssetLinksByIdRaw({
78
83
  aasIdentifier: encodedAasIdentifier,
@@ -83,6 +88,7 @@ export class AasDiscoveryClient {
83
88
  success: true,
84
89
  data: result.map(convertApiAssetIdToCoreAssetId),
85
90
  statusCode: response.raw.status,
91
+ etag: getEtag(response.raw),
86
92
  };
87
93
  }
88
94
  catch (err) {
@@ -91,6 +97,7 @@ export class AasDiscoveryClient {
91
97
  success: false,
92
98
  error: customError,
93
99
  statusCode: AasDiscoveryClient.extractStatusCode(err, customError),
100
+ ...getConditionalErrorFields(err),
94
101
  };
95
102
  }
96
103
  }
@@ -100,19 +107,20 @@ export class AasDiscoveryClient {
100
107
  * @param options Object containing:
101
108
  * - configuration: The http request options
102
109
  * - aasIdentifier: The Asset Administration Shell’s unique id
110
+ * - ifMatch?: Sent as `If-Match` header; the request fails with `preconditionFailed` if the resource has changed since the `etag` was issued
103
111
  *
104
112
  * @returns Either `{ success: true; data: ... }` or `{ success: false; error: ... }`.
105
113
  */
106
114
  async deleteAllAssetLinksById(options) {
107
- const { configuration, aasIdentifier } = options;
115
+ const { configuration, aasIdentifier, ifMatch } = options;
108
116
  try {
109
- const apiInstance = new AasDiscoveryService.AssetAdministrationShellBasicDiscoveryAPIApi(applyDefaults(configuration));
117
+ const apiInstance = new AasDiscoveryService.AssetAdministrationShellBasicDiscoveryAPIApi(applyDefaults(configuration, { ifMatch }));
110
118
  const encodedAasIdentifier = base64Encode(aasIdentifier);
111
119
  const response = await apiInstance.deleteAllAssetLinksByIdRaw({
112
120
  aasIdentifier: encodedAasIdentifier,
113
121
  });
114
122
  const result = await response.value();
115
- return { success: true, data: result, statusCode: response.raw.status };
123
+ return { success: true, data: result, statusCode: response.raw.status, etag: getEtag(response.raw) };
116
124
  }
117
125
  catch (err) {
118
126
  const customError = await handleApiError(err);
@@ -120,6 +128,7 @@ export class AasDiscoveryClient {
120
128
  success: false,
121
129
  error: customError,
122
130
  statusCode: AasDiscoveryClient.extractStatusCode(err, customError),
131
+ ...getConditionalErrorFields(err),
123
132
  };
124
133
  }
125
134
  }
@@ -129,13 +138,14 @@ export class AasDiscoveryClient {
129
138
  * @param options Object containing:
130
139
  * - configuration: The http request options
131
140
  * - aasIdentifier: The Asset Administration Shell’s unique id
141
+ * - ifNoneMatch?: Sent as `If-None-Match` header; returns `{ success: true; notModified: true }` without data if the representation still has this `etag`
132
142
  *
133
143
  * @returns Either `{ success: true; data: ... }` or `{ success: false; error: ... }`.
134
144
  */
135
145
  async getAllAssetLinksById(options) {
136
- const { configuration, aasIdentifier } = options;
146
+ const { configuration, aasIdentifier, ifNoneMatch } = options;
137
147
  try {
138
- const apiInstance = new AasDiscoveryService.AssetAdministrationShellBasicDiscoveryAPIApi(applyDefaults(configuration));
148
+ const apiInstance = new AasDiscoveryService.AssetAdministrationShellBasicDiscoveryAPIApi(applyDefaults(configuration, { ifNoneMatch }));
139
149
  const encodedAasIdentifier = base64Encode(aasIdentifier);
140
150
  const response = await apiInstance.getAllAssetLinksByIdRaw({
141
151
  aasIdentifier: encodedAasIdentifier,
@@ -145,14 +155,20 @@ export class AasDiscoveryClient {
145
155
  success: true,
146
156
  data: result.map(convertApiAssetIdToCoreAssetId),
147
157
  statusCode: response.raw.status,
158
+ etag: getEtag(response.raw),
148
159
  };
149
160
  }
150
161
  catch (err) {
162
+ const notModified = getNotModifiedResult(err, ifNoneMatch);
163
+ if (notModified) {
164
+ return notModified;
165
+ }
151
166
  const customError = await handleApiError(err);
152
167
  return {
153
168
  success: false,
154
169
  error: customError,
155
170
  statusCode: AasDiscoveryClient.extractStatusCode(err, customError),
171
+ ...getConditionalErrorFields(err),
156
172
  };
157
173
  }
158
174
  }
@@ -183,6 +199,7 @@ export class AasDiscoveryClient {
183
199
  success: true,
184
200
  data: { pagedResult, result: shellIds },
185
201
  statusCode: response.raw.status,
202
+ etag: getEtag(response.raw),
186
203
  };
187
204
  }
188
205
  catch (err) {
@@ -191,6 +208,7 @@ export class AasDiscoveryClient {
191
208
  success: false,
192
209
  error: customError,
193
210
  statusCode: AasDiscoveryClient.extractStatusCode(err, customError),
211
+ ...getConditionalErrorFields(err),
194
212
  };
195
213
  }
196
214
  }
@@ -208,7 +226,7 @@ export class AasDiscoveryClient {
208
226
  const apiInstance = new AasDiscoveryService.DescriptionAPIApi(applyDefaults(configuration));
209
227
  const response = await apiInstance.getSelfDescriptionRaw();
210
228
  const result = await response.value();
211
- return { success: true, data: result, statusCode: response.raw.status };
229
+ return { success: true, data: result, statusCode: response.raw.status, etag: getEtag(response.raw) };
212
230
  }
213
231
  catch (err) {
214
232
  const customError = await handleApiError(err);
@@ -216,6 +234,7 @@ export class AasDiscoveryClient {
216
234
  success: false,
217
235
  error: customError,
218
236
  statusCode: AasDiscoveryClient.extractStatusCode(err, customError),
237
+ ...getConditionalErrorFields(err),
219
238
  };
220
239
  }
221
240
  }
@@ -1,4 +1,4 @@
1
- import type { ApiResult } from '../models/api';
1
+ import type { ApiResult, ConditionalApiResult } from '../models/api';
2
2
  import { AasRegistryService } from '../generated';
3
3
  import { Configuration } from '../generated/runtime';
4
4
  import { AssetAdministrationShellDescriptor, SubmodelDescriptor } from '../models/Descriptors';
@@ -46,12 +46,14 @@ export declare class AasRegistryClient {
46
46
  * @param options Object containing:
47
47
  * - configuration: The http request options
48
48
  * - aasIdentifier: The Asset Administration Shell’s unique id (UTF8-BASE64-URL-encoded)
49
+ * - ifMatch?: Sent as `If-Match` header; the request fails with `preconditionFailed` if the resource has changed since the `etag` was issued
49
50
  *
50
51
  * @returns Either `{ success: true; data: ... }` or `{ success: false; error: ... }`.
51
52
  */
52
53
  deleteAssetAdministrationShellDescriptorById(options: {
53
54
  configuration: Configuration;
54
55
  aasIdentifier: string;
56
+ ifMatch?: string;
55
57
  }): Promise<ApiResult<void, AasRegistryService.Result>>;
56
58
  /**
57
59
  * Returns a specific Asset Administration Shell Descriptor
@@ -59,13 +61,15 @@ export declare class AasRegistryClient {
59
61
  * @param options Object containing:
60
62
  * - configuration: The http request options
61
63
  * - aasIdentifier: The Asset Administration Shell’s unique id (UTF8-BASE64-URL-encoded)
64
+ * - ifNoneMatch?: Sent as `If-None-Match` header; returns `{ success: true; notModified: true }` without data if the representation still has this `etag`
62
65
  *
63
66
  * @returns Either `{ success: true; data: ... }` or `{ success: false; error: ... }`.
64
67
  */
65
- getAssetAdministrationShellDescriptorById(options: {
68
+ getAssetAdministrationShellDescriptorById<IfNoneMatch extends string | undefined = undefined>(options: {
66
69
  configuration: Configuration;
67
70
  aasIdentifier: string;
68
- }): Promise<ApiResult<AssetAdministrationShellDescriptor, AasRegistryService.Result>>;
71
+ ifNoneMatch?: IfNoneMatch;
72
+ }): Promise<ConditionalApiResult<AssetAdministrationShellDescriptor, AasRegistryService.Result, IfNoneMatch>>;
69
73
  /**
70
74
  * Creates or updates an existing Asset Administration Shell Descriptor
71
75
  *
@@ -73,6 +77,8 @@ export declare class AasRegistryClient {
73
77
  * - configuration: The http request options
74
78
  * - aasIdentifier: The Asset Administration Shell’s unique id (UTF8-BASE64-URL-encoded)
75
79
  * - assetAdministrationShellDescriptor: Asset Administration Shell Descriptor object
80
+ * - ifMatch?: Sent as `If-Match` header; the request fails with `preconditionFailed` if the resource has changed since the `etag` was issued
81
+ * - ifNoneMatch?: Sent as `If-None-Match` header; use `*` to only create the resource (fails with `preconditionFailed` if it exists)
76
82
  *
77
83
  * @returns Either `{ success: true; data: ... }` or `{ success: false; error: ... }`.
78
84
  */
@@ -80,6 +86,8 @@ export declare class AasRegistryClient {
80
86
  configuration: Configuration;
81
87
  aasIdentifier: string;
82
88
  assetAdministrationShellDescriptor: AssetAdministrationShellDescriptor;
89
+ ifMatch?: string;
90
+ ifNoneMatch?: string;
83
91
  }): Promise<ApiResult<AssetAdministrationShellDescriptor | void, AasRegistryService.Result>>;
84
92
  /**
85
93
  * Returns all Submodel Descriptors
@@ -89,18 +97,20 @@ export declare class AasRegistryClient {
89
97
  * - aasIdentifier: The Asset Administration Shell’s unique id (UTF8-BASE64-URL-encoded)
90
98
  * - limit?: The maximum number of elements in the response array
91
99
  * - cursor?: A server-generated identifier retrieved from paging_metadata that specifies from which position the result listing should continue
100
+ * - ifNoneMatch?: Sent as `If-None-Match` header; returns `{ success: true; notModified: true }` without data if the representation still has this `etag`
92
101
  *
93
102
  * @returns Either `{ success: true; data: ... }` or `{ success: false; error: ... }`.
94
103
  */
95
- getAllSubmodelDescriptorsThroughSuperpath(options: {
104
+ getAllSubmodelDescriptorsThroughSuperpath<IfNoneMatch extends string | undefined = undefined>(options: {
96
105
  configuration: Configuration;
97
106
  aasIdentifier: string;
98
107
  limit?: number;
99
108
  cursor?: string;
100
- }): Promise<ApiResult<{
109
+ ifNoneMatch?: IfNoneMatch;
110
+ }): Promise<ConditionalApiResult<{
101
111
  pagedResult: AasRegistryService.PagedResultPagingMetadata | undefined;
102
112
  result: SubmodelDescriptor[];
103
- }, AasRegistryService.Result>>;
113
+ }, AasRegistryService.Result, IfNoneMatch>>;
104
114
  /**
105
115
  * Creates a new Submodel Descriptor, i.e. registers a submodel
106
116
  *
@@ -108,6 +118,7 @@ export declare class AasRegistryClient {
108
118
  * - configuration: The http request options.
109
119
  * - aasIdentifier: The Asset Administration Shell’s unique id (UTF8-BASE64-URL-encoded)
110
120
  * - submodelDescriptor: Submodel Descriptor object
121
+ * - ifMatch?: Sent as `If-Match` header; the request fails with `preconditionFailed` if the resource has changed since the `etag` was issued
111
122
  *
112
123
  * @returns Either `{ success: true; data: ... }` or `{ success: false; error: ... }`.
113
124
  */
@@ -115,6 +126,7 @@ export declare class AasRegistryClient {
115
126
  configuration: Configuration;
116
127
  aasIdentifier: string;
117
128
  submodelDescriptor: SubmodelDescriptor;
129
+ ifMatch?: string;
118
130
  }): Promise<ApiResult<SubmodelDescriptor, AasRegistryService.Result>>;
119
131
  /**
120
132
  * Returns a specific Submodel Descriptor
@@ -123,14 +135,16 @@ export declare class AasRegistryClient {
123
135
  * - configuration: The http request options
124
136
  * - aasIdentifier: The Asset Administration Shell’s unique id (UTF8-BASE64-URL-encoded)
125
137
  * - submodelIdentifier: The Submodel’s unique id (UTF8-BASE64-URL-encoded)
138
+ * - ifNoneMatch?: Sent as `If-None-Match` header; returns `{ success: true; notModified: true }` without data if the representation still has this `etag`
126
139
  *
127
140
  * @returns Either `{ success: true; data: ... }` or `{ success: false; error: ... }`.
128
141
  */
129
- getSubmodelDescriptorByIdThroughSuperpath(options: {
142
+ getSubmodelDescriptorByIdThroughSuperpath<IfNoneMatch extends string | undefined = undefined>(options: {
130
143
  configuration: Configuration;
131
144
  aasIdentifier: string;
132
145
  submodelIdentifier: string;
133
- }): Promise<ApiResult<SubmodelDescriptor, AasRegistryService.Result>>;
146
+ ifNoneMatch?: IfNoneMatch;
147
+ }): Promise<ConditionalApiResult<SubmodelDescriptor, AasRegistryService.Result, IfNoneMatch>>;
134
148
  /**
135
149
  * Deletes a Submodel Descriptor, i.e. de-registers a submodel
136
150
  *
@@ -138,6 +152,7 @@ export declare class AasRegistryClient {
138
152
  * - configuration: The http request options
139
153
  * - aasIdentifier: The Asset Administration Shell’s unique id (UTF8-BASE64-URL-encoded)
140
154
  * - submodelIdentifier: The Submodel’s unique id (UTF8-BASE64-URL-encoded)
155
+ * - ifMatch?: Sent as `If-Match` header; the request fails with `preconditionFailed` if the resource has changed since the `etag` was issued
141
156
  *
142
157
  * @returns Either `{ success: true; data: ... }` or `{ success: false; error: ... }`.
143
158
  */
@@ -145,6 +160,7 @@ export declare class AasRegistryClient {
145
160
  configuration: Configuration;
146
161
  aasIdentifier: string;
147
162
  submodelIdentifier: string;
163
+ ifMatch?: string;
148
164
  }): Promise<ApiResult<void, AasRegistryService.Result>>;
149
165
  /**
150
166
  * Creates or updates an existing Submodel Descriptor
@@ -154,6 +170,8 @@ export declare class AasRegistryClient {
154
170
  * - aasIdentifier: The Asset Administration Shell’s unique id (UTF8-BASE64-URL-encoded)
155
171
  * - submodelIdentifier: The Submodel’s unique id (UTF8-BASE64-URL-encoded)
156
172
  * - submodelDescriptor: Submodel Descriptor object
173
+ * - ifMatch?: Sent as `If-Match` header; the request fails with `preconditionFailed` if the resource has changed since the `etag` was issued
174
+ * - ifNoneMatch?: Sent as `If-None-Match` header; use `*` to only create the resource (fails with `preconditionFailed` if it exists)
157
175
  *
158
176
  * @returns Either `{ success: true; data: ... }` or `{ success: false; error: ... }`.
159
177
  */
@@ -162,6 +180,8 @@ export declare class AasRegistryClient {
162
180
  aasIdentifier: string;
163
181
  submodelIdentifier: string;
164
182
  submodelDescriptor: SubmodelDescriptor;
183
+ ifMatch?: string;
184
+ ifNoneMatch?: string;
165
185
  }): Promise<ApiResult<SubmodelDescriptor | void, AasRegistryService.Result>>;
166
186
  /**
167
187
  * Returns the self-describing information of a network resource (ServiceDescription)