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.
- package/README.md +54 -0
- package/bundle/index.cjs +1190 -513
- package/bundle/index.cjs.map +1 -1
- package/bundle/index.mjs +1190 -513
- package/bundle/index.mjs.map +1 -1
- package/dist/clients/AasDiscoveryClient.d.ts +9 -3
- package/dist/clients/AasDiscoveryClient.js +28 -9
- package/dist/clients/AasRegistryClient.d.ts +28 -8
- package/dist/clients/AasRegistryClient.js +63 -21
- package/dist/clients/AasRepositoryClient.d.ts +170 -56
- package/dist/clients/AasRepositoryClient.js +385 -136
- package/dist/clients/AasxFileClient.d.ts +11 -3
- package/dist/clients/AasxFileClient.js +27 -11
- package/dist/clients/ConceptDescriptionRepositoryClient.d.ts +11 -3
- package/dist/clients/ConceptDescriptionRepositoryClient.js +40 -12
- package/dist/clients/SubmodelRegistryClient.d.ts +11 -3
- package/dist/clients/SubmodelRegistryClient.js +28 -8
- package/dist/clients/SubmodelRepositoryClient.d.ts +108 -34
- package/dist/clients/SubmodelRepositoryClient.js +262 -106
- package/dist/lib/apiConfig.d.ts +2 -1
- package/dist/lib/apiConfig.js +27 -2
- package/dist/lib/conditionalRequests.d.ts +28 -0
- package/dist/lib/conditionalRequests.js +55 -0
- package/dist/lib/errorHandler.js +9 -4
- package/dist/models/api.d.ts +38 -2
- package/dist/services/AasService.d.ts +13 -3
- package/dist/services/AasService.js +45 -7
- package/dist/services/SubmodelService.d.ts +13 -3
- package/dist/services/SubmodelService.js +49 -7
- package/package.json +1 -1
|
@@ -2,6 +2,7 @@ import { SubmodelRegistryService } 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 { convertApiSubmodelDescriptorToCoreSubmodelDescriptor, convertCoreSubmodelDescriptorToApiSubmodelDescriptor, } from '../lib/convertAasDescriptorTypes';
|
|
6
7
|
import { handleApiError } from '../lib/errorHandler';
|
|
7
8
|
export class SubmodelRegistryClient {
|
|
@@ -51,6 +52,7 @@ export class SubmodelRegistryClient {
|
|
|
51
52
|
success: true,
|
|
52
53
|
data: { pagedResult, result: submodelDescriptors },
|
|
53
54
|
statusCode: response.raw.status,
|
|
55
|
+
etag: getEtag(response.raw),
|
|
54
56
|
};
|
|
55
57
|
}
|
|
56
58
|
catch (err) {
|
|
@@ -59,6 +61,7 @@ export class SubmodelRegistryClient {
|
|
|
59
61
|
success: false,
|
|
60
62
|
error: customError,
|
|
61
63
|
statusCode: SubmodelRegistryClient.extractStatusCode(err, customError),
|
|
64
|
+
...getConditionalErrorFields(err),
|
|
62
65
|
};
|
|
63
66
|
}
|
|
64
67
|
}
|
|
@@ -83,6 +86,7 @@ export class SubmodelRegistryClient {
|
|
|
83
86
|
success: true,
|
|
84
87
|
data: convertApiSubmodelDescriptorToCoreSubmodelDescriptor(result),
|
|
85
88
|
statusCode: response.raw.status,
|
|
89
|
+
etag: getEtag(response.raw),
|
|
86
90
|
};
|
|
87
91
|
}
|
|
88
92
|
catch (err) {
|
|
@@ -91,6 +95,7 @@ export class SubmodelRegistryClient {
|
|
|
91
95
|
success: false,
|
|
92
96
|
error: customError,
|
|
93
97
|
statusCode: SubmodelRegistryClient.extractStatusCode(err, customError),
|
|
98
|
+
...getConditionalErrorFields(err),
|
|
94
99
|
};
|
|
95
100
|
}
|
|
96
101
|
}
|
|
@@ -100,19 +105,20 @@ export class SubmodelRegistryClient {
|
|
|
100
105
|
* @param options Object containing:
|
|
101
106
|
* - configuration: The http request options
|
|
102
107
|
* - submodelIdentifier: The Submodel’s unique id (UTF8-BASE64-URL-encoded)
|
|
108
|
+
* - ifMatch?: Sent as `If-Match` header; the request fails with `preconditionFailed` if the resource has changed since the `etag` was issued
|
|
103
109
|
*
|
|
104
110
|
* @returns Either `{ success: true; data: ... }` or `{ success: false; error: ... }`.
|
|
105
111
|
*/
|
|
106
112
|
async deleteSubmodelDescriptorById(options) {
|
|
107
|
-
const { configuration, submodelIdentifier } = options;
|
|
113
|
+
const { configuration, submodelIdentifier, ifMatch } = options;
|
|
108
114
|
try {
|
|
109
|
-
const apiInstance = new SubmodelRegistryService.SubmodelRegistryAPIApi(applyDefaults(configuration));
|
|
115
|
+
const apiInstance = new SubmodelRegistryService.SubmodelRegistryAPIApi(applyDefaults(configuration, { ifMatch }));
|
|
110
116
|
const encodedSubmodelIdentifier = base64Encode(SubmodelRegistryClient.requireIdentifier(submodelIdentifier, 'submodelIdentifier'));
|
|
111
117
|
const response = await apiInstance.deleteSubmodelDescriptorByIdRaw({
|
|
112
118
|
submodelIdentifier: encodedSubmodelIdentifier,
|
|
113
119
|
});
|
|
114
120
|
const result = await response.value();
|
|
115
|
-
return { success: true, data: result, statusCode: response.raw.status };
|
|
121
|
+
return { success: true, data: result, statusCode: response.raw.status, etag: getEtag(response.raw) };
|
|
116
122
|
}
|
|
117
123
|
catch (err) {
|
|
118
124
|
const customError = await handleApiError(err);
|
|
@@ -120,6 +126,7 @@ export class SubmodelRegistryClient {
|
|
|
120
126
|
success: false,
|
|
121
127
|
error: customError,
|
|
122
128
|
statusCode: SubmodelRegistryClient.extractStatusCode(err, customError),
|
|
129
|
+
...getConditionalErrorFields(err),
|
|
123
130
|
};
|
|
124
131
|
}
|
|
125
132
|
}
|
|
@@ -129,13 +136,14 @@ export class SubmodelRegistryClient {
|
|
|
129
136
|
* @param options Object containing:
|
|
130
137
|
* - configuration: The http request options
|
|
131
138
|
* - submodelIdentifier: The Submodel’s unique id (UTF8-BASE64-URL-encoded)
|
|
139
|
+
* - ifNoneMatch?: Sent as `If-None-Match` header; returns `{ success: true; notModified: true }` without data if the representation still has this `etag`
|
|
132
140
|
*
|
|
133
141
|
* @returns Either `{ success: true; data: ... }` or `{ success: false; error: ... }`.
|
|
134
142
|
*/
|
|
135
143
|
async getSubmodelDescriptorById(options) {
|
|
136
|
-
const { configuration, submodelIdentifier } = options;
|
|
144
|
+
const { configuration, submodelIdentifier, ifNoneMatch } = options;
|
|
137
145
|
try {
|
|
138
|
-
const apiInstance = new SubmodelRegistryService.SubmodelRegistryAPIApi(applyDefaults(configuration));
|
|
146
|
+
const apiInstance = new SubmodelRegistryService.SubmodelRegistryAPIApi(applyDefaults(configuration, { ifNoneMatch }));
|
|
139
147
|
const encodedSubmodelIdentifier = base64Encode(SubmodelRegistryClient.requireIdentifier(submodelIdentifier, 'submodelIdentifier'));
|
|
140
148
|
const response = await apiInstance.getSubmodelDescriptorByIdRaw({
|
|
141
149
|
submodelIdentifier: encodedSubmodelIdentifier,
|
|
@@ -145,14 +153,20 @@ export class SubmodelRegistryClient {
|
|
|
145
153
|
success: true,
|
|
146
154
|
data: convertApiSubmodelDescriptorToCoreSubmodelDescriptor(result),
|
|
147
155
|
statusCode: response.raw.status,
|
|
156
|
+
etag: getEtag(response.raw),
|
|
148
157
|
};
|
|
149
158
|
}
|
|
150
159
|
catch (err) {
|
|
160
|
+
const notModified = getNotModifiedResult(err, ifNoneMatch);
|
|
161
|
+
if (notModified) {
|
|
162
|
+
return notModified;
|
|
163
|
+
}
|
|
151
164
|
const customError = await handleApiError(err);
|
|
152
165
|
return {
|
|
153
166
|
success: false,
|
|
154
167
|
error: customError,
|
|
155
168
|
statusCode: SubmodelRegistryClient.extractStatusCode(err, customError),
|
|
169
|
+
...getConditionalErrorFields(err),
|
|
156
170
|
};
|
|
157
171
|
}
|
|
158
172
|
}
|
|
@@ -163,13 +177,15 @@ export class SubmodelRegistryClient {
|
|
|
163
177
|
* - configuration: The http request options
|
|
164
178
|
* - submodelIdentifier: The Submodel’s unique id (UTF8-BASE64-URL-encoded)
|
|
165
179
|
* - submodelDescriptor: Submodel Descriptor object
|
|
180
|
+
* - ifMatch?: Sent as `If-Match` header; the request fails with `preconditionFailed` if the resource has changed since the `etag` was issued
|
|
181
|
+
* - ifNoneMatch?: Sent as `If-None-Match` header; use `*` to only create the resource (fails with `preconditionFailed` if it exists)
|
|
166
182
|
*
|
|
167
183
|
* @returns Either `{ success: true; data: ... }` or `{ success: false; error: ... }`.
|
|
168
184
|
*/
|
|
169
185
|
async putSubmodelDescriptorById(options) {
|
|
170
|
-
const { configuration, submodelIdentifier, submodelDescriptor } = options;
|
|
186
|
+
const { configuration, submodelIdentifier, submodelDescriptor, ifMatch, ifNoneMatch } = options;
|
|
171
187
|
try {
|
|
172
|
-
const apiInstance = new SubmodelRegistryService.SubmodelRegistryAPIApi(applyDefaults(configuration));
|
|
188
|
+
const apiInstance = new SubmodelRegistryService.SubmodelRegistryAPIApi(applyDefaults(configuration, { ifMatch, ifNoneMatch }));
|
|
173
189
|
const encodedSubmodelIdentifier = base64Encode(SubmodelRegistryClient.requireIdentifier(submodelIdentifier, 'submodelIdentifier'));
|
|
174
190
|
const response = await apiInstance.putSubmodelDescriptorByIdRaw({
|
|
175
191
|
submodelIdentifier: encodedSubmodelIdentifier,
|
|
@@ -180,6 +196,7 @@ export class SubmodelRegistryClient {
|
|
|
180
196
|
success: true,
|
|
181
197
|
data: undefined,
|
|
182
198
|
statusCode: response.raw.status,
|
|
199
|
+
etag: getEtag(response.raw),
|
|
183
200
|
};
|
|
184
201
|
}
|
|
185
202
|
const result = await response.value();
|
|
@@ -187,6 +204,7 @@ export class SubmodelRegistryClient {
|
|
|
187
204
|
success: true,
|
|
188
205
|
data: result ? convertApiSubmodelDescriptorToCoreSubmodelDescriptor(result) : undefined,
|
|
189
206
|
statusCode: response.raw.status,
|
|
207
|
+
etag: getEtag(response.raw),
|
|
190
208
|
};
|
|
191
209
|
}
|
|
192
210
|
catch (err) {
|
|
@@ -195,6 +213,7 @@ export class SubmodelRegistryClient {
|
|
|
195
213
|
success: false,
|
|
196
214
|
error: customError,
|
|
197
215
|
statusCode: SubmodelRegistryClient.extractStatusCode(err, customError),
|
|
216
|
+
...getConditionalErrorFields(err),
|
|
198
217
|
};
|
|
199
218
|
}
|
|
200
219
|
}
|
|
@@ -212,7 +231,7 @@ export class SubmodelRegistryClient {
|
|
|
212
231
|
const apiInstance = new SubmodelRegistryService.DescriptionAPIApi(applyDefaults(configuration));
|
|
213
232
|
const response = await apiInstance.getSelfDescriptionRaw();
|
|
214
233
|
const result = await response.value();
|
|
215
|
-
return { success: true, data: result, statusCode: response.raw.status };
|
|
234
|
+
return { success: true, data: result, statusCode: response.raw.status, etag: getEtag(response.raw) };
|
|
216
235
|
}
|
|
217
236
|
catch (err) {
|
|
218
237
|
const customError = await handleApiError(err);
|
|
@@ -220,6 +239,7 @@ export class SubmodelRegistryClient {
|
|
|
220
239
|
success: false,
|
|
221
240
|
error: customError,
|
|
222
241
|
statusCode: SubmodelRegistryClient.extractStatusCode(err, customError),
|
|
242
|
+
...getConditionalErrorFields(err),
|
|
223
243
|
};
|
|
224
244
|
}
|
|
225
245
|
}
|