basyx-typescript-sdk 2.4.1 → 2.4.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.
@@ -217,7 +217,7 @@ export declare class AasRepositoryClient {
217
217
  * @param options Object containing:
218
218
  * - configuration: The http request options
219
219
  * - aasIdentifier: The Asset Administration Shell’s unique id
220
- * - fileName: The name of the file
220
+ * - fileName: The name of the file, sent as filename of the file part and as `fileName` field
221
221
  * - file: The file to upload
222
222
  * - ifMatch?: Sent as `If-Match` header; the request fails with `preconditionFailed` if the resource has changed since the `etag` was issued
223
223
  * - ifNoneMatch?: Sent as `If-None-Match` header; use `*` to only create the resource (fails with `preconditionFailed` if it exists)
@@ -948,7 +948,7 @@ export declare class AasRepositoryClient {
948
948
  * - aasIdentifier: The Asset Administration Shell’s unique id
949
949
  * - submodelIdentifier: The Submodel’s unique id
950
950
  * - idShortPath: IdShort path to the submodel element (dot-separated)
951
- * - fileName: The name of the file
951
+ * - fileName: The name of the file, sent as filename of the file part and as `fileName` field
952
952
  * - file: The file to upload
953
953
  * - ifMatch?: Sent as `If-Match` header; the request fails with `preconditionFailed` if the resource has changed since the `etag` was issued
954
954
  * - ifNoneMatch?: Sent as `If-None-Match` header; use `*` to only create the resource (fails with `preconditionFailed` if it exists)
@@ -6,6 +6,7 @@ import { getConditionalErrorFields, getEtag, getNotModifiedResult } from '../lib
6
6
  import { convertApiAasToCoreAas, convertApiAssetInformationToCoreAssetInformation, convertApiReferenceToCoreReference, convertCoreAasToApiAas, convertCoreAssetInformationToApiAssetInformation, convertCoreReferenceToApiReference, } from '../lib/convertAasTypes';
7
7
  import { convertApiSubmodelElementToCoreSubmodelElement, convertApiSubmodelToCoreSubmodel, convertCoreSubmodelElementToApiSubmodelElement, convertCoreSubmodelToApiSubmodel, } from '../lib/convertSubmodelTypes';
8
8
  import { handleApiError } from '../lib/errorHandler';
9
+ import { withFileName } from '../lib/multipartFile';
9
10
  import { getOperationHandle } from '../lib/operationHandle';
10
11
  import { convertQueryResult, toQueryRequestBody } from '../lib/queryRequests';
11
12
  export class AasRepositoryClient {
@@ -489,7 +490,7 @@ export class AasRepositoryClient {
489
490
  * @param options Object containing:
490
491
  * - configuration: The http request options
491
492
  * - aasIdentifier: The Asset Administration Shell’s unique id
492
- * - fileName: The name of the file
493
+ * - fileName: The name of the file, sent as filename of the file part and as `fileName` field
493
494
  * - file: The file to upload
494
495
  * - ifMatch?: Sent as `If-Match` header; the request fails with `preconditionFailed` if the resource has changed since the `etag` was issued
495
496
  * - ifNoneMatch?: Sent as `If-None-Match` header; use `*` to only create the resource (fails with `preconditionFailed` if it exists)
@@ -504,7 +505,7 @@ export class AasRepositoryClient {
504
505
  const response = await apiInstance.putThumbnailAasRepositoryRaw({
505
506
  aasIdentifier: encodedAasIdentifier,
506
507
  fileName: fileName,
507
- file: file,
508
+ file: withFileName(file, fileName),
508
509
  });
509
510
  const result = await response.value();
510
511
  return { success: true, data: result, statusCode: response.raw.status, etag: getEtag(response.raw) };
@@ -1915,7 +1916,7 @@ export class AasRepositoryClient {
1915
1916
  * - aasIdentifier: The Asset Administration Shell’s unique id
1916
1917
  * - submodelIdentifier: The Submodel’s unique id
1917
1918
  * - idShortPath: IdShort path to the submodel element (dot-separated)
1918
- * - fileName: The name of the file
1919
+ * - fileName: The name of the file, sent as filename of the file part and as `fileName` field
1919
1920
  * - file: The file to upload
1920
1921
  * - ifMatch?: Sent as `If-Match` header; the request fails with `preconditionFailed` if the resource has changed since the `etag` was issued
1921
1922
  * - ifNoneMatch?: Sent as `If-None-Match` header; use `*` to only create the resource (fails with `preconditionFailed` if it exists)
@@ -1933,7 +1934,7 @@ export class AasRepositoryClient {
1933
1934
  submodelIdentifier: encodedSubmodelIdentifier,
1934
1935
  idShortPath: idShortPath,
1935
1936
  fileName: fileName,
1936
- file: file,
1937
+ file: withFileName(file, fileName),
1937
1938
  });
1938
1939
  const result = await response.value();
1939
1940
  return { success: true, data: result, statusCode: response.raw.status, etag: getEtag(response.raw) };
@@ -31,7 +31,7 @@ export declare class AasxFileClient {
31
31
  * - configuration: The http request options.
32
32
  * - aasIds?: A list of Asset Administration Shells' unique ids
33
33
  * - file: The file to upload
34
- * - fileName: The name of the file
34
+ * - fileName: The name of the file, sent as filename of the file part and as `fileName` field
35
35
  *
36
36
  * @returns Either `{ success: true; data: ... }` or `{ success: false; error: ... }`.
37
37
  */
@@ -64,7 +64,7 @@ export declare class AasxFileClient {
64
64
  * - packageId: The package Id (UTF8-BASE64-URL-encoded)
65
65
  * - aasIds?: A list of Asset Administration Shells' unique ids
66
66
  * - file: The file to upload
67
- * - fileName: The name of the file
67
+ * - fileName: The name of the file, sent as filename of the file part and as `fileName` field
68
68
  * - ifMatch?: Sent as `If-Match` header; the request fails with `preconditionFailed` if the resource has changed since the `etag` was issued
69
69
  * - ifNoneMatch?: Sent as `If-None-Match` header; use `*` to only create the resource (fails with `preconditionFailed` if it exists)
70
70
  *
@@ -4,6 +4,7 @@ import { applyDefaults } from '../lib/apiConfig';
4
4
  import { base64Encode } from '../lib/base64Url';
5
5
  import { getConditionalErrorFields, getEtag, getNotModifiedResult } from '../lib/conditionalRequests';
6
6
  import { handleApiError } from '../lib/errorHandler';
7
+ import { withFileName } from '../lib/multipartFile';
7
8
  export class AasxFileClient {
8
9
  static requireIdentifier(value, field) {
9
10
  if (value === null || value === undefined || value.trim() === '') {
@@ -74,7 +75,7 @@ export class AasxFileClient {
74
75
  * - configuration: The http request options.
75
76
  * - aasIds?: A list of Asset Administration Shells' unique ids
76
77
  * - file: The file to upload
77
- * - fileName: The name of the file
78
+ * - fileName: The name of the file, sent as filename of the file part and as `fileName` field
78
79
  *
79
80
  * @returns Either `{ success: true; data: ... }` or `{ success: false; error: ... }`.
80
81
  */
@@ -84,7 +85,7 @@ export class AasxFileClient {
84
85
  const apiInstance = new AasxFileService.AASXFileServerAPIApi(applyDefaults(configuration));
85
86
  const response = await apiInstance.postAASXPackageRaw({
86
87
  aasIds: aasIds,
87
- file: file,
88
+ file: withFileName(file, fileName),
88
89
  fileName: fileName,
89
90
  });
90
91
  const result = await response.value();
@@ -143,7 +144,7 @@ export class AasxFileClient {
143
144
  * - packageId: The package Id (UTF8-BASE64-URL-encoded)
144
145
  * - aasIds?: A list of Asset Administration Shells' unique ids
145
146
  * - file: The file to upload
146
- * - fileName: The name of the file
147
+ * - fileName: The name of the file, sent as filename of the file part and as `fileName` field
147
148
  * - ifMatch?: Sent as `If-Match` header; the request fails with `preconditionFailed` if the resource has changed since the `etag` was issued
148
149
  * - ifNoneMatch?: Sent as `If-None-Match` header; use `*` to only create the resource (fails with `preconditionFailed` if it exists)
149
150
  *
@@ -157,7 +158,7 @@ export class AasxFileClient {
157
158
  const response = await apiInstance.putAASXByPackageIdRaw({
158
159
  packageId: encodedPackageId,
159
160
  aasIds: aasIds,
160
- file: file,
161
+ file: withFileName(file, fileName),
161
162
  fileName: fileName,
162
163
  });
163
164
  const result = await response.value();
@@ -689,7 +689,7 @@ export declare class SubmodelRepositoryClient {
689
689
  * - configuration: The http request options
690
690
  * - submodelIdentifier: The Submodel's unique id
691
691
  * - idShortPath: IdShort path to the submodel element (dot-separated)
692
- * - fileName?: Name of the uploaded file
692
+ * - fileName?: Name of the uploaded file, sent as filename of the file part and as `fileName` field
693
693
  * - file?: File content
694
694
  * - ifMatch?: Sent as `If-Match` header; the request fails with `preconditionFailed` if the resource has changed since the `etag` was issued
695
695
  * - ifNoneMatch?: Sent as `If-None-Match` header; use `*` to only create the resource (fails with `preconditionFailed` if it exists)
@@ -5,6 +5,7 @@ import { base64Encode } from '../lib/base64Url';
5
5
  import { getConditionalErrorFields, getEtag, getNotModifiedResult } from '../lib/conditionalRequests';
6
6
  import { convertApiSubmodelElementToCoreSubmodelElement, convertApiSubmodelToCoreSubmodel, convertCoreSubmodelElementToApiSubmodelElement, convertCoreSubmodelToApiSubmodel, } from '../lib/convertSubmodelTypes';
7
7
  import { handleApiError } from '../lib/errorHandler';
8
+ import { withFileName } from '../lib/multipartFile';
8
9
  import { getOperationHandle } from '../lib/operationHandle';
9
10
  import { convertQueryResult, toQueryRequestBody } from '../lib/queryRequests';
10
11
  //import { SubmodelElement } from 'src/generated/SubmodelRepositoryService';
@@ -1391,7 +1392,7 @@ export class SubmodelRepositoryClient {
1391
1392
  * - configuration: The http request options
1392
1393
  * - submodelIdentifier: The Submodel's unique id
1393
1394
  * - idShortPath: IdShort path to the submodel element (dot-separated)
1394
- * - fileName?: Name of the uploaded file
1395
+ * - fileName?: Name of the uploaded file, sent as filename of the file part and as `fileName` field
1395
1396
  * - file?: File content
1396
1397
  * - ifMatch?: Sent as `If-Match` header; the request fails with `preconditionFailed` if the resource has changed since the `etag` was issued
1397
1398
  * - ifNoneMatch?: Sent as `If-None-Match` header; use `*` to only create the resource (fails with `preconditionFailed` if it exists)
@@ -1407,7 +1408,7 @@ export class SubmodelRepositoryClient {
1407
1408
  submodelIdentifier: encodedSubmodelIdentifier,
1408
1409
  idShortPath: idShortPath,
1409
1410
  fileName: fileName,
1410
- file: file,
1411
+ file: file && withFileName(file, fileName),
1411
1412
  });
1412
1413
  const result = await response.value();
1413
1414
  return { success: true, data: result, statusCode: response.raw.status, etag: getEtag(response.raw) };
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Names a file for a multipart upload, so that the name is sent as the `filename` parameter of the
3
+ * file part's `Content-Disposition` header. AAS Part 2 V3.2 reads the file name only from there;
4
+ * a plain `Blob` would otherwise be sent with the default name `blob`.
5
+ *
6
+ * @function withFileName
7
+ * @param {Blob} file - The file content to upload.
8
+ * @param {string} [fileName] - The requested file name. Without a name, the file is returned unchanged.
9
+ * @returns {Blob} A `File` with the requested name and the content type of the given file.
10
+ */
11
+ export declare function withFileName(file: Blob, fileName?: string): Blob;
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Names a file for a multipart upload, so that the name is sent as the `filename` parameter of the
3
+ * file part's `Content-Disposition` header. AAS Part 2 V3.2 reads the file name only from there;
4
+ * a plain `Blob` would otherwise be sent with the default name `blob`.
5
+ *
6
+ * @function withFileName
7
+ * @param {Blob} file - The file content to upload.
8
+ * @param {string} [fileName] - The requested file name. Without a name, the file is returned unchanged.
9
+ * @returns {Blob} A `File` with the requested name and the content type of the given file.
10
+ */
11
+ export function withFileName(file, fileName) {
12
+ const name = fileName?.trim();
13
+ if (!name)
14
+ return file;
15
+ if (file instanceof File && file.name === name)
16
+ return file;
17
+ return new File([file], name, { type: file.type });
18
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "basyx-typescript-sdk",
3
- "version": "2.4.1",
3
+ "version": "2.4.2",
4
4
  "description": "BaSyx TypeScript SDK for developing applications and components for the Asset Administration Shell (AAS)",
5
5
  "main": "bundle/index.cjs",
6
6
  "module": "bundle/index.mjs",