basyx-typescript-sdk 0.1.10 → 0.2.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.
@@ -0,0 +1,2 @@
1
+ // This file is auto-generated by @hey-api/openapi-ts
2
+ export {};
package/dist/index.d.ts CHANGED
@@ -1 +1,3 @@
1
1
  export * from './clients';
2
+ export * as AasTypes from './generated/types.gen';
3
+ export * as AasRepositoryModels from './models/aas-repository';
package/dist/index.js ADDED
@@ -0,0 +1,3 @@
1
+ export * from './clients';
2
+ export * as AasTypes from './generated/types.gen';
3
+ export * as AasRepositoryModels from './models/aas-repository';
@@ -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,50 @@
1
+ import { AssetAdministrationShell as CoreAssetAdministrationShell, AssetInformation as CoreAssetInformation, Reference as CoreReference } from '@aas-core-works/aas-core3.0-typescript/types';
2
+ import { AssetAdministrationShell as ApiAssetAdministrationShell, AssetInformation as ApiAssetInformation, Reference as ApiReference } from '../generated/types.gen';
3
+ /**
4
+ * Convert an API AssetAdministrationShell to a Core Works AssetAdministrationShell
5
+ *
6
+ * @function convertApiAasToCoreAas
7
+ * @param {ApiAssetAdministrationShell} aas - The API AssetAdministrationShell to convert
8
+ * @returns {CoreAssetAdministrationShell} The Core Works AssetAdministrationShell
9
+ */
10
+ export declare function convertApiAasToCoreAas(aas: ApiAssetAdministrationShell): CoreAssetAdministrationShell;
11
+ /**
12
+ * Convert a Core Works AssetAdministrationShell to an API AssetAdministrationShell
13
+ *
14
+ * @function convertCoreAasToApiAas
15
+ * @param {CoreAssetAdministrationShell} aas - The Core Works AssetAdministrationShell to convert
16
+ * @returns {ApiAssetAdministrationShell} The API AssetAdministrationShell
17
+ */
18
+ export declare function convertCoreAasToApiAas(aas: CoreAssetAdministrationShell): ApiAssetAdministrationShell;
19
+ /**
20
+ * Convert an API AssetInformation to a Core Works AssetInformation
21
+ *
22
+ * @function convertApiAssetInformationToCoreAssetInformation
23
+ * @param {ApiAssetInformation} assetInformation - The API AssetInformation to convert
24
+ * @returns {CoreAssetInformation} The Core Works AssetInformation
25
+ */
26
+ export declare function convertApiAssetInformationToCoreAssetInformation(assetInformation: ApiAssetInformation): CoreAssetInformation;
27
+ /**
28
+ * Convert a Core Works AssetInformation to an API AssetInformation
29
+ *
30
+ * @function convertCoreAssetInformationToApiAssetInformation
31
+ * @param {CoreAssetInformation} assetInformation - The Core Works AssetInformation to convert
32
+ * @returns {ApiAssetInformation} The API AssetInformation
33
+ */
34
+ export declare function convertCoreAssetInformationToApiAssetInformation(assetInformation: CoreAssetInformation): ApiAssetInformation;
35
+ /**
36
+ * Convert an API Reference to a Core Works Reference
37
+ *
38
+ * @function convertApiReferenceToCoreReference
39
+ * @param {ApiReference} reference - The API Reference to convert
40
+ * @returns {CoreReference} The Core Works Reference
41
+ */
42
+ export declare function convertApiReferenceToCoreReference(reference: ApiReference): CoreReference;
43
+ /**
44
+ * Convert a Core Works Reference to an API Reference
45
+ *
46
+ * @function convertCoreReferenceToApiReference
47
+ * @param {CoreReference} reference - The Core Works Reference to convert
48
+ * @returns {ApiReference} The API Reference
49
+ */
50
+ export declare function convertCoreReferenceToApiReference(reference: CoreReference): ApiReference;
@@ -0,0 +1,113 @@
1
+ import { jsonization } from '@aas-core-works/aas-core3.0-typescript';
2
+ import { AssetAdministrationShell as CoreAssetAdministrationShell, AssetInformation as CoreAssetInformation, Reference as CoreReference, } from '@aas-core-works/aas-core3.0-typescript/types';
3
+ /**
4
+ * Convert an API AssetAdministrationShell to a Core Works AssetAdministrationShell
5
+ *
6
+ * @function convertApiAasToCoreAas
7
+ * @param {ApiAssetAdministrationShell} aas - The API AssetAdministrationShell to convert
8
+ * @returns {CoreAssetAdministrationShell} The Core Works AssetAdministrationShell
9
+ */
10
+ export function convertApiAasToCoreAas(aas) {
11
+ // first stringify
12
+ let shell = JSON.stringify(aas);
13
+ // then parse
14
+ shell = JSON.parse(shell);
15
+ // then jsonize
16
+ const instanceOrError = jsonization.assetAdministrationShellFromJsonable(shell);
17
+ if (instanceOrError.error !== null) {
18
+ throw instanceOrError.error;
19
+ }
20
+ const instance = instanceOrError.mustValue();
21
+ // set the prototype
22
+ Object.setPrototypeOf(instance, CoreAssetAdministrationShell.prototype);
23
+ return instance;
24
+ }
25
+ /**
26
+ * Convert a Core Works AssetAdministrationShell to an API AssetAdministrationShell
27
+ *
28
+ * @function convertCoreAasToApiAas
29
+ * @param {CoreAssetAdministrationShell} aas - The Core Works AssetAdministrationShell to convert
30
+ * @returns {ApiAssetAdministrationShell} The API AssetAdministrationShell
31
+ */
32
+ export function convertCoreAasToApiAas(aas) {
33
+ // first jsonize
34
+ const jsonableAas = jsonization.toJsonable(aas);
35
+ // then stringify
36
+ const shell = JSON.stringify(jsonableAas);
37
+ // then parse
38
+ return JSON.parse(shell);
39
+ }
40
+ /**
41
+ * Convert an API AssetInformation to a Core Works AssetInformation
42
+ *
43
+ * @function convertApiAssetInformationToCoreAssetInformation
44
+ * @param {ApiAssetInformation} assetInformation - The API AssetInformation to convert
45
+ * @returns {CoreAssetInformation} The Core Works AssetInformation
46
+ */
47
+ export function convertApiAssetInformationToCoreAssetInformation(assetInformation) {
48
+ // first stringify
49
+ let asset = JSON.stringify(assetInformation);
50
+ // then parse
51
+ asset = JSON.parse(asset);
52
+ // then jsonize
53
+ const instanceOrError = jsonization.assetInformationFromJsonable(asset);
54
+ if (instanceOrError.error !== null) {
55
+ throw instanceOrError.error;
56
+ }
57
+ const instance = instanceOrError.mustValue();
58
+ // set the prototype
59
+ Object.setPrototypeOf(instance, CoreAssetInformation.prototype);
60
+ return instance;
61
+ }
62
+ /**
63
+ * Convert a Core Works AssetInformation to an API AssetInformation
64
+ *
65
+ * @function convertCoreAssetInformationToApiAssetInformation
66
+ * @param {CoreAssetInformation} assetInformation - The Core Works AssetInformation to convert
67
+ * @returns {ApiAssetInformation} The API AssetInformation
68
+ */
69
+ export function convertCoreAssetInformationToApiAssetInformation(assetInformation) {
70
+ // first jsonize
71
+ const jsonableAsset = jsonization.toJsonable(assetInformation);
72
+ // then stringify
73
+ const asset = JSON.stringify(jsonableAsset);
74
+ // then parse
75
+ return JSON.parse(asset);
76
+ }
77
+ /**
78
+ * Convert an API Reference to a Core Works Reference
79
+ *
80
+ * @function convertApiReferenceToCoreReference
81
+ * @param {ApiReference} reference - The API Reference to convert
82
+ * @returns {CoreReference} The Core Works Reference
83
+ */
84
+ export function convertApiReferenceToCoreReference(reference) {
85
+ // first stringify
86
+ let ref = JSON.stringify(reference);
87
+ // then parse
88
+ ref = JSON.parse(ref);
89
+ // then jsonize
90
+ const instanceOrError = jsonization.referenceFromJsonable(ref);
91
+ if (instanceOrError.error !== null) {
92
+ throw instanceOrError.error;
93
+ }
94
+ const instance = instanceOrError.mustValue();
95
+ // set the prototype
96
+ Object.setPrototypeOf(instance, CoreReference.prototype);
97
+ return instance;
98
+ }
99
+ /**
100
+ * Convert a Core Works Reference to an API Reference
101
+ *
102
+ * @function convertCoreReferenceToApiReference
103
+ * @param {CoreReference} reference - The Core Works Reference to convert
104
+ * @returns {ApiReference} The API Reference
105
+ */
106
+ export function convertCoreReferenceToApiReference(reference) {
107
+ // first jsonize
108
+ const jsonableRef = jsonization.toJsonable(reference);
109
+ // then stringify
110
+ const ref = JSON.stringify(jsonableRef);
111
+ // then parse
112
+ return JSON.parse(ref);
113
+ }
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Creates a custom client configuration
3
+ *
4
+ * @function createCustomClient
5
+ * @param baseURL The base URL of the API
6
+ * @param headers The headers to be included in the request
7
+ * @returns {Client} The custom client
8
+ */
9
+ export declare function createCustomClient(baseURL: string, headers?: Headers): import("@hey-api/client-fetch").Client;
@@ -0,0 +1,15 @@
1
+ import { createClient } from '@hey-api/client-fetch';
2
+ /**
3
+ * Creates a custom client configuration
4
+ *
5
+ * @function createCustomClient
6
+ * @param baseURL The base URL of the API
7
+ * @param headers The headers to be included in the request
8
+ * @returns {Client} The custom client
9
+ */
10
+ export function createCustomClient(baseURL, headers = new Headers()) {
11
+ return createClient({
12
+ baseUrl: baseURL,
13
+ headers,
14
+ });
15
+ }
@@ -0,0 +1,65 @@
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
+ }
11
+ export interface GetAllAssetAdministrationShellsResponse {
12
+ pagedResult: PagedResultPagingMetadata | undefined;
13
+ result: AssetAdministrationShell[] | undefined;
14
+ }
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 {
63
+ pagedResult: PagedResultPagingMetadata | undefined;
64
+ result: Reference[] | undefined;
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.10",
3
+ "version": "0.2.0",
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",
@@ -16,7 +16,7 @@
16
16
  "license": "MIT",
17
17
  "files": [
18
18
  "bundle",
19
- "dist/index.d.ts",
19
+ "dist",
20
20
  "README.md",
21
21
  "LICENSE"
22
22
  ],
@@ -27,7 +27,7 @@
27
27
  "lint:check": "eslint ./",
28
28
  "lint:fix": "eslint --fix ./",
29
29
  "test": "jest --coverage",
30
- "start": "ts-node -r tsconfig-paths/register src/testFunctions.ts"
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
  }