basyx-typescript-sdk 0.0.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.
Files changed (36) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +44 -0
  3. package/dist/clients/AasRepositoryClient.d.ts +158 -0
  4. package/dist/clients/AasRepositoryClient.js +474 -0
  5. package/dist/clients/index.d.ts +1 -0
  6. package/dist/clients/index.js +5 -0
  7. package/dist/generated/aas-repository/index.d.ts +2 -0
  8. package/dist/generated/aas-repository/index.js +19 -0
  9. package/dist/generated/aas-repository/sdk.gen.d.ts +210 -0
  10. package/dist/generated/aas-repository/sdk.gen.js +430 -0
  11. package/dist/generated/aas-repository/types.gen.d.ts +3380 -0
  12. package/dist/generated/aas-repository/types.gen.js +3 -0
  13. package/dist/index.d.ts +1 -0
  14. package/dist/index.js +17 -0
  15. package/dist/lib/convertAasTypes.d.ts +50 -0
  16. package/dist/lib/convertAasTypes.js +111 -0
  17. package/dist/lib/createAasRepoClient.d.ts +9 -0
  18. package/dist/lib/createAasRepoClient.js +18 -0
  19. package/dist/models/aas-repository.d.ts +10 -0
  20. package/dist/models/aas-repository.js +2 -0
  21. package/package.json +47 -0
  22. package/src/clients/AasRepositoryClient.ts +501 -0
  23. package/src/clients/index.ts +1 -0
  24. package/src/generated/aas-repository/index.ts +3 -0
  25. package/src/generated/aas-repository/sdk.gen.ts +620 -0
  26. package/src/generated/aas-repository/types.gen.ts +3786 -0
  27. package/src/index.ts +1 -0
  28. package/src/lib/convertAasTypes.ts +123 -0
  29. package/src/lib/createAasRepoClient.ts +16 -0
  30. package/src/models/aas-repository.ts +12 -0
  31. package/src/tests/clients/AasRepositoryClient.test.ts +270 -0
  32. package/src/tests/lib/convertAasTypes.test.ts +201 -0
  33. package/src/tests/lib/createAasRepoClient.test.ts +55 -0
  34. package/src/tests/models/.gitkeep +0 -0
  35. package/src/tests/utils/.gitkeep +0 -0
  36. package/src/utils/.gitkeep +0 -0
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ // This file is auto-generated by @hey-api/openapi-ts
3
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1 @@
1
+ export * from './clients';
package/dist/index.js ADDED
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./clients"), exports);
@@ -0,0 +1,50 @@
1
+ import type { AssetAdministrationShell as ApiAssetAdministrationShell, AssetInformation as ApiAssetInformation, Reference as ApiReference } from '@/generated/aas-repository/types.gen';
2
+ import type { 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 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,111 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.convertApiAasToCoreAas = convertApiAasToCoreAas;
4
+ exports.convertCoreAasToApiAas = convertCoreAasToApiAas;
5
+ exports.convertApiAssetInformationToCoreAssetInformation = convertApiAssetInformationToCoreAssetInformation;
6
+ exports.convertCoreAssetInformationToApiAssetInformation = convertCoreAssetInformationToApiAssetInformation;
7
+ exports.convertApiReferenceToCoreReference = convertApiReferenceToCoreReference;
8
+ exports.convertCoreReferenceToApiReference = convertCoreReferenceToApiReference;
9
+ const aas_core3_0_typescript_1 = require("@aas-core-works/aas-core3.0-typescript");
10
+ /**
11
+ * Convert an API AssetAdministrationShell to a Core Works AssetAdministrationShell
12
+ *
13
+ * @function convertApiAasToCoreAas
14
+ * @param {ApiAssetAdministrationShell} aas - The API AssetAdministrationShell to convert
15
+ * @returns {CoreAssetAdministrationShell} The Core Works AssetAdministrationShell
16
+ */
17
+ function convertApiAasToCoreAas(aas) {
18
+ // first stringify
19
+ let shell = JSON.stringify(aas);
20
+ // then parse
21
+ shell = JSON.parse(shell);
22
+ // then jsonize
23
+ const instanceOrError = aas_core3_0_typescript_1.jsonization.assetAdministrationShellFromJsonable(shell);
24
+ if (instanceOrError.error !== null) {
25
+ throw instanceOrError.error;
26
+ }
27
+ return instanceOrError.mustValue();
28
+ }
29
+ /**
30
+ * Convert a Core Works AssetAdministrationShell to an API AssetAdministrationShell
31
+ *
32
+ * @function convertCoreAasToApiAas
33
+ * @param {CoreAssetAdministrationShell} aas - The Core Works AssetAdministrationShell to convert
34
+ * @returns {ApiAssetAdministrationShell} The API AssetAdministrationShell
35
+ */
36
+ function convertCoreAasToApiAas(aas) {
37
+ // first jsonize
38
+ const jsonableAas = aas_core3_0_typescript_1.jsonization.toJsonable(aas);
39
+ // then stringify
40
+ const shell = JSON.stringify(jsonableAas);
41
+ // then parse
42
+ return JSON.parse(shell);
43
+ }
44
+ /**
45
+ * Convert an API AssetInformation to a Core Works AssetInformation
46
+ *
47
+ * @function convertApiAssetInformationToCoreAssetInformation
48
+ * @param {ApiAssetInformation} assetInformation - The API AssetInformation to convert
49
+ * @returns {CoreAssetInformation} The Core Works AssetInformation
50
+ */
51
+ function convertApiAssetInformationToCoreAssetInformation(assetInformation) {
52
+ // first stringify
53
+ let asset = JSON.stringify(assetInformation);
54
+ // then parse
55
+ asset = JSON.parse(asset);
56
+ // then jsonize
57
+ const instanceOrError = aas_core3_0_typescript_1.jsonization.assetInformationFromJsonable(asset);
58
+ if (instanceOrError.error !== null) {
59
+ throw instanceOrError.error;
60
+ }
61
+ return instanceOrError.mustValue();
62
+ }
63
+ /**
64
+ * Convert a Core Works AssetInformation to an API AssetInformation
65
+ *
66
+ * @function convertCoreAssetInformationToApiAssetInformation
67
+ * @param {CoreAssetInformation} assetInformation - The Core Works AssetInformation to convert
68
+ * @returns {ApiAssetInformation} The API AssetInformation
69
+ */
70
+ function convertCoreAssetInformationToApiAssetInformation(assetInformation) {
71
+ // first jsonize
72
+ const jsonableAsset = aas_core3_0_typescript_1.jsonization.toJsonable(assetInformation);
73
+ // then stringify
74
+ const asset = JSON.stringify(jsonableAsset);
75
+ // then parse
76
+ return JSON.parse(asset);
77
+ }
78
+ /**
79
+ * Convert an API Reference to a Core Works Reference
80
+ *
81
+ * @function convertApiReferenceToCoreReference
82
+ * @param {ApiReference} reference - The API Reference to convert
83
+ * @returns {CoreReference} The Core Works Reference
84
+ */
85
+ function convertApiReferenceToCoreReference(reference) {
86
+ // first stringify
87
+ let ref = JSON.stringify(reference);
88
+ // then parse
89
+ ref = JSON.parse(ref);
90
+ // then jsonize
91
+ const instanceOrError = aas_core3_0_typescript_1.jsonization.referenceFromJsonable(ref);
92
+ if (instanceOrError.error !== null) {
93
+ throw instanceOrError.error;
94
+ }
95
+ return instanceOrError.mustValue();
96
+ }
97
+ /**
98
+ * Convert a Core Works Reference to an API Reference
99
+ *
100
+ * @function convertCoreReferenceToApiReference
101
+ * @param {CoreReference} reference - The Core Works Reference to convert
102
+ * @returns {ApiReference} The API Reference
103
+ */
104
+ function convertCoreReferenceToApiReference(reference) {
105
+ // first jsonize
106
+ const jsonableRef = aas_core3_0_typescript_1.jsonization.toJsonable(reference);
107
+ // then stringify
108
+ const ref = JSON.stringify(jsonableRef);
109
+ // then parse
110
+ return JSON.parse(ref);
111
+ }
@@ -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<Request, Response, unknown, import("@hey-api/client-fetch").RequestOptions<boolean, string>>;
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createCustomClient = createCustomClient;
4
+ const client_fetch_1 = require("@hey-api/client-fetch");
5
+ /**
6
+ * Creates a custom client configuration
7
+ *
8
+ * @function createCustomClient
9
+ * @param baseURL The base URL of the API
10
+ * @param headers The headers to be included in the request
11
+ * @returns {Client} The custom client
12
+ */
13
+ function createCustomClient(baseURL, headers = new Headers()) {
14
+ return (0, client_fetch_1.createClient)({
15
+ baseUrl: baseURL,
16
+ headers,
17
+ });
18
+ }
@@ -0,0 +1,10 @@
1
+ import type { PagedResultPagingMetadata } from '@/generated/aas-repository/types.gen';
2
+ import type { AssetAdministrationShell, Reference } from '@aas-core-works/aas-core3.0-typescript/types';
3
+ export interface GetAllAssetAdministrationShellsResponse {
4
+ pagedResult: PagedResultPagingMetadata | undefined;
5
+ result: AssetAdministrationShell[] | undefined;
6
+ }
7
+ export interface getAllSubmodelReferencesResponse {
8
+ pagedResult: PagedResultPagingMetadata | undefined;
9
+ result: Reference[] | undefined;
10
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
package/package.json ADDED
@@ -0,0 +1,47 @@
1
+ {
2
+ "name": "basyx-typescript-sdk",
3
+ "version": "0.0.1",
4
+ "description": "BaSyx TypeScript SDK for developing applications and components for the Asset Administration Shell (AAS)",
5
+ "main": "dist/index.js",
6
+ "repository": "https://github.com/eclipse-basyx/basyx-typescript-sdk.git",
7
+ "author": "Aaron Zielstorff <aaron.zielstorff@iese.fraunhofer.de>",
8
+ "license": "MIT",
9
+ "files": [
10
+ "dist",
11
+ "src",
12
+ "README.md",
13
+ "LICENSE"
14
+ ],
15
+ "scripts": {
16
+ "gen:aasrepository": "openapi-ts -c @hey-api/client-fetch -i ./openapi/Plattform_i40-AssetAdministrationShellRepositoryServiceSpecification-V3.0.3_SSP-001-resolved.json -o ./src/generated/aas-repository",
17
+ "build": "tsc",
18
+ "lint:check": "eslint ./",
19
+ "lint:fix": "eslint --fix ./",
20
+ "test": "jest --coverage",
21
+ "start": "ts-node -r tsconfig-paths/register src/testFunctions.ts"
22
+ },
23
+ "dependencies": {
24
+ "@aas-core-works/aas-core3.0-typescript": "^1.0.3",
25
+ "@hey-api/client-fetch": "^0.7.0"
26
+ },
27
+ "devDependencies": {
28
+ "@hey-api/openapi-ts": "^0.62.1",
29
+ "@types/jest": "^29.5.14",
30
+ "@types/node": "^22.10.7",
31
+ "@typescript-eslint/eslint-plugin": "^8.21.0",
32
+ "@typescript-eslint/parser": "^8.20.0",
33
+ "eslint": "^9.18.0",
34
+ "eslint-config-prettier": "^10.0.1",
35
+ "eslint-plugin-prettier": "^5.2.3",
36
+ "eslint-plugin-simple-import-sort": "^12.1.1",
37
+ "jest": "^29.7.0",
38
+ "jiti": "^2.4.2",
39
+ "openapi-typescript-codegen": "^0.29.0",
40
+ "prettier": "^3.4.2",
41
+ "ts-jest": "^29.2.5",
42
+ "ts-node": "^10.9.2",
43
+ "tsconfig-paths": "^4.2.0",
44
+ "typescript": "^5.7.3",
45
+ "typescript-eslint": "^8.21.0"
46
+ }
47
+ }