basyx-typescript-sdk 0.1.11 → 0.2.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 +14 -1
- package/bundle/index.js +287 -235
- package/bundle/index.js.map +1 -1
- package/dist/clients/AasRepositoryClient.d.ts +198 -129
- package/dist/clients/AasRepositoryClient.js +245 -234
- package/dist/index.d.ts +2 -0
- package/dist/index.js +2 -0
- package/dist/lib/base64Url.d.ts +32 -0
- package/dist/lib/base64Url.js +62 -0
- package/dist/models/AssetId.d.ts +11 -0
- package/dist/models/AssetId.js +1 -0
- package/dist/models/aas-repository.d.ts +58 -3
- package/dist/models/api.d.ts +12 -0
- package/dist/models/api.js +1 -0
- package/dist/models/index.d.ts +3 -0
- package/dist/models/index.js +3 -0
- package/package.json +3 -2
package/dist/index.js
CHANGED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Encodes a given string into Base64 format.
|
|
3
|
+
* Optionally transforms the output into a URL-safe Base64 string.
|
|
4
|
+
*
|
|
5
|
+
* The process includes:
|
|
6
|
+
* 1. Trimming the input string.
|
|
7
|
+
* 2. Percent-encoding the string.
|
|
8
|
+
* 3. Converting percent-encoded characters back to their raw representation.
|
|
9
|
+
* 4. Encoding the result into Base64.
|
|
10
|
+
* 5. Optionally making the Base64 string URL safe by replacing '+' with '-', '/' with '_' and removing trailing '='.
|
|
11
|
+
*
|
|
12
|
+
* @function base64Encode
|
|
13
|
+
* @param {string} string - The string to encode.
|
|
14
|
+
* @param {boolean} [urlSafe=true] - Whether to return a URL-safe encoded string. Defaults to true.
|
|
15
|
+
* @returns {string} The Base64 encoded string, converted to URL-safe format if requested.
|
|
16
|
+
*/
|
|
17
|
+
export declare function base64Encode(string: string, urlSafe?: boolean): string;
|
|
18
|
+
/**
|
|
19
|
+
* Decodes a URL-safe Base64 encoded string into its original representation.
|
|
20
|
+
*
|
|
21
|
+
* The process includes:
|
|
22
|
+
* 1. Trimming the input string.
|
|
23
|
+
* 2. Replacing URL-safe characters '-' and '_' with their Base64 equivalents '+' and '/'.
|
|
24
|
+
* 3. Restoring padding if missing.
|
|
25
|
+
* 4. Decoding from Base64.
|
|
26
|
+
* 5. Escaping the decoded string before decoding percent-encoded characters.
|
|
27
|
+
*
|
|
28
|
+
* @function base64Decode
|
|
29
|
+
* @param {string} urlSafeBase64String - The URL-safe Base64 encoded string to decode.
|
|
30
|
+
* @returns {string} The decoded string.
|
|
31
|
+
*/
|
|
32
|
+
export declare function base64Decode(urlSafeBase64String: string): string;
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Encodes a given string into Base64 format.
|
|
3
|
+
* Optionally transforms the output into a URL-safe Base64 string.
|
|
4
|
+
*
|
|
5
|
+
* The process includes:
|
|
6
|
+
* 1. Trimming the input string.
|
|
7
|
+
* 2. Percent-encoding the string.
|
|
8
|
+
* 3. Converting percent-encoded characters back to their raw representation.
|
|
9
|
+
* 4. Encoding the result into Base64.
|
|
10
|
+
* 5. Optionally making the Base64 string URL safe by replacing '+' with '-', '/' with '_' and removing trailing '='.
|
|
11
|
+
*
|
|
12
|
+
* @function base64Encode
|
|
13
|
+
* @param {string} string - The string to encode.
|
|
14
|
+
* @param {boolean} [urlSafe=true] - Whether to return a URL-safe encoded string. Defaults to true.
|
|
15
|
+
* @returns {string} The Base64 encoded string, converted to URL-safe format if requested.
|
|
16
|
+
*/
|
|
17
|
+
export function base64Encode(string, urlSafe = true) {
|
|
18
|
+
string = string.trim();
|
|
19
|
+
if (string === '')
|
|
20
|
+
return '';
|
|
21
|
+
const encodedUriComponent = encodeURIComponent(string);
|
|
22
|
+
const unescapedEncodedUriComponent = unescape(encodedUriComponent); // reverse percent-encoding
|
|
23
|
+
const base64String = btoa(unescapedEncodedUriComponent);
|
|
24
|
+
if (!urlSafe)
|
|
25
|
+
return base64String;
|
|
26
|
+
const urlSafeBase64String = base64String
|
|
27
|
+
.replace(/\+/g, '-') // Replace + with -
|
|
28
|
+
.replace(/\//g, '_') // Replace / with _
|
|
29
|
+
.replace(/=+$/, ''); // Remove padding (=)
|
|
30
|
+
return urlSafeBase64String;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Decodes a URL-safe Base64 encoded string into its original representation.
|
|
34
|
+
*
|
|
35
|
+
* The process includes:
|
|
36
|
+
* 1. Trimming the input string.
|
|
37
|
+
* 2. Replacing URL-safe characters '-' and '_' with their Base64 equivalents '+' and '/'.
|
|
38
|
+
* 3. Restoring padding if missing.
|
|
39
|
+
* 4. Decoding from Base64.
|
|
40
|
+
* 5. Escaping the decoded string before decoding percent-encoded characters.
|
|
41
|
+
*
|
|
42
|
+
* @function base64Decode
|
|
43
|
+
* @param {string} urlSafeBase64String - The URL-safe Base64 encoded string to decode.
|
|
44
|
+
* @returns {string} The decoded string.
|
|
45
|
+
*/
|
|
46
|
+
export function base64Decode(urlSafeBase64String) {
|
|
47
|
+
urlSafeBase64String = urlSafeBase64String.trim();
|
|
48
|
+
if (urlSafeBase64String === '')
|
|
49
|
+
return '';
|
|
50
|
+
let base64String = urlSafeBase64String
|
|
51
|
+
.replace(/-/g, '+') // Replace - with +
|
|
52
|
+
.replace(/_/g, '/') // Replace _ with /
|
|
53
|
+
.replace(/%3D/g, '=');
|
|
54
|
+
// Restore missing padding if needed.
|
|
55
|
+
const incompleteFourChars = base64String.length % 4;
|
|
56
|
+
if (incompleteFourChars > 0)
|
|
57
|
+
base64String += '=='.substring(0, 4 - incompleteFourChars);
|
|
58
|
+
const encodedUriComponent = atob(base64String);
|
|
59
|
+
const escapedEncodedUriComponent = escape(encodedUriComponent);
|
|
60
|
+
const decodedString = decodeURIComponent(escapedEncodedUriComponent);
|
|
61
|
+
return decodedString;
|
|
62
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Represents an asset identifier.
|
|
3
|
+
*
|
|
4
|
+
* @remarks
|
|
5
|
+
* The "name" property can either be "globalAssetId" to denote a global identifier, or any other string representing a custom identifier type.
|
|
6
|
+
* The "value" property contains the actual identifier.
|
|
7
|
+
*/
|
|
8
|
+
export type AssetId = {
|
|
9
|
+
name: string;
|
|
10
|
+
value: string;
|
|
11
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,10 +1,65 @@
|
|
|
1
|
-
import type { AssetAdministrationShell, Reference } from '@aas-core-works/aas-core3.0-typescript/types';
|
|
2
|
-
import type { PagedResultPagingMetadata } from '../generated/types.gen';
|
|
1
|
+
import type { AssetAdministrationShell, AssetInformation, Reference } from '@aas-core-works/aas-core3.0-typescript/types';
|
|
2
|
+
import type { AssetinformationThumbnailBody, PagedResultPagingMetadata } from '../generated/types.gen';
|
|
3
|
+
export interface GetAllAssetAdministrationShellsOptions {
|
|
4
|
+
baseUrl: string;
|
|
5
|
+
headers?: Headers;
|
|
6
|
+
assetIds?: string[];
|
|
7
|
+
idShort?: string;
|
|
8
|
+
limit?: number;
|
|
9
|
+
cursor?: string;
|
|
10
|
+
}
|
|
3
11
|
export interface GetAllAssetAdministrationShellsResponse {
|
|
4
12
|
pagedResult: PagedResultPagingMetadata | undefined;
|
|
5
13
|
result: AssetAdministrationShell[] | undefined;
|
|
6
14
|
}
|
|
7
|
-
export interface
|
|
15
|
+
export interface PostAssetAdministrationShellOptions {
|
|
16
|
+
baseUrl: string;
|
|
17
|
+
assetAdministrationShell: AssetAdministrationShell;
|
|
18
|
+
headers?: Headers;
|
|
19
|
+
}
|
|
20
|
+
export interface AasIdentifierOptions {
|
|
21
|
+
baseUrl: string;
|
|
22
|
+
aasIdentifier: string;
|
|
23
|
+
headers?: Headers;
|
|
24
|
+
}
|
|
25
|
+
export interface PutAssetAdministrationShellOptions {
|
|
26
|
+
baseUrl: string;
|
|
27
|
+
aasIdentifier: string;
|
|
28
|
+
assetAdministrationShell: AssetAdministrationShell;
|
|
29
|
+
headers?: Headers;
|
|
30
|
+
}
|
|
31
|
+
export interface PutAssetInformationOptions {
|
|
32
|
+
baseUrl: string;
|
|
33
|
+
aasIdentifier: string;
|
|
34
|
+
assetInformation: AssetInformation;
|
|
35
|
+
headers?: Headers;
|
|
36
|
+
}
|
|
37
|
+
export interface PutThumbnailOptions {
|
|
38
|
+
baseUrl: string;
|
|
39
|
+
aasIdentifier: string;
|
|
40
|
+
thumbnail: AssetinformationThumbnailBody;
|
|
41
|
+
headers?: Headers;
|
|
42
|
+
}
|
|
43
|
+
export interface GetAllSubmodelReferencesOptions {
|
|
44
|
+
baseUrl: string;
|
|
45
|
+
aasIdentifier: string;
|
|
46
|
+
headers?: Headers;
|
|
47
|
+
limit?: number;
|
|
48
|
+
cursor?: string;
|
|
49
|
+
}
|
|
50
|
+
export interface PostSubmodelReferenceOptions {
|
|
51
|
+
baseUrl: string;
|
|
52
|
+
aasIdentifier: string;
|
|
53
|
+
submodelReference: Reference;
|
|
54
|
+
headers?: Headers;
|
|
55
|
+
}
|
|
56
|
+
export interface DeleteSubmodelReferenceByIdOptions {
|
|
57
|
+
baseUrl: string;
|
|
58
|
+
aasIdentifier: string;
|
|
59
|
+
submodelIdentifier: string;
|
|
60
|
+
headers?: Headers;
|
|
61
|
+
}
|
|
62
|
+
export interface GetAllSubmodelReferencesResponse {
|
|
8
63
|
pagedResult: PagedResultPagingMetadata | undefined;
|
|
9
64
|
result: Reference[] | undefined;
|
|
10
65
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "basyx-typescript-sdk",
|
|
3
|
-
"version": "0.1
|
|
3
|
+
"version": "0.2.1",
|
|
4
4
|
"description": "BaSyx TypeScript SDK for developing applications and components for the Asset Administration Shell (AAS)",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "bundle/index.js",
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
"lint:check": "eslint ./",
|
|
28
28
|
"lint:fix": "eslint --fix ./",
|
|
29
29
|
"test": "jest --coverage",
|
|
30
|
-
"
|
|
30
|
+
"docs": "typedoc --options typedoc.json"
|
|
31
31
|
},
|
|
32
32
|
"dependencies": {
|
|
33
33
|
"@hey-api/client-fetch": "^0.7.0"
|
|
@@ -55,6 +55,7 @@
|
|
|
55
55
|
"ts-jest": "^29.2.5",
|
|
56
56
|
"ts-node": "^10.9.2",
|
|
57
57
|
"tsconfig-paths": "^4.2.0",
|
|
58
|
+
"typedoc": "^0.28.1",
|
|
58
59
|
"typescript": "^5.7.3",
|
|
59
60
|
"typescript-eslint": "^8.21.0"
|
|
60
61
|
}
|