basyx-typescript-sdk 0.1.11 → 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.
- package/README.md +13 -0
- package/bundle/index.js +157 -108
- package/bundle/index.js.map +1 -1
- package/dist/clients/AasRepositoryClient.d.ts +78 -79
- package/dist/clients/AasRepositoryClient.js +115 -107
- package/dist/index.d.ts +2 -0
- package/dist/index.js +2 -0
- package/dist/lib/base64Url.d.ts +32 -0
- package/dist/lib/base64Url.js +62 -0
- package/dist/models/aas-repository.d.ts +58 -3
- package/package.json +3 -2
|
@@ -1,31 +1,27 @@
|
|
|
1
1
|
import * as AasRepository from '../generated';
|
|
2
|
+
import { base64Encode } from '../lib/base64Url';
|
|
2
3
|
import { convertApiAasToCoreAas, convertApiAssetInformationToCoreAssetInformation, convertApiReferenceToCoreReference, convertCoreAasToApiAas, convertCoreAssetInformationToApiAssetInformation, convertCoreReferenceToApiReference, } from '../lib/convertAasTypes';
|
|
3
4
|
import { createCustomClient } from '../lib/createAasRepoClient';
|
|
4
5
|
export class AasRepositoryClient {
|
|
5
6
|
/**
|
|
6
7
|
* Returns all Asset Administration Shells
|
|
7
8
|
*
|
|
8
|
-
* @async
|
|
9
9
|
* @function getAllAssetAdministrationShells
|
|
10
|
-
* @param
|
|
11
|
-
* @param
|
|
12
|
-
* @param
|
|
13
|
-
* @param
|
|
14
|
-
* @param
|
|
15
|
-
* @param
|
|
10
|
+
* @param {GetAllAssetAdministrationShellsOptions} options - Options object.
|
|
11
|
+
* @param {string} options.baseUrl - The API base URL
|
|
12
|
+
* @param {Headers} [options.headers] - Request headers
|
|
13
|
+
* @param {string[]} [options.assetIds] - A list of specific Asset identifiers. Every single value asset identifier is a base64-url-encoded
|
|
14
|
+
* @param {string} [options.idShort] - The Asset Administration Shell's IdShort
|
|
15
|
+
* @param {number} [options.limit] - The maximum number of elements in the response array
|
|
16
|
+
* @param {string} [options.cursor] - A server-generated identifier retrieved from pagingMetadata that specifies from which position the result listing should continue
|
|
16
17
|
* @returns {Promise<GetAllAssetAdministrationShellsResponse>} Requested Asset Administration Shells
|
|
17
18
|
*/
|
|
18
|
-
async getAllAssetAdministrationShells(
|
|
19
|
+
async getAllAssetAdministrationShells({ baseUrl, headers, assetIds, idShort, limit, cursor, }) {
|
|
19
20
|
try {
|
|
20
|
-
const client = createCustomClient(
|
|
21
|
+
const client = createCustomClient(baseUrl, headers);
|
|
21
22
|
const { data, error } = await AasRepository.getAllAssetAdministrationShells({
|
|
22
23
|
client,
|
|
23
|
-
query: {
|
|
24
|
-
assetIds,
|
|
25
|
-
idShort,
|
|
26
|
-
limit,
|
|
27
|
-
cursor,
|
|
28
|
-
},
|
|
24
|
+
query: { assetIds, idShort, limit, cursor },
|
|
29
25
|
});
|
|
30
26
|
if (error) {
|
|
31
27
|
console.error('Error from server:', error);
|
|
@@ -45,16 +41,16 @@ export class AasRepositoryClient {
|
|
|
45
41
|
/**
|
|
46
42
|
* Creates a new Asset Administration Shell
|
|
47
43
|
*
|
|
48
|
-
* @async
|
|
49
44
|
* @function postAssetAdministrationShell
|
|
50
|
-
* @param
|
|
51
|
-
* @param
|
|
52
|
-
* @param
|
|
45
|
+
* @param {PostAssetAdministrationShellOptions} options - Options object.
|
|
46
|
+
* @param {string} options.baseUrl - The API base URL
|
|
47
|
+
* @param {AssetAdministrationShell} options.assetAdministrationShell - Asset Administration Shell object
|
|
48
|
+
* @param {Headers} [options.headers] - Request headers
|
|
53
49
|
* @returns {Promise<AssetAdministrationShell>} Asset Administration Shell created successfully
|
|
54
50
|
*/
|
|
55
|
-
async postAssetAdministrationShell(
|
|
51
|
+
async postAssetAdministrationShell({ baseUrl, assetAdministrationShell, headers, }) {
|
|
56
52
|
try {
|
|
57
|
-
const client = createCustomClient(
|
|
53
|
+
const client = createCustomClient(baseUrl, headers);
|
|
58
54
|
const { data, error } = await AasRepository.postAssetAdministrationShell({
|
|
59
55
|
client,
|
|
60
56
|
body: convertCoreAasToApiAas(assetAdministrationShell),
|
|
@@ -73,19 +69,20 @@ export class AasRepositoryClient {
|
|
|
73
69
|
/**
|
|
74
70
|
* Deletes an Asset Administration Shell
|
|
75
71
|
*
|
|
76
|
-
* @async
|
|
77
72
|
* @function deleteAssetAdministrationShellById
|
|
78
|
-
* @param
|
|
79
|
-
* @param
|
|
80
|
-
* @param
|
|
73
|
+
* @param {AasIdentifierOptions} options - Options object.
|
|
74
|
+
* @param {string} options.baseUrl - The API base URL
|
|
75
|
+
* @param {string} options.aasIdentifier - The Asset Administration Shell's unique id
|
|
76
|
+
* @param {Headers} [options.headers] - Request headers
|
|
81
77
|
* @returns {Promise<void>} Asset Administration Shell deleted successfully
|
|
82
78
|
*/
|
|
83
|
-
async deleteAssetAdministrationShellById(
|
|
79
|
+
async deleteAssetAdministrationShellById({ baseUrl, aasIdentifier, headers }) {
|
|
84
80
|
try {
|
|
85
|
-
const client = createCustomClient(
|
|
81
|
+
const client = createCustomClient(baseUrl, headers);
|
|
82
|
+
const encodedAasIdentifier = base64Encode(aasIdentifier);
|
|
86
83
|
const { error } = await AasRepository.deleteAssetAdministrationShellById({
|
|
87
84
|
client,
|
|
88
|
-
path: { aasIdentifier },
|
|
85
|
+
path: { aasIdentifier: encodedAasIdentifier },
|
|
89
86
|
});
|
|
90
87
|
if (error) {
|
|
91
88
|
console.error('Error from server:', error);
|
|
@@ -101,19 +98,20 @@ export class AasRepositoryClient {
|
|
|
101
98
|
/**
|
|
102
99
|
* Returns a specific Asset Administration Shell
|
|
103
100
|
*
|
|
104
|
-
* @async
|
|
105
101
|
* @function getAssetAdministrationShellById
|
|
106
|
-
* @param
|
|
107
|
-
* @param
|
|
108
|
-
* @param
|
|
102
|
+
* @param {AasIdentifierOptions} options - Options object.
|
|
103
|
+
* @param {string} options.baseUrl - The API base URL
|
|
104
|
+
* @param {string} options.aasIdentifier - The Asset Administration Shell's unique id
|
|
105
|
+
* @param {Headers} [options.headers] - Request headers
|
|
109
106
|
* @returns {Promise<AssetAdministrationShell>} Requested Asset Administration Shell
|
|
110
107
|
*/
|
|
111
|
-
async getAssetAdministrationShellById(
|
|
108
|
+
async getAssetAdministrationShellById({ baseUrl, aasIdentifier, headers, }) {
|
|
112
109
|
try {
|
|
113
|
-
const client = createCustomClient(
|
|
110
|
+
const client = createCustomClient(baseUrl, headers);
|
|
111
|
+
const encodedAasIdentifier = base64Encode(aasIdentifier);
|
|
114
112
|
const { data, error } = await AasRepository.getAssetAdministrationShellById({
|
|
115
113
|
client,
|
|
116
|
-
path: { aasIdentifier },
|
|
114
|
+
path: { aasIdentifier: encodedAasIdentifier },
|
|
117
115
|
});
|
|
118
116
|
if (error) {
|
|
119
117
|
console.error('Error from server:', error);
|
|
@@ -129,20 +127,21 @@ export class AasRepositoryClient {
|
|
|
129
127
|
/**
|
|
130
128
|
* Updates an existing Asset Administration Shell
|
|
131
129
|
*
|
|
132
|
-
* @async
|
|
133
130
|
* @function putAssetAdministrationShellById
|
|
134
|
-
* @param
|
|
135
|
-
* @param
|
|
136
|
-
* @param
|
|
137
|
-
* @param
|
|
131
|
+
* @param {PutAssetAdministrationShellOptions} options - Options object.
|
|
132
|
+
* @param {string} options.baseUrl - The API base URL
|
|
133
|
+
* @param {string} options.aasIdentifier - The Asset Administration Shell's unique id
|
|
134
|
+
* @param {AssetAdministrationShell} options.assetAdministrationShell - Asset Administration Shell object
|
|
135
|
+
* @param {Headers} [options.headers] - Request headers
|
|
138
136
|
* @returns {Promise<void>} Asset Administration Shell updated successfully
|
|
139
137
|
*/
|
|
140
|
-
async putAssetAdministrationShellById(
|
|
138
|
+
async putAssetAdministrationShellById({ baseUrl, aasIdentifier, assetAdministrationShell, headers, }) {
|
|
141
139
|
try {
|
|
142
|
-
const client = createCustomClient(
|
|
140
|
+
const client = createCustomClient(baseUrl, headers);
|
|
141
|
+
const encodedAasIdentifier = base64Encode(aasIdentifier);
|
|
143
142
|
const { error } = await AasRepository.putAssetAdministrationShellById({
|
|
144
143
|
client,
|
|
145
|
-
path: { aasIdentifier },
|
|
144
|
+
path: { aasIdentifier: encodedAasIdentifier },
|
|
146
145
|
body: convertCoreAasToApiAas(assetAdministrationShell),
|
|
147
146
|
});
|
|
148
147
|
if (error) {
|
|
@@ -159,19 +158,20 @@ export class AasRepositoryClient {
|
|
|
159
158
|
/**
|
|
160
159
|
* Returns the Asset Information
|
|
161
160
|
*
|
|
162
|
-
* @async
|
|
163
161
|
* @function getAssetInformation
|
|
164
|
-
* @param
|
|
165
|
-
* @param
|
|
166
|
-
* @param
|
|
162
|
+
* @param {AasIdentifierOptions} options - Options object.
|
|
163
|
+
* @param {string} options.baseUrl - The API base URL
|
|
164
|
+
* @param {string} options.aasIdentifier - The Asset Administration Shell's unique id
|
|
165
|
+
* @param {Headers} [options.headers] - Request headers
|
|
167
166
|
* @returns {Promise<AssetInformation>} Requested Asset Information
|
|
168
167
|
*/
|
|
169
|
-
async getAssetInformation(
|
|
168
|
+
async getAssetInformation({ baseUrl, aasIdentifier, headers }) {
|
|
170
169
|
try {
|
|
171
|
-
const client = createCustomClient(
|
|
170
|
+
const client = createCustomClient(baseUrl, headers);
|
|
171
|
+
const encodedAasIdentifier = base64Encode(aasIdentifier);
|
|
172
172
|
const { data, error } = await AasRepository.getAssetInformationAasRepository({
|
|
173
173
|
client,
|
|
174
|
-
path: { aasIdentifier },
|
|
174
|
+
path: { aasIdentifier: encodedAasIdentifier },
|
|
175
175
|
});
|
|
176
176
|
if (error) {
|
|
177
177
|
console.error('Error from server:', error);
|
|
@@ -187,20 +187,21 @@ export class AasRepositoryClient {
|
|
|
187
187
|
/**
|
|
188
188
|
* Updates the Asset Information
|
|
189
189
|
*
|
|
190
|
-
* @async
|
|
191
190
|
* @function putAssetInformation
|
|
192
|
-
* @param
|
|
193
|
-
* @param
|
|
194
|
-
* @param
|
|
195
|
-
* @param
|
|
191
|
+
* @param {PutAssetInformationOptions} options - Options object.
|
|
192
|
+
* @param {string} options.baseUrl - The API base URL
|
|
193
|
+
* @param {string} options.aasIdentifier - The Asset Administration Shell's unique id
|
|
194
|
+
* @param {AssetInformation} options.assetInformation - Asset Information object
|
|
195
|
+
* @param {Headers} [options.headers] - Request headers
|
|
196
196
|
* @returns {Promise<void>} Asset Information updated successfully
|
|
197
197
|
*/
|
|
198
|
-
async putAssetInformation(
|
|
198
|
+
async putAssetInformation({ baseUrl, aasIdentifier, assetInformation, headers, }) {
|
|
199
199
|
try {
|
|
200
|
-
const client = createCustomClient(
|
|
200
|
+
const client = createCustomClient(baseUrl, headers);
|
|
201
|
+
const encodedAasIdentifier = base64Encode(aasIdentifier);
|
|
201
202
|
const { error } = await AasRepository.putAssetInformationAasRepository({
|
|
202
203
|
client,
|
|
203
|
-
path: { aasIdentifier },
|
|
204
|
+
path: { aasIdentifier: encodedAasIdentifier },
|
|
204
205
|
body: convertCoreAssetInformationToApiAssetInformation(assetInformation),
|
|
205
206
|
});
|
|
206
207
|
if (error) {
|
|
@@ -217,19 +218,20 @@ export class AasRepositoryClient {
|
|
|
217
218
|
/**
|
|
218
219
|
* Deletes the Thumbnail
|
|
219
220
|
*
|
|
220
|
-
* @async
|
|
221
221
|
* @function deleteThumbnail
|
|
222
|
-
* @param
|
|
223
|
-
* @param
|
|
224
|
-
* @param
|
|
222
|
+
* @param {AasIdentifierOptions} options - Options object.
|
|
223
|
+
* @param {string} options.baseUrl - The API base URL
|
|
224
|
+
* @param {string} options.aasIdentifier - The Asset Administration Shell's unique id
|
|
225
|
+
* @param {Headers} [options.headers] - Request headers
|
|
225
226
|
* @returns {Promise<void>} Thumbnail deletion successful
|
|
226
227
|
*/
|
|
227
|
-
async deleteThumbnail(
|
|
228
|
+
async deleteThumbnail({ baseUrl, aasIdentifier, headers }) {
|
|
228
229
|
try {
|
|
229
|
-
const client = createCustomClient(
|
|
230
|
+
const client = createCustomClient(baseUrl, headers);
|
|
231
|
+
const encodedAasIdentifier = base64Encode(aasIdentifier);
|
|
230
232
|
const { error } = await AasRepository.deleteThumbnailAasRepository({
|
|
231
233
|
client,
|
|
232
|
-
path: { aasIdentifier },
|
|
234
|
+
path: { aasIdentifier: encodedAasIdentifier },
|
|
233
235
|
});
|
|
234
236
|
if (error) {
|
|
235
237
|
console.error('Error from server:', error);
|
|
@@ -245,19 +247,20 @@ export class AasRepositoryClient {
|
|
|
245
247
|
/**
|
|
246
248
|
* Returns the Thumbnail
|
|
247
249
|
*
|
|
248
|
-
* @async
|
|
249
250
|
* @function getThumbnail
|
|
250
|
-
* @param
|
|
251
|
-
* @param
|
|
252
|
-
* @param
|
|
251
|
+
* @param {AasIdentifierOptions} options - Options object.
|
|
252
|
+
* @param {string} options.baseUrl - The API base URL
|
|
253
|
+
* @param {string} options.aasIdentifier - The Asset Administration Shell's unique id
|
|
254
|
+
* @param {Headers} [options.headers] - Request headers
|
|
253
255
|
* @returns {Promise<Blob | File>} The thumbnail of the Asset Information.
|
|
254
256
|
*/
|
|
255
|
-
async getThumbnail(
|
|
257
|
+
async getThumbnail({ baseUrl, aasIdentifier, headers }) {
|
|
256
258
|
try {
|
|
257
|
-
const client = createCustomClient(
|
|
259
|
+
const client = createCustomClient(baseUrl, headers);
|
|
260
|
+
const encodedAasIdentifier = base64Encode(aasIdentifier);
|
|
258
261
|
const { data, error } = await AasRepository.getThumbnailAasRepository({
|
|
259
262
|
client,
|
|
260
|
-
path: { aasIdentifier },
|
|
263
|
+
path: { aasIdentifier: encodedAasIdentifier },
|
|
261
264
|
});
|
|
262
265
|
if (error) {
|
|
263
266
|
console.error('Error from server:', error);
|
|
@@ -273,20 +276,21 @@ export class AasRepositoryClient {
|
|
|
273
276
|
/**
|
|
274
277
|
* Updates the Thumbnail
|
|
275
278
|
*
|
|
276
|
-
* @async
|
|
277
279
|
* @function putThumbnail
|
|
278
|
-
* @param
|
|
279
|
-
* @param
|
|
280
|
-
* @param
|
|
281
|
-
* @param
|
|
280
|
+
* @param {PutThumbnailOptions} options - Options object.
|
|
281
|
+
* @param {string} options.baseUrl - The API base URL
|
|
282
|
+
* @param {string} options.aasIdentifier - The Asset Administration Shell's unique id
|
|
283
|
+
* @param {AssetinformationThumbnailBody} options.thumbnail - Thumbnail to upload
|
|
284
|
+
* @param {Headers} [options.headers] - Request headers
|
|
282
285
|
* @returns {Promise<void>} Thumbnail updated successfully
|
|
283
286
|
*/
|
|
284
|
-
async putThumbnail(
|
|
287
|
+
async putThumbnail({ baseUrl, aasIdentifier, thumbnail, headers }) {
|
|
285
288
|
try {
|
|
286
|
-
const client = createCustomClient(
|
|
289
|
+
const client = createCustomClient(baseUrl, headers);
|
|
290
|
+
const encodedAasIdentifier = base64Encode(aasIdentifier);
|
|
287
291
|
const { error } = await AasRepository.putThumbnailAasRepository({
|
|
288
292
|
client,
|
|
289
|
-
path: { aasIdentifier },
|
|
293
|
+
path: { aasIdentifier: encodedAasIdentifier },
|
|
290
294
|
body: thumbnail,
|
|
291
295
|
});
|
|
292
296
|
if (error) {
|
|
@@ -303,21 +307,22 @@ export class AasRepositoryClient {
|
|
|
303
307
|
/**
|
|
304
308
|
* Returns all submodel references
|
|
305
309
|
*
|
|
306
|
-
* @async
|
|
307
310
|
* @function getAllSubmodelReferences
|
|
308
|
-
* @param
|
|
309
|
-
* @param
|
|
310
|
-
* @param
|
|
311
|
-
* @param
|
|
312
|
-
* @param
|
|
313
|
-
* @
|
|
311
|
+
* @param {GetAllSubmodelReferencesOptions} options - Options object.
|
|
312
|
+
* @param {string} options.baseUrl - The API base URL
|
|
313
|
+
* @param {string} options.aasIdentifier - The Asset Administration Shell's unique id
|
|
314
|
+
* @param {Headers} [options.headers] - Request headers
|
|
315
|
+
* @param {number} [options.limit] - The maximum number of elements in the response array
|
|
316
|
+
* @param {string} [options.cursor] - A server-generated identifier retrieved from pagingMetadata that specifies from which position the result listing should continue
|
|
317
|
+
* @returns {Promise<GetAllSubmodelReferencesResponse>} Requested submodel references
|
|
314
318
|
*/
|
|
315
|
-
async getAllSubmodelReferences(
|
|
319
|
+
async getAllSubmodelReferences({ baseUrl, aasIdentifier, headers, limit, cursor, }) {
|
|
316
320
|
try {
|
|
317
|
-
const client = createCustomClient(
|
|
321
|
+
const client = createCustomClient(baseUrl, headers);
|
|
322
|
+
const encodedAasIdentifier = base64Encode(aasIdentifier);
|
|
318
323
|
const { data, error } = await AasRepository.getAllSubmodelReferencesAasRepository({
|
|
319
324
|
client,
|
|
320
|
-
path: { aasIdentifier },
|
|
325
|
+
path: { aasIdentifier: encodedAasIdentifier },
|
|
321
326
|
query: {
|
|
322
327
|
limit,
|
|
323
328
|
cursor,
|
|
@@ -341,20 +346,21 @@ export class AasRepositoryClient {
|
|
|
341
346
|
/**
|
|
342
347
|
* Creates a submodel reference at the Asset Administration Shell
|
|
343
348
|
*
|
|
344
|
-
* @async
|
|
345
349
|
* @function postSubmodelReference
|
|
346
|
-
* @param
|
|
347
|
-
* @param
|
|
348
|
-
* @param
|
|
349
|
-
* @param
|
|
350
|
-
* @
|
|
350
|
+
* @param {PostSubmodelReferenceOptions} options - Options object.
|
|
351
|
+
* @param {string} options.baseUrl - The API base URL
|
|
352
|
+
* @param {string} options.aasIdentifier - The Asset Administration Shell's unique id
|
|
353
|
+
* @param {Reference} options.submodelReference - Reference to the Submodel
|
|
354
|
+
* @param {Headers} [options.headers] - Request headers
|
|
355
|
+
* @returns {Promise<Reference>} Submodel reference created successfully
|
|
351
356
|
*/
|
|
352
|
-
async postSubmodelReference(
|
|
357
|
+
async postSubmodelReference({ baseUrl, aasIdentifier, submodelReference, headers, }) {
|
|
353
358
|
try {
|
|
354
|
-
const client = createCustomClient(
|
|
359
|
+
const client = createCustomClient(baseUrl, headers);
|
|
360
|
+
const encodedAasIdentifier = base64Encode(aasIdentifier);
|
|
355
361
|
const { data, error } = await AasRepository.postSubmodelReferenceAasRepository({
|
|
356
362
|
client,
|
|
357
|
-
path: { aasIdentifier },
|
|
363
|
+
path: { aasIdentifier: encodedAasIdentifier },
|
|
358
364
|
body: convertCoreReferenceToApiReference(submodelReference),
|
|
359
365
|
});
|
|
360
366
|
if (error) {
|
|
@@ -371,20 +377,22 @@ export class AasRepositoryClient {
|
|
|
371
377
|
/**
|
|
372
378
|
* Deletes the submodel reference from the Asset Administration Shell. Does not delete the submodel itself!
|
|
373
379
|
*
|
|
374
|
-
* @async
|
|
375
380
|
* @function deleteSubmodelReferenceById
|
|
376
|
-
* @param
|
|
377
|
-
* @param
|
|
378
|
-
* @param
|
|
379
|
-
* @param
|
|
381
|
+
* @param {DeleteSubmodelReferenceByIdOptions} options - Options object.
|
|
382
|
+
* @param {string} options.baseUrl - The API base URL
|
|
383
|
+
* @param {string} options.aasIdentifier - The Asset Administration Shell's unique id
|
|
384
|
+
* @param {string} options.submodelIdentifier - The Submodel's unique id
|
|
385
|
+
* @param {Headers} [options.headers] - Request headers
|
|
380
386
|
* @returns {Promise<void>} Submodel reference deleted successfully
|
|
381
387
|
*/
|
|
382
|
-
async deleteSubmodelReferenceById(
|
|
388
|
+
async deleteSubmodelReferenceById({ baseUrl, aasIdentifier, submodelIdentifier, headers, }) {
|
|
383
389
|
try {
|
|
384
|
-
const client = createCustomClient(
|
|
390
|
+
const client = createCustomClient(baseUrl, headers);
|
|
391
|
+
const encodedAasIdentifier = base64Encode(aasIdentifier);
|
|
392
|
+
const encodedSubmodelIdentifier = base64Encode(submodelIdentifier);
|
|
385
393
|
const { error } = await AasRepository.deleteSubmodelReferenceByIdAasRepository({
|
|
386
394
|
client,
|
|
387
|
-
path: { aasIdentifier, submodelIdentifier },
|
|
395
|
+
path: { aasIdentifier: encodedAasIdentifier, submodelIdentifier: encodedSubmodelIdentifier },
|
|
388
396
|
});
|
|
389
397
|
if (error) {
|
|
390
398
|
console.error('Error from server:', error);
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -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
|
+
}
|
|
@@ -1,10 +1,65 @@
|
|
|
1
|
-
import type { AssetAdministrationShell, Reference } from '@aas-core-works/aas-core3.0-typescript/types';
|
|
2
|
-
import type { PagedResultPagingMetadata } from '../generated/types.gen';
|
|
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
|
+
}
|
|
3
11
|
export interface GetAllAssetAdministrationShellsResponse {
|
|
4
12
|
pagedResult: PagedResultPagingMetadata | undefined;
|
|
5
13
|
result: AssetAdministrationShell[] | undefined;
|
|
6
14
|
}
|
|
7
|
-
export interface
|
|
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 {
|
|
8
63
|
pagedResult: PagedResultPagingMetadata | undefined;
|
|
9
64
|
result: Reference[] | undefined;
|
|
10
65
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "basyx-typescript-sdk",
|
|
3
|
-
"version": "0.
|
|
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",
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
"lint:check": "eslint ./",
|
|
28
28
|
"lint:fix": "eslint --fix ./",
|
|
29
29
|
"test": "jest --coverage",
|
|
30
|
-
"
|
|
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
|
}
|