basyx-typescript-sdk 2.2.3 → 2.2.5
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 +115 -0
- package/bundle/index.cjs +2854 -2052
- package/bundle/index.cjs.map +1 -1
- package/bundle/index.mjs +2854 -2052
- package/bundle/index.mjs.map +1 -1
- package/dist/clients/AasDiscoveryClient.d.ts +3 -2
- package/dist/clients/AasDiscoveryClient.js +78 -20
- package/dist/clients/AasRegistryClient.d.ts +4 -2
- package/dist/clients/AasRegistryClient.js +153 -45
- package/dist/clients/AasRepositoryClient.d.ts +73 -16
- package/dist/clients/AasRepositoryClient.js +682 -263
- package/dist/clients/AasxFileClient.d.ts +18 -0
- package/dist/clients/AasxFileClient.js +100 -25
- package/dist/clients/ConceptDescriptionRepositoryClient.d.ts +3 -1
- package/dist/clients/ConceptDescriptionRepositoryClient.js +93 -29
- package/dist/clients/SubmodelRegistryClient.d.ts +3 -1
- package/dist/clients/SubmodelRegistryClient.js +91 -21
- package/dist/clients/SubmodelRepositoryClient.d.ts +229 -22
- package/dist/clients/SubmodelRepositoryClient.js +689 -201
- package/dist/generated/AasDiscoveryService/models/index.d.ts +2 -2
- package/dist/generated/AasRegistryService/apis/AssetAdministrationShellRegistryAPIApi.d.ts +1 -1
- package/dist/generated/AasRegistryService/apis/AssetAdministrationShellRegistryAPIApi.js +1 -1
- package/dist/generated/AasRegistryService/apis/DescriptionAPIApi.d.ts +1 -1
- package/dist/generated/AasRegistryService/apis/DescriptionAPIApi.js +1 -1
- package/dist/generated/AasRegistryService/index.d.ts +1 -1
- package/dist/generated/AasRegistryService/index.js +1 -1
- package/dist/generated/AasRegistryService/models/index.d.ts +3 -3
- package/dist/generated/AasRepositoryService/apis/AssetAdministrationShellRepositoryAPIApi.d.ts +3 -3
- package/dist/generated/AasRepositoryService/apis/AssetAdministrationShellRepositoryAPIApi.js +1 -1
- package/dist/generated/AasRepositoryService/apis/DescriptionAPIApi.d.ts +1 -1
- package/dist/generated/AasRepositoryService/apis/DescriptionAPIApi.js +1 -1
- package/dist/generated/AasRepositoryService/apis/SerializationAPIApi.d.ts +1 -1
- package/dist/generated/AasRepositoryService/apis/SerializationAPIApi.js +1 -1
- package/dist/generated/AasRepositoryService/index.d.ts +1 -1
- package/dist/generated/AasRepositoryService/index.js +1 -1
- package/dist/generated/AasRepositoryService/models/index.d.ts +7 -7
- package/dist/generated/AasxFileService/apis/AASXFileServerAPIApi.d.ts +5 -3
- package/dist/generated/AasxFileService/apis/AASXFileServerAPIApi.js +6 -0
- package/dist/generated/AasxFileService/apis/DescriptionAPIApi.d.ts +26 -0
- package/dist/generated/AasxFileService/apis/DescriptionAPIApi.js +40 -0
- package/dist/generated/AasxFileService/apis/index.d.ts +1 -0
- package/dist/generated/AasxFileService/apis/index.js +1 -0
- package/dist/generated/AasxFileService/models/index.d.ts +45 -0
- package/dist/generated/ConceptDescriptionRepositoryService/models/index.d.ts +2 -2
- package/dist/generated/SubmodelRegistryService/models/index.d.ts +2 -2
- package/dist/generated/SubmodelRepositoryService/models/index.d.ts +9 -9
- package/dist/generated/runtime.js +7 -0
- package/dist/lib/aas-dataformat-xml/xmlization.js +1 -1
- package/dist/lib/errorHandler.js +13 -2
- package/dist/models/api.d.ts +4 -2
- package/dist/services/AasService.d.ts +21 -1
- package/dist/services/AasService.js +114 -26
- package/dist/services/SubmodelService.d.ts +21 -1
- package/dist/services/SubmodelService.js +119 -21
- package/package.json +23 -12
- package/dist/generated/AasRegistryService/runtime.d.ts +0 -181
- package/dist/generated/AasRegistryService/runtime.js +0 -326
- package/dist/generated/AasRepositoryService/runtime.d.ts +0 -181
- package/dist/generated/AasRepositoryService/runtime.js +0 -326
|
@@ -11,6 +11,12 @@ export interface AasServiceConfig {
|
|
|
11
11
|
conceptDescriptionRepositoryConfig?: Configuration;
|
|
12
12
|
discoveryConfig?: Configuration;
|
|
13
13
|
}
|
|
14
|
+
export interface AasListResolutionWarning {
|
|
15
|
+
descriptorId?: string;
|
|
16
|
+
endpoint?: string;
|
|
17
|
+
errorType: string;
|
|
18
|
+
message: string;
|
|
19
|
+
}
|
|
14
20
|
/**
|
|
15
21
|
* AasService combines and orchestrates multiple clients and services, including:
|
|
16
22
|
* - AasRegistryClient
|
|
@@ -40,15 +46,21 @@ export declare class AasService {
|
|
|
40
46
|
*
|
|
41
47
|
* @param options Object containing:
|
|
42
48
|
* - preferRegistry?: Whether to prefer registry over repository (default: true)
|
|
49
|
+
* - strictRegistryResolution?: Whether registry endpoint resolution failures should fail immediately (default: false)
|
|
43
50
|
* - limit?: Maximum number of elements to retrieve
|
|
44
51
|
* - cursor?: Pagination cursor
|
|
45
52
|
* - includeSubmodels?: Whether to fetch submodels for each shell (default: false)
|
|
46
53
|
* - includeConceptDescriptions?: Whether to fetch concept descriptions (default: false)
|
|
47
54
|
*
|
|
48
|
-
* @returns Either
|
|
55
|
+
* @returns Either
|
|
56
|
+
* `{ success: true; data: { shells, source, submodels?, warnings? } }`
|
|
57
|
+
* or `{ success: false; error: ... }`.
|
|
58
|
+
* When `strictRegistryResolution` is `true`, unresolved registry descriptors return
|
|
59
|
+
* `RegistryResolutionError` with `warnings`.
|
|
49
60
|
*/
|
|
50
61
|
getAasList(options?: {
|
|
51
62
|
preferRegistry?: boolean;
|
|
63
|
+
strictRegistryResolution?: boolean;
|
|
52
64
|
limit?: number;
|
|
53
65
|
cursor?: string;
|
|
54
66
|
includeSubmodels?: boolean;
|
|
@@ -57,6 +69,7 @@ export declare class AasService {
|
|
|
57
69
|
shells: AssetAdministrationShell[];
|
|
58
70
|
source: 'registry' | 'repository';
|
|
59
71
|
submodels?: Record<string, Submodel[]>;
|
|
72
|
+
warnings?: AasListResolutionWarning[];
|
|
60
73
|
}, any>>;
|
|
61
74
|
/**
|
|
62
75
|
* Retrieves an Asset Administration Shell by ID.
|
|
@@ -220,6 +233,13 @@ export declare class AasService {
|
|
|
220
233
|
submodelEndpoint?: string;
|
|
221
234
|
submodelElementPath?: string;
|
|
222
235
|
}, any>>;
|
|
236
|
+
/**
|
|
237
|
+
* Creates a repository configuration for an endpoint while preserving auth and middleware.
|
|
238
|
+
*
|
|
239
|
+
* @param basePath The endpoint base path to target
|
|
240
|
+
* @returns Configuration with endpoint basePath plus repository auth/settings
|
|
241
|
+
*/
|
|
242
|
+
private createRepositoryEndpointConfiguration;
|
|
223
243
|
/**
|
|
224
244
|
* Helper method to create an AAS descriptor from an AssetAdministrationShell.
|
|
225
245
|
* Populates descriptor fields from the shell including metadata and endpoint configuration.
|
|
@@ -49,16 +49,23 @@ export class AasService {
|
|
|
49
49
|
*
|
|
50
50
|
* @param options Object containing:
|
|
51
51
|
* - preferRegistry?: Whether to prefer registry over repository (default: true)
|
|
52
|
+
* - strictRegistryResolution?: Whether registry endpoint resolution failures should fail immediately (default: false)
|
|
52
53
|
* - limit?: Maximum number of elements to retrieve
|
|
53
54
|
* - cursor?: Pagination cursor
|
|
54
55
|
* - includeSubmodels?: Whether to fetch submodels for each shell (default: false)
|
|
55
56
|
* - includeConceptDescriptions?: Whether to fetch concept descriptions (default: false)
|
|
56
57
|
*
|
|
57
|
-
* @returns Either
|
|
58
|
+
* @returns Either
|
|
59
|
+
* `{ success: true; data: { shells, source, submodels?, warnings? } }`
|
|
60
|
+
* or `{ success: false; error: ... }`.
|
|
61
|
+
* When `strictRegistryResolution` is `true`, unresolved registry descriptors return
|
|
62
|
+
* `RegistryResolutionError` with `warnings`.
|
|
58
63
|
*/
|
|
59
64
|
async getAasList(options) {
|
|
60
65
|
const preferRegistry = options?.preferRegistry ?? true;
|
|
66
|
+
const strictRegistryResolution = options?.strictRegistryResolution ?? false;
|
|
61
67
|
const includeSubmodels = options?.includeSubmodels ?? false;
|
|
68
|
+
let registryResolutionWarnings = [];
|
|
62
69
|
// Try registry first if configured and preferred
|
|
63
70
|
if (preferRegistry && this.aasRegistryConfig) {
|
|
64
71
|
const registryResult = await this.aasRegistryClient.getAllAssetAdministrationShellDescriptors({
|
|
@@ -69,34 +76,79 @@ export class AasService {
|
|
|
69
76
|
if (registryResult.success) {
|
|
70
77
|
// Fetch actual shells from descriptor endpoints
|
|
71
78
|
const shells = [];
|
|
79
|
+
const warnings = [];
|
|
72
80
|
for (const descriptor of registryResult.data.result) {
|
|
81
|
+
if (!descriptor.id) {
|
|
82
|
+
warnings.push({
|
|
83
|
+
errorType: 'MissingDescriptorId',
|
|
84
|
+
message: 'AAS descriptor does not contain an id and cannot be resolved',
|
|
85
|
+
});
|
|
86
|
+
continue;
|
|
87
|
+
}
|
|
73
88
|
const endpoint = extractEndpointHref(descriptor, 'AAS-3.0');
|
|
74
|
-
if (endpoint
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
89
|
+
if (!endpoint) {
|
|
90
|
+
warnings.push({
|
|
91
|
+
descriptorId: descriptor.id,
|
|
92
|
+
errorType: 'MissingEndpoint',
|
|
93
|
+
message: 'AAS descriptor has no AAS-3.0 endpoint and cannot be resolved',
|
|
94
|
+
});
|
|
95
|
+
continue;
|
|
96
|
+
}
|
|
97
|
+
// Extract base URL from endpoint (remove /shells/{id} part)
|
|
98
|
+
const baseUrl = endpoint.match(/^(https?:\/\/[^/]+(?::\d+)?)/)?.[1] || endpoint;
|
|
99
|
+
const config = this.createRepositoryEndpointConfiguration(baseUrl);
|
|
100
|
+
const shellResult = await this.aasRepositoryClient.getAssetAdministrationShellById({
|
|
101
|
+
configuration: config,
|
|
102
|
+
aasIdentifier: descriptor.id,
|
|
103
|
+
});
|
|
104
|
+
if (shellResult.success) {
|
|
105
|
+
shells.push(shellResult.data);
|
|
106
|
+
}
|
|
107
|
+
else {
|
|
108
|
+
const resolutionError = shellResult.error;
|
|
109
|
+
warnings.push({
|
|
110
|
+
descriptorId: descriptor.id,
|
|
111
|
+
endpoint,
|
|
112
|
+
errorType: resolutionError?.errorType || 'EndpointResolutionError',
|
|
113
|
+
message: resolutionError?.message ||
|
|
114
|
+
resolutionError?.messages?.[0]?.text ||
|
|
115
|
+
'Failed to resolve AAS from descriptor endpoint',
|
|
81
116
|
});
|
|
82
|
-
if (shellResult.success) {
|
|
83
|
-
shells.push(shellResult.data);
|
|
84
|
-
}
|
|
85
117
|
}
|
|
86
118
|
}
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
119
|
+
if (strictRegistryResolution && warnings.length > 0) {
|
|
120
|
+
return {
|
|
121
|
+
success: false,
|
|
122
|
+
error: {
|
|
123
|
+
errorType: 'RegistryResolutionError',
|
|
124
|
+
message: 'Failed to resolve one or more AAS descriptors via registry endpoints',
|
|
125
|
+
warnings,
|
|
126
|
+
},
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
// If registry descriptors exist but none were resolvable, fall back to repository when possible.
|
|
130
|
+
if (warnings.length > 0 && shells.length === 0 && this.aasRepositoryConfig) {
|
|
131
|
+
registryResolutionWarnings = warnings;
|
|
132
|
+
}
|
|
133
|
+
else {
|
|
134
|
+
// Fetch submodels if requested
|
|
135
|
+
let submodelsMap;
|
|
136
|
+
if (includeSubmodels) {
|
|
137
|
+
submodelsMap = await this.fetchSubmodelsForShells(shells, options?.includeConceptDescriptions);
|
|
138
|
+
}
|
|
139
|
+
return {
|
|
140
|
+
success: true,
|
|
141
|
+
data: {
|
|
142
|
+
shells,
|
|
143
|
+
source: 'registry',
|
|
144
|
+
...(submodelsMap && { submodels: submodelsMap }),
|
|
145
|
+
...(warnings.length > 0 && { warnings }),
|
|
146
|
+
},
|
|
147
|
+
};
|
|
91
148
|
}
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
shells,
|
|
96
|
-
source: 'registry',
|
|
97
|
-
...(submodelsMap && { submodels: submodelsMap }),
|
|
98
|
-
},
|
|
99
|
-
};
|
|
149
|
+
}
|
|
150
|
+
else {
|
|
151
|
+
registryResolutionWarnings = [];
|
|
100
152
|
}
|
|
101
153
|
}
|
|
102
154
|
// Fall back to repository if registry failed or not configured
|
|
@@ -119,6 +171,7 @@ export class AasService {
|
|
|
119
171
|
shells,
|
|
120
172
|
source: 'repository',
|
|
121
173
|
...(submodelsMap && { submodels: submodelsMap }),
|
|
174
|
+
...(registryResolutionWarnings.length > 0 && { warnings: registryResolutionWarnings }),
|
|
122
175
|
},
|
|
123
176
|
};
|
|
124
177
|
}
|
|
@@ -162,7 +215,7 @@ export class AasService {
|
|
|
162
215
|
// Extract base URL from endpoint (remove /shells/{id} part)
|
|
163
216
|
const baseUrl = endpoint.match(/^(https?:\/\/[^/]+(?::\d+)?)/)?.[1] || endpoint;
|
|
164
217
|
// Try to fetch from descriptor endpoint
|
|
165
|
-
const config =
|
|
218
|
+
const config = this.createRepositoryEndpointConfiguration(baseUrl);
|
|
166
219
|
const shellResult = await this.aasRepositoryClient.getAssetAdministrationShellById({
|
|
167
220
|
configuration: config,
|
|
168
221
|
aasIdentifier,
|
|
@@ -292,9 +345,21 @@ export class AasService {
|
|
|
292
345
|
}
|
|
293
346
|
const [, baseUrl, encodedId] = match;
|
|
294
347
|
// Decode the ID
|
|
295
|
-
|
|
348
|
+
let aasIdentifier;
|
|
349
|
+
try {
|
|
350
|
+
aasIdentifier = base64Decode(encodedId);
|
|
351
|
+
}
|
|
352
|
+
catch {
|
|
353
|
+
return {
|
|
354
|
+
success: false,
|
|
355
|
+
error: {
|
|
356
|
+
errorType: 'InvalidEndpoint',
|
|
357
|
+
message: 'Endpoint contains an invalid Base64URL-encoded AAS identifier.',
|
|
358
|
+
},
|
|
359
|
+
};
|
|
360
|
+
}
|
|
296
361
|
// Create configuration for the endpoint
|
|
297
|
-
const config =
|
|
362
|
+
const config = this.createRepositoryEndpointConfiguration(baseUrl);
|
|
298
363
|
// Fetch the shell
|
|
299
364
|
const shellResult = await this.aasRepositoryClient.getAssetAdministrationShellById({
|
|
300
365
|
configuration: config,
|
|
@@ -660,6 +725,29 @@ export class AasService {
|
|
|
660
725
|
},
|
|
661
726
|
};
|
|
662
727
|
}
|
|
728
|
+
/**
|
|
729
|
+
* Creates a repository configuration for an endpoint while preserving auth and middleware.
|
|
730
|
+
*
|
|
731
|
+
* @param basePath The endpoint base path to target
|
|
732
|
+
* @returns Configuration with endpoint basePath plus repository auth/settings
|
|
733
|
+
*/
|
|
734
|
+
createRepositoryEndpointConfiguration(basePath) {
|
|
735
|
+
if (!this.aasRepositoryConfig) {
|
|
736
|
+
return new Configuration({ basePath });
|
|
737
|
+
}
|
|
738
|
+
return new Configuration({
|
|
739
|
+
basePath,
|
|
740
|
+
fetchApi: this.aasRepositoryConfig.fetchApi,
|
|
741
|
+
middleware: this.aasRepositoryConfig.middleware,
|
|
742
|
+
queryParamsStringify: this.aasRepositoryConfig.queryParamsStringify,
|
|
743
|
+
username: this.aasRepositoryConfig.username,
|
|
744
|
+
password: this.aasRepositoryConfig.password,
|
|
745
|
+
apiKey: this.aasRepositoryConfig.apiKey,
|
|
746
|
+
accessToken: this.aasRepositoryConfig.accessToken,
|
|
747
|
+
headers: this.aasRepositoryConfig.headers,
|
|
748
|
+
credentials: this.aasRepositoryConfig.credentials,
|
|
749
|
+
});
|
|
750
|
+
}
|
|
663
751
|
/**
|
|
664
752
|
* Helper method to create an AAS descriptor from an AssetAdministrationShell.
|
|
665
753
|
* Populates descriptor fields from the shell including metadata and endpoint configuration.
|
|
@@ -7,6 +7,12 @@ export interface SubmodelServiceConfig {
|
|
|
7
7
|
submodelRepositoryConfig?: Configuration;
|
|
8
8
|
conceptDescriptionRepositoryConfig?: Configuration;
|
|
9
9
|
}
|
|
10
|
+
export interface SubmodelListResolutionWarning {
|
|
11
|
+
submodelIdentifier?: string;
|
|
12
|
+
endpoint?: string;
|
|
13
|
+
errorType: string;
|
|
14
|
+
message: string;
|
|
15
|
+
}
|
|
10
16
|
/**
|
|
11
17
|
* SubmodelService combines Submodel Registry, Submodel Repository, and Concept Description Repository clients
|
|
12
18
|
* to provide higher-level functionality for working with Submodels.
|
|
@@ -33,14 +39,20 @@ export declare class SubmodelService {
|
|
|
33
39
|
*
|
|
34
40
|
* @param options Object containing:
|
|
35
41
|
* - preferRegistry?: Whether to prefer registry over repository (default: true)
|
|
42
|
+
* - strictRegistryResolution?: Whether registry endpoint resolution failures should fail immediately (default: false)
|
|
36
43
|
* - limit?: Maximum number of elements to retrieve
|
|
37
44
|
* - cursor?: Pagination cursor
|
|
38
45
|
* - includeConceptDescriptions?: Whether to fetch concept descriptions (default: false)
|
|
39
46
|
*
|
|
40
|
-
* @returns Either
|
|
47
|
+
* @returns Either
|
|
48
|
+
* `{ success: true; data: { submodels, source, conceptDescriptions?, warnings? } }`
|
|
49
|
+
* or `{ success: false; error: ... }`.
|
|
50
|
+
* When `strictRegistryResolution` is `true`, unresolved registry descriptors return
|
|
51
|
+
* `RegistryResolutionError` with `warnings`.
|
|
41
52
|
*/
|
|
42
53
|
getSubmodelList(options?: {
|
|
43
54
|
preferRegistry?: boolean;
|
|
55
|
+
strictRegistryResolution?: boolean;
|
|
44
56
|
limit?: number;
|
|
45
57
|
cursor?: string;
|
|
46
58
|
includeConceptDescriptions?: boolean;
|
|
@@ -48,6 +60,7 @@ export declare class SubmodelService {
|
|
|
48
60
|
submodels: Submodel[];
|
|
49
61
|
source: 'registry' | 'repository';
|
|
50
62
|
conceptDescriptions?: ConceptDescription[];
|
|
63
|
+
warnings?: SubmodelListResolutionWarning[];
|
|
51
64
|
}, any>>;
|
|
52
65
|
/**
|
|
53
66
|
* Retrieves a Submodel by ID.
|
|
@@ -108,6 +121,13 @@ export declare class SubmodelService {
|
|
|
108
121
|
submodel: Submodel;
|
|
109
122
|
conceptDescriptions?: ConceptDescription[];
|
|
110
123
|
}, any>>;
|
|
124
|
+
/**
|
|
125
|
+
* Creates a repository configuration for an endpoint while preserving auth and middleware.
|
|
126
|
+
*
|
|
127
|
+
* @param basePath The endpoint base path to target
|
|
128
|
+
* @returns Configuration with endpoint basePath plus repository auth/settings
|
|
129
|
+
*/
|
|
130
|
+
private createRepositoryEndpointConfiguration;
|
|
111
131
|
/**
|
|
112
132
|
* Creates a Submodel and optionally registers it in the registry.
|
|
113
133
|
*
|
|
@@ -38,15 +38,22 @@ export class SubmodelService {
|
|
|
38
38
|
*
|
|
39
39
|
* @param options Object containing:
|
|
40
40
|
* - preferRegistry?: Whether to prefer registry over repository (default: true)
|
|
41
|
+
* - strictRegistryResolution?: Whether registry endpoint resolution failures should fail immediately (default: false)
|
|
41
42
|
* - limit?: Maximum number of elements to retrieve
|
|
42
43
|
* - cursor?: Pagination cursor
|
|
43
44
|
* - includeConceptDescriptions?: Whether to fetch concept descriptions (default: false)
|
|
44
45
|
*
|
|
45
|
-
* @returns Either
|
|
46
|
+
* @returns Either
|
|
47
|
+
* `{ success: true; data: { submodels, source, conceptDescriptions?, warnings? } }`
|
|
48
|
+
* or `{ success: false; error: ... }`.
|
|
49
|
+
* When `strictRegistryResolution` is `true`, unresolved registry descriptors return
|
|
50
|
+
* `RegistryResolutionError` with `warnings`.
|
|
46
51
|
*/
|
|
47
52
|
async getSubmodelList(options) {
|
|
48
53
|
const preferRegistry = options?.preferRegistry ?? true;
|
|
54
|
+
const strictRegistryResolution = options?.strictRegistryResolution ?? false;
|
|
49
55
|
const includeConceptDescriptions = options?.includeConceptDescriptions ?? false;
|
|
56
|
+
let registryResolutionWarnings = [];
|
|
50
57
|
// Try registry first if configured and preferred
|
|
51
58
|
if (preferRegistry && this.submodelRegistryConfig) {
|
|
52
59
|
const registryResult = await this.submodelRegistryClient.getAllSubmodelDescriptors({
|
|
@@ -56,29 +63,84 @@ export class SubmodelService {
|
|
|
56
63
|
});
|
|
57
64
|
if (registryResult.success) {
|
|
58
65
|
const descriptors = registryResult.data.result;
|
|
59
|
-
//
|
|
60
|
-
const
|
|
66
|
+
// Resolve submodels from descriptor endpoints and aggregate warnings deterministically.
|
|
67
|
+
const descriptorResults = await Promise.all(descriptors.map(async (descriptor) => {
|
|
68
|
+
if (!descriptor.id) {
|
|
69
|
+
return {
|
|
70
|
+
submodel: null,
|
|
71
|
+
warning: {
|
|
72
|
+
errorType: 'MissingDescriptorId',
|
|
73
|
+
message: 'Submodel descriptor does not contain an id and cannot be resolved',
|
|
74
|
+
},
|
|
75
|
+
};
|
|
76
|
+
}
|
|
61
77
|
const endpoint = descriptor.endpoints?.[0]?.protocolInformation?.href;
|
|
62
78
|
if (!endpoint) {
|
|
63
|
-
return
|
|
79
|
+
return {
|
|
80
|
+
submodel: null,
|
|
81
|
+
warning: {
|
|
82
|
+
submodelIdentifier: descriptor.id,
|
|
83
|
+
errorType: 'MissingEndpoint',
|
|
84
|
+
message: 'Submodel descriptor has no endpoint and cannot be resolved',
|
|
85
|
+
},
|
|
86
|
+
};
|
|
64
87
|
}
|
|
65
88
|
const submodelResult = await this.getSubmodelByEndpoint({ endpoint });
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
89
|
+
if (submodelResult.success) {
|
|
90
|
+
return { submodel: submodelResult.data.submodel };
|
|
91
|
+
}
|
|
92
|
+
const resolutionError = submodelResult.error;
|
|
93
|
+
return {
|
|
94
|
+
submodel: null,
|
|
95
|
+
warning: {
|
|
96
|
+
submodelIdentifier: descriptor.id,
|
|
97
|
+
endpoint,
|
|
98
|
+
errorType: resolutionError?.errorType || 'EndpointResolutionError',
|
|
99
|
+
message: resolutionError?.message ||
|
|
100
|
+
resolutionError?.messages?.[0]?.text ||
|
|
101
|
+
'Failed to resolve Submodel from descriptor endpoint',
|
|
102
|
+
},
|
|
103
|
+
};
|
|
104
|
+
}));
|
|
105
|
+
const submodels = descriptorResults
|
|
106
|
+
.map((result) => result.submodel)
|
|
107
|
+
.filter((sm) => sm !== null);
|
|
108
|
+
const warnings = descriptorResults
|
|
109
|
+
.map((result) => result.warning)
|
|
110
|
+
.filter((warning) => warning !== undefined);
|
|
111
|
+
if (strictRegistryResolution && warnings.length > 0) {
|
|
112
|
+
return {
|
|
113
|
+
success: false,
|
|
114
|
+
error: {
|
|
115
|
+
errorType: 'RegistryResolutionError',
|
|
116
|
+
message: 'Failed to resolve one or more Submodel descriptors via registry endpoints',
|
|
117
|
+
warnings,
|
|
118
|
+
},
|
|
119
|
+
};
|
|
73
120
|
}
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
121
|
+
// If registry descriptors exist but none were resolvable, fall back to repository when possible.
|
|
122
|
+
if (warnings.length > 0 && submodels.length === 0 && this.submodelRepositoryConfig) {
|
|
123
|
+
registryResolutionWarnings = warnings;
|
|
124
|
+
}
|
|
125
|
+
else {
|
|
126
|
+
// Fetch concept descriptions if requested
|
|
127
|
+
let conceptDescriptions;
|
|
128
|
+
if (includeConceptDescriptions) {
|
|
129
|
+
conceptDescriptions = await this.fetchConceptDescriptionsForSubmodels(submodels);
|
|
130
|
+
}
|
|
131
|
+
return {
|
|
132
|
+
success: true,
|
|
133
|
+
data: {
|
|
134
|
+
submodels,
|
|
135
|
+
source: 'registry',
|
|
136
|
+
...(conceptDescriptions && { conceptDescriptions }),
|
|
137
|
+
...(warnings.length > 0 && { warnings }),
|
|
138
|
+
},
|
|
139
|
+
};
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
else {
|
|
143
|
+
registryResolutionWarnings = [];
|
|
82
144
|
}
|
|
83
145
|
}
|
|
84
146
|
// Fall back to repository if registry failed or not configured
|
|
@@ -101,6 +163,7 @@ export class SubmodelService {
|
|
|
101
163
|
submodels,
|
|
102
164
|
source: 'repository',
|
|
103
165
|
...(conceptDescriptions && { conceptDescriptions }),
|
|
166
|
+
...(registryResolutionWarnings.length > 0 && { warnings: registryResolutionWarnings }),
|
|
104
167
|
},
|
|
105
168
|
};
|
|
106
169
|
}
|
|
@@ -263,9 +326,21 @@ export class SubmodelService {
|
|
|
263
326
|
}
|
|
264
327
|
const [, baseUrl, encodedId] = match;
|
|
265
328
|
// Decode the ID
|
|
266
|
-
|
|
329
|
+
let submodelIdentifier;
|
|
330
|
+
try {
|
|
331
|
+
submodelIdentifier = base64Decode(encodedId);
|
|
332
|
+
}
|
|
333
|
+
catch {
|
|
334
|
+
return {
|
|
335
|
+
success: false,
|
|
336
|
+
error: {
|
|
337
|
+
errorType: 'InvalidEndpoint',
|
|
338
|
+
message: 'Endpoint contains an invalid Base64URL-encoded Submodel identifier.',
|
|
339
|
+
},
|
|
340
|
+
};
|
|
341
|
+
}
|
|
267
342
|
// Create configuration for the endpoint
|
|
268
|
-
const config =
|
|
343
|
+
const config = this.createRepositoryEndpointConfiguration(baseUrl);
|
|
269
344
|
// Fetch the submodel
|
|
270
345
|
const submodelResult = await this.submodelRepositoryClient.getSubmodelById({
|
|
271
346
|
configuration: config,
|
|
@@ -288,6 +363,29 @@ export class SubmodelService {
|
|
|
288
363
|
},
|
|
289
364
|
};
|
|
290
365
|
}
|
|
366
|
+
/**
|
|
367
|
+
* Creates a repository configuration for an endpoint while preserving auth and middleware.
|
|
368
|
+
*
|
|
369
|
+
* @param basePath The endpoint base path to target
|
|
370
|
+
* @returns Configuration with endpoint basePath plus repository auth/settings
|
|
371
|
+
*/
|
|
372
|
+
createRepositoryEndpointConfiguration(basePath) {
|
|
373
|
+
if (!this.submodelRepositoryConfig) {
|
|
374
|
+
return new Configuration({ basePath });
|
|
375
|
+
}
|
|
376
|
+
return new Configuration({
|
|
377
|
+
basePath,
|
|
378
|
+
fetchApi: this.submodelRepositoryConfig.fetchApi,
|
|
379
|
+
middleware: this.submodelRepositoryConfig.middleware,
|
|
380
|
+
queryParamsStringify: this.submodelRepositoryConfig.queryParamsStringify,
|
|
381
|
+
username: this.submodelRepositoryConfig.username,
|
|
382
|
+
password: this.submodelRepositoryConfig.password,
|
|
383
|
+
apiKey: this.submodelRepositoryConfig.apiKey,
|
|
384
|
+
accessToken: this.submodelRepositoryConfig.accessToken,
|
|
385
|
+
headers: this.submodelRepositoryConfig.headers,
|
|
386
|
+
credentials: this.submodelRepositoryConfig.credentials,
|
|
387
|
+
});
|
|
388
|
+
}
|
|
291
389
|
/**
|
|
292
390
|
* Creates a Submodel and optionally registers it in the registry.
|
|
293
391
|
*
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "basyx-typescript-sdk",
|
|
3
|
-
"version": "2.2.
|
|
3
|
+
"version": "2.2.5",
|
|
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",
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
"repository": "https://github.com/eclipse-basyx/basyx-typescript-sdk.git",
|
|
16
16
|
"author": "Aaron Zielstorff <aaron.zielstorff@iese.fraunhofer.de>",
|
|
17
17
|
"license": "MIT",
|
|
18
|
-
"packageManager": "pnpm@
|
|
18
|
+
"packageManager": "pnpm@11.0.0-rc.0",
|
|
19
19
|
"files": [
|
|
20
20
|
"bundle",
|
|
21
21
|
"dist",
|
|
@@ -36,6 +36,16 @@
|
|
|
36
36
|
"test:watch": "vitest",
|
|
37
37
|
"test:unit": "vitest run --project unit-tests",
|
|
38
38
|
"test:integration": "vitest run --project integration-tests",
|
|
39
|
+
"test:engine": "node scripts/test-engine.mjs",
|
|
40
|
+
"test:engine:list-components": "node scripts/test-engine.mjs --list-components",
|
|
41
|
+
"validate:openapi-coverage": "node scripts/validate-openapi-coverage.mjs",
|
|
42
|
+
"validate:openapi-coverage:aasrepo": "node scripts/validate-openapi-coverage.mjs --service aasRepository",
|
|
43
|
+
"validate:openapi-coverage:aasdiscovery": "node scripts/validate-openapi-coverage.mjs --service aasDiscovery",
|
|
44
|
+
"validate:openapi-coverage:aasregistry": "node scripts/validate-openapi-coverage.mjs --service aasRegistry",
|
|
45
|
+
"validate:openapi-coverage:smregistry": "node scripts/validate-openapi-coverage.mjs --service submodelRegistry",
|
|
46
|
+
"validate:openapi-coverage:smrepo": "node scripts/validate-openapi-coverage.mjs --service submodelRepository",
|
|
47
|
+
"validate:openapi-coverage:cdrepo": "node scripts/validate-openapi-coverage.mjs --service conceptDescriptionRepository",
|
|
48
|
+
"validate:openapi-coverage:aasxfileserver": "node scripts/validate-openapi-coverage.mjs --service aasxFileServer",
|
|
39
49
|
"docs": "typedoc --options typedoc.json",
|
|
40
50
|
"gen-aasrepo": "openapi-generator-cli generate -i openapi/aasrepository.yaml -g typescript-fetch -o src/generated/AasRepositoryService --additional-properties=withoutRuntimeChecks=true",
|
|
41
51
|
"gen-submodelrepo": "openapi-generator-cli generate -i openapi/smrepository.yaml -g typescript-fetch -o src/generated/SubmodelRepositoryService --additional-properties=withoutRuntimeChecks=true",
|
|
@@ -52,25 +62,26 @@
|
|
|
52
62
|
"@aas-core-works/aas-core3.1-typescript": "^1.0.0",
|
|
53
63
|
"@eslint/js": "^10.0.1",
|
|
54
64
|
"@openapitools/openapi-generator-cli": "^2.18.4",
|
|
55
|
-
"@vitest/coverage-v8": "^4.1.4",
|
|
56
65
|
"@types/node": "^25.0.0",
|
|
57
|
-
"@typescript-eslint/eslint-plugin": "^8.
|
|
58
|
-
"@typescript-eslint/parser": "^8.
|
|
59
|
-
"
|
|
66
|
+
"@typescript-eslint/eslint-plugin": "^8.59.0",
|
|
67
|
+
"@typescript-eslint/parser": "^8.59.0",
|
|
68
|
+
"@vitest/coverage-v8": "^4.1.5",
|
|
69
|
+
"eslint": "^10.2.1",
|
|
60
70
|
"eslint-config-prettier": "^10.0.1",
|
|
61
71
|
"eslint-plugin-simple-import-sort": "^13.0.0",
|
|
62
72
|
"jiti": "^2.4.2",
|
|
63
|
-
"prettier": "^3.
|
|
64
|
-
"rolldown": "^1.0.0-rc.
|
|
73
|
+
"prettier": "^3.8.3",
|
|
74
|
+
"rolldown": "^1.0.0-rc.17",
|
|
65
75
|
"ts-node": "^10.9.2",
|
|
66
76
|
"tsconfig-paths": "^4.2.0",
|
|
67
77
|
"typedoc": "^0.28.1",
|
|
68
|
-
"typescript": "^
|
|
69
|
-
"typescript-eslint": "^8.
|
|
70
|
-
"vitest": "^4.1.
|
|
78
|
+
"typescript": "^6.0.3",
|
|
79
|
+
"typescript-eslint": "^8.59.0",
|
|
80
|
+
"vitest": "^4.1.5",
|
|
81
|
+
"yaml": "^2.8.3"
|
|
71
82
|
},
|
|
72
83
|
"dependencies": {
|
|
73
|
-
"
|
|
84
|
+
"xmlsax-typescript": "^1.0.0-rc.1"
|
|
74
85
|
},
|
|
75
86
|
"pnpm": {
|
|
76
87
|
"onlyBuiltDependencies": [
|