@ai-sdk-tool/parser 4.0.0 → 4.0.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/dist/{chunk-CXWS24JX.js → chunk-76E6H46R.js} +2 -2
- package/dist/{chunk-2KK5BDZF.js → chunk-DJB4DAZO.js} +23 -6
- package/dist/chunk-DJB4DAZO.js.map +1 -0
- package/dist/{chunk-ERJKQKCR.js → chunk-DPGORNPB.js} +17 -7
- package/dist/chunk-DPGORNPB.js.map +1 -0
- package/dist/community.cjs +36 -9
- package/dist/community.cjs.map +1 -1
- package/dist/community.js +3 -3
- package/dist/index.cjs +36 -9
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +3 -3
- package/dist/rxml.cjs +22 -5
- package/dist/rxml.cjs.map +1 -1
- package/dist/rxml.js +2 -2
- package/dist/schema-coerce.cjs +22 -5
- package/dist/schema-coerce.cjs.map +1 -1
- package/dist/schema-coerce.js +1 -1
- package/package.json +1 -1
- package/dist/chunk-2KK5BDZF.js.map +0 -1
- package/dist/chunk-ERJKQKCR.js.map +0 -1
- /package/dist/{chunk-CXWS24JX.js.map → chunk-76E6H46R.js.map} +0 -0
package/dist/index.js
CHANGED
|
@@ -27,16 +27,16 @@ import {
|
|
|
27
27
|
xmlToolMiddleware,
|
|
28
28
|
yamlProtocol,
|
|
29
29
|
yamlToolMiddleware
|
|
30
|
-
} from "./chunk-
|
|
30
|
+
} from "./chunk-DPGORNPB.js";
|
|
31
31
|
import {
|
|
32
32
|
escapeRegExp
|
|
33
|
-
} from "./chunk-
|
|
33
|
+
} from "./chunk-76E6H46R.js";
|
|
34
34
|
import {
|
|
35
35
|
parse,
|
|
36
36
|
stringify,
|
|
37
37
|
transform
|
|
38
38
|
} from "./chunk-IX4FJELL.js";
|
|
39
|
-
import "./chunk-
|
|
39
|
+
import "./chunk-DJB4DAZO.js";
|
|
40
40
|
export {
|
|
41
41
|
createDynamicIfThenElseSchema,
|
|
42
42
|
createToolMiddleware,
|
package/dist/rxml.cjs
CHANGED
|
@@ -586,13 +586,20 @@ function coerceStringWithoutSchema(value) {
|
|
|
586
586
|
}
|
|
587
587
|
function coerceStringToObject(s, unwrapped) {
|
|
588
588
|
try {
|
|
589
|
-
|
|
590
|
-
normalized = normalized.replace(EMPTY_OBJECT_REGEX, "{}");
|
|
591
|
-
const obj = JSON.parse(normalized);
|
|
589
|
+
const obj = JSON.parse(s);
|
|
592
590
|
if (obj && typeof obj === "object" && !Array.isArray(obj)) {
|
|
593
591
|
return coerceObjectToObject(obj, unwrapped);
|
|
594
592
|
}
|
|
595
593
|
} catch (e) {
|
|
594
|
+
try {
|
|
595
|
+
let normalized = s.replace(/'/g, '"');
|
|
596
|
+
normalized = normalized.replace(EMPTY_OBJECT_REGEX, "{}");
|
|
597
|
+
const obj = JSON.parse(normalized);
|
|
598
|
+
if (obj && typeof obj === "object" && !Array.isArray(obj)) {
|
|
599
|
+
return coerceObjectToObject(obj, unwrapped);
|
|
600
|
+
}
|
|
601
|
+
} catch (e2) {
|
|
602
|
+
}
|
|
596
603
|
}
|
|
597
604
|
return null;
|
|
598
605
|
}
|
|
@@ -600,8 +607,7 @@ function coerceStringToArray(s, unwrapped) {
|
|
|
600
607
|
const prefixItems = Array.isArray(unwrapped.prefixItems) ? unwrapped.prefixItems : void 0;
|
|
601
608
|
const itemsSchema = unwrapped.items;
|
|
602
609
|
try {
|
|
603
|
-
const
|
|
604
|
-
const arr = JSON.parse(normalized);
|
|
610
|
+
const arr = JSON.parse(s);
|
|
605
611
|
if (Array.isArray(arr)) {
|
|
606
612
|
if (prefixItems && arr.length === prefixItems.length) {
|
|
607
613
|
return arr.map((v, i) => coerceBySchema(v, prefixItems[i]));
|
|
@@ -609,6 +615,17 @@ function coerceStringToArray(s, unwrapped) {
|
|
|
609
615
|
return arr.map((v) => coerceBySchema(v, itemsSchema));
|
|
610
616
|
}
|
|
611
617
|
} catch (e) {
|
|
618
|
+
try {
|
|
619
|
+
const normalized = s.replace(/'/g, '"');
|
|
620
|
+
const arr = JSON.parse(normalized);
|
|
621
|
+
if (Array.isArray(arr)) {
|
|
622
|
+
if (prefixItems && arr.length === prefixItems.length) {
|
|
623
|
+
return arr.map((v, i) => coerceBySchema(v, prefixItems[i]));
|
|
624
|
+
}
|
|
625
|
+
return arr.map((v) => coerceBySchema(v, itemsSchema));
|
|
626
|
+
}
|
|
627
|
+
} catch (e2) {
|
|
628
|
+
}
|
|
612
629
|
const csv = s.includes("\n") ? s.split(NEWLINE_SPLIT_REGEX) : s.split(COMMA_SPLIT_REGEX);
|
|
613
630
|
const trimmed = csv.map((x) => x.trim()).filter((x) => x.length > 0);
|
|
614
631
|
if (prefixItems && trimmed.length === prefixItems.length) {
|