basyx-typescript-sdk 1.1.0 → 1.1.2
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/bundle/index.cjs +94 -94
- package/bundle/index.cjs.map +1 -1
- package/bundle/index.mjs +94 -94
- package/bundle/index.mjs.map +1 -1
- package/dist/services/AasService.d.ts +6 -6
- package/dist/services/AasService.js +49 -49
- package/dist/services/SubmodelService.d.ts +6 -6
- package/dist/services/SubmodelService.js +45 -45
- package/package.json +1 -1
|
@@ -4,8 +4,8 @@ import { Configuration } from '../generated';
|
|
|
4
4
|
import { AssetId } from '../models/AssetId';
|
|
5
5
|
import { AssetAdministrationShellDescriptor } from '../models/Descriptors';
|
|
6
6
|
export interface AasServiceConfig {
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
aasRegistryConfig?: Configuration;
|
|
8
|
+
aasRepositoryConfig?: Configuration;
|
|
9
9
|
submodelRegistryConfig?: Configuration;
|
|
10
10
|
submodelRepositoryConfig?: Configuration;
|
|
11
11
|
conceptDescriptionRepositoryConfig?: Configuration;
|
|
@@ -22,11 +22,11 @@ export interface AasServiceConfig {
|
|
|
22
22
|
* by coordinating operations across these BaSyx components, demonstrating the multi-client pattern.
|
|
23
23
|
*/
|
|
24
24
|
export declare class AasService {
|
|
25
|
-
private
|
|
26
|
-
private
|
|
25
|
+
private aasRegistryClient;
|
|
26
|
+
private aasRepositoryClient;
|
|
27
27
|
private discoveryClient;
|
|
28
|
-
private
|
|
29
|
-
private
|
|
28
|
+
private aasRegistryConfig?;
|
|
29
|
+
private aasRepositoryConfig?;
|
|
30
30
|
private discoveryConfig?;
|
|
31
31
|
private submodelService;
|
|
32
32
|
constructor(config: AasServiceConfig);
|
|
@@ -18,24 +18,24 @@ import { SubmodelService } from './SubmodelService';
|
|
|
18
18
|
* by coordinating operations across these BaSyx components, demonstrating the multi-client pattern.
|
|
19
19
|
*/
|
|
20
20
|
export class AasService {
|
|
21
|
-
|
|
22
|
-
|
|
21
|
+
aasRegistryClient;
|
|
22
|
+
aasRepositoryClient;
|
|
23
23
|
discoveryClient;
|
|
24
|
-
|
|
25
|
-
|
|
24
|
+
aasRegistryConfig;
|
|
25
|
+
aasRepositoryConfig;
|
|
26
26
|
discoveryConfig;
|
|
27
27
|
submodelService;
|
|
28
28
|
constructor(config) {
|
|
29
|
-
this.
|
|
30
|
-
this.
|
|
29
|
+
this.aasRegistryClient = new AasRegistryClient();
|
|
30
|
+
this.aasRepositoryClient = new AasRepositoryClient();
|
|
31
31
|
this.discoveryClient = new AasDiscoveryClient();
|
|
32
|
-
this.
|
|
33
|
-
this.
|
|
32
|
+
this.aasRegistryConfig = config.aasRegistryConfig;
|
|
33
|
+
this.aasRepositoryConfig = config.aasRepositoryConfig;
|
|
34
34
|
this.discoveryConfig = config.discoveryConfig;
|
|
35
35
|
// Use separate submodel configs if provided, otherwise fall back to AAS configs
|
|
36
36
|
this.submodelService = new SubmodelService({
|
|
37
|
-
|
|
38
|
-
|
|
37
|
+
submodelRegistryConfig: config.submodelRegistryConfig ?? config.aasRegistryConfig,
|
|
38
|
+
submodelRepositoryConfig: config.submodelRepositoryConfig ?? config.aasRepositoryConfig,
|
|
39
39
|
conceptDescriptionRepositoryConfig: config.conceptDescriptionRepositoryConfig,
|
|
40
40
|
});
|
|
41
41
|
}
|
|
@@ -60,9 +60,9 @@ export class AasService {
|
|
|
60
60
|
const preferRegistry = options?.preferRegistry ?? true;
|
|
61
61
|
const includeSubmodels = options?.includeSubmodels ?? false;
|
|
62
62
|
// Try registry first if configured and preferred
|
|
63
|
-
if (preferRegistry && this.
|
|
64
|
-
const registryResult = await this.
|
|
65
|
-
configuration: this.
|
|
63
|
+
if (preferRegistry && this.aasRegistryConfig) {
|
|
64
|
+
const registryResult = await this.aasRegistryClient.getAllAssetAdministrationShellDescriptors({
|
|
65
|
+
configuration: this.aasRegistryConfig,
|
|
66
66
|
limit: options?.limit,
|
|
67
67
|
cursor: options?.cursor,
|
|
68
68
|
});
|
|
@@ -75,7 +75,7 @@ export class AasService {
|
|
|
75
75
|
// Extract base URL from endpoint (remove /shells/{id} part)
|
|
76
76
|
const baseUrl = endpoint.match(/^(https?:\/\/[^/]+(?::\d+)?)/)?.[1] || endpoint;
|
|
77
77
|
const config = new Configuration({ basePath: baseUrl });
|
|
78
|
-
const shellResult = await this.
|
|
78
|
+
const shellResult = await this.aasRepositoryClient.getAssetAdministrationShellById({
|
|
79
79
|
configuration: config,
|
|
80
80
|
aasIdentifier: descriptor.id,
|
|
81
81
|
});
|
|
@@ -100,9 +100,9 @@ export class AasService {
|
|
|
100
100
|
}
|
|
101
101
|
}
|
|
102
102
|
// Fall back to repository if registry failed or not configured
|
|
103
|
-
if (this.
|
|
104
|
-
const repositoryResult = await this.
|
|
105
|
-
configuration: this.
|
|
103
|
+
if (this.aasRepositoryConfig) {
|
|
104
|
+
const repositoryResult = await this.aasRepositoryClient.getAllAssetAdministrationShells({
|
|
105
|
+
configuration: this.aasRepositoryConfig,
|
|
106
106
|
limit: options?.limit,
|
|
107
107
|
cursor: options?.cursor,
|
|
108
108
|
});
|
|
@@ -150,9 +150,9 @@ export class AasService {
|
|
|
150
150
|
async getAasById(options) {
|
|
151
151
|
const { aasIdentifier, useRegistryEndpoint = true, includeSubmodels = false } = options;
|
|
152
152
|
// Try registry-based flow first
|
|
153
|
-
if (useRegistryEndpoint && this.
|
|
154
|
-
const descriptorResult = await this.
|
|
155
|
-
configuration: this.
|
|
153
|
+
if (useRegistryEndpoint && this.aasRegistryConfig) {
|
|
154
|
+
const descriptorResult = await this.aasRegistryClient.getAssetAdministrationShellDescriptorById({
|
|
155
|
+
configuration: this.aasRegistryConfig,
|
|
156
156
|
aasIdentifier,
|
|
157
157
|
});
|
|
158
158
|
if (descriptorResult.success) {
|
|
@@ -163,7 +163,7 @@ export class AasService {
|
|
|
163
163
|
const baseUrl = endpoint.match(/^(https?:\/\/[^/]+(?::\d+)?)/)?.[1] || endpoint;
|
|
164
164
|
// Try to fetch from descriptor endpoint
|
|
165
165
|
const config = new Configuration({ basePath: baseUrl });
|
|
166
|
-
const shellResult = await this.
|
|
166
|
+
const shellResult = await this.aasRepositoryClient.getAssetAdministrationShellById({
|
|
167
167
|
configuration: config,
|
|
168
168
|
aasIdentifier,
|
|
169
169
|
});
|
|
@@ -188,7 +188,7 @@ export class AasService {
|
|
|
188
188
|
}
|
|
189
189
|
}
|
|
190
190
|
// Fall back to repository
|
|
191
|
-
if (!this.
|
|
191
|
+
if (!this.aasRepositoryConfig) {
|
|
192
192
|
return {
|
|
193
193
|
success: false,
|
|
194
194
|
error: {
|
|
@@ -197,8 +197,8 @@ export class AasService {
|
|
|
197
197
|
},
|
|
198
198
|
};
|
|
199
199
|
}
|
|
200
|
-
const shellResult = await this.
|
|
201
|
-
configuration: this.
|
|
200
|
+
const shellResult = await this.aasRepositoryClient.getAssetAdministrationShellById({
|
|
201
|
+
configuration: this.aasRepositoryConfig,
|
|
202
202
|
aasIdentifier,
|
|
203
203
|
});
|
|
204
204
|
if (shellResult.success) {
|
|
@@ -236,9 +236,9 @@ export class AasService {
|
|
|
236
236
|
async getAasEndpointById(options) {
|
|
237
237
|
const { aasIdentifier, useRegistry = true } = options;
|
|
238
238
|
// Try registry first if configured and requested
|
|
239
|
-
if (useRegistry && this.
|
|
240
|
-
const descriptorResult = await this.
|
|
241
|
-
configuration: this.
|
|
239
|
+
if (useRegistry && this.aasRegistryConfig) {
|
|
240
|
+
const descriptorResult = await this.aasRegistryClient.getAssetAdministrationShellDescriptorById({
|
|
241
|
+
configuration: this.aasRegistryConfig,
|
|
242
242
|
aasIdentifier,
|
|
243
243
|
});
|
|
244
244
|
if (descriptorResult.success) {
|
|
@@ -249,7 +249,7 @@ export class AasService {
|
|
|
249
249
|
}
|
|
250
250
|
}
|
|
251
251
|
// Fall back to constructing from repository base
|
|
252
|
-
if (!this.
|
|
252
|
+
if (!this.aasRepositoryConfig) {
|
|
253
253
|
return {
|
|
254
254
|
success: false,
|
|
255
255
|
error: {
|
|
@@ -258,7 +258,7 @@ export class AasService {
|
|
|
258
258
|
},
|
|
259
259
|
};
|
|
260
260
|
}
|
|
261
|
-
const repositoryBasePath = this.
|
|
261
|
+
const repositoryBasePath = this.aasRepositoryConfig.basePath || 'http://localhost:8081';
|
|
262
262
|
const encodedId = base64Encode(aasIdentifier);
|
|
263
263
|
const endpoint = `${repositoryBasePath}/shells/${encodedId}`;
|
|
264
264
|
return { success: true, data: endpoint };
|
|
@@ -296,7 +296,7 @@ export class AasService {
|
|
|
296
296
|
// Create configuration for the endpoint
|
|
297
297
|
const config = new Configuration({ basePath: baseUrl });
|
|
298
298
|
// Fetch the shell
|
|
299
|
-
const shellResult = await this.
|
|
299
|
+
const shellResult = await this.aasRepositoryClient.getAssetAdministrationShellById({
|
|
300
300
|
configuration: config,
|
|
301
301
|
aasIdentifier,
|
|
302
302
|
});
|
|
@@ -333,7 +333,7 @@ export class AasService {
|
|
|
333
333
|
*/
|
|
334
334
|
async createAas(options) {
|
|
335
335
|
const { shell, registerInRegistry = true } = options;
|
|
336
|
-
if (!this.
|
|
336
|
+
if (!this.aasRepositoryConfig) {
|
|
337
337
|
return {
|
|
338
338
|
success: false,
|
|
339
339
|
error: {
|
|
@@ -343,18 +343,18 @@ export class AasService {
|
|
|
343
343
|
};
|
|
344
344
|
}
|
|
345
345
|
// Create AAS in repository
|
|
346
|
-
const shellResult = await this.
|
|
347
|
-
configuration: this.
|
|
346
|
+
const shellResult = await this.aasRepositoryClient.postAssetAdministrationShell({
|
|
347
|
+
configuration: this.aasRepositoryConfig,
|
|
348
348
|
assetAdministrationShell: shell,
|
|
349
349
|
});
|
|
350
350
|
if (!shellResult.success) {
|
|
351
351
|
return { success: false, error: shellResult.error };
|
|
352
352
|
}
|
|
353
353
|
// Register descriptor in registry if configured and requested
|
|
354
|
-
if (registerInRegistry && this.
|
|
354
|
+
if (registerInRegistry && this.aasRegistryConfig) {
|
|
355
355
|
const descriptor = this.createDescriptorFromAas(shell);
|
|
356
|
-
const descriptorResult = await this.
|
|
357
|
-
configuration: this.
|
|
356
|
+
const descriptorResult = await this.aasRegistryClient.postAssetAdministrationShellDescriptor({
|
|
357
|
+
configuration: this.aasRegistryConfig,
|
|
358
358
|
assetAdministrationShellDescriptor: descriptor,
|
|
359
359
|
});
|
|
360
360
|
if (!descriptorResult.success) {
|
|
@@ -393,7 +393,7 @@ export class AasService {
|
|
|
393
393
|
*/
|
|
394
394
|
async updateAas(options) {
|
|
395
395
|
const { shell, updateInRegistry = true } = options;
|
|
396
|
-
if (!this.
|
|
396
|
+
if (!this.aasRepositoryConfig) {
|
|
397
397
|
return {
|
|
398
398
|
success: false,
|
|
399
399
|
error: {
|
|
@@ -403,8 +403,8 @@ export class AasService {
|
|
|
403
403
|
};
|
|
404
404
|
}
|
|
405
405
|
// Update AAS in repository
|
|
406
|
-
const shellResult = await this.
|
|
407
|
-
configuration: this.
|
|
406
|
+
const shellResult = await this.aasRepositoryClient.putAssetAdministrationShellById({
|
|
407
|
+
configuration: this.aasRepositoryConfig,
|
|
408
408
|
aasIdentifier: shell.id,
|
|
409
409
|
assetAdministrationShell: shell,
|
|
410
410
|
});
|
|
@@ -414,10 +414,10 @@ export class AasService {
|
|
|
414
414
|
// Use the returned shell if available, otherwise use the input shell
|
|
415
415
|
const updatedShell = shellResult.data || shell;
|
|
416
416
|
// Update descriptor in registry if configured and requested
|
|
417
|
-
if (updateInRegistry && this.
|
|
417
|
+
if (updateInRegistry && this.aasRegistryConfig) {
|
|
418
418
|
const descriptor = this.createDescriptorFromAas(shell);
|
|
419
|
-
const descriptorResult = await this.
|
|
420
|
-
configuration: this.
|
|
419
|
+
const descriptorResult = await this.aasRegistryClient.putAssetAdministrationShellDescriptorById({
|
|
420
|
+
configuration: this.aasRegistryConfig,
|
|
421
421
|
aasIdentifier: shell.id,
|
|
422
422
|
assetAdministrationShellDescriptor: descriptor,
|
|
423
423
|
});
|
|
@@ -459,9 +459,9 @@ export class AasService {
|
|
|
459
459
|
async deleteAas(options) {
|
|
460
460
|
const { aasIdentifier, deleteFromRegistry = true } = options;
|
|
461
461
|
// Remove from registry first if configured and requested
|
|
462
|
-
if (deleteFromRegistry && this.
|
|
463
|
-
const registryResult = await this.
|
|
464
|
-
configuration: this.
|
|
462
|
+
if (deleteFromRegistry && this.aasRegistryConfig) {
|
|
463
|
+
const registryResult = await this.aasRegistryClient.deleteAssetAdministrationShellDescriptorById({
|
|
464
|
+
configuration: this.aasRegistryConfig,
|
|
465
465
|
aasIdentifier,
|
|
466
466
|
});
|
|
467
467
|
if (!registryResult.success) {
|
|
@@ -469,9 +469,9 @@ export class AasService {
|
|
|
469
469
|
}
|
|
470
470
|
}
|
|
471
471
|
// Remove from repository
|
|
472
|
-
if (this.
|
|
473
|
-
const repoResult = await this.
|
|
474
|
-
configuration: this.
|
|
472
|
+
if (this.aasRepositoryConfig) {
|
|
473
|
+
const repoResult = await this.aasRepositoryClient.deleteAssetAdministrationShellById({
|
|
474
|
+
configuration: this.aasRepositoryConfig,
|
|
475
475
|
aasIdentifier,
|
|
476
476
|
});
|
|
477
477
|
if (!repoResult.success) {
|
|
@@ -673,7 +673,7 @@ export class AasService {
|
|
|
673
673
|
null // endpoints set below
|
|
674
674
|
);
|
|
675
675
|
// Set endpoint using repository base path
|
|
676
|
-
const repositoryBasePath = this.
|
|
676
|
+
const repositoryBasePath = this.aasRepositoryConfig.basePath || 'http://localhost:8081';
|
|
677
677
|
const encodedId = base64Encode(shell.id);
|
|
678
678
|
descriptor.endpoints = [
|
|
679
679
|
{
|
|
@@ -3,8 +3,8 @@ import type { ApiResult } from '../models/api';
|
|
|
3
3
|
import { Configuration } from '../generated/runtime';
|
|
4
4
|
import { SubmodelDescriptor } from '../models/Descriptors';
|
|
5
5
|
export interface SubmodelServiceConfig {
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
submodelRegistryConfig?: Configuration;
|
|
7
|
+
submodelRepositoryConfig?: Configuration;
|
|
8
8
|
conceptDescriptionRepositoryConfig?: Configuration;
|
|
9
9
|
}
|
|
10
10
|
/**
|
|
@@ -16,11 +16,11 @@ export interface SubmodelServiceConfig {
|
|
|
16
16
|
* Submodel Repository, and Concept Description Repository.
|
|
17
17
|
*/
|
|
18
18
|
export declare class SubmodelService {
|
|
19
|
-
private
|
|
20
|
-
private
|
|
19
|
+
private submodelRegistryClient;
|
|
20
|
+
private submodelRepositoryClient;
|
|
21
21
|
private conceptDescriptionClient;
|
|
22
|
-
private
|
|
23
|
-
private
|
|
22
|
+
private submodelRegistryConfig?;
|
|
23
|
+
private submodelRepositoryConfig?;
|
|
24
24
|
private conceptDescriptionRepositoryConfig?;
|
|
25
25
|
constructor(config: SubmodelServiceConfig);
|
|
26
26
|
/**
|
|
@@ -14,18 +14,18 @@ import { SubmodelDescriptor } from '../models/Descriptors';
|
|
|
14
14
|
* Submodel Repository, and Concept Description Repository.
|
|
15
15
|
*/
|
|
16
16
|
export class SubmodelService {
|
|
17
|
-
|
|
18
|
-
|
|
17
|
+
submodelRegistryClient;
|
|
18
|
+
submodelRepositoryClient;
|
|
19
19
|
conceptDescriptionClient;
|
|
20
|
-
|
|
21
|
-
|
|
20
|
+
submodelRegistryConfig;
|
|
21
|
+
submodelRepositoryConfig;
|
|
22
22
|
conceptDescriptionRepositoryConfig;
|
|
23
23
|
constructor(config) {
|
|
24
|
-
this.
|
|
25
|
-
this.
|
|
24
|
+
this.submodelRegistryClient = new SubmodelRegistryClient();
|
|
25
|
+
this.submodelRepositoryClient = new SubmodelRepositoryClient();
|
|
26
26
|
this.conceptDescriptionClient = new ConceptDescriptionRepositoryClient();
|
|
27
|
-
this.
|
|
28
|
-
this.
|
|
27
|
+
this.submodelRegistryConfig = config.submodelRegistryConfig;
|
|
28
|
+
this.submodelRepositoryConfig = config.submodelRepositoryConfig;
|
|
29
29
|
this.conceptDescriptionRepositoryConfig = config.conceptDescriptionRepositoryConfig;
|
|
30
30
|
}
|
|
31
31
|
/**
|
|
@@ -48,9 +48,9 @@ export class SubmodelService {
|
|
|
48
48
|
const preferRegistry = options?.preferRegistry ?? true;
|
|
49
49
|
const includeConceptDescriptions = options?.includeConceptDescriptions ?? false;
|
|
50
50
|
// Try registry first if configured and preferred
|
|
51
|
-
if (preferRegistry && this.
|
|
52
|
-
const registryResult = await this.
|
|
53
|
-
configuration: this.
|
|
51
|
+
if (preferRegistry && this.submodelRegistryConfig) {
|
|
52
|
+
const registryResult = await this.submodelRegistryClient.getAllSubmodelDescriptors({
|
|
53
|
+
configuration: this.submodelRegistryConfig,
|
|
54
54
|
limit: options?.limit,
|
|
55
55
|
cursor: options?.cursor,
|
|
56
56
|
});
|
|
@@ -82,9 +82,9 @@ export class SubmodelService {
|
|
|
82
82
|
}
|
|
83
83
|
}
|
|
84
84
|
// Fall back to repository if registry failed or not configured
|
|
85
|
-
if (this.
|
|
86
|
-
const repositoryResult = await this.
|
|
87
|
-
configuration: this.
|
|
85
|
+
if (this.submodelRepositoryConfig) {
|
|
86
|
+
const repositoryResult = await this.submodelRepositoryClient.getAllSubmodels({
|
|
87
|
+
configuration: this.submodelRepositoryConfig,
|
|
88
88
|
limit: options?.limit,
|
|
89
89
|
cursor: options?.cursor,
|
|
90
90
|
});
|
|
@@ -131,9 +131,9 @@ export class SubmodelService {
|
|
|
131
131
|
async getSubmodelById(options) {
|
|
132
132
|
const { submodelIdentifier, useRegistryEndpoint = true, includeConceptDescriptions = false } = options;
|
|
133
133
|
// Try registry-based flow first
|
|
134
|
-
if (useRegistryEndpoint && this.
|
|
135
|
-
const descriptorResult = await this.
|
|
136
|
-
configuration: this.
|
|
134
|
+
if (useRegistryEndpoint && this.submodelRegistryConfig) {
|
|
135
|
+
const descriptorResult = await this.submodelRegistryClient.getSubmodelDescriptorById({
|
|
136
|
+
configuration: this.submodelRegistryConfig,
|
|
137
137
|
submodelIdentifier,
|
|
138
138
|
});
|
|
139
139
|
if (descriptorResult.success) {
|
|
@@ -161,7 +161,7 @@ export class SubmodelService {
|
|
|
161
161
|
}
|
|
162
162
|
}
|
|
163
163
|
// Fall back to repository
|
|
164
|
-
if (!this.
|
|
164
|
+
if (!this.submodelRepositoryConfig) {
|
|
165
165
|
return {
|
|
166
166
|
success: false,
|
|
167
167
|
error: {
|
|
@@ -170,8 +170,8 @@ export class SubmodelService {
|
|
|
170
170
|
},
|
|
171
171
|
};
|
|
172
172
|
}
|
|
173
|
-
const submodelResult = await this.
|
|
174
|
-
configuration: this.
|
|
173
|
+
const submodelResult = await this.submodelRepositoryClient.getSubmodelById({
|
|
174
|
+
configuration: this.submodelRepositoryConfig,
|
|
175
175
|
submodelIdentifier,
|
|
176
176
|
});
|
|
177
177
|
if (submodelResult.success) {
|
|
@@ -208,9 +208,9 @@ export class SubmodelService {
|
|
|
208
208
|
async getSubmodelEndpointById(options) {
|
|
209
209
|
const { submodelIdentifier, useRegistry = true } = options;
|
|
210
210
|
// Try registry first if configured and requested
|
|
211
|
-
if (useRegistry && this.
|
|
212
|
-
const descriptorResult = await this.
|
|
213
|
-
configuration: this.
|
|
211
|
+
if (useRegistry && this.submodelRegistryConfig) {
|
|
212
|
+
const descriptorResult = await this.submodelRegistryClient.getSubmodelDescriptorById({
|
|
213
|
+
configuration: this.submodelRegistryConfig,
|
|
214
214
|
submodelIdentifier,
|
|
215
215
|
});
|
|
216
216
|
if (descriptorResult.success) {
|
|
@@ -221,7 +221,7 @@ export class SubmodelService {
|
|
|
221
221
|
}
|
|
222
222
|
}
|
|
223
223
|
// Fall back to constructing from repository base
|
|
224
|
-
if (!this.
|
|
224
|
+
if (!this.submodelRepositoryConfig) {
|
|
225
225
|
return {
|
|
226
226
|
success: false,
|
|
227
227
|
error: {
|
|
@@ -230,7 +230,7 @@ export class SubmodelService {
|
|
|
230
230
|
},
|
|
231
231
|
};
|
|
232
232
|
}
|
|
233
|
-
const repositoryBasePath = this.
|
|
233
|
+
const repositoryBasePath = this.submodelRepositoryConfig.basePath || 'http://localhost:8082';
|
|
234
234
|
const encodedId = base64Encode(submodelIdentifier);
|
|
235
235
|
const endpoint = `${repositoryBasePath}/submodels/${encodedId}`;
|
|
236
236
|
return { success: true, data: endpoint };
|
|
@@ -267,7 +267,7 @@ export class SubmodelService {
|
|
|
267
267
|
// Create configuration for the endpoint
|
|
268
268
|
const config = new Configuration({ basePath: baseUrl });
|
|
269
269
|
// Fetch the submodel
|
|
270
|
-
const submodelResult = await this.
|
|
270
|
+
const submodelResult = await this.submodelRepositoryClient.getSubmodelById({
|
|
271
271
|
configuration: config,
|
|
272
272
|
submodelIdentifier,
|
|
273
273
|
});
|
|
@@ -303,7 +303,7 @@ export class SubmodelService {
|
|
|
303
303
|
*/
|
|
304
304
|
async createSubmodel(options) {
|
|
305
305
|
const { submodel, registerInRegistry = true } = options;
|
|
306
|
-
if (!this.
|
|
306
|
+
if (!this.submodelRepositoryConfig) {
|
|
307
307
|
return {
|
|
308
308
|
success: false,
|
|
309
309
|
error: {
|
|
@@ -313,18 +313,18 @@ export class SubmodelService {
|
|
|
313
313
|
};
|
|
314
314
|
}
|
|
315
315
|
// Create Submodel in repository
|
|
316
|
-
const submodelResult = await this.
|
|
317
|
-
configuration: this.
|
|
316
|
+
const submodelResult = await this.submodelRepositoryClient.postSubmodel({
|
|
317
|
+
configuration: this.submodelRepositoryConfig,
|
|
318
318
|
submodel: submodel,
|
|
319
319
|
});
|
|
320
320
|
if (!submodelResult.success) {
|
|
321
321
|
return { success: false, error: submodelResult.error };
|
|
322
322
|
}
|
|
323
323
|
// Register descriptor in registry if configured and requested
|
|
324
|
-
if (registerInRegistry && this.
|
|
324
|
+
if (registerInRegistry && this.submodelRegistryConfig) {
|
|
325
325
|
const descriptor = this.createDescriptorFromSubmodel(submodel);
|
|
326
|
-
const descriptorResult = await this.
|
|
327
|
-
configuration: this.
|
|
326
|
+
const descriptorResult = await this.submodelRegistryClient.postSubmodelDescriptor({
|
|
327
|
+
configuration: this.submodelRegistryConfig,
|
|
328
328
|
submodelDescriptor: descriptor,
|
|
329
329
|
});
|
|
330
330
|
if (!descriptorResult.success) {
|
|
@@ -363,7 +363,7 @@ export class SubmodelService {
|
|
|
363
363
|
*/
|
|
364
364
|
async updateSubmodel(options) {
|
|
365
365
|
const { submodel, updateInRegistry = true } = options;
|
|
366
|
-
if (!this.
|
|
366
|
+
if (!this.submodelRepositoryConfig) {
|
|
367
367
|
return {
|
|
368
368
|
success: false,
|
|
369
369
|
error: {
|
|
@@ -373,8 +373,8 @@ export class SubmodelService {
|
|
|
373
373
|
};
|
|
374
374
|
}
|
|
375
375
|
// Update Submodel in repository
|
|
376
|
-
const submodelResult = await this.
|
|
377
|
-
configuration: this.
|
|
376
|
+
const submodelResult = await this.submodelRepositoryClient.putSubmodelById({
|
|
377
|
+
configuration: this.submodelRepositoryConfig,
|
|
378
378
|
submodelIdentifier: submodel.id,
|
|
379
379
|
submodel: submodel,
|
|
380
380
|
});
|
|
@@ -384,10 +384,10 @@ export class SubmodelService {
|
|
|
384
384
|
// Use the returned submodel if available, otherwise use the input submodel
|
|
385
385
|
const updatedSubmodel = submodelResult.data || submodel;
|
|
386
386
|
// Update descriptor in registry if configured and requested
|
|
387
|
-
if (updateInRegistry && this.
|
|
387
|
+
if (updateInRegistry && this.submodelRegistryConfig) {
|
|
388
388
|
const descriptor = this.createDescriptorFromSubmodel(submodel);
|
|
389
|
-
const descriptorResult = await this.
|
|
390
|
-
configuration: this.
|
|
389
|
+
const descriptorResult = await this.submodelRegistryClient.putSubmodelDescriptorById({
|
|
390
|
+
configuration: this.submodelRegistryConfig,
|
|
391
391
|
submodelIdentifier: submodel.id,
|
|
392
392
|
submodelDescriptor: descriptor,
|
|
393
393
|
});
|
|
@@ -427,9 +427,9 @@ export class SubmodelService {
|
|
|
427
427
|
async deleteSubmodel(options) {
|
|
428
428
|
const { submodelIdentifier, deleteFromRegistry = true } = options;
|
|
429
429
|
// Remove from registry first if configured and requested
|
|
430
|
-
if (deleteFromRegistry && this.
|
|
431
|
-
const registryResult = await this.
|
|
432
|
-
configuration: this.
|
|
430
|
+
if (deleteFromRegistry && this.submodelRegistryConfig) {
|
|
431
|
+
const registryResult = await this.submodelRegistryClient.deleteSubmodelDescriptorById({
|
|
432
|
+
configuration: this.submodelRegistryConfig,
|
|
433
433
|
submodelIdentifier,
|
|
434
434
|
});
|
|
435
435
|
if (!registryResult.success) {
|
|
@@ -437,9 +437,9 @@ export class SubmodelService {
|
|
|
437
437
|
}
|
|
438
438
|
}
|
|
439
439
|
// Remove from repository
|
|
440
|
-
if (this.
|
|
441
|
-
const repositoryResult = await this.
|
|
442
|
-
configuration: this.
|
|
440
|
+
if (this.submodelRepositoryConfig) {
|
|
441
|
+
const repositoryResult = await this.submodelRepositoryClient.deleteSubmodelById({
|
|
442
|
+
configuration: this.submodelRepositoryConfig,
|
|
443
443
|
submodelIdentifier,
|
|
444
444
|
});
|
|
445
445
|
if (!repositoryResult.success) {
|
|
@@ -457,7 +457,7 @@ export class SubmodelService {
|
|
|
457
457
|
*/
|
|
458
458
|
createDescriptorFromSubmodel(submodel) {
|
|
459
459
|
// Set endpoint using repository base path
|
|
460
|
-
const repositoryBasePath = this.
|
|
460
|
+
const repositoryBasePath = this.submodelRepositoryConfig.basePath || 'http://localhost:8082';
|
|
461
461
|
const encodedId = base64Encode(submodel.id);
|
|
462
462
|
const endpoints = [
|
|
463
463
|
{
|
package/package.json
CHANGED