basyx-typescript-sdk 2.2.2 → 2.2.4
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 +176 -168
- package/bundle/index.cjs +33543 -30338
- package/bundle/index.cjs.map +1 -1
- package/bundle/index.mjs +33407 -30282
- package/bundle/index.mjs.map +1 -1
- package/dist/lib/aas-dataformat-xml/xmlization.js +1 -1
- package/package.json +28 -17
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-

|
|
2
2
|

|
|
3
|
-

|
|
3
|
+
[](https://www.npmjs.com/package/basyx-typescript-sdk)
|
|
4
4
|

|
|
5
5
|
|
|
6
6
|
# basyx-typescript-sdk
|
|
@@ -10,6 +10,7 @@ BaSyx TypeScript SDK for developing applications and components for the Asset Ad
|
|
|
10
10
|
## Features
|
|
11
11
|
|
|
12
12
|
High-level orchestration services:
|
|
13
|
+
|
|
13
14
|
- **AasService**: Unified API for AAS operations across registry and repository
|
|
14
15
|
- Create, read, update, delete AAS with automatic registry synchronization
|
|
15
16
|
- Fetch AAS with their submodels in a single call
|
|
@@ -20,6 +21,7 @@ High-level orchestration services:
|
|
|
20
21
|
- Automatic fallback to repository when registry unavailable
|
|
21
22
|
|
|
22
23
|
Clients for the AAS API components:
|
|
24
|
+
|
|
23
25
|
- AAS Repository
|
|
24
26
|
- Submodel Repository
|
|
25
27
|
- Concept Description Repository
|
|
@@ -29,6 +31,7 @@ Clients for the AAS API components:
|
|
|
29
31
|
- AASX File Service
|
|
30
32
|
|
|
31
33
|
Utility functions for working with AAS data:
|
|
34
|
+
|
|
32
35
|
- Utils for Descriptors
|
|
33
36
|
- Utils for KeyTypes
|
|
34
37
|
- Utils for MultiLanguageProperties
|
|
@@ -41,20 +44,38 @@ Utility functions for working with AAS data:
|
|
|
41
44
|
```bash
|
|
42
45
|
npm install basyx-typescript-sdk
|
|
43
46
|
# or
|
|
44
|
-
|
|
47
|
+
pnpm add basyx-typescript-sdk
|
|
45
48
|
```
|
|
46
49
|
|
|
47
50
|
> See https://www.npmjs.com/package/basyx-typescript-sdk
|
|
48
51
|
|
|
49
52
|
---
|
|
50
53
|
|
|
51
|
-
> [!IMPORTANT]
|
|
52
|
-
> Make sure to also install `@aas-core-works/aas-core3.1-typescript` in your project:
|
|
54
|
+
> [!IMPORTANT] Make sure to also install `@aas-core-works/aas-core3.1-typescript` in your project:
|
|
53
55
|
|
|
54
56
|
```bash
|
|
55
57
|
npm install @aas-core-works/aas-core3.1-typescript
|
|
56
58
|
# or
|
|
57
|
-
|
|
59
|
+
pnpm add @aas-core-works/aas-core3.1-typescript
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
## Development
|
|
63
|
+
|
|
64
|
+
```bash
|
|
65
|
+
pnpm install
|
|
66
|
+
pnpm format:check
|
|
67
|
+
pnpm lint:check
|
|
68
|
+
pnpm type-check
|
|
69
|
+
pnpm build
|
|
70
|
+
pnpm bundle
|
|
71
|
+
pnpm test
|
|
72
|
+
pnpm verify:compat
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
Use `.nvmrc` to align local Node.js with CI:
|
|
76
|
+
|
|
77
|
+
```bash
|
|
78
|
+
nvm use
|
|
58
79
|
```
|
|
59
80
|
|
|
60
81
|
## Import Styles
|
|
@@ -92,12 +113,7 @@ const encoded = Lib.base64Encode('my-id');
|
|
|
92
113
|
|
|
93
114
|
```typescript
|
|
94
115
|
// Combine direct and namespaced imports
|
|
95
|
-
import {
|
|
96
|
-
AasService,
|
|
97
|
-
Configuration,
|
|
98
|
-
Utils,
|
|
99
|
-
base64Encode
|
|
100
|
-
} from 'basyx-typescript-sdk';
|
|
116
|
+
import { AasService, Configuration, Utils, base64Encode } from 'basyx-typescript-sdk';
|
|
101
117
|
|
|
102
118
|
// Use directly imported functions
|
|
103
119
|
const id = base64Encode('my-id');
|
|
@@ -114,18 +130,18 @@ const element = Utils.getSubmodelElementByIdShort(submodel, 'myElement');
|
|
|
114
130
|
import { AasRepositoryClient, Configuration } from 'basyx-typescript-sdk';
|
|
115
131
|
|
|
116
132
|
async function getAllShells() {
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
133
|
+
const client = new AasRepositoryClient();
|
|
134
|
+
const configuration = new Configuration({
|
|
135
|
+
basePath: 'http://localhost:8081',
|
|
136
|
+
});
|
|
137
|
+
|
|
138
|
+
const response = await client.getAllAssetAdministrationShells({ configuration });
|
|
139
|
+
|
|
140
|
+
if (response.success) {
|
|
141
|
+
console.log('Shells:', response.data.result);
|
|
142
|
+
} else {
|
|
143
|
+
console.error('Error:', response.error);
|
|
144
|
+
}
|
|
129
145
|
}
|
|
130
146
|
```
|
|
131
147
|
|
|
@@ -137,56 +153,56 @@ import { AssetAdministrationShell, AssetInformation, AssetKind } from '@aas-core
|
|
|
137
153
|
|
|
138
154
|
// Initialize service with both registry and repository
|
|
139
155
|
const service = new AasService({
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
156
|
+
registryConfig: new Configuration({ basePath: 'http://localhost:8084' }),
|
|
157
|
+
repositoryConfig: new Configuration({ basePath: 'http://localhost:8081' }),
|
|
158
|
+
// Optional: Separate configs for submodel services (used when includeSubmodels is enabled)
|
|
159
|
+
// If not provided, falls back to using registryConfig/repositoryConfig for submodels
|
|
160
|
+
// In typical BaSyx deployments, submodel services run on different ports:
|
|
161
|
+
submodelRegistryConfig: new Configuration({ basePath: 'http://localhost:8083' }),
|
|
162
|
+
submodelRepositoryConfig: new Configuration({ basePath: 'http://localhost:8081' }),
|
|
163
|
+
// Optional: Discovery service config (used for asset ID lookups)
|
|
164
|
+
discoveryConfig: new Configuration({ basePath: 'http://localhost:8086' }),
|
|
149
165
|
});
|
|
150
166
|
|
|
151
167
|
// Create a new AAS (automatically registers in registry)
|
|
152
168
|
const shell = new AssetAdministrationShell(
|
|
153
|
-
|
|
154
|
-
|
|
169
|
+
'https://example.com/ids/aas/my-aas',
|
|
170
|
+
new AssetInformation(AssetKind.Instance)
|
|
155
171
|
);
|
|
156
172
|
|
|
157
173
|
const createResult = await service.createAas({ shell });
|
|
158
174
|
if (createResult.success) {
|
|
159
|
-
|
|
175
|
+
console.log('Created AAS:', createResult.data.shell);
|
|
160
176
|
}
|
|
161
177
|
|
|
162
178
|
// Get AAS list from registry with automatic endpoint resolution
|
|
163
179
|
const listResult = await service.getAasList();
|
|
164
180
|
if (listResult.success) {
|
|
165
|
-
|
|
181
|
+
console.log('All shells:', listResult.data.shells);
|
|
166
182
|
}
|
|
167
183
|
|
|
168
184
|
// Get AAS by ID (uses registry endpoint if available)
|
|
169
|
-
const getResult = await service.getAasById({
|
|
170
|
-
|
|
185
|
+
const getResult = await service.getAasById({
|
|
186
|
+
aasIdentifier: 'https://example.com/ids/aas/my-aas',
|
|
171
187
|
});
|
|
172
188
|
|
|
173
189
|
// Get AAS with its submodels in a single call
|
|
174
190
|
const withSubmodels = await service.getAasById({
|
|
175
|
-
|
|
176
|
-
|
|
191
|
+
aasIdentifier: 'https://example.com/ids/aas/my-aas',
|
|
192
|
+
includeSubmodels: true,
|
|
177
193
|
});
|
|
178
194
|
if (withSubmodels.success) {
|
|
179
|
-
|
|
180
|
-
|
|
195
|
+
console.log('Shell:', withSubmodels.data.shell);
|
|
196
|
+
console.log('Submodels:', withSubmodels.data.submodels); // Array of submodels
|
|
181
197
|
}
|
|
182
198
|
|
|
183
199
|
// Get all AAS with their submodels
|
|
184
200
|
const allWithSubmodels = await service.getAasList({ includeSubmodels: true });
|
|
185
201
|
if (allWithSubmodels.success) {
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
202
|
+
allWithSubmodels.data.shells.forEach((shell, index) => {
|
|
203
|
+
console.log(`Shell ${index}:`, shell.id);
|
|
204
|
+
console.log(`Submodels:`, allWithSubmodels.data.submodels?.[shell.id]);
|
|
205
|
+
});
|
|
190
206
|
}
|
|
191
207
|
|
|
192
208
|
// Update AAS (updates both repository and registry)
|
|
@@ -195,118 +211,109 @@ const updateResult = await service.updateAas({ shell });
|
|
|
195
211
|
|
|
196
212
|
// Get endpoint for an AAS
|
|
197
213
|
const endpointResult = await service.getAasEndpointById({
|
|
198
|
-
|
|
214
|
+
aasIdentifier: 'https://example.com/ids/aas/my-aas',
|
|
199
215
|
});
|
|
200
216
|
|
|
201
217
|
// Get AAS directly by endpoint URL
|
|
202
218
|
const byEndpointResult = await service.getAasByEndpoint({
|
|
203
|
-
|
|
219
|
+
endpoint: 'http://localhost:8081/shells/encoded-id',
|
|
204
220
|
});
|
|
205
221
|
|
|
206
222
|
// Delete AAS (removes from both registry and repository)
|
|
207
|
-
await service.deleteAas({
|
|
208
|
-
|
|
223
|
+
await service.deleteAas({
|
|
224
|
+
aasIdentifier: 'https://example.com/ids/aas/my-aas',
|
|
209
225
|
});
|
|
210
226
|
|
|
211
227
|
// Find AAS by asset IDs using discovery service
|
|
212
228
|
const assetIds = [
|
|
213
|
-
|
|
214
|
-
|
|
229
|
+
{ name: 'serialNumber', value: '12345' },
|
|
230
|
+
{ name: 'deviceId', value: 'device-001' },
|
|
215
231
|
];
|
|
216
232
|
|
|
217
|
-
const byAssetIdResult = await service.getAasByAssetId({
|
|
218
|
-
|
|
219
|
-
|
|
233
|
+
const byAssetIdResult = await service.getAasByAssetId({
|
|
234
|
+
assetIds,
|
|
235
|
+
includeSubmodels: true, // Optionally include submodels
|
|
220
236
|
});
|
|
221
237
|
if (byAssetIdResult.success) {
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
238
|
+
console.log('Found AAS IDs:', byAssetIdResult.data.aasIds);
|
|
239
|
+
console.log('Found shells:', byAssetIdResult.data.shells);
|
|
240
|
+
// If multiple AAS match the asset IDs, all are returned
|
|
225
241
|
}
|
|
226
242
|
|
|
227
243
|
// Fetch AAS with submodels and their concept descriptions
|
|
228
244
|
const serviceWithCD = new AasService({
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
245
|
+
registryConfig: new Configuration({ basePath: 'http://localhost:8084' }),
|
|
246
|
+
repositoryConfig: new Configuration({ basePath: 'http://localhost:8081' }),
|
|
247
|
+
submodelRegistryConfig: new Configuration({ basePath: 'http://localhost:8085' }),
|
|
248
|
+
submodelRepositoryConfig: new Configuration({ basePath: 'http://localhost:8082' }),
|
|
249
|
+
conceptDescriptionRepositoryConfig: new Configuration({ basePath: 'http://localhost:8083' }),
|
|
234
250
|
});
|
|
235
251
|
|
|
236
252
|
const withConceptDescriptions = await serviceWithCD.getAasById({
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
253
|
+
aasIdentifier: 'https://example.com/ids/aas/my-aas',
|
|
254
|
+
includeSubmodels: true,
|
|
255
|
+
includeConceptDescriptions: true,
|
|
240
256
|
});
|
|
241
257
|
if (withConceptDescriptions.success) {
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
258
|
+
console.log('Shell:', withConceptDescriptions.data.shell);
|
|
259
|
+
console.log('Submodels with CDs:', withConceptDescriptions.data.submodels);
|
|
260
|
+
// Concept descriptions are fetched for all semantic IDs in submodels and their elements
|
|
245
261
|
}
|
|
246
262
|
|
|
247
263
|
// Resolve a Reference to get endpoints for AAS, Submodel, or SubmodelElement
|
|
248
264
|
import { Reference, Key, KeyTypes, ReferenceTypes } from '@aas-core-works/aas-core3.1-typescript/types';
|
|
249
265
|
|
|
250
266
|
// Example 1: Reference to AAS and Submodel
|
|
251
|
-
const reference1 = new Reference(
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
new Key(KeyTypes.Submodel, 'https://example.com/ids/sm/my-submodel'),
|
|
256
|
-
]
|
|
257
|
-
);
|
|
267
|
+
const reference1 = new Reference(ReferenceTypes.ModelReference, [
|
|
268
|
+
new Key(KeyTypes.AssetAdministrationShell, 'https://example.com/ids/aas/my-aas'),
|
|
269
|
+
new Key(KeyTypes.Submodel, 'https://example.com/ids/sm/my-submodel'),
|
|
270
|
+
]);
|
|
258
271
|
|
|
259
272
|
const resolved1 = await service.resolveReference({ reference: reference1 });
|
|
260
273
|
if (resolved1.success) {
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
274
|
+
console.log('AAS Endpoint:', resolved1.data.aasEndpoint);
|
|
275
|
+
// e.g., 'http://localhost:8081/shells/encoded-aas-id'
|
|
276
|
+
console.log('Submodel Endpoint:', resolved1.data.submodelEndpoint);
|
|
277
|
+
// e.g., 'http://localhost:8082/submodels/encoded-sm-id'
|
|
265
278
|
}
|
|
266
279
|
|
|
267
280
|
// Example 2: Reference to a specific SubmodelElement
|
|
268
|
-
const reference2 = new Reference(
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
new Key(KeyTypes.Property, 'MyProperty'),
|
|
274
|
-
]
|
|
275
|
-
);
|
|
281
|
+
const reference2 = new Reference(ReferenceTypes.ModelReference, [
|
|
282
|
+
new Key(KeyTypes.AssetAdministrationShell, 'https://example.com/ids/aas/my-aas'),
|
|
283
|
+
new Key(KeyTypes.Submodel, 'https://example.com/ids/sm/my-submodel'),
|
|
284
|
+
new Key(KeyTypes.Property, 'MyProperty'),
|
|
285
|
+
]);
|
|
276
286
|
|
|
277
287
|
const resolved2 = await service.resolveReference({ reference: reference2 });
|
|
278
288
|
if (resolved2.success) {
|
|
279
|
-
|
|
280
|
-
|
|
289
|
+
console.log('SubmodelElement Path:', resolved2.data.submodelElementPath);
|
|
290
|
+
// e.g., 'http://localhost:8082/submodels/encoded-sm-id/submodel-elements/MyProperty'
|
|
281
291
|
}
|
|
282
292
|
|
|
283
293
|
// Example 3: Reference to nested SubmodelElements
|
|
284
|
-
const reference3 = new Reference(
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
new Key(KeyTypes.Property, 'NestedProperty'),
|
|
290
|
-
]
|
|
291
|
-
);
|
|
294
|
+
const reference3 = new Reference(ReferenceTypes.ModelReference, [
|
|
295
|
+
new Key(KeyTypes.Submodel, 'https://example.com/ids/sm/my-submodel'),
|
|
296
|
+
new Key(KeyTypes.SubmodelElementCollection, 'MyCollection'),
|
|
297
|
+
new Key(KeyTypes.Property, 'NestedProperty'),
|
|
298
|
+
]);
|
|
292
299
|
|
|
293
300
|
const resolved3 = await service.resolveReference({ reference: reference3 });
|
|
294
301
|
if (resolved3.success) {
|
|
295
|
-
|
|
296
|
-
|
|
302
|
+
console.log('SubmodelElement Path:', resolved3.data.submodelElementPath);
|
|
303
|
+
// e.g., 'http://localhost:8082/submodels/encoded-sm-id/submodel-elements/MyCollection.NestedProperty'
|
|
297
304
|
}
|
|
298
305
|
|
|
299
306
|
// Fetch all AAS with submodels and concept descriptions
|
|
300
307
|
const allWithCD = await serviceWithCD.getAasList({
|
|
301
|
-
|
|
302
|
-
|
|
308
|
+
includeSubmodels: true,
|
|
309
|
+
includeConceptDescriptions: true,
|
|
303
310
|
});
|
|
304
311
|
if (allWithCD.success) {
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
312
|
+
allWithCD.data.shells.forEach((shell) => {
|
|
313
|
+
console.log('Shell:', shell.id);
|
|
314
|
+
console.log('Submodels:', allWithCD.data.submodels?.[shell.id]);
|
|
315
|
+
// Concept descriptions are available through the submodel service
|
|
316
|
+
});
|
|
310
317
|
}
|
|
311
318
|
```
|
|
312
319
|
|
|
@@ -318,43 +325,43 @@ import { Submodel, ModellingKind } from '@aas-core-works/aas-core3.1-typescript/
|
|
|
318
325
|
|
|
319
326
|
// Initialize service with both registry and repository
|
|
320
327
|
const service = new SubmodelService({
|
|
321
|
-
|
|
322
|
-
|
|
328
|
+
registryConfig: new Configuration({ basePath: 'http://localhost:8085' }),
|
|
329
|
+
repositoryConfig: new Configuration({ basePath: 'http://localhost:8082' }),
|
|
323
330
|
});
|
|
324
331
|
|
|
325
332
|
// Create a new Submodel (automatically registers in registry)
|
|
326
333
|
const submodel = new Submodel(
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
334
|
+
'https://example.com/ids/sm/my-submodel',
|
|
335
|
+
null, // extensions
|
|
336
|
+
null, // category
|
|
337
|
+
'MySubmodel', // idShort
|
|
338
|
+
null, // displayName
|
|
339
|
+
null, // description
|
|
340
|
+
null, // administration
|
|
341
|
+
ModellingKind.Instance
|
|
335
342
|
);
|
|
336
343
|
|
|
337
344
|
const createResult = await service.createSubmodel({ submodel });
|
|
338
345
|
if (createResult.success) {
|
|
339
|
-
|
|
340
|
-
|
|
346
|
+
console.log('Created Submodel:', createResult.data.submodel);
|
|
347
|
+
console.log('Registry Descriptor:', createResult.data.descriptor);
|
|
341
348
|
}
|
|
342
349
|
|
|
343
350
|
// Get Submodel list from registry with automatic endpoint resolution
|
|
344
351
|
const listResult = await service.getSubmodelList({ preferRegistry: true });
|
|
345
352
|
if (listResult.success) {
|
|
346
|
-
|
|
347
|
-
|
|
353
|
+
console.log('All submodels:', listResult.data.submodels);
|
|
354
|
+
console.log('Fetched from:', listResult.data.source); // 'registry' or 'repository'
|
|
348
355
|
}
|
|
349
356
|
|
|
350
357
|
// Get Submodel by ID (uses registry endpoint if available)
|
|
351
358
|
const getResult = await service.getSubmodelById({
|
|
352
|
-
|
|
353
|
-
|
|
359
|
+
submodelIdentifier: 'https://example.com/ids/sm/my-submodel',
|
|
360
|
+
useRegistryEndpoint: true,
|
|
354
361
|
});
|
|
355
362
|
if (getResult.success) {
|
|
356
|
-
|
|
357
|
-
|
|
363
|
+
console.log('Submodel:', getResult.data.submodel);
|
|
364
|
+
console.log('Descriptor:', getResult.data.descriptor);
|
|
358
365
|
}
|
|
359
366
|
|
|
360
367
|
// Update Submodel (updates both repository and registry)
|
|
@@ -363,25 +370,25 @@ const updateResult = await service.updateSubmodel({ submodel });
|
|
|
363
370
|
|
|
364
371
|
// Get endpoint for a Submodel
|
|
365
372
|
const endpointResult = await service.getSubmodelEndpointById({
|
|
366
|
-
|
|
373
|
+
submodelIdentifier: 'https://example.com/ids/sm/my-submodel',
|
|
367
374
|
});
|
|
368
375
|
if (endpointResult.success) {
|
|
369
|
-
|
|
376
|
+
console.log('Endpoint:', endpointResult.data);
|
|
370
377
|
}
|
|
371
378
|
|
|
372
379
|
// Get Submodel directly by endpoint URL
|
|
373
380
|
const byEndpointResult = await service.getSubmodelByEndpoint({
|
|
374
|
-
|
|
381
|
+
endpoint: 'http://localhost:8082/submodels/encoded-id',
|
|
375
382
|
});
|
|
376
383
|
|
|
377
384
|
// Delete Submodel (removes from both registry and repository)
|
|
378
385
|
await service.deleteSubmodel({
|
|
379
|
-
|
|
386
|
+
submodelIdentifier: 'https://example.com/ids/sm/my-submodel',
|
|
380
387
|
});
|
|
381
388
|
|
|
382
389
|
// Service works with only repository (no registry)
|
|
383
390
|
const repoOnlyService = new SubmodelService({
|
|
384
|
-
|
|
391
|
+
repositoryConfig: new Configuration({ basePath: 'http://localhost:8082' }),
|
|
385
392
|
});
|
|
386
393
|
|
|
387
394
|
const repoList = await repoOnlyService.getSubmodelList();
|
|
@@ -389,39 +396,39 @@ const repoList = await repoOnlyService.getSubmodelList();
|
|
|
389
396
|
|
|
390
397
|
// Fetch submodels with concept descriptions
|
|
391
398
|
const serviceWithCD = new SubmodelService({
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
399
|
+
registryConfig: new Configuration({ basePath: 'http://localhost:8085' }),
|
|
400
|
+
repositoryConfig: new Configuration({ basePath: 'http://localhost:8082' }),
|
|
401
|
+
conceptDescriptionRepositoryConfig: new Configuration({ basePath: 'http://localhost:8083' }),
|
|
395
402
|
});
|
|
396
403
|
|
|
397
404
|
// Get submodel with its concept descriptions
|
|
398
405
|
const withCD = await serviceWithCD.getSubmodelById({
|
|
399
|
-
|
|
400
|
-
|
|
406
|
+
submodelIdentifier: 'https://example.com/ids/sm/my-submodel',
|
|
407
|
+
includeConceptDescriptions: true,
|
|
401
408
|
});
|
|
402
409
|
if (withCD.success) {
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
410
|
+
console.log('Submodel:', withCD.data.submodel);
|
|
411
|
+
console.log('Concept Descriptions:', withCD.data.conceptDescriptions);
|
|
412
|
+
// conceptDescriptions array contains all unique CDs referenced by:
|
|
413
|
+
// - The submodel's semanticId
|
|
414
|
+
// - All submodel elements' semanticId properties (recursively through collections, lists, entities)
|
|
408
415
|
}
|
|
409
416
|
|
|
410
417
|
// Get all submodels with concept descriptions
|
|
411
418
|
const listWithCD = await serviceWithCD.getSubmodelList({
|
|
412
|
-
|
|
413
|
-
|
|
419
|
+
preferRegistry: false,
|
|
420
|
+
includeConceptDescriptions: true,
|
|
414
421
|
});
|
|
415
422
|
if (listWithCD.success) {
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
423
|
+
console.log('Submodels:', listWithCD.data.submodels);
|
|
424
|
+
console.log('All Concept Descriptions:', listWithCD.data.conceptDescriptions);
|
|
425
|
+
// Concept descriptions are deduplicated across all submodels
|
|
419
426
|
}
|
|
420
427
|
|
|
421
428
|
// Get submodel by endpoint with concept descriptions
|
|
422
429
|
const byEndpointWithCD = await serviceWithCD.getSubmodelByEndpoint({
|
|
423
|
-
|
|
424
|
-
|
|
430
|
+
endpoint: 'http://localhost:8082/submodels/encoded-id',
|
|
431
|
+
includeConceptDescriptions: true,
|
|
425
432
|
});
|
|
426
433
|
```
|
|
427
434
|
|
|
@@ -447,29 +454,30 @@ const encoded = base64Encode('https://example.com/ids/aas/my-aas');
|
|
|
447
454
|
```typescript
|
|
448
455
|
import { serializeXml, deserializeXml } from 'basyx-typescript-sdk';
|
|
449
456
|
import { BaSyxEnvironment } from 'basyx-typescript-sdk';
|
|
450
|
-
import {
|
|
457
|
+
import {
|
|
458
|
+
AssetAdministrationShell,
|
|
459
|
+
AssetInformation,
|
|
460
|
+
AssetKind,
|
|
461
|
+
Submodel,
|
|
462
|
+
ModellingKind,
|
|
463
|
+
} from '@aas-core-works/aas-core3.1-typescript/types';
|
|
451
464
|
|
|
452
465
|
// Create an environment with AAS and Submodels
|
|
453
466
|
const environment = new BaSyxEnvironment(
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
null,
|
|
469
|
-
ModellingKind.Instance
|
|
470
|
-
)
|
|
471
|
-
],
|
|
472
|
-
[] // conceptDescriptions
|
|
467
|
+
[new AssetAdministrationShell('https://example.com/ids/aas/my-aas', new AssetInformation(AssetKind.Instance))],
|
|
468
|
+
[
|
|
469
|
+
new Submodel(
|
|
470
|
+
'https://example.com/ids/sm/my-submodel',
|
|
471
|
+
null,
|
|
472
|
+
null,
|
|
473
|
+
'MySubmodel',
|
|
474
|
+
null,
|
|
475
|
+
null,
|
|
476
|
+
null,
|
|
477
|
+
ModellingKind.Instance
|
|
478
|
+
),
|
|
479
|
+
],
|
|
480
|
+
[] // conceptDescriptions
|
|
473
481
|
);
|
|
474
482
|
|
|
475
483
|
// Serialize to XML string
|