@ai-sdk-tool/parser 3.3.0 → 3.3.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-3QJVNEHE.js → chunk-7E6UFDFQ.js} +3 -3
- package/dist/{chunk-TR2ARLIF.js → chunk-EW3A6Y7O.js} +2 -2
- package/dist/{chunk-DZB6Y354.js → chunk-OUGMLYAW.js} +167 -18
- package/dist/chunk-OUGMLYAW.js.map +1 -0
- package/dist/community.cjs +166 -17
- package/dist/community.cjs.map +1 -1
- package/dist/community.js +3 -3
- package/dist/index.cjs +166 -17
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +3 -3
- package/dist/rxml.cjs +166 -17
- package/dist/rxml.cjs.map +1 -1
- package/dist/rxml.js +2 -2
- package/dist/schema-coerce.cjs +166 -17
- package/dist/schema-coerce.cjs.map +1 -1
- package/dist/schema-coerce.js +1 -1
- package/package.json +2 -2
- package/dist/chunk-DZB6Y354.js.map +0 -1
- /package/dist/{chunk-3QJVNEHE.js.map → chunk-7E6UFDFQ.js.map} +0 -0
- /package/dist/{chunk-TR2ARLIF.js.map → chunk-EW3A6Y7O.js.map} +0 -0
package/dist/community.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
2
|
createToolMiddleware,
|
|
3
3
|
xmlProtocol
|
|
4
|
-
} from "./chunk-
|
|
5
|
-
import "./chunk-
|
|
4
|
+
} from "./chunk-7E6UFDFQ.js";
|
|
5
|
+
import "./chunk-EW3A6Y7O.js";
|
|
6
6
|
import "./chunk-IX4FJELL.js";
|
|
7
|
-
import "./chunk-
|
|
7
|
+
import "./chunk-OUGMLYAW.js";
|
|
8
8
|
|
|
9
9
|
// src/community/sijawara.ts
|
|
10
10
|
var sijawaraDetailedXmlToolMiddleware = createToolMiddleware({
|
package/dist/index.cjs
CHANGED
|
@@ -1618,6 +1618,153 @@ function getSchemaType(schema) {
|
|
|
1618
1618
|
}
|
|
1619
1619
|
return;
|
|
1620
1620
|
}
|
|
1621
|
+
function schemaAllowsPropertyViaCombinators(s, key, depth) {
|
|
1622
|
+
const anyOfValues = s.anyOf;
|
|
1623
|
+
const oneOfValues = s.oneOf;
|
|
1624
|
+
const allOfValues = s.allOf;
|
|
1625
|
+
let hasCombinator = false;
|
|
1626
|
+
let anyOfAllows = true;
|
|
1627
|
+
let oneOfAllows = true;
|
|
1628
|
+
let allOfAllows = true;
|
|
1629
|
+
if (Array.isArray(anyOfValues)) {
|
|
1630
|
+
hasCombinator = true;
|
|
1631
|
+
anyOfAllows = anyOfValues.some(
|
|
1632
|
+
(sub) => schemaHasProperty(sub, key, depth + 1)
|
|
1633
|
+
);
|
|
1634
|
+
}
|
|
1635
|
+
if (Array.isArray(oneOfValues)) {
|
|
1636
|
+
hasCombinator = true;
|
|
1637
|
+
oneOfAllows = oneOfValues.some(
|
|
1638
|
+
(sub) => schemaHasProperty(sub, key, depth + 1)
|
|
1639
|
+
);
|
|
1640
|
+
}
|
|
1641
|
+
if (Array.isArray(allOfValues)) {
|
|
1642
|
+
hasCombinator = true;
|
|
1643
|
+
allOfAllows = allOfValues.every(
|
|
1644
|
+
(sub) => schemaHasProperty(sub, key, depth + 1)
|
|
1645
|
+
);
|
|
1646
|
+
}
|
|
1647
|
+
if (!hasCombinator) {
|
|
1648
|
+
return false;
|
|
1649
|
+
}
|
|
1650
|
+
return anyOfAllows && oneOfAllows && allOfAllows;
|
|
1651
|
+
}
|
|
1652
|
+
function schemaHasPropertyDirectly(s, key) {
|
|
1653
|
+
const props = s.properties;
|
|
1654
|
+
if (props && typeof props === "object" && !Array.isArray(props) && Object.hasOwn(props, key) && props[key] !== false) {
|
|
1655
|
+
return true;
|
|
1656
|
+
}
|
|
1657
|
+
const required = s.required;
|
|
1658
|
+
if (Array.isArray(required) && required.includes(key)) {
|
|
1659
|
+
return true;
|
|
1660
|
+
}
|
|
1661
|
+
const patternSchemas = getPatternSchemasForKey(s.patternProperties, key);
|
|
1662
|
+
return patternSchemas.some((schema) => schema !== false);
|
|
1663
|
+
}
|
|
1664
|
+
function schemaHasPropertyViaAdditional(s) {
|
|
1665
|
+
const additional = s.additionalProperties;
|
|
1666
|
+
if (additional === true || additional && typeof additional === "object" && !Array.isArray(additional)) {
|
|
1667
|
+
return true;
|
|
1668
|
+
}
|
|
1669
|
+
if (Object.hasOwn(s, "additionalProperties")) {
|
|
1670
|
+
return false;
|
|
1671
|
+
}
|
|
1672
|
+
const type = s.type;
|
|
1673
|
+
const isObjectType = type === "object" || Array.isArray(type) && type.includes("object");
|
|
1674
|
+
const hasObjectKeywords = s.properties && typeof s.properties === "object" && !Array.isArray(s.properties) || s.patternProperties && typeof s.patternProperties === "object" && !Array.isArray(s.patternProperties) || Array.isArray(s.required) && s.required.length > 0;
|
|
1675
|
+
return !!(isObjectType || hasObjectKeywords);
|
|
1676
|
+
}
|
|
1677
|
+
function schemaDisallowsPropertyDirectly(s, key) {
|
|
1678
|
+
const props = s.properties;
|
|
1679
|
+
if (props && typeof props === "object" && !Array.isArray(props) && Object.hasOwn(props, key) && props[key] === false) {
|
|
1680
|
+
return true;
|
|
1681
|
+
}
|
|
1682
|
+
const patternSchemas = getPatternSchemasForKey(s.patternProperties, key);
|
|
1683
|
+
return patternSchemas.some((schema) => schema === false);
|
|
1684
|
+
}
|
|
1685
|
+
function schemaHasProperty(schema, key, depth = 0) {
|
|
1686
|
+
if (depth > 5) {
|
|
1687
|
+
return true;
|
|
1688
|
+
}
|
|
1689
|
+
const unwrapped = unwrapJsonSchema(schema);
|
|
1690
|
+
if (schemaIsUnconstrained(unwrapped)) {
|
|
1691
|
+
return true;
|
|
1692
|
+
}
|
|
1693
|
+
if (!unwrapped || typeof unwrapped !== "object") {
|
|
1694
|
+
return false;
|
|
1695
|
+
}
|
|
1696
|
+
const s = unwrapped;
|
|
1697
|
+
if (schemaDisallowsPropertyDirectly(s, key)) {
|
|
1698
|
+
return false;
|
|
1699
|
+
}
|
|
1700
|
+
if (schemaHasPropertyDirectly(s, key)) {
|
|
1701
|
+
return true;
|
|
1702
|
+
}
|
|
1703
|
+
if (schemaHasPropertyViaAdditional(s)) {
|
|
1704
|
+
return true;
|
|
1705
|
+
}
|
|
1706
|
+
return schemaAllowsPropertyViaCombinators(s, key, depth);
|
|
1707
|
+
}
|
|
1708
|
+
function schemaIsUnconstrained(schema) {
|
|
1709
|
+
const unwrapped = unwrapJsonSchema(schema);
|
|
1710
|
+
if (unwrapped == null || unwrapped === true) {
|
|
1711
|
+
return true;
|
|
1712
|
+
}
|
|
1713
|
+
if (typeof unwrapped !== "object" || Array.isArray(unwrapped)) {
|
|
1714
|
+
return false;
|
|
1715
|
+
}
|
|
1716
|
+
return Object.keys(unwrapped).length === 0;
|
|
1717
|
+
}
|
|
1718
|
+
function getPatternSchemasForKey(patternProperties, key) {
|
|
1719
|
+
if (!patternProperties || typeof patternProperties !== "object" || Array.isArray(patternProperties)) {
|
|
1720
|
+
return [];
|
|
1721
|
+
}
|
|
1722
|
+
const schemas = [];
|
|
1723
|
+
for (const [pattern, schema] of Object.entries(
|
|
1724
|
+
patternProperties
|
|
1725
|
+
)) {
|
|
1726
|
+
try {
|
|
1727
|
+
const regex = new RegExp(pattern);
|
|
1728
|
+
if (regex.test(key)) {
|
|
1729
|
+
schemas.push(schema);
|
|
1730
|
+
}
|
|
1731
|
+
} catch (e) {
|
|
1732
|
+
}
|
|
1733
|
+
}
|
|
1734
|
+
return schemas;
|
|
1735
|
+
}
|
|
1736
|
+
function coerceValueForKey(value, key, unwrapped) {
|
|
1737
|
+
const schemas = [];
|
|
1738
|
+
const props = unwrapped.properties;
|
|
1739
|
+
if (props && Object.hasOwn(props, key)) {
|
|
1740
|
+
schemas.push(props[key]);
|
|
1741
|
+
}
|
|
1742
|
+
const patternSchemas = getPatternSchemasForKey(
|
|
1743
|
+
unwrapped.patternProperties,
|
|
1744
|
+
key
|
|
1745
|
+
);
|
|
1746
|
+
if (patternSchemas.length > 0) {
|
|
1747
|
+
schemas.push(...patternSchemas);
|
|
1748
|
+
}
|
|
1749
|
+
if (schemas.length > 0) {
|
|
1750
|
+
let out = value;
|
|
1751
|
+
for (const schema of schemas) {
|
|
1752
|
+
if (typeof schema === "boolean") {
|
|
1753
|
+
continue;
|
|
1754
|
+
}
|
|
1755
|
+
out = coerceBySchema(out, schema);
|
|
1756
|
+
}
|
|
1757
|
+
return out;
|
|
1758
|
+
}
|
|
1759
|
+
const additional = unwrapped.additionalProperties;
|
|
1760
|
+
if (additional && typeof additional === "object" && !Array.isArray(additional)) {
|
|
1761
|
+
return coerceBySchema(value, additional);
|
|
1762
|
+
}
|
|
1763
|
+
if (additional === true || additional === false) {
|
|
1764
|
+
return value;
|
|
1765
|
+
}
|
|
1766
|
+
return coerceBySchema(value, void 0);
|
|
1767
|
+
}
|
|
1621
1768
|
function coerceStringWithoutSchema(value) {
|
|
1622
1769
|
const s = value.trim();
|
|
1623
1770
|
const lower = s.toLowerCase();
|
|
@@ -1648,13 +1795,7 @@ function coerceStringToObject(s, unwrapped) {
|
|
|
1648
1795
|
normalized = normalized.replace(EMPTY_OBJECT_REGEX, "{}");
|
|
1649
1796
|
const obj = JSON.parse(normalized);
|
|
1650
1797
|
if (obj && typeof obj === "object" && !Array.isArray(obj)) {
|
|
1651
|
-
|
|
1652
|
-
const out = {};
|
|
1653
|
-
for (const [k, v] of Object.entries(obj)) {
|
|
1654
|
-
const propSchema = props ? props[k] : void 0;
|
|
1655
|
-
out[k] = typeof propSchema === "boolean" ? v : coerceBySchema(v, propSchema);
|
|
1656
|
-
}
|
|
1657
|
-
return out;
|
|
1798
|
+
return coerceObjectToObject(obj, unwrapped);
|
|
1658
1799
|
}
|
|
1659
1800
|
} catch (e) {
|
|
1660
1801
|
}
|
|
@@ -1684,10 +1825,8 @@ function coerceStringToArray(s, unwrapped) {
|
|
|
1684
1825
|
}
|
|
1685
1826
|
function coerceObjectToObject(value, unwrapped) {
|
|
1686
1827
|
const out = {};
|
|
1687
|
-
const props = unwrapped.properties;
|
|
1688
1828
|
for (const [k, v] of Object.entries(value)) {
|
|
1689
|
-
|
|
1690
|
-
out[k] = typeof propSchema === "boolean" ? v : coerceBySchema(v, propSchema);
|
|
1829
|
+
out[k] = coerceValueForKey(v, k, unwrapped);
|
|
1691
1830
|
}
|
|
1692
1831
|
return out;
|
|
1693
1832
|
}
|
|
@@ -1704,16 +1843,22 @@ function coerceObjectToArray(maybe, prefixItems, itemsSchema) {
|
|
|
1704
1843
|
return coerceArrayToArray(arr, prefixItems, itemsSchema);
|
|
1705
1844
|
}
|
|
1706
1845
|
const keys = Object.keys(maybe);
|
|
1707
|
-
if (keys.length === 1) {
|
|
1708
|
-
const singleValue = maybe[keys[0]];
|
|
1709
|
-
if (Array.isArray(singleValue)) {
|
|
1710
|
-
return singleValue.map((v) => coerceBySchema(v, itemsSchema));
|
|
1711
|
-
}
|
|
1712
|
-
}
|
|
1713
1846
|
if (keys.length > 0 && keys.every((k) => DIGIT_KEY_REGEX.test(k))) {
|
|
1714
1847
|
const arr = keys.sort((a, b) => Number(a) - Number(b)).map((k) => maybe[k]);
|
|
1715
1848
|
return coerceArrayToArray(arr, prefixItems, itemsSchema);
|
|
1716
1849
|
}
|
|
1850
|
+
if (keys.length === 1) {
|
|
1851
|
+
const singleKey = keys[0];
|
|
1852
|
+
if (!(schemaIsUnconstrained(itemsSchema) || schemaHasProperty(itemsSchema, singleKey))) {
|
|
1853
|
+
const singleValue = maybe[singleKey];
|
|
1854
|
+
if (Array.isArray(singleValue)) {
|
|
1855
|
+
return singleValue.map((v) => coerceBySchema(v, itemsSchema));
|
|
1856
|
+
}
|
|
1857
|
+
if (singleValue && typeof singleValue === "object") {
|
|
1858
|
+
return [coerceBySchema(singleValue, itemsSchema)];
|
|
1859
|
+
}
|
|
1860
|
+
}
|
|
1861
|
+
}
|
|
1717
1862
|
return null;
|
|
1718
1863
|
}
|
|
1719
1864
|
function coercePrimitiveToArray(value, prefixItems, itemsSchema) {
|
|
@@ -1773,11 +1918,15 @@ function coerceArrayValue(value, prefixItems, itemsSchema) {
|
|
|
1773
1918
|
if (result !== null) {
|
|
1774
1919
|
return result;
|
|
1775
1920
|
}
|
|
1921
|
+
if (getSchemaType(itemsSchema) === "array") {
|
|
1922
|
+
return [value];
|
|
1923
|
+
}
|
|
1924
|
+
return [coerceBySchema(value, itemsSchema)];
|
|
1776
1925
|
}
|
|
1777
1926
|
if (value == null || typeof value === "string" || typeof value === "number" || typeof value === "boolean") {
|
|
1778
1927
|
return coercePrimitiveToArray(value, prefixItems, itemsSchema);
|
|
1779
1928
|
}
|
|
1780
|
-
return value;
|
|
1929
|
+
return [value];
|
|
1781
1930
|
}
|
|
1782
1931
|
function coerceBySchema(value, schema) {
|
|
1783
1932
|
const unwrapped = unwrapJsonSchema(schema);
|