basyx-typescript-sdk 2.1.0 → 2.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.
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsonization } from '@aas-core-works/aas-core3.1-typescript';
|
|
2
|
-
import { AdministrativeInformation, AnnotatedRelationshipElement, AssetAdministrationShell, AssetInformation, AssetKind, BasicEventElement, Blob, Capability, ConceptDescription, DataSpecificationIec61360,
|
|
2
|
+
import { AdministrativeInformation, AnnotatedRelationshipElement, AssetAdministrationShell, AssetInformation, AssetKind, BasicEventElement, Blob, Capability, ConceptDescription, DataSpecificationIec61360, EmbeddedDataSpecification, Entity, Extension, File, Key, KeyTypes, LangStringDefinitionTypeIec61360, LangStringNameType, LangStringPreferredNameTypeIec61360, LangStringShortNameTypeIec61360, LangStringTextType, LevelType, MultiLanguageProperty, Operation, OperationVariable, Property, Qualifier, Range, Reference, ReferenceElement, ReferenceTypes, RelationshipElement, Resource, SpecificAssetId, Submodel, SubmodelElementCollection, SubmodelElementList, ValueList, ValueReferencePair, } from '@aas-core-works/aas-core3.1-typescript/types';
|
|
3
3
|
import { buildObject, buildXmlNode, parseXmlString, serializeXml as serializeXmlNode } from 'xml-sax-ts';
|
|
4
4
|
import { BaSyxEnvironment } from '../../models/BaSyxEnvironment';
|
|
5
5
|
export function serializeXml(data, namespacePrefix = 'aas') {
|
|
@@ -882,7 +882,11 @@ export function deserializeXml(xmlString) {
|
|
|
882
882
|
if (!xmlString || xmlString.trim() === '') {
|
|
883
883
|
return new BaSyxEnvironment();
|
|
884
884
|
}
|
|
885
|
-
const rootNode = parseXmlString(xmlString
|
|
885
|
+
const rootNode = parseXmlString(xmlString, {
|
|
886
|
+
// Merge adjacent text callbacks and skip line/column tracking for faster parse.
|
|
887
|
+
coalesceText: true,
|
|
888
|
+
trackPosition: false,
|
|
889
|
+
});
|
|
886
890
|
const parsed = buildObject(rootNode, {
|
|
887
891
|
stripNamespaces: true,
|
|
888
892
|
arrayElements: ARRAY_ELEMENTS,
|
|
@@ -930,6 +934,24 @@ const ARRAY_ELEMENTS = new Set([
|
|
|
930
934
|
'qualifier',
|
|
931
935
|
'operationVariable',
|
|
932
936
|
]);
|
|
937
|
+
function parseDataTypeDefXsd(dataType) {
|
|
938
|
+
if (dataType === undefined || dataType === null || dataType === '') {
|
|
939
|
+
return undefined;
|
|
940
|
+
}
|
|
941
|
+
if (typeof dataType !== 'string' || !dataType.startsWith('xs:')) {
|
|
942
|
+
throw new Error(`Invalid literal of DataTypeDefXsd: ${String(dataType)}`);
|
|
943
|
+
}
|
|
944
|
+
const result = jsonization.dataTypeDefXsdFromJsonable(dataType);
|
|
945
|
+
if (result.error !== null || result.value === null) {
|
|
946
|
+
const errorMessage = typeof result.error === 'string'
|
|
947
|
+
? result.error
|
|
948
|
+
: typeof result.error?.message === 'string'
|
|
949
|
+
? result.error.message
|
|
950
|
+
: `Invalid literal of DataTypeDefXsd: ${dataType}`;
|
|
951
|
+
throw new Error(errorMessage);
|
|
952
|
+
}
|
|
953
|
+
return result.value;
|
|
954
|
+
}
|
|
933
955
|
function parseAssetAdministrationShell(data) {
|
|
934
956
|
return new AssetAdministrationShell(data.id, parseAssetInformation(data.assetInformation), data.extensions?.extension ? data.extensions.extension.map(parseExtension) : undefined, data.category || undefined, data.idShort || undefined, data.displayName?.langStringNameType
|
|
935
957
|
? data.displayName.langStringNameType.map(parseLangStringNameType)
|
|
@@ -940,15 +962,7 @@ function parseAssetAdministrationShell(data) {
|
|
|
940
962
|
: undefined, data.derivedFrom ? parseReference(data.derivedFrom) : undefined, data.submodels?.reference ? data.submodels.reference.map(parseReference) : undefined);
|
|
941
963
|
}
|
|
942
964
|
function parseExtension(data) {
|
|
943
|
-
|
|
944
|
-
let valueType = data.valueType || undefined;
|
|
945
|
-
if (valueType && typeof valueType === 'string' && valueType.startsWith('xs:')) {
|
|
946
|
-
// Extract the type after 'xs:' prefix and map to enum
|
|
947
|
-
const typeValue = valueType.substring(3);
|
|
948
|
-
const capitalizedType = typeValue.charAt(0).toUpperCase() + typeValue.slice(1);
|
|
949
|
-
// Map string to DataTypeDefXsd enum value
|
|
950
|
-
valueType = DataTypeDefXsd[capitalizedType];
|
|
951
|
-
}
|
|
965
|
+
const valueType = parseDataTypeDefXsd(data.valueType);
|
|
952
966
|
return new Extension(data.name, data.semanticId ? parseReference(data.semanticId) : undefined, data.supplementalSemanticIds?.reference
|
|
953
967
|
? data.supplementalSemanticIds.reference.map(parseReference)
|
|
954
968
|
: undefined, valueType, data.value || undefined, data.refersTo?.reference ? data.refersTo.reference.map(parseReference) : undefined);
|
|
@@ -1056,15 +1070,7 @@ function parseSubmodel(data) {
|
|
|
1056
1070
|
: undefined, data.submodelElements ? parseSubmodelElements(data.submodelElements) : undefined);
|
|
1057
1071
|
}
|
|
1058
1072
|
function parseQualifier(data) {
|
|
1059
|
-
|
|
1060
|
-
let valueType = data.valueType || undefined;
|
|
1061
|
-
if (valueType && typeof valueType === 'string') {
|
|
1062
|
-
// Convert string to enum value using jsonization (expects xs: prefix)
|
|
1063
|
-
const result = jsonization.dataTypeDefXsdFromJsonable(valueType);
|
|
1064
|
-
if (result.error === null && result.value !== null) {
|
|
1065
|
-
valueType = result.value;
|
|
1066
|
-
}
|
|
1067
|
-
}
|
|
1073
|
+
const valueType = parseDataTypeDefXsd(data.valueType);
|
|
1068
1074
|
return new Qualifier(data.type, valueType, data.semanticId ? parseReference(data.semanticId) : undefined, data.supplementalSemanticIds?.reference
|
|
1069
1075
|
? data.supplementalSemanticIds.reference.map(parseReference)
|
|
1070
1076
|
: undefined, data.kind ? (jsonization.qualifierKindFromJsonable(data.kind).value ?? data.kind) : undefined, data.value || undefined, data.valueId ? parseReference(data.valueId) : undefined);
|
|
@@ -1097,15 +1103,7 @@ function parseSubmodelElements(data) {
|
|
|
1097
1103
|
return elements;
|
|
1098
1104
|
}
|
|
1099
1105
|
function parseProperty(data) {
|
|
1100
|
-
|
|
1101
|
-
let valueType = data.valueType || undefined;
|
|
1102
|
-
if (valueType && typeof valueType === 'string') {
|
|
1103
|
-
// Convert string to enum value using jsonization (expects xs: prefix)
|
|
1104
|
-
const result = jsonization.dataTypeDefXsdFromJsonable(valueType);
|
|
1105
|
-
if (result.error === null && result.value !== null) {
|
|
1106
|
-
valueType = result.value;
|
|
1107
|
-
}
|
|
1108
|
-
}
|
|
1106
|
+
const valueType = parseDataTypeDefXsd(data.valueType);
|
|
1109
1107
|
return new Property(valueType, data.extensions?.extension ? ensureArray(data.extensions.extension).map(parseExtension) : undefined, data.category || undefined, data.idShort || undefined, data.displayName?.langStringNameType
|
|
1110
1108
|
? ensureArray(data.displayName.langStringNameType).map(parseLangStringNameType)
|
|
1111
1109
|
: undefined, data.description?.langStringTextType
|
|
@@ -1128,15 +1126,7 @@ function parseMultiLanguageProperty(data) {
|
|
|
1128
1126
|
: undefined, data.value?.langStringTextType ? data.value.langStringTextType.map(parseLangStringTextType) : undefined, data.valueId ? parseReference(data.valueId) : undefined);
|
|
1129
1127
|
}
|
|
1130
1128
|
function parseRange(data) {
|
|
1131
|
-
|
|
1132
|
-
let valueType = data.valueType || undefined;
|
|
1133
|
-
if (valueType && typeof valueType === 'string') {
|
|
1134
|
-
// Convert string to enum value using jsonization (expects xs: prefix)
|
|
1135
|
-
const result = jsonization.dataTypeDefXsdFromJsonable(valueType);
|
|
1136
|
-
if (result.error === null && result.value !== null) {
|
|
1137
|
-
valueType = result.value;
|
|
1138
|
-
}
|
|
1139
|
-
}
|
|
1129
|
+
const valueType = parseDataTypeDefXsd(data.valueType);
|
|
1140
1130
|
return new Range(valueType, data.extensions?.extension ? data.extensions.extension.map(parseExtension) : undefined, data.category || undefined, data.idShort || undefined, data.displayName?.langStringNameType
|
|
1141
1131
|
? data.displayName.langStringNameType.map(parseLangStringNameType)
|
|
1142
1132
|
: undefined, data.description?.langStringTextType
|
|
@@ -1242,7 +1232,7 @@ function parseSubmodelElementList(data) {
|
|
|
1242
1232
|
? data.supplementalSemanticIds.reference.map(parseReference)
|
|
1243
1233
|
: undefined, data.qualifiers?.qualifier ? data.qualifiers.qualifier.map(parseQualifier) : undefined, data.embeddedDataSpecifications?.embeddedDataSpecification
|
|
1244
1234
|
? data.embeddedDataSpecifications.embeddedDataSpecification.map(parseEmbeddedDataSpecification)
|
|
1245
|
-
: undefined, data.orderRelevant !== undefined ? data.orderRelevant === 'true' || data.orderRelevant === true : undefined, data.semanticIdListElement ? parseReference(data.semanticIdListElement) : undefined, data.valueTypeListElement
|
|
1235
|
+
: undefined, data.orderRelevant !== undefined ? data.orderRelevant === 'true' || data.orderRelevant === true : undefined, data.semanticIdListElement ? parseReference(data.semanticIdListElement) : undefined, parseDataTypeDefXsd(data.valueTypeListElement), data.value ? parseSubmodelElements(data.value) : undefined);
|
|
1246
1236
|
}
|
|
1247
1237
|
function parseOperation(data) {
|
|
1248
1238
|
const ensureArray = (val) => (Array.isArray(val) ? val : val ? [val] : []);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "basyx-typescript-sdk",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.2",
|
|
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",
|
|
@@ -41,13 +41,14 @@
|
|
|
41
41
|
},
|
|
42
42
|
"devDependencies": {
|
|
43
43
|
"@aas-core-works/aas-core3.1-typescript": "^1.0.0",
|
|
44
|
+
"@eslint/js": "^10.0.1",
|
|
44
45
|
"@openapitools/openapi-generator-cli": "^2.18.4",
|
|
45
46
|
"@rollup/plugin-node-resolve": "^16.0.0",
|
|
46
47
|
"@types/jest": "^30.0.0",
|
|
47
48
|
"@types/node": "^25.0.0",
|
|
48
49
|
"@typescript-eslint/eslint-plugin": "^8.21.0",
|
|
49
50
|
"@typescript-eslint/parser": "^8.20.0",
|
|
50
|
-
"eslint": "^
|
|
51
|
+
"eslint": "^10.0.0",
|
|
51
52
|
"eslint-config-prettier": "^10.0.1",
|
|
52
53
|
"eslint-plugin-prettier": "^5.2.3",
|
|
53
54
|
"eslint-plugin-simple-import-sort": "^12.1.1",
|
|
@@ -64,6 +65,6 @@
|
|
|
64
65
|
"typescript-eslint": "^8.21.0"
|
|
65
66
|
},
|
|
66
67
|
"dependencies": {
|
|
67
|
-
"xml-sax-ts": "^0.
|
|
68
|
+
"xml-sax-ts": "^0.4.0"
|
|
68
69
|
}
|
|
69
70
|
}
|