@coasys/ad4m 0.11.0 → 0.11.1
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/lib/index.cjs +46 -18
- package/lib/index.js +46 -18
- package/lib/src/model/Ad4mModel.js +46 -18
- package/package.json +1 -1
- package/src/model/Ad4mModel.ts +41 -17
package/lib/index.cjs
CHANGED
|
@@ -18846,27 +18846,55 @@ WHERE ${whereConditions.join(' AND ')}
|
|
|
18846
18846
|
const isEmptyObject = typeof currentValue === 'object' && currentValue !== null && !Array.isArray(currentValue) && Object.keys(currentValue).length === 0;
|
|
18847
18847
|
if (!currentValue || currentValue === "" || currentValue === 0 || isEmptyObject) {
|
|
18848
18848
|
let convertedValue = target;
|
|
18849
|
-
//
|
|
18850
|
-
if (
|
|
18851
|
-
|
|
18852
|
-
|
|
18853
|
-
|
|
18854
|
-
|
|
18849
|
+
// Only process if target has a value
|
|
18850
|
+
if (target !== undefined && target !== null) {
|
|
18851
|
+
// Check if we need to resolve a non-literal language expression
|
|
18852
|
+
if (propMeta.resolveLanguage != undefined && propMeta.resolveLanguage !== 'literal' && typeof target === 'string') {
|
|
18853
|
+
// For non-literal languages, resolve the expression via perspective.getExpression()
|
|
18854
|
+
// Note: Literals are already parsed by SurrealDB's fn::parse_literal()
|
|
18855
|
+
try {
|
|
18856
|
+
const expression = await perspective.getExpression(target);
|
|
18857
|
+
if (expression) {
|
|
18858
|
+
// Parse the expression data if it's a JSON string
|
|
18859
|
+
try {
|
|
18860
|
+
convertedValue = JSON.parse(expression.data);
|
|
18861
|
+
}
|
|
18862
|
+
catch {
|
|
18863
|
+
// If parsing fails, use the data as-is
|
|
18864
|
+
convertedValue = expression.data;
|
|
18865
|
+
}
|
|
18866
|
+
}
|
|
18867
|
+
}
|
|
18868
|
+
catch (e) {
|
|
18869
|
+
console.warn(`Failed to resolve expression for ${propName}:`, e);
|
|
18870
|
+
convertedValue = target; // Fall back to raw value
|
|
18855
18871
|
}
|
|
18856
18872
|
}
|
|
18857
|
-
|
|
18858
|
-
|
|
18859
|
-
|
|
18860
|
-
|
|
18861
|
-
|
|
18862
|
-
|
|
18863
|
-
|
|
18864
|
-
|
|
18865
|
-
|
|
18866
|
-
|
|
18873
|
+
else if (typeof target === 'string' && target.startsWith('literal://')) {
|
|
18874
|
+
// Fallback: If we somehow got a literal URL that wasn't parsed by SurrealDB, parse it now
|
|
18875
|
+
try {
|
|
18876
|
+
const parsed = Literal.fromUrl(target).get();
|
|
18877
|
+
if (parsed.data !== undefined) {
|
|
18878
|
+
convertedValue = parsed.data;
|
|
18879
|
+
}
|
|
18880
|
+
else {
|
|
18881
|
+
convertedValue = parsed;
|
|
18882
|
+
}
|
|
18883
|
+
}
|
|
18884
|
+
catch (e) {
|
|
18885
|
+
// If literal parsing fails, just use the value as-is (don't bail)
|
|
18886
|
+
convertedValue = target;
|
|
18887
|
+
}
|
|
18867
18888
|
}
|
|
18868
|
-
else if (
|
|
18869
|
-
|
|
18889
|
+
else if (typeof target === 'string') {
|
|
18890
|
+
// Type conversion: check the instance property's current type
|
|
18891
|
+
const expectedType = typeof instance[propName];
|
|
18892
|
+
if (expectedType === 'number') {
|
|
18893
|
+
convertedValue = Number(target);
|
|
18894
|
+
}
|
|
18895
|
+
else if (expectedType === 'boolean') {
|
|
18896
|
+
convertedValue = target === 'true' || target === '1';
|
|
18897
|
+
}
|
|
18870
18898
|
}
|
|
18871
18899
|
}
|
|
18872
18900
|
// Apply transform function if it exists
|
package/lib/index.js
CHANGED
|
@@ -18842,27 +18842,55 @@ WHERE ${whereConditions.join(' AND ')}
|
|
|
18842
18842
|
const isEmptyObject = typeof currentValue === 'object' && currentValue !== null && !Array.isArray(currentValue) && Object.keys(currentValue).length === 0;
|
|
18843
18843
|
if (!currentValue || currentValue === "" || currentValue === 0 || isEmptyObject) {
|
|
18844
18844
|
let convertedValue = target;
|
|
18845
|
-
//
|
|
18846
|
-
if (
|
|
18847
|
-
|
|
18848
|
-
|
|
18849
|
-
|
|
18850
|
-
|
|
18845
|
+
// Only process if target has a value
|
|
18846
|
+
if (target !== undefined && target !== null) {
|
|
18847
|
+
// Check if we need to resolve a non-literal language expression
|
|
18848
|
+
if (propMeta.resolveLanguage != undefined && propMeta.resolveLanguage !== 'literal' && typeof target === 'string') {
|
|
18849
|
+
// For non-literal languages, resolve the expression via perspective.getExpression()
|
|
18850
|
+
// Note: Literals are already parsed by SurrealDB's fn::parse_literal()
|
|
18851
|
+
try {
|
|
18852
|
+
const expression = await perspective.getExpression(target);
|
|
18853
|
+
if (expression) {
|
|
18854
|
+
// Parse the expression data if it's a JSON string
|
|
18855
|
+
try {
|
|
18856
|
+
convertedValue = JSON.parse(expression.data);
|
|
18857
|
+
}
|
|
18858
|
+
catch {
|
|
18859
|
+
// If parsing fails, use the data as-is
|
|
18860
|
+
convertedValue = expression.data;
|
|
18861
|
+
}
|
|
18862
|
+
}
|
|
18863
|
+
}
|
|
18864
|
+
catch (e) {
|
|
18865
|
+
console.warn(`Failed to resolve expression for ${propName}:`, e);
|
|
18866
|
+
convertedValue = target; // Fall back to raw value
|
|
18851
18867
|
}
|
|
18852
18868
|
}
|
|
18853
|
-
|
|
18854
|
-
|
|
18855
|
-
|
|
18856
|
-
|
|
18857
|
-
|
|
18858
|
-
|
|
18859
|
-
|
|
18860
|
-
|
|
18861
|
-
|
|
18862
|
-
|
|
18869
|
+
else if (typeof target === 'string' && target.startsWith('literal://')) {
|
|
18870
|
+
// Fallback: If we somehow got a literal URL that wasn't parsed by SurrealDB, parse it now
|
|
18871
|
+
try {
|
|
18872
|
+
const parsed = Literal.fromUrl(target).get();
|
|
18873
|
+
if (parsed.data !== undefined) {
|
|
18874
|
+
convertedValue = parsed.data;
|
|
18875
|
+
}
|
|
18876
|
+
else {
|
|
18877
|
+
convertedValue = parsed;
|
|
18878
|
+
}
|
|
18879
|
+
}
|
|
18880
|
+
catch (e) {
|
|
18881
|
+
// If literal parsing fails, just use the value as-is (don't bail)
|
|
18882
|
+
convertedValue = target;
|
|
18883
|
+
}
|
|
18863
18884
|
}
|
|
18864
|
-
else if (
|
|
18865
|
-
|
|
18885
|
+
else if (typeof target === 'string') {
|
|
18886
|
+
// Type conversion: check the instance property's current type
|
|
18887
|
+
const expectedType = typeof instance[propName];
|
|
18888
|
+
if (expectedType === 'number') {
|
|
18889
|
+
convertedValue = Number(target);
|
|
18890
|
+
}
|
|
18891
|
+
else if (expectedType === 'boolean') {
|
|
18892
|
+
convertedValue = target === 'true' || target === '1';
|
|
18893
|
+
}
|
|
18866
18894
|
}
|
|
18867
18895
|
}
|
|
18868
18896
|
// Apply transform function if it exists
|
|
@@ -1109,27 +1109,55 @@ WHERE ${whereConditions.join(' AND ')}
|
|
|
1109
1109
|
const isEmptyObject = typeof currentValue === 'object' && currentValue !== null && !Array.isArray(currentValue) && Object.keys(currentValue).length === 0;
|
|
1110
1110
|
if (!currentValue || currentValue === "" || currentValue === 0 || isEmptyObject) {
|
|
1111
1111
|
let convertedValue = target;
|
|
1112
|
-
//
|
|
1113
|
-
if (
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1112
|
+
// Only process if target has a value
|
|
1113
|
+
if (target !== undefined && target !== null) {
|
|
1114
|
+
// Check if we need to resolve a non-literal language expression
|
|
1115
|
+
if (propMeta.resolveLanguage != undefined && propMeta.resolveLanguage !== 'literal' && typeof target === 'string') {
|
|
1116
|
+
// For non-literal languages, resolve the expression via perspective.getExpression()
|
|
1117
|
+
// Note: Literals are already parsed by SurrealDB's fn::parse_literal()
|
|
1118
|
+
try {
|
|
1119
|
+
const expression = await perspective.getExpression(target);
|
|
1120
|
+
if (expression) {
|
|
1121
|
+
// Parse the expression data if it's a JSON string
|
|
1122
|
+
try {
|
|
1123
|
+
convertedValue = JSON.parse(expression.data);
|
|
1124
|
+
}
|
|
1125
|
+
catch {
|
|
1126
|
+
// If parsing fails, use the data as-is
|
|
1127
|
+
convertedValue = expression.data;
|
|
1128
|
+
}
|
|
1129
|
+
}
|
|
1130
|
+
}
|
|
1131
|
+
catch (e) {
|
|
1132
|
+
console.warn(`Failed to resolve expression for ${propName}:`, e);
|
|
1133
|
+
convertedValue = target; // Fall back to raw value
|
|
1118
1134
|
}
|
|
1119
1135
|
}
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1136
|
+
else if (typeof target === 'string' && target.startsWith('literal://')) {
|
|
1137
|
+
// Fallback: If we somehow got a literal URL that wasn't parsed by SurrealDB, parse it now
|
|
1138
|
+
try {
|
|
1139
|
+
const parsed = Literal.fromUrl(target).get();
|
|
1140
|
+
if (parsed.data !== undefined) {
|
|
1141
|
+
convertedValue = parsed.data;
|
|
1142
|
+
}
|
|
1143
|
+
else {
|
|
1144
|
+
convertedValue = parsed;
|
|
1145
|
+
}
|
|
1146
|
+
}
|
|
1147
|
+
catch (e) {
|
|
1148
|
+
// If literal parsing fails, just use the value as-is (don't bail)
|
|
1149
|
+
convertedValue = target;
|
|
1150
|
+
}
|
|
1130
1151
|
}
|
|
1131
|
-
else if (
|
|
1132
|
-
|
|
1152
|
+
else if (typeof target === 'string') {
|
|
1153
|
+
// Type conversion: check the instance property's current type
|
|
1154
|
+
const expectedType = typeof instance[propName];
|
|
1155
|
+
if (expectedType === 'number') {
|
|
1156
|
+
convertedValue = Number(target);
|
|
1157
|
+
}
|
|
1158
|
+
else if (expectedType === 'boolean') {
|
|
1159
|
+
convertedValue = target === 'true' || target === '1';
|
|
1160
|
+
}
|
|
1133
1161
|
}
|
|
1134
1162
|
}
|
|
1135
1163
|
// Apply transform function if it exists
|
package/package.json
CHANGED
package/src/model/Ad4mModel.ts
CHANGED
|
@@ -1319,24 +1319,48 @@ WHERE ${whereConditions.join(' AND ')}
|
|
|
1319
1319
|
if (!currentValue || currentValue === "" || currentValue === 0 || isEmptyObject) {
|
|
1320
1320
|
let convertedValue = target;
|
|
1321
1321
|
|
|
1322
|
-
//
|
|
1323
|
-
if (
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1322
|
+
// Only process if target has a value
|
|
1323
|
+
if (target !== undefined && target !== null) {
|
|
1324
|
+
// Check if we need to resolve a non-literal language expression
|
|
1325
|
+
if (propMeta.resolveLanguage != undefined && propMeta.resolveLanguage !== 'literal' && typeof target === 'string') {
|
|
1326
|
+
// For non-literal languages, resolve the expression via perspective.getExpression()
|
|
1327
|
+
// Note: Literals are already parsed by SurrealDB's fn::parse_literal()
|
|
1328
|
+
try {
|
|
1329
|
+
const expression = await perspective.getExpression(target);
|
|
1330
|
+
if (expression) {
|
|
1331
|
+
// Parse the expression data if it's a JSON string
|
|
1332
|
+
try {
|
|
1333
|
+
convertedValue = JSON.parse(expression.data);
|
|
1334
|
+
} catch {
|
|
1335
|
+
// If parsing fails, use the data as-is
|
|
1336
|
+
convertedValue = expression.data;
|
|
1337
|
+
}
|
|
1338
|
+
}
|
|
1339
|
+
} catch (e) {
|
|
1340
|
+
console.warn(`Failed to resolve expression for ${propName}:`, e);
|
|
1341
|
+
convertedValue = target; // Fall back to raw value
|
|
1342
|
+
}
|
|
1343
|
+
} else if (typeof target === 'string' && target.startsWith('literal://')) {
|
|
1344
|
+
// Fallback: If we somehow got a literal URL that wasn't parsed by SurrealDB, parse it now
|
|
1345
|
+
try {
|
|
1346
|
+
const parsed = Literal.fromUrl(target).get();
|
|
1347
|
+
if(parsed.data !== undefined) {
|
|
1348
|
+
convertedValue = parsed.data;
|
|
1349
|
+
} else {
|
|
1350
|
+
convertedValue = parsed;
|
|
1351
|
+
}
|
|
1352
|
+
} catch (e) {
|
|
1353
|
+
// If literal parsing fails, just use the value as-is (don't bail)
|
|
1354
|
+
convertedValue = target;
|
|
1355
|
+
}
|
|
1356
|
+
} else if (typeof target === 'string') {
|
|
1357
|
+
// Type conversion: check the instance property's current type
|
|
1358
|
+
const expectedType = typeof instance[propName];
|
|
1359
|
+
if (expectedType === 'number') {
|
|
1360
|
+
convertedValue = Number(target);
|
|
1361
|
+
} else if (expectedType === 'boolean') {
|
|
1362
|
+
convertedValue = target === 'true' || target === '1';
|
|
1328
1363
|
}
|
|
1329
|
-
} catch (e) {
|
|
1330
|
-
console.warn(`Failed to parse literal URL for ${propName}:`, e);
|
|
1331
|
-
convertedValue = target; // Fall back to raw value
|
|
1332
|
-
}
|
|
1333
|
-
} else {
|
|
1334
|
-
// Type conversion: check the instance property's current type
|
|
1335
|
-
const expectedType = typeof instance[propName];
|
|
1336
|
-
if (expectedType === 'number' && typeof target === 'string') {
|
|
1337
|
-
convertedValue = Number(target);
|
|
1338
|
-
} else if (expectedType === 'boolean' && typeof target === 'string') {
|
|
1339
|
-
convertedValue = target === 'true' || target === '1';
|
|
1340
1364
|
}
|
|
1341
1365
|
}
|
|
1342
1366
|
|