@ecomweb/sdk 0.4.0 → 0.5.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/dist/index.js CHANGED
@@ -1463,6 +1463,1259 @@ function isSettingVisible(setting, values) {
1463
1463
  return value !== rule.not_equals;
1464
1464
  }
1465
1465
 
1466
+ // src/types/metafield-engine.ts
1467
+ var METAFIELD_OWNER_TYPES = [
1468
+ "product",
1469
+ "variant",
1470
+ "collection",
1471
+ "customer",
1472
+ "order",
1473
+ "page",
1474
+ "blog_post",
1475
+ "location",
1476
+ "shop"
1477
+ ];
1478
+ var METAFIELD_BASE_TYPES = [
1479
+ "single_line_text",
1480
+ "multi_line_text",
1481
+ "rich_text",
1482
+ "email",
1483
+ "integer",
1484
+ "decimal",
1485
+ "date",
1486
+ "date_time",
1487
+ "url",
1488
+ "link",
1489
+ "weight",
1490
+ "volume",
1491
+ "dimension",
1492
+ "boolean",
1493
+ "color",
1494
+ "rating",
1495
+ "money",
1496
+ "language",
1497
+ "json",
1498
+ "file",
1499
+ "image",
1500
+ "video",
1501
+ "product",
1502
+ "variant",
1503
+ "collection",
1504
+ "page",
1505
+ "blog_post",
1506
+ "customer",
1507
+ "order",
1508
+ "metaobject_reference",
1509
+ "mixed_reference"
1510
+ ];
1511
+ var BASE_TYPE_SET = new Set(METAFIELD_BASE_TYPES);
1512
+ function isMetafieldType(value) {
1513
+ if (typeof value !== "string") return false;
1514
+ const base2 = value.startsWith("list.") ? value.slice(5) : value;
1515
+ return BASE_TYPE_SET.has(base2);
1516
+ }
1517
+ function isListType(type) {
1518
+ return type.startsWith("list.");
1519
+ }
1520
+ function baseTypeOf(type) {
1521
+ return isListType(type) ? type.slice(5) : type;
1522
+ }
1523
+ var METAFIELD_TYPE_GROUPS = [
1524
+ {
1525
+ group: "text",
1526
+ types: ["single_line_text", "multi_line_text", "rich_text", "email"]
1527
+ },
1528
+ { group: "media", types: ["file", "image", "video"] },
1529
+ {
1530
+ group: "reference",
1531
+ types: [
1532
+ "blog_post",
1533
+ "collection",
1534
+ "customer",
1535
+ "metaobject_reference",
1536
+ "order",
1537
+ "page",
1538
+ "product",
1539
+ "variant"
1540
+ ]
1541
+ },
1542
+ { group: "link", types: ["link", "url"] },
1543
+ { group: "date_time", types: ["date", "date_time"] },
1544
+ { group: "number", types: ["integer", "decimal", "rating", "money"] },
1545
+ { group: "measurement", types: ["weight", "volume", "dimension"] },
1546
+ { group: "other", types: ["boolean", "color", "language"] },
1547
+ { group: "advanced", types: ["json", "mixed_reference"] }
1548
+ ];
1549
+ var RESOURCE_REFERENCE_TYPES = [
1550
+ "product",
1551
+ "variant",
1552
+ "collection",
1553
+ "page",
1554
+ "blog_post",
1555
+ "customer",
1556
+ "order"
1557
+ ];
1558
+ var METAOBJECT_REFERENCE_TYPES = [
1559
+ "metaobject_reference",
1560
+ "mixed_reference"
1561
+ ];
1562
+ var MEDIA_TYPES = ["file", "image", "video"];
1563
+ var PRIVATE_REFERENCE_TYPES = ["customer", "order"];
1564
+ var METAFIELD_LIMITS = {
1565
+ definitions_per_owner_type: 100,
1566
+ pinned_per_owner_type: 20,
1567
+ metaobject_definitions: 100,
1568
+ fields_per_metaobject: 40,
1569
+ filter_keys: 5,
1570
+ value_bytes: 65536,
1571
+ list_items: 128,
1572
+ choices: 128,
1573
+ allowed_domains: 20,
1574
+ regex_length: 200,
1575
+ regex_value_length: 500,
1576
+ single_line_text_length: 5e3,
1577
+ multi_line_text_length: 65e3,
1578
+ link_text_length: 255,
1579
+ email_length: 254,
1580
+ name_length: 255,
1581
+ description_length: 5e3,
1582
+ mixed_reference_definitions_min: 2,
1583
+ mixed_reference_definitions_max: 10
1584
+ };
1585
+ function issue(path, code, message) {
1586
+ return { path, code, message };
1587
+ }
1588
+ function ok(value) {
1589
+ return { ok: true, value };
1590
+ }
1591
+ function fail(path, code, message) {
1592
+ return { ok: false, errors: [issue(path, code, message)] };
1593
+ }
1594
+ function joinPath(base2, segment) {
1595
+ if (typeof segment === "number") return `${base2}[${segment}]`;
1596
+ return base2 ? `${base2}.${segment}` : segment;
1597
+ }
1598
+ function isPlainObject(value) {
1599
+ return typeof value === "object" && value !== null && !Array.isArray(value);
1600
+ }
1601
+ function hasOwn(object, key) {
1602
+ return Object.prototype.hasOwnProperty.call(object, key);
1603
+ }
1604
+ function unknownKeys(object, allowed, path) {
1605
+ return Object.keys(object).filter((key) => !allowed.includes(key)).map((key) => issue(joinPath(path, key), "unknown_key", `unknown key "${key}"`));
1606
+ }
1607
+ function codePoints(text) {
1608
+ return [...text].length;
1609
+ }
1610
+ var METAFIELD_KEY_PATTERN = /^[a-z0-9_]{2,64}$/;
1611
+ var METAOBJECT_TYPE_PATTERN = /^[a-z0-9_-]{2,64}$/;
1612
+ var ENTRY_HANDLE_PATTERN = /^[a-z0-9-]{1,255}$/;
1613
+ function asciiFold(text) {
1614
+ return text.normalize("NFD").replace(/[\u0300-\u036f]/g, "").replace(/\u0111/g, "d").replace(/\u0110/g, "D");
1615
+ }
1616
+ function slugify(text, separator, max) {
1617
+ const edge = new RegExp(`^${separator}+|${separator}+$`, "g");
1618
+ return asciiFold(text).toLowerCase().replace(/[^a-z0-9]+/g, separator).replace(edge, "").slice(0, max).replace(edge, "");
1619
+ }
1620
+ function toMetafieldKey(text) {
1621
+ return slugify(text, "_", 64);
1622
+ }
1623
+ function toEntryHandle(text) {
1624
+ const handle = slugify(text, "-", 255);
1625
+ return RESERVED_KEYS.includes(handle) ? "" : handle;
1626
+ }
1627
+ function isValidEntryHandle(handle) {
1628
+ return ENTRY_HANDLE_PATTERN.test(handle) && !RESERVED_KEYS.includes(handle);
1629
+ }
1630
+ function metafieldIdentifier(namespace, key) {
1631
+ return `${namespace}.${key}`;
1632
+ }
1633
+ var RESERVED_KEYS = ["__proto__", "constructor", "prototype"];
1634
+ function parseMetafieldIdentifier(identifier) {
1635
+ const parts = identifier.split(".");
1636
+ if (parts.length !== 2) return null;
1637
+ const [namespace, key] = parts;
1638
+ if (!METAFIELD_KEY_PATTERN.test(namespace) || !METAFIELD_KEY_PATTERN.test(key)) {
1639
+ return null;
1640
+ }
1641
+ if (RESERVED_KEYS.includes(namespace) || RESERVED_KEYS.includes(key)) return null;
1642
+ return { namespace, key };
1643
+ }
1644
+ function matchesPattern(pattern, text) {
1645
+ try {
1646
+ return new RegExp("^(?:" + pattern + ")$", "u").test(text);
1647
+ } catch {
1648
+ return false;
1649
+ }
1650
+ }
1651
+ function textChecker(limit, singleLine) {
1652
+ return (value, v, _ctx, path) => {
1653
+ if (typeof value !== "string") return fail(path, "invalid_type", "must be text");
1654
+ if (singleLine && /[\r\n]/.test(value)) {
1655
+ return fail(path, "invalid_format", "must be a single line");
1656
+ }
1657
+ const length = codePoints(value);
1658
+ const cap = v.regex !== void 0 ? Math.min(limit, METAFIELD_LIMITS.regex_value_length) : limit;
1659
+ const max = Math.min(cap, v.max_length ?? cap);
1660
+ if (length > max) return fail(path, "too_long", `must be at most ${max} characters`);
1661
+ if (v.min_length !== void 0 && length < v.min_length) {
1662
+ return fail(path, "too_short", `must be at least ${v.min_length} characters`);
1663
+ }
1664
+ if (v.regex !== void 0 && !matchesPattern(v.regex, value)) {
1665
+ return fail(path, "pattern_mismatch", "does not match the required pattern");
1666
+ }
1667
+ if (v.choices !== void 0 && !v.choices.includes(value)) {
1668
+ return fail(path, "not_a_choice", `must be one of: ${v.choices.join(", ")}`);
1669
+ }
1670
+ return ok(value);
1671
+ };
1672
+ }
1673
+ var EMAIL = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
1674
+ var checkEmail = (value, _v, _ctx, path) => {
1675
+ if (typeof value !== "string") return fail(path, "invalid_type", "must be text");
1676
+ const email = value.trim().toLowerCase();
1677
+ if (email.length > METAFIELD_LIMITS.email_length || !EMAIL.test(email)) {
1678
+ return fail(path, "invalid_format", "must be an email address");
1679
+ }
1680
+ return ok(email);
1681
+ };
1682
+ var checkInteger = (value, v, _ctx, path) => {
1683
+ if (typeof value !== "number" || !Number.isSafeInteger(value)) {
1684
+ return fail(path, "invalid_type", "must be a whole number");
1685
+ }
1686
+ if (typeof v.min === "number" && value < v.min) {
1687
+ return fail(path, "too_small", `must be at least ${v.min}`);
1688
+ }
1689
+ if (typeof v.max === "number" && value > v.max) {
1690
+ return fail(path, "too_big", `must be at most ${v.max}`);
1691
+ }
1692
+ return ok(value === 0 ? 0 : value);
1693
+ };
1694
+ var DECIMAL_INPUT = /^[+-]?\d+(\.\d+)?$/;
1695
+ function normalizeDecimal(input) {
1696
+ let text;
1697
+ if (typeof input === "number") {
1698
+ if (!Number.isFinite(input)) return null;
1699
+ text = String(input);
1700
+ } else if (typeof input === "string") {
1701
+ text = input.trim();
1702
+ } else {
1703
+ return null;
1704
+ }
1705
+ if (text.length > 40 || !DECIMAL_INPUT.test(text)) return null;
1706
+ const negative = text.startsWith("-");
1707
+ if (text[0] === "-" || text[0] === "+") text = text.slice(1);
1708
+ const [whole, fraction = ""] = text.split(".");
1709
+ const integer = whole.replace(/^0+(?=\d)/, "");
1710
+ const decimals = fraction.replace(/0+$/, "");
1711
+ const magnitude = decimals ? `${integer}.${decimals}` : integer;
1712
+ return magnitude === "0" ? "0" : `${negative ? "-" : ""}${magnitude}`;
1713
+ }
1714
+ function compareDecimal(a, b) {
1715
+ const aNegative = a.startsWith("-");
1716
+ const bNegative = b.startsWith("-");
1717
+ if (aNegative !== bNegative) return aNegative ? -1 : 1;
1718
+ const sign = aNegative ? -1 : 1;
1719
+ const [aWhole, aFraction = ""] = (aNegative ? a.slice(1) : a).split(".");
1720
+ const [bWhole, bFraction = ""] = (bNegative ? b.slice(1) : b).split(".");
1721
+ let order;
1722
+ if (aWhole.length !== bWhole.length) {
1723
+ order = aWhole.length > bWhole.length ? 1 : -1;
1724
+ } else if (aWhole !== bWhole) {
1725
+ order = aWhole > bWhole ? 1 : -1;
1726
+ } else {
1727
+ const width = Math.max(aFraction.length, bFraction.length);
1728
+ const aPadded = aFraction.padEnd(width, "0");
1729
+ const bPadded = bFraction.padEnd(width, "0");
1730
+ order = aPadded === bPadded ? 0 : aPadded > bPadded ? 1 : -1;
1731
+ }
1732
+ return order === 0 ? 0 : order * sign;
1733
+ }
1734
+ var checkDecimal = (value, v, _ctx, path) => {
1735
+ const decimal = normalizeDecimal(value);
1736
+ if (decimal === null) return fail(path, "invalid_type", "must be a decimal number");
1737
+ const fraction = decimal.split(".")[1] ?? "";
1738
+ if (v.max_precision !== void 0 && fraction.length > v.max_precision) {
1739
+ return fail(path, "precision_exceeded", `must have at most ${v.max_precision} decimal places`);
1740
+ }
1741
+ if (typeof v.min === "string" && compareDecimal(decimal, v.min) < 0) {
1742
+ return fail(path, "too_small", `must be at least ${v.min}`);
1743
+ }
1744
+ if (typeof v.max === "string" && compareDecimal(decimal, v.max) > 0) {
1745
+ return fail(path, "too_big", `must be at most ${v.max}`);
1746
+ }
1747
+ return ok(decimal);
1748
+ };
1749
+ var checkBoolean = (value, _v, _ctx, path) => typeof value === "boolean" ? ok(value) : fail(path, "invalid_type", "must be true or false");
1750
+ var COLOR = /^#[0-9a-fA-F]{6}$/;
1751
+ var checkColor = (value, _v, _ctx, path) => typeof value === "string" && COLOR.test(value) ? ok(value.toLowerCase()) : fail(path, "invalid_format", "must be a hex color such as #1a2b3c");
1752
+ function isCalendarDate(year, month, day) {
1753
+ const date = /* @__PURE__ */ new Date(0);
1754
+ date.setUTCFullYear(year, month - 1, day);
1755
+ return date.getUTCFullYear() === year && date.getUTCMonth() === month - 1 && date.getUTCDate() === day;
1756
+ }
1757
+ var DATE = /^(\d{4})-(\d{2})-(\d{2})$/;
1758
+ function normalizeDate(input) {
1759
+ if (typeof input !== "string") return null;
1760
+ const match = DATE.exec(input);
1761
+ if (!match || !isCalendarDate(+match[1], +match[2], +match[3])) return null;
1762
+ return input;
1763
+ }
1764
+ var DATE_TIME = /^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2})(?::(\d{2})(?:\.\d{1,3})?)?(Z|[+-](\d{2}):(\d{2}))$/;
1765
+ function normalizeDateTime(input) {
1766
+ if (typeof input !== "string") return null;
1767
+ const match = DATE_TIME.exec(input);
1768
+ if (!match || !isCalendarDate(+match[1], +match[2], +match[3])) return null;
1769
+ if (+match[4] > 23 || +match[5] > 59 || +(match[6] ?? "0") > 59) return null;
1770
+ if (match[8] !== void 0 && (+match[8] > 23 || +match[9] > 59)) return null;
1771
+ const ms = Date.parse(input);
1772
+ if (Number.isNaN(ms)) return null;
1773
+ const iso = new Date(ms).toISOString();
1774
+ return /^\d{4}-/.test(iso) ? `${iso.slice(0, 19)}Z` : null;
1775
+ }
1776
+ function dateChecker(normalize, format) {
1777
+ return (value, v, _ctx, path) => {
1778
+ const normalized = normalize(value);
1779
+ if (normalized === null) return fail(path, "invalid_format", `must be ${format}`);
1780
+ if (typeof v.min === "string" && normalized < v.min) {
1781
+ return fail(path, "too_small", `must be on or after ${v.min}`);
1782
+ }
1783
+ if (typeof v.max === "string" && normalized > v.max) {
1784
+ return fail(path, "too_big", `must be on or before ${v.max}`);
1785
+ }
1786
+ return ok(normalized);
1787
+ };
1788
+ }
1789
+ var MAX_URL_LENGTH = 2048;
1790
+ var UNSAFE_URL_CHARS = /[\u0000-\u001f\u007f-\u009f"<>`\\]/;
1791
+ function parseHttpUrl(value) {
1792
+ if (typeof value !== "string" || value.length > MAX_URL_LENGTH || /\s/.test(value) || UNSAFE_URL_CHARS.test(value)) {
1793
+ return null;
1794
+ }
1795
+ try {
1796
+ const url = new URL(value);
1797
+ return url.protocol === "http:" || url.protocol === "https:" ? url : null;
1798
+ } catch {
1799
+ return null;
1800
+ }
1801
+ }
1802
+ function hostAllowed(url, domains) {
1803
+ if (!domains) return true;
1804
+ const host = url.hostname.toLowerCase();
1805
+ return domains.some((domain) => host === domain || host.endsWith(`.${domain}`));
1806
+ }
1807
+ var checkUrl = (value, v, _ctx, path) => {
1808
+ const url = parseHttpUrl(value);
1809
+ if (!url) return fail(path, "invalid_format", "must be an http(s) URL");
1810
+ if (!hostAllowed(url, v.allowed_domains)) {
1811
+ return fail(path, "domain_not_allowed", `must be on ${(v.allowed_domains ?? []).join(", ")}`);
1812
+ }
1813
+ return ok(value);
1814
+ };
1815
+ var checkLink = (value, v, ctx, path) => {
1816
+ if (!isPlainObject(value)) {
1817
+ return fail(path, "invalid_type", "must be an object with url and text");
1818
+ }
1819
+ const extra = unknownKeys(value, ["url", "text"], path);
1820
+ if (extra.length) return { ok: false, errors: extra };
1821
+ const url = checkUrl(value.url, v, ctx, joinPath(path, "url"));
1822
+ if (!url.ok) return url;
1823
+ const text = value.text ?? "";
1824
+ if (typeof text !== "string") return fail(joinPath(path, "text"), "invalid_type", "must be text");
1825
+ if (codePoints(text) > METAFIELD_LIMITS.link_text_length) {
1826
+ return fail(
1827
+ joinPath(path, "text"),
1828
+ "too_long",
1829
+ `must be at most ${METAFIELD_LIMITS.link_text_length} characters`
1830
+ );
1831
+ }
1832
+ return ok({ url: url.value, text });
1833
+ };
1834
+ var LANGUAGE = /^([a-zA-Z]{2,3})(?:-([a-zA-Z]{4}))?(?:-([a-zA-Z]{2}|\d{3}))?$/;
1835
+ var checkLanguage = (value, _v, _ctx, path) => {
1836
+ const match = typeof value === "string" ? LANGUAGE.exec(value) : null;
1837
+ if (!match) {
1838
+ return fail(path, "invalid_format", "must be a language tag such as vi or en-US");
1839
+ }
1840
+ const script = match[2] ? match[2][0].toUpperCase() + match[2].slice(1).toLowerCase() : void 0;
1841
+ return ok([match[1].toLowerCase(), script, match[3]?.toUpperCase()].filter(Boolean).join("-"));
1842
+ };
1843
+ var checkJson = (value, _v, _ctx, path) => {
1844
+ let text;
1845
+ let nonFinite = false;
1846
+ try {
1847
+ text = JSON.stringify(value, (_key, item) => {
1848
+ if (typeof item === "number" && !Number.isFinite(item)) nonFinite = true;
1849
+ return item;
1850
+ });
1851
+ } catch {
1852
+ text = void 0;
1853
+ }
1854
+ if (nonFinite) return fail(path, "invalid_format", "must not contain NaN or Infinity");
1855
+ return text === void 0 ? fail(path, "invalid_type", "must be JSON") : ok(JSON.parse(text));
1856
+ };
1857
+ var MAX_RICH_ERRORS = 100;
1858
+ var MAILTO = /^mailto:[^\s@?&#,]+@[^\s@?&#,]+$/i;
1859
+ function richChildren(children, path, errors, each) {
1860
+ if (!Array.isArray(children)) {
1861
+ errors.push(issue(path, "invalid_type", "must be a list of nodes"));
1862
+ return [];
1863
+ }
1864
+ const out = [];
1865
+ for (let index = 0; index < children.length; index++) {
1866
+ if (errors.length >= MAX_RICH_ERRORS) break;
1867
+ const node = each(children[index], joinPath(path, index));
1868
+ if (node) out.push(node);
1869
+ }
1870
+ return out;
1871
+ }
1872
+ function richText(node, path, errors) {
1873
+ errors.push(...unknownKeys(node, ["type", "value", "bold", "italic"], path));
1874
+ if (typeof node.value !== "string") {
1875
+ errors.push(issue(joinPath(path, "value"), "invalid_type", "must be text"));
1876
+ return null;
1877
+ }
1878
+ for (const mark of ["bold", "italic"]) {
1879
+ if (node[mark] !== void 0 && typeof node[mark] !== "boolean") {
1880
+ errors.push(issue(joinPath(path, mark), "invalid_type", "must be true or false"));
1881
+ }
1882
+ }
1883
+ const out = { type: "text", value: node.value };
1884
+ if (node.bold === true) out.bold = true;
1885
+ if (node.italic === true) out.italic = true;
1886
+ return out;
1887
+ }
1888
+ function richInline(node, path, errors) {
1889
+ if (!isPlainObject(node)) {
1890
+ errors.push(issue(path, "invalid_node", "must be a text or link node"));
1891
+ return null;
1892
+ }
1893
+ if (node.type === "text") return richText(node, path, errors);
1894
+ if (node.type === "link") {
1895
+ errors.push(...unknownKeys(node, ["type", "url", "title", "children"], path));
1896
+ const url = typeof node.url === "string" ? node.url : "";
1897
+ if (!parseHttpUrl(url) && !(url.length <= MAX_URL_LENGTH && MAILTO.test(url) && !UNSAFE_URL_CHARS.test(url))) {
1898
+ errors.push(issue(joinPath(path, "url"), "unsafe_url", "must be an http(s) or mailto link"));
1899
+ }
1900
+ if (node.title !== void 0 && typeof node.title !== "string") {
1901
+ errors.push(issue(joinPath(path, "title"), "invalid_type", "must be text"));
1902
+ }
1903
+ const children = richChildren(node.children, joinPath(path, "children"), errors, (child, at) => {
1904
+ if (isPlainObject(child) && child.type === "text") return richText(child, at, errors);
1905
+ errors.push(issue(joinPath(at, "type"), "invalid_node", "a link may only contain text"));
1906
+ return null;
1907
+ });
1908
+ const out = { type: "link", url, children };
1909
+ if (typeof node.title === "string") out.title = node.title;
1910
+ return out;
1911
+ }
1912
+ errors.push(
1913
+ issue(joinPath(path, "type"), "invalid_node", `unexpected node type ${JSON.stringify(String(node.type).slice(0, 40))}`)
1914
+ );
1915
+ return null;
1916
+ }
1917
+ function richBlock(node, path, errors) {
1918
+ if (!isPlainObject(node)) {
1919
+ errors.push(issue(path, "invalid_node", "must be a paragraph, heading or list node"));
1920
+ return null;
1921
+ }
1922
+ const inline = (child, at) => richInline(child, at, errors);
1923
+ const children = (at, from) => richChildren(from, joinPath(at, "children"), errors, inline);
1924
+ switch (node.type) {
1925
+ case "paragraph":
1926
+ errors.push(...unknownKeys(node, ["type", "children"], path));
1927
+ return { type: "paragraph", children: children(path, node.children) };
1928
+ case "heading": {
1929
+ errors.push(...unknownKeys(node, ["type", "level", "children"], path));
1930
+ const level = node.level;
1931
+ if (typeof level !== "number" || !Number.isInteger(level) || level < 1 || level > 6) {
1932
+ errors.push(issue(joinPath(path, "level"), "invalid_format", "must be 1 to 6"));
1933
+ }
1934
+ return { type: "heading", level, children: children(path, node.children) };
1935
+ }
1936
+ case "list": {
1937
+ errors.push(...unknownKeys(node, ["type", "listType", "children"], path));
1938
+ if (node.listType !== "ordered" && node.listType !== "unordered") {
1939
+ errors.push(issue(joinPath(path, "listType"), "invalid_format", "must be ordered or unordered"));
1940
+ }
1941
+ const items = richChildren(node.children, joinPath(path, "children"), errors, (child, at) => {
1942
+ if (!isPlainObject(child) || child.type !== "list-item") {
1943
+ errors.push(issue(at, "invalid_node", "must be a list-item node"));
1944
+ return null;
1945
+ }
1946
+ errors.push(...unknownKeys(child, ["type", "children"], at));
1947
+ return { type: "list-item", children: children(at, child.children) };
1948
+ });
1949
+ return { type: "list", listType: node.listType, children: items };
1950
+ }
1951
+ default:
1952
+ errors.push(
1953
+ issue(joinPath(path, "type"), "invalid_node", `unexpected node type ${JSON.stringify(String(node.type).slice(0, 40))}`)
1954
+ );
1955
+ return null;
1956
+ }
1957
+ }
1958
+ var MAX_RICH_TOP_NODES = 2e3;
1959
+ function validateRichText(input, path = "") {
1960
+ if (!isPlainObject(input) || input.type !== "root") {
1961
+ return fail(path, "invalid_node", "must be a rich-text root node");
1962
+ }
1963
+ if (Array.isArray(input.children) && input.children.length > MAX_RICH_TOP_NODES) {
1964
+ return fail(path, "too_large", "has too many nodes");
1965
+ }
1966
+ const errors = unknownKeys(input, ["type", "children"], path);
1967
+ const children = richChildren(
1968
+ input.children,
1969
+ joinPath(path, "children"),
1970
+ errors,
1971
+ (child, at) => richBlock(child, at, errors)
1972
+ );
1973
+ return errors.length ? { ok: false, errors: errors.slice(0, MAX_RICH_ERRORS) } : ok({ type: "root", children });
1974
+ }
1975
+ function richTextLength(root) {
1976
+ let count = 0;
1977
+ const visit = (node) => {
1978
+ if (node.type === "text") count += codePoints(node.value);
1979
+ else node.children.forEach(visit);
1980
+ };
1981
+ for (const block of root.children) {
1982
+ if (block.type === "list") block.children.forEach((item) => item.children.forEach(visit));
1983
+ else block.children.forEach(visit);
1984
+ }
1985
+ return count;
1986
+ }
1987
+ var checkRichText = (value, v, _ctx, path) => {
1988
+ const tree = validateRichText(value, path);
1989
+ if (!tree.ok) return tree;
1990
+ if (v.max_length !== void 0 && richTextLength(tree.value) > v.max_length) {
1991
+ return fail(path, "too_long", `must be at most ${v.max_length} characters`);
1992
+ }
1993
+ return tree;
1994
+ };
1995
+ var MEASUREMENT_UNITS = {
1996
+ weight: { g: 1, kg: 1e3, oz: 28.349523125, lb: 453.59237 },
1997
+ volume: {
1998
+ ml: 1,
1999
+ cl: 10,
2000
+ l: 1e3,
2001
+ m3: 1e6,
2002
+ fl_oz: 29.5735295625,
2003
+ pt: 473.176473,
2004
+ qt: 946.352946,
2005
+ gal: 3785.411784
2006
+ },
2007
+ dimension: { mm: 1, cm: 10, m: 1e3, in: 25.4, ft: 304.8, yd: 914.4 }
2008
+ };
2009
+ function measurementInBaseUnit(measurement, type) {
2010
+ const units = MEASUREMENT_UNITS[type];
2011
+ return hasOwn(units, measurement.unit) ? Number(measurement.value) * units[measurement.unit] : null;
2012
+ }
2013
+ function measurementChecker(type) {
2014
+ const unitList = Object.keys(MEASUREMENT_UNITS[type]).join(", ");
2015
+ return (value, v, _ctx, path) => {
2016
+ if (!isPlainObject(value)) return fail(path, "invalid_type", "must be an object with value and unit");
2017
+ const extra = unknownKeys(value, ["value", "unit"], path);
2018
+ if (extra.length) return { ok: false, errors: extra };
2019
+ const amount = normalizeDecimal(value.value);
2020
+ if (amount === null) return fail(joinPath(path, "value"), "invalid_type", "must be a decimal number");
2021
+ if (typeof value.unit !== "string" || !hasOwn(MEASUREMENT_UNITS[type], value.unit)) {
2022
+ return fail(joinPath(path, "unit"), "invalid_unit", `must be one of: ${unitList}`);
2023
+ }
2024
+ const measurement = { value: amount, unit: value.unit };
2025
+ const base2 = measurementInBaseUnit(measurement, type);
2026
+ if (typeof v.min === "object" && v.min !== null) {
2027
+ const min = measurementInBaseUnit(v.min, type);
2028
+ if (min !== null && base2 < min) {
2029
+ return fail(path, "too_small", `must be at least ${v.min.value} ${v.min.unit}`);
2030
+ }
2031
+ }
2032
+ if (typeof v.max === "object" && v.max !== null) {
2033
+ const max = measurementInBaseUnit(v.max, type);
2034
+ if (max !== null && base2 > max) {
2035
+ return fail(path, "too_big", `must be at most ${v.max.value} ${v.max.unit}`);
2036
+ }
2037
+ }
2038
+ return ok(measurement);
2039
+ };
2040
+ }
2041
+ var checkRating = (value, v, _ctx, path) => {
2042
+ if (!isPlainObject(value)) {
2043
+ return fail(path, "invalid_type", "must be an object with value, scale_min and scale_max");
2044
+ }
2045
+ const extra = unknownKeys(value, ["value", "scale_min", "scale_max"], path);
2046
+ if (extra.length) return { ok: false, errors: extra };
2047
+ const parts = { value: "", scale_min: "", scale_max: "" };
2048
+ for (const key of ["value", "scale_min", "scale_max"]) {
2049
+ const decimal = normalizeDecimal(value[key]);
2050
+ if (decimal === null) return fail(joinPath(path, key), "invalid_type", "must be a decimal number");
2051
+ parts[key] = decimal;
2052
+ }
2053
+ if (v.scale_min !== void 0 && compareDecimal(parts.scale_min, v.scale_min) !== 0 || v.scale_max !== void 0 && compareDecimal(parts.scale_max, v.scale_max) !== 0) {
2054
+ return fail(path, "scale_mismatch", `must use the scale ${v.scale_min} to ${v.scale_max}`);
2055
+ }
2056
+ if (compareDecimal(parts.value, parts.scale_min) < 0) {
2057
+ return fail(joinPath(path, "value"), "too_small", `must be at least ${parts.scale_min}`);
2058
+ }
2059
+ if (compareDecimal(parts.value, parts.scale_max) > 0) {
2060
+ return fail(joinPath(path, "value"), "too_big", `must be at most ${parts.scale_max}`);
2061
+ }
2062
+ return ok(parts);
2063
+ };
2064
+ var checkMoney = (value, _v, ctx, path) => {
2065
+ if (!isPlainObject(value)) return fail(path, "invalid_type", "must be an object with amount and currency_code");
2066
+ const extra = unknownKeys(value, ["amount", "currency_code"], path);
2067
+ if (extra.length) return { ok: false, errors: extra };
2068
+ const amount = normalizeDecimal(value.amount);
2069
+ if (amount === null) return fail(joinPath(path, "amount"), "invalid_type", "must be a decimal number");
2070
+ const currency = typeof value.currency_code === "string" ? value.currency_code.toUpperCase() : "";
2071
+ const expected = ctx.currency_code.toUpperCase();
2072
+ if (currency !== expected) {
2073
+ return fail(joinPath(path, "currency_code"), "currency_mismatch", `must be ${expected}`);
2074
+ }
2075
+ return ok({ amount, currency_code: currency });
2076
+ };
2077
+ var UUID = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
2078
+ var checkAsset = (value, _v, _ctx, path) => typeof value === "string" && UUID.test(value) ? ok(value.toLowerCase()) : fail(path, "invalid_format", "must be an asset id");
2079
+ function allowedFileKinds(type, validations) {
2080
+ switch (baseTypeOf(type)) {
2081
+ case "image":
2082
+ return ["image"];
2083
+ case "video":
2084
+ return ["video"];
2085
+ case "file":
2086
+ return validations.file_types ?? null;
2087
+ default:
2088
+ return null;
2089
+ }
2090
+ }
2091
+ var ID = /^[1-9]\d{0,18}$/;
2092
+ var MAX_BIGINT = "9223372036854775807";
2093
+ function normalizeId(input) {
2094
+ if (typeof input === "number") {
2095
+ return Number.isSafeInteger(input) && input > 0 ? String(input) : null;
2096
+ }
2097
+ if (typeof input !== "string" || !ID.test(input)) return null;
2098
+ if (input.length === MAX_BIGINT.length && input > MAX_BIGINT) return null;
2099
+ return input;
2100
+ }
2101
+ var checkId = (value, _v, _ctx, path) => {
2102
+ const id = normalizeId(value);
2103
+ return id === null ? fail(path, "invalid_format", "must be a record id") : ok(id);
2104
+ };
2105
+ var CHECKERS = {
2106
+ single_line_text: textChecker(METAFIELD_LIMITS.single_line_text_length, true),
2107
+ multi_line_text: textChecker(METAFIELD_LIMITS.multi_line_text_length, false),
2108
+ rich_text: checkRichText,
2109
+ email: checkEmail,
2110
+ integer: checkInteger,
2111
+ decimal: checkDecimal,
2112
+ date: dateChecker(normalizeDate, "a date (YYYY-MM-DD)"),
2113
+ date_time: dateChecker(normalizeDateTime, "a date and time (YYYY-MM-DDTHH:mm:ssZ)"),
2114
+ url: checkUrl,
2115
+ link: checkLink,
2116
+ weight: measurementChecker("weight"),
2117
+ volume: measurementChecker("volume"),
2118
+ dimension: measurementChecker("dimension"),
2119
+ boolean: checkBoolean,
2120
+ color: checkColor,
2121
+ rating: checkRating,
2122
+ money: checkMoney,
2123
+ language: checkLanguage,
2124
+ json: checkJson,
2125
+ file: checkAsset,
2126
+ image: checkAsset,
2127
+ video: checkAsset,
2128
+ product: checkId,
2129
+ variant: checkId,
2130
+ collection: checkId,
2131
+ page: checkId,
2132
+ blog_post: checkId,
2133
+ customer: checkId,
2134
+ order: checkId,
2135
+ metaobject_reference: checkId,
2136
+ mixed_reference: checkId
2137
+ };
2138
+ function isBlankValue(value) {
2139
+ return value === null || value === void 0 || value === "" || Array.isArray(value) && value.length === 0;
2140
+ }
2141
+ var TEXT_BASE_TYPES = ["single_line_text", "multi_line_text", "email", "url"];
2142
+ function isBlankScalar(base2, value) {
2143
+ if (isBlankValue(value)) return true;
2144
+ if (typeof value === "string") return TEXT_BASE_TYPES.includes(base2) && value.trim() === "";
2145
+ return base2 === "rich_text" && isPlainObject(value) && value.type === "root" && Array.isArray(value.children) && value.children.length === 0;
2146
+ }
2147
+ function isBlankValueFor(type, value) {
2148
+ if (!isMetafieldType(type)) return isBlankValue(value);
2149
+ if (isListType(type)) return isBlankValue(value);
2150
+ return isBlankScalar(baseTypeOf(type), value);
2151
+ }
2152
+ function checkList(base2, checker, value, v, ctx, path) {
2153
+ if (!Array.isArray(value)) return fail(path, "invalid_type", "must be a list");
2154
+ const max = Math.min(METAFIELD_LIMITS.list_items, v.list_max ?? METAFIELD_LIMITS.list_items);
2155
+ if (value.length > max) return fail(path, "list_too_long", `must have at most ${max} items`);
2156
+ if (v.list_min !== void 0 && value.length < v.list_min) {
2157
+ return fail(path, "list_too_short", `must have at least ${v.list_min} items`);
2158
+ }
2159
+ const items = [];
2160
+ const errors = [];
2161
+ for (let index = 0; index < value.length; index++) {
2162
+ const item = value[index];
2163
+ const at = joinPath(path, index);
2164
+ const result = isBlankScalar(base2, item) ? fail(at, "blank", "is empty") : checker(item, v, ctx, at);
2165
+ if (result.ok) items.push(result.value);
2166
+ else errors.push(...result.errors);
2167
+ }
2168
+ return errors.length ? { ok: false, errors } : ok(items);
2169
+ }
2170
+ function isStorableJson(json) {
2171
+ for (const match of json.matchAll(/\\(?:u([0-9a-f]{4})|[^u])/g)) {
2172
+ const code = match[1] === void 0 ? -1 : parseInt(match[1], 16);
2173
+ if (code === 0 || code >= 55296 && code <= 57343) return false;
2174
+ }
2175
+ return true;
2176
+ }
2177
+ function byteLength(text) {
2178
+ return new TextEncoder().encode(text).length;
2179
+ }
2180
+ function validateMetafieldValue(type, validations, value, ctx, path = "") {
2181
+ if (!isMetafieldType(type)) return fail(path, "invalid_type", "is not a metafield type");
2182
+ if (!isPlainObject(validations)) validations = {};
2183
+ if (isBlankValueFor(type, value)) return fail(path, "blank", "is empty; send null to clear it");
2184
+ if (isListType(type) && Array.isArray(value) && value.length > 4 * METAFIELD_LIMITS.list_items) {
2185
+ return fail(path, "list_too_long", `must have at most ${METAFIELD_LIMITS.list_items} items`);
2186
+ }
2187
+ const base2 = baseTypeOf(type);
2188
+ const checker = hasOwn(CHECKERS, base2) ? CHECKERS[base2] : void 0;
2189
+ if (!checker) return fail(path, "invalid_type", `type ${String(type).slice(0, 40)} is not supported`);
2190
+ const result = isListType(type) ? checkList(base2, checker, value, validations, ctx, path) : checker(value, validations, ctx, path);
2191
+ if (!result.ok) return result;
2192
+ const json = JSON.stringify(result.value);
2193
+ if (!isStorableJson(json)) {
2194
+ return fail(path, "invalid_format", "contains characters that cannot be stored");
2195
+ }
2196
+ if (byteLength(json) > METAFIELD_LIMITS.value_bytes) {
2197
+ return fail(path, "too_large", `must be at most ${METAFIELD_LIMITS.value_bytes} bytes`);
2198
+ }
2199
+ return result;
2200
+ }
2201
+ var VALIDATION_KEYS = {
2202
+ single_line_text: ["min_length", "max_length", "regex", "choices"],
2203
+ multi_line_text: ["min_length", "max_length"],
2204
+ rich_text: ["max_length"],
2205
+ email: [],
2206
+ integer: ["min", "max"],
2207
+ decimal: ["min", "max", "max_precision"],
2208
+ date: ["min", "max"],
2209
+ date_time: ["min", "max"],
2210
+ url: ["allowed_domains"],
2211
+ link: ["allowed_domains"],
2212
+ weight: ["min", "max"],
2213
+ volume: ["min", "max"],
2214
+ dimension: ["min", "max"],
2215
+ boolean: [],
2216
+ color: [],
2217
+ rating: ["scale_min", "scale_max"],
2218
+ money: [],
2219
+ language: [],
2220
+ json: [],
2221
+ file: ["file_types"],
2222
+ image: [],
2223
+ video: [],
2224
+ product: [],
2225
+ variant: [],
2226
+ collection: [],
2227
+ page: [],
2228
+ blog_post: [],
2229
+ customer: [],
2230
+ order: [],
2231
+ metaobject_reference: ["metaobject_definition_id"],
2232
+ mixed_reference: ["metaobject_definition_ids"]
2233
+ };
2234
+ function isSafeRegex(pattern) {
2235
+ if (/\\[1-9]|\\k</.test(pattern)) return false;
2236
+ if (/\(\?<?[=!]/.test(pattern)) return false;
2237
+ let quantifiers = 0;
2238
+ let bars = 0;
2239
+ let afterQuantifier = false;
2240
+ for (let i = 0; i < pattern.length; i++) {
2241
+ const char = pattern[i];
2242
+ const wasQuantifier = afterQuantifier;
2243
+ afterQuantifier = false;
2244
+ if (char === "\\") {
2245
+ const escaped = pattern[i + 1];
2246
+ i++;
2247
+ if ((escaped === "u" || escaped === "p" || escaped === "P") && pattern[i + 1] === "{") {
2248
+ const close = pattern.indexOf("}", i + 1);
2249
+ i = close === -1 ? pattern.length : close;
2250
+ }
2251
+ continue;
2252
+ }
2253
+ if (char === "[") {
2254
+ i++;
2255
+ while (i < pattern.length && pattern[i] !== "]") {
2256
+ if (pattern[i] === "\\") i++;
2257
+ i++;
2258
+ }
2259
+ continue;
2260
+ }
2261
+ if (char === "(") {
2262
+ if (pattern[i + 1] === "?") i++;
2263
+ continue;
2264
+ }
2265
+ if (char === ")") {
2266
+ const next = pattern[i + 1];
2267
+ if (next === "*" || next === "+") return false;
2268
+ if (next === "{" && /^\{\d+(,\d*)?\}/.test(pattern.slice(i + 1))) return false;
2269
+ continue;
2270
+ }
2271
+ if (char === "|") {
2272
+ bars++;
2273
+ } else if (char === "*" || char === "+" || char === "?") {
2274
+ if (!(char === "?" && wasQuantifier)) {
2275
+ quantifiers++;
2276
+ afterQuantifier = true;
2277
+ }
2278
+ } else if (char === "{") {
2279
+ const match = /^\{\d+(,\d*)?\}/.exec(pattern.slice(i));
2280
+ if (match) {
2281
+ if (match[1] !== void 0) quantifiers++;
2282
+ afterQuantifier = true;
2283
+ i += match[0].length - 1;
2284
+ }
2285
+ }
2286
+ }
2287
+ return quantifiers <= 2 && bars <= 4;
2288
+ }
2289
+ var HOSTNAME = /^(?=.{1,253}$)(?:[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?\.)+[a-z]{2,63}$/;
2290
+ var FILE_KINDS = ["image", "video", "document"];
2291
+ function normalizeBound(base2, input) {
2292
+ switch (base2) {
2293
+ case "integer":
2294
+ return typeof input === "number" && Number.isSafeInteger(input) ? input : null;
2295
+ case "decimal":
2296
+ return normalizeDecimal(input);
2297
+ case "date":
2298
+ return normalizeDate(input);
2299
+ case "date_time":
2300
+ return normalizeDateTime(input);
2301
+ case "weight":
2302
+ case "volume":
2303
+ case "dimension": {
2304
+ if (!isPlainObject(input) || Object.keys(input).some((k) => k !== "value" && k !== "unit")) return null;
2305
+ const amount = normalizeDecimal(input.value);
2306
+ if (amount === null || typeof input.unit !== "string" || !hasOwn(MEASUREMENT_UNITS[base2], input.unit)) {
2307
+ return null;
2308
+ }
2309
+ return { value: amount, unit: input.unit };
2310
+ }
2311
+ default:
2312
+ return null;
2313
+ }
2314
+ }
2315
+ function compareBound(base2, a, b) {
2316
+ if (typeof a === "number" && typeof b === "number") return a - b;
2317
+ if (typeof a === "object" && typeof b === "object") {
2318
+ const type = base2;
2319
+ return (measurementInBaseUnit(a, type) ?? 0) - (measurementInBaseUnit(b, type) ?? 0);
2320
+ }
2321
+ if (base2 === "decimal") return compareDecimal(a, b);
2322
+ return a < b ? -1 : a > b ? 1 : 0;
2323
+ }
2324
+ function isWholeNumber(value, min, max) {
2325
+ return typeof value === "number" && Number.isInteger(value) && value >= min && value <= max;
2326
+ }
2327
+ function validateValidations(type, input, path = "validations") {
2328
+ if (!isMetafieldType(type)) return fail(path, "invalid_type", "is not a metafield type");
2329
+ const raw = input === void 0 || input === null ? {} : input;
2330
+ if (!isPlainObject(raw)) return fail(path, "invalid_type", "must be an object");
2331
+ const base2 = baseTypeOf(type);
2332
+ const allowed = [
2333
+ ...VALIDATION_KEYS[base2],
2334
+ ...isListType(type) ? ["list_min", "list_max"] : []
2335
+ ];
2336
+ const errors = unknownKeys(raw, allowed, path);
2337
+ const out = {};
2338
+ const has = (key) => allowed.includes(key) && raw[key] !== void 0;
2339
+ const bad = (key, message, code = "invalid_validation") => errors.push(issue(joinPath(path, key), code, message));
2340
+ for (const key of ["min_length", "max_length"]) {
2341
+ if (!has(key)) continue;
2342
+ const cap = base2 === "single_line_text" ? METAFIELD_LIMITS.single_line_text_length : METAFIELD_LIMITS.multi_line_text_length;
2343
+ if (isWholeNumber(raw[key], 0, cap)) out[key] = raw[key];
2344
+ else bad(key, "must be a whole number of 0 or more");
2345
+ }
2346
+ if (has("regex")) {
2347
+ const pattern = raw.regex;
2348
+ if (typeof pattern !== "string" || pattern.length === 0 || pattern.length > METAFIELD_LIMITS.regex_length) {
2349
+ bad("regex", `must be 1 to ${METAFIELD_LIMITS.regex_length} characters`);
2350
+ } else if (!isSafeRegex(pattern)) {
2351
+ bad("regex", "is too complex: no backreferences or lookaround, no repetition after a group, at most 2 optional or repeated parts and 4 alternatives", "unsafe_regex");
2352
+ } else {
2353
+ try {
2354
+ new RegExp(pattern, "u");
2355
+ out.regex = pattern;
2356
+ } catch {
2357
+ bad("regex", "is not a valid pattern");
2358
+ }
2359
+ }
2360
+ }
2361
+ if (has("regex")) {
2362
+ const limit = METAFIELD_LIMITS.regex_value_length;
2363
+ if (out.max_length !== void 0 && out.max_length > limit) {
2364
+ bad("max_length", `must be at most ${limit} when a pattern applies`);
2365
+ } else if (out.regex !== void 0 && out.max_length === void 0) {
2366
+ out.max_length = limit;
2367
+ }
2368
+ }
2369
+ if (out.min_length !== void 0 && out.max_length !== void 0 && out.min_length > out.max_length) {
2370
+ bad("min_length", "must not exceed max_length");
2371
+ }
2372
+ if (has("choices")) {
2373
+ const choices = raw.choices;
2374
+ if (!Array.isArray(choices) || choices.length === 0 || choices.length > METAFIELD_LIMITS.choices) {
2375
+ bad("choices", `must list 1 to ${METAFIELD_LIMITS.choices} values`);
2376
+ } else if (choices.some(
2377
+ (c) => typeof c !== "string" || c === "" || /[\r\n]/.test(c) || codePoints(c) > METAFIELD_LIMITS.single_line_text_length
2378
+ )) {
2379
+ bad("choices", "must be non-empty single-line text");
2380
+ } else if (new Set(choices).size !== choices.length) {
2381
+ bad("choices", "must not repeat a value");
2382
+ } else if (choices.some((c) => {
2383
+ const length = codePoints(c);
2384
+ if (length > METAFIELD_LIMITS.regex_value_length && out.regex !== void 0) return true;
2385
+ if (out.max_length !== void 0 && length > out.max_length) return true;
2386
+ if (out.min_length !== void 0 && length < out.min_length) return true;
2387
+ return out.regex !== void 0 && !matchesPattern(out.regex, c);
2388
+ })) {
2389
+ bad("choices", "includes a value the pattern or length rules reject");
2390
+ } else {
2391
+ out.choices = [...choices];
2392
+ }
2393
+ }
2394
+ for (const key of ["min", "max"]) {
2395
+ if (!has(key)) continue;
2396
+ const bound = normalizeBound(base2, raw[key]);
2397
+ if (bound === null) bad(key, `is not a valid ${base2} bound`);
2398
+ else out[key] = bound;
2399
+ }
2400
+ if (out.min !== void 0 && out.max !== void 0 && compareBound(base2, out.min, out.max) > 0) {
2401
+ bad("min", "must not exceed max");
2402
+ }
2403
+ if (has("max_precision")) {
2404
+ if (isWholeNumber(raw.max_precision, 0, 9)) out.max_precision = raw.max_precision;
2405
+ else bad("max_precision", "must be a whole number from 0 to 9");
2406
+ }
2407
+ if (has("allowed_domains")) {
2408
+ const domains = raw.allowed_domains;
2409
+ const lowered = Array.isArray(domains) ? domains.map((d) => typeof d === "string" ? d.toLowerCase() : "") : [];
2410
+ if (!Array.isArray(domains) || domains.length === 0 || domains.length > METAFIELD_LIMITS.allowed_domains || lowered.some((d) => !HOSTNAME.test(d))) {
2411
+ bad("allowed_domains", `must list 1 to ${METAFIELD_LIMITS.allowed_domains} domains such as youtube.com`);
2412
+ } else {
2413
+ out.allowed_domains = [...new Set(lowered)];
2414
+ }
2415
+ }
2416
+ if (base2 === "rating") {
2417
+ for (const key of ["scale_min", "scale_max"]) {
2418
+ if (raw[key] === void 0) {
2419
+ bad(key, "is required for a rating", "required");
2420
+ continue;
2421
+ }
2422
+ const decimal = normalizeDecimal(raw[key]);
2423
+ if (decimal === null) bad(key, "must be a decimal number");
2424
+ else out[key] = decimal;
2425
+ }
2426
+ if (out.scale_min !== void 0 && out.scale_max !== void 0 && compareDecimal(out.scale_min, out.scale_max) >= 0) {
2427
+ bad("scale_min", "must be below scale_max");
2428
+ }
2429
+ }
2430
+ if (has("file_types")) {
2431
+ const kinds = raw.file_types;
2432
+ if (!Array.isArray(kinds) || kinds.length === 0 || kinds.some((k) => !FILE_KINDS.includes(k)) || new Set(kinds).size !== kinds.length) {
2433
+ bad("file_types", "must list image, video and/or document");
2434
+ } else {
2435
+ out.file_types = [...kinds];
2436
+ }
2437
+ }
2438
+ if (base2 === "metaobject_reference") {
2439
+ const id = normalizeId(raw.metaobject_definition_id);
2440
+ if (raw.metaobject_definition_id === void 0) {
2441
+ bad("metaobject_definition_id", "is required", "required");
2442
+ } else if (id === null) {
2443
+ bad("metaobject_definition_id", "must be a metaobject definition id");
2444
+ } else {
2445
+ out.metaobject_definition_id = id;
2446
+ }
2447
+ }
2448
+ if (base2 === "mixed_reference") {
2449
+ const ids = Array.isArray(raw.metaobject_definition_ids) ? raw.metaobject_definition_ids.map(normalizeId) : null;
2450
+ if (raw.metaobject_definition_ids === void 0) {
2451
+ bad("metaobject_definition_ids", "is required", "required");
2452
+ } else if (!ids || ids.length < METAFIELD_LIMITS.mixed_reference_definitions_min || ids.length > METAFIELD_LIMITS.mixed_reference_definitions_max || ids.some((id) => id === null) || new Set(ids).size !== ids.length) {
2453
+ bad(
2454
+ "metaobject_definition_ids",
2455
+ `must list ${METAFIELD_LIMITS.mixed_reference_definitions_min} to ${METAFIELD_LIMITS.mixed_reference_definitions_max} different definition ids`
2456
+ );
2457
+ } else {
2458
+ out.metaobject_definition_ids = ids;
2459
+ }
2460
+ }
2461
+ for (const key of ["list_min", "list_max"]) {
2462
+ if (!has(key)) continue;
2463
+ if (isWholeNumber(raw[key], 0, METAFIELD_LIMITS.list_items)) out[key] = raw[key];
2464
+ else bad(key, `must be a whole number from 0 to ${METAFIELD_LIMITS.list_items}`);
2465
+ }
2466
+ if (out.list_min !== void 0 && out.list_max !== void 0 && out.list_min > out.list_max) {
2467
+ bad("list_min", "must not exceed list_max");
2468
+ }
2469
+ return errors.length ? { ok: false, errors } : ok(out);
2470
+ }
2471
+ function storefrontAccessAllowed(owner) {
2472
+ return owner !== "customer" && owner !== "order" && owner !== "location";
2473
+ }
2474
+ function allowedCustomerAccess(owner) {
2475
+ if (owner === "customer") return ["none", "read", "read_write"];
2476
+ if (owner === "order") return ["none", "read"];
2477
+ return ["none"];
2478
+ }
2479
+ var METAFIELD_DEFINITION_KEYS = [
2480
+ "owner_type",
2481
+ "namespace",
2482
+ "key",
2483
+ "name",
2484
+ "description",
2485
+ "type",
2486
+ "validations",
2487
+ "storefront_access",
2488
+ "customer_access"
2489
+ ];
2490
+ function readName(value, path, errors) {
2491
+ const name = typeof value === "string" ? value.trim() : "";
2492
+ if (!name || codePoints(name) > METAFIELD_LIMITS.name_length) {
2493
+ errors.push(issue(path, "invalid_format", `must be 1 to ${METAFIELD_LIMITS.name_length} characters`));
2494
+ }
2495
+ return name;
2496
+ }
2497
+ function readDescription(value, path, errors) {
2498
+ if (value === void 0 || value === null) return null;
2499
+ if (typeof value !== "string" || codePoints(value) > METAFIELD_LIMITS.description_length) {
2500
+ errors.push(issue(path, "invalid_format", `must be text of at most ${METAFIELD_LIMITS.description_length} characters`));
2501
+ return null;
2502
+ }
2503
+ return value.trim() || null;
2504
+ }
2505
+ function readKey(value, path, errors, pattern = METAFIELD_KEY_PATTERN) {
2506
+ if (typeof value !== "string" || !pattern.test(value)) {
2507
+ errors.push(issue(path, "invalid_format", "must be 2 to 64 lowercase letters, digits or underscores"));
2508
+ return "";
2509
+ }
2510
+ if (RESERVED_KEYS.includes(value)) {
2511
+ errors.push(issue(path, "invalid_format", "is a reserved name"));
2512
+ return "";
2513
+ }
2514
+ return value;
2515
+ }
2516
+ function readBoolean(value, fallback, path, errors) {
2517
+ if (value === void 0) return fallback;
2518
+ if (typeof value !== "boolean") {
2519
+ errors.push(issue(path, "invalid_type", "must be true or false"));
2520
+ return fallback;
2521
+ }
2522
+ return value;
2523
+ }
2524
+ function readTypeAndValidations(input, path, errors) {
2525
+ if (!isMetafieldType(input.type)) {
2526
+ errors.push(issue(joinPath(path, "type"), "invalid_format", "is not a metafield type"));
2527
+ return null;
2528
+ }
2529
+ const validations = validateValidations(input.type, input.validations, joinPath(path, "validations"));
2530
+ if (!validations.ok) {
2531
+ errors.push(...validations.errors);
2532
+ return null;
2533
+ }
2534
+ return { type: input.type, validations: validations.value };
2535
+ }
2536
+ function validateMetafieldDefinition(input) {
2537
+ if (!isPlainObject(input)) return fail("", "invalid_type", "must be an object");
2538
+ const errors = unknownKeys(input, METAFIELD_DEFINITION_KEYS, "");
2539
+ const owner = input.owner_type;
2540
+ if (!METAFIELD_OWNER_TYPES.includes(owner)) {
2541
+ errors.push(issue("owner_type", "invalid_format", `must be one of: ${METAFIELD_OWNER_TYPES.join(", ")}`));
2542
+ }
2543
+ const namespace = readKey(input.namespace ?? "custom", "namespace", errors);
2544
+ const key = readKey(input.key, "key", errors);
2545
+ const name = readName(input.name, "name", errors);
2546
+ const description = readDescription(input.description, "description", errors);
2547
+ const typed = readTypeAndValidations(input, "", errors);
2548
+ const storefront = readBoolean(input.storefront_access, false, "storefront_access", errors);
2549
+ if (storefront && METAFIELD_OWNER_TYPES.includes(owner) && !storefrontAccessAllowed(owner)) {
2550
+ errors.push(issue("storefront_access", "not_allowed", `is not available for ${owner} metafields`));
2551
+ }
2552
+ const customer = input.customer_access ?? "none";
2553
+ if (!allowedCustomerAccess(owner).includes(customer)) {
2554
+ errors.push(issue("customer_access", "not_allowed", `must be one of: ${allowedCustomerAccess(owner).join(", ")}`));
2555
+ }
2556
+ if (errors.length || !typed) return { ok: false, errors };
2557
+ const out = {
2558
+ owner_type: owner,
2559
+ namespace,
2560
+ key,
2561
+ name,
2562
+ description,
2563
+ type: typed.type,
2564
+ validations: typed.validations,
2565
+ storefront_access: storefront,
2566
+ customer_access: customer
2567
+ };
2568
+ return storable(out);
2569
+ }
2570
+ function storable(out) {
2571
+ if (!isStorableJson(JSON.stringify(out))) {
2572
+ return fail("", "invalid_format", "contains characters that cannot be stored");
2573
+ }
2574
+ return ok(out);
2575
+ }
2576
+ var FILTERABLE_TYPES = ["single_line_text", "boolean", "integer", "date"];
2577
+ var METAOBJECT_DEFINITION_KEYS = [
2578
+ "type",
2579
+ "name",
2580
+ "description",
2581
+ "fields",
2582
+ "display_name_key",
2583
+ "filter_keys",
2584
+ "has_status",
2585
+ "storefront_access",
2586
+ "customer_access"
2587
+ ];
2588
+ var FIELD_KEYS = ["key", "name", "description", "type", "required", "validations"];
2589
+ function readField(input, path, errors) {
2590
+ if (!isPlainObject(input)) {
2591
+ errors.push(issue(path, "invalid_type", "must be an object"));
2592
+ return null;
2593
+ }
2594
+ errors.push(...unknownKeys(input, FIELD_KEYS, path));
2595
+ const key = readKey(input.key, joinPath(path, "key"), errors);
2596
+ const name = readName(input.name, joinPath(path, "name"), errors);
2597
+ const description = readDescription(input.description, joinPath(path, "description"), errors);
2598
+ const required = readBoolean(input.required, false, joinPath(path, "required"), errors);
2599
+ const typed = readTypeAndValidations(input, path, errors);
2600
+ return typed ? { key, name, description, type: typed.type, required, validations: typed.validations } : null;
2601
+ }
2602
+ function validateMetaobjectDefinition(input) {
2603
+ if (!isPlainObject(input)) return fail("", "invalid_type", "must be an object");
2604
+ const errors = unknownKeys(input, METAOBJECT_DEFINITION_KEYS, "");
2605
+ const type = typeof input.type === "string" && METAOBJECT_TYPE_PATTERN.test(input.type) ? input.type : "";
2606
+ if (!type) {
2607
+ errors.push(issue("type", "invalid_format", "must be 2 to 64 lowercase letters, digits, underscores or hyphens"));
2608
+ } else if (RESERVED_KEYS.includes(type)) {
2609
+ errors.push(issue("type", "invalid_format", "is a reserved name"));
2610
+ }
2611
+ const name = readName(input.name, "name", errors);
2612
+ const description = readDescription(input.description, "description", errors);
2613
+ const fields = [];
2614
+ if (!Array.isArray(input.fields)) {
2615
+ errors.push(issue("fields", "invalid_type", "must be a list of fields"));
2616
+ } else if (input.fields.length === 0) {
2617
+ errors.push(issue("fields", "too_short", "must have at least 1 field"));
2618
+ } else if (input.fields.length > METAFIELD_LIMITS.fields_per_metaobject) {
2619
+ errors.push(issue("fields", "too_long", `must have at most ${METAFIELD_LIMITS.fields_per_metaobject} fields`));
2620
+ } else {
2621
+ const seen = /* @__PURE__ */ new Set();
2622
+ input.fields.forEach((raw, index) => {
2623
+ const path = joinPath("fields", index);
2624
+ const field = readField(raw, path, errors);
2625
+ if (!field) return;
2626
+ if (seen.has(field.key)) errors.push(issue(joinPath(path, "key"), "duplicate", `"${field.key}" is used twice`));
2627
+ seen.add(field.key);
2628
+ fields.push(field);
2629
+ });
2630
+ }
2631
+ const byKey = new Map(fields.map((field) => [field.key, field]));
2632
+ const isSingleLine = (key) => byKey.get(key)?.type === "single_line_text";
2633
+ let displayNameKey;
2634
+ if (input.display_name_key === void 0) {
2635
+ displayNameKey = fields.find((field) => field.type === "single_line_text")?.key ?? null;
2636
+ } else if (input.display_name_key === null) {
2637
+ displayNameKey = null;
2638
+ } else if (typeof input.display_name_key === "string" && isSingleLine(input.display_name_key)) {
2639
+ displayNameKey = input.display_name_key;
2640
+ } else {
2641
+ displayNameKey = null;
2642
+ errors.push(issue("display_name_key", "invalid_format", "must name a single line text field"));
2643
+ }
2644
+ const filterKeys = [];
2645
+ const rawFilters = input.filter_keys ?? [];
2646
+ if (!Array.isArray(rawFilters)) {
2647
+ errors.push(issue("filter_keys", "invalid_type", "must be a list of field keys"));
2648
+ } else if (rawFilters.length > METAFIELD_LIMITS.filter_keys) {
2649
+ errors.push(issue("filter_keys", "too_long", `must have at most ${METAFIELD_LIMITS.filter_keys} keys`));
2650
+ } else {
2651
+ rawFilters.forEach((key, index) => {
2652
+ const path = joinPath("filter_keys", index);
2653
+ const field = typeof key === "string" ? byKey.get(key) : void 0;
2654
+ if (!field) errors.push(issue(path, "invalid_format", "must name a field of this definition"));
2655
+ else if (!FILTERABLE_TYPES.includes(field.type)) {
2656
+ errors.push(issue(path, "not_allowed", "only single line text, true or false, integer and date fields can be filters"));
2657
+ } else if (filterKeys.includes(field.key)) errors.push(issue(path, "duplicate", `"${field.key}" is listed twice`));
2658
+ else filterKeys.push(field.key);
2659
+ });
2660
+ }
2661
+ const hasStatus = readBoolean(input.has_status, true, "has_status", errors);
2662
+ const storefront = readBoolean(input.storefront_access, false, "storefront_access", errors);
2663
+ const customer = input.customer_access ?? "none";
2664
+ if (customer !== "none" && customer !== "read") {
2665
+ errors.push(issue("customer_access", "not_allowed", "must be none or read"));
2666
+ }
2667
+ if (errors.length) return { ok: false, errors };
2668
+ return storable({
2669
+ type,
2670
+ name,
2671
+ description,
2672
+ fields,
2673
+ display_name_key: displayNameKey,
2674
+ filter_keys: filterKeys,
2675
+ has_status: hasStatus,
2676
+ storefront_access: storefront,
2677
+ customer_access: customer
2678
+ });
2679
+ }
2680
+ function validateMetaobjectEntry(fields, input, ctx) {
2681
+ if (!Array.isArray(fields)) return fail("", "invalid_type", "fields must be a list");
2682
+ if (!isPlainObject(input)) return fail("", "invalid_type", "must be an object of field values");
2683
+ const errors = unknownKeys(input, fields.map((field) => field.key), "");
2684
+ const out = {};
2685
+ for (const field of fields) {
2686
+ const raw = hasOwn(input, field.key) ? input[field.key] : void 0;
2687
+ if (isBlankValueFor(field.type, raw)) {
2688
+ if (field.required) errors.push(issue(field.key, "required", "is required"));
2689
+ continue;
2690
+ }
2691
+ const result = validateMetafieldValue(field.type, field.validations, raw, ctx, field.key);
2692
+ if (result.ok) {
2693
+ Object.defineProperty(out, field.key, { value: result.value, enumerable: true, writable: true, configurable: true });
2694
+ } else errors.push(...result.errors);
2695
+ }
2696
+ if (!errors.length && byteLength(JSON.stringify(out)) > METAFIELD_LIMITS.value_bytes) {
2697
+ return fail("", "too_large", `must be at most ${METAFIELD_LIMITS.value_bytes} bytes`);
2698
+ }
2699
+ return errors.length ? { ok: false, errors } : ok(out);
2700
+ }
2701
+ function entryDisplayName(definition, fields, handle) {
2702
+ const value = definition.display_name_key ? fields[definition.display_name_key] : void 0;
2703
+ return typeof value === "string" && value.trim() ? [...value.trim()].slice(0, METAFIELD_LIMITS.name_length).join("") : handle;
2704
+ }
2705
+ function checkMetaobjectFieldChanges(before, after) {
2706
+ const prior = new Map(before.map((field) => [field.key, field]));
2707
+ const errors = after.flatMap((field, index) => {
2708
+ const old = prior.get(field.key);
2709
+ return old && old.type !== field.type ? [issue(joinPath(joinPath("fields", index), "type"), "immutable", `cannot change the type of "${field.key}"`)] : [];
2710
+ });
2711
+ if (errors.length) return { ok: false, errors };
2712
+ const kept = new Set(after.map((field) => field.key));
2713
+ return ok({
2714
+ removed: before.filter((field) => !kept.has(field.key)).map((field) => field.key),
2715
+ added: after.filter((field) => !prior.has(field.key)).map((field) => field.key)
2716
+ });
2717
+ }
2718
+
1466
2719
  // src/modules/storage/image-transform.ts
1467
2720
  var OBJECT_PREFIX = "/storage/v1/object/public/";
1468
2721
  var RENDER_PREFIX = "/storage/v1/render/image/public/";
@@ -1872,6 +3125,42 @@ var ThemesApi = class {
1872
3125
  }
1873
3126
  };
1874
3127
 
3128
+ // src/modules/metaobjects/api.ts
3129
+ var EMPTY = { items: [], next_cursor: null };
3130
+ var MetaobjectsApi = class {
3131
+ constructor(publicHttp, authHttp) {
3132
+ this.publicHttp = publicHttp;
3133
+ this.authHttp = authHttp;
3134
+ }
3135
+ /**
3136
+ * Active entries of a metaobject type. A type that is unknown or hidden
3137
+ * from this reader lists as empty: the API answers 404 for both, the same
3138
+ * as a missing type, so it never reveals which types exist.
3139
+ */
3140
+ async list(storeRef, type, params = {}) {
3141
+ const query = new URLSearchParams();
3142
+ for (const [key, value] of Object.entries(params.filter ?? {})) {
3143
+ query.append(`filter[${key}]`, String(value));
3144
+ }
3145
+ if (params.cursor) query.set("cursor", params.cursor);
3146
+ if (params.limit !== void 0) query.set("limit", String(params.limit));
3147
+ const search = query.toString();
3148
+ const http = params.as_customer ? this.authHttp : this.publicHttp;
3149
+ const res = await http.get(
3150
+ `/public/stores/${storeRef}/metaobjects/${encodeURIComponent(type)}${search ? `?${search}` : ""}`
3151
+ );
3152
+ return unwrapOrNull(res, [404]) ?? EMPTY;
3153
+ }
3154
+ /** One active entry by handle; null when it, or its type, is missing or hidden. */
3155
+ async get(storeRef, type, handle, options = {}) {
3156
+ const http = options.as_customer ? this.authHttp : this.publicHttp;
3157
+ const res = await http.get(
3158
+ `/public/stores/${storeRef}/metaobjects/${encodeURIComponent(type)}/${encodeURIComponent(handle)}`
3159
+ );
3160
+ return unwrapOrNull(res, [404]);
3161
+ }
3162
+ };
3163
+
1875
3164
  // src/modules/search/api.ts
1876
3165
  var SearchApi = class {
1877
3166
  constructor(http) {
@@ -2063,6 +3352,24 @@ var CustomersApi = class {
2063
3352
  payload
2064
3353
  );
2065
3354
  }
3355
+ /** The signed-in customer's metafields with customer access (spec §6.6). */
3356
+ async getMetafields(storeRef) {
3357
+ const res = await this.http.get(
3358
+ `/tenant/stores/${storeRef}/customers/metafields`
3359
+ );
3360
+ return unwrap(res);
3361
+ }
3362
+ /**
3363
+ * Writes read_write metafields; `value: null` clears one. Throws
3364
+ * METAFIELD_VALUE_INVALID (details.errors[] by path) or METAFIELD_NOT_WRITABLE.
3365
+ */
3366
+ async updateMetafields(storeRef, values) {
3367
+ const res = await this.http.put(
3368
+ `/tenant/stores/${storeRef}/customers/metafields`,
3369
+ { values }
3370
+ );
3371
+ return unwrap(res);
3372
+ }
2066
3373
  };
2067
3374
 
2068
3375
  // src/modules/addresses/api.ts
@@ -2518,6 +3825,7 @@ function createEcomwebSdk(options) {
2518
3825
  blog: new BlogApi(publicHttp, authHttp),
2519
3826
  stores: new StoresApi(publicHttp),
2520
3827
  themes: new ThemesApi(publicHttp),
3828
+ metaobjects: new MetaobjectsApi(publicHttp, authHttp),
2521
3829
  search: new SearchApi(publicHttp),
2522
3830
  banners: new BannersApi(publicHttp),
2523
3831
  shipping: new ShippingApi(publicHttp),
@@ -2556,6 +3864,8 @@ export {
2556
3864
  DiscountMethodSchema,
2557
3865
  EMAIL_COLOR_PATTERN,
2558
3866
  EMAIL_PALETTE_DEFAULTS,
3867
+ ENTRY_HANDLE_PATTERN,
3868
+ FILTERABLE_TYPES,
2559
3869
  INVENTORY_ADJUSTMENT_REASONS,
2560
3870
  INVENTORY_ERROR_CODES,
2561
3871
  INVENTORY_POLICIES,
@@ -2568,15 +3878,26 @@ export {
2568
3878
  LEVEL_WARD,
2569
3879
  MAX_RULES_PER_SET,
2570
3880
  MAX_RULE_VALUE_ENTRIES,
3881
+ MEASUREMENT_UNITS,
3882
+ MEDIA_TYPES,
2571
3883
  MERCHANT_ADJUSTMENT_REASONS,
3884
+ METAFIELD_BASE_TYPES,
3885
+ METAFIELD_KEY_PATTERN,
3886
+ METAFIELD_LIMITS,
3887
+ METAFIELD_OWNER_TYPES,
3888
+ METAFIELD_TYPE_GROUPS,
3889
+ METAOBJECT_REFERENCE_TYPES,
3890
+ METAOBJECT_TYPE_PATTERN,
2572
3891
  MemoryTokenStorage,
2573
3892
  MenusApi,
3893
+ MetaobjectsApi,
2574
3894
  OBJECT_PREFIX,
2575
3895
  ORDER_ACTOR_TYPES,
2576
3896
  ORDER_EVENT_TYPES,
2577
3897
  ORDER_SOURCES,
2578
3898
  OrdersApi,
2579
3899
  PAGINATION_DEFAULTS,
3900
+ PRIVATE_REFERENCE_TYPES,
2580
3901
  PRODUCT_STATUS_LABELS,
2581
3902
  PROMOTION_MODE_COLORS,
2582
3903
  PROMOTION_MODE_LABELS,
@@ -2601,6 +3922,7 @@ export {
2601
3922
  PromotionWithDiscountSchema,
2602
3923
  PromotionsApi,
2603
3924
  RENDER_PREFIX,
3925
+ RESOURCE_REFERENCE_TYPES,
2604
3926
  RULE_FIELDS,
2605
3927
  RedirectsApi,
2606
3928
  ReviewsApi,
@@ -2614,6 +3936,9 @@ export {
2614
3936
  ThemesApi,
2615
3937
  UNAVAILABLE_STATES,
2616
3938
  UpdatePromotionSchema,
3939
+ VALIDATION_KEYS,
3940
+ allowedCustomerAccess,
3941
+ allowedFileKinds,
2617
3942
  allowedValuesFor,
2618
3943
  appliedPromotionSchema,
2619
3944
  assetBaseUrl,
@@ -2623,6 +3948,7 @@ export {
2623
3948
  baseDeleteOptionsSchema,
2624
3949
  baseDeleteResultSchema,
2625
3950
  baseQueryParamsSchema,
3951
+ baseTypeOf,
2626
3952
  blogCategorySchema,
2627
3953
  blogCommentSchema,
2628
3954
  blogCommentWithRepliesSchema,
@@ -2637,7 +3963,9 @@ export {
2637
3963
  categorySchema,
2638
3964
  categoryTreeSchema,
2639
3965
  categoryWithChildrenSchema,
3966
+ checkMetaobjectFieldChanges,
2640
3967
  colorSchema,
3968
+ compareDecimal,
2641
3969
  contentPageSchema,
2642
3970
  createAuthAwareHttpClient,
2643
3971
  createBannerSchema,
@@ -2671,22 +3999,35 @@ export {
2671
3999
  embeddedScriptPlacementSchema,
2672
4000
  embeddedScriptSchema,
2673
4001
  ensureSuccess,
4002
+ entryDisplayName,
2674
4003
  fromObjectPublicUrlToRender,
2675
4004
  fulfillmentStatusSchema,
2676
4005
  idSchema,
2677
4006
  integrationStatusSchema,
2678
4007
  inventoryStatusSchema,
4008
+ isBlankValue,
4009
+ isBlankValueFor,
2679
4010
  isEditableStatus,
4011
+ isListType,
4012
+ isMetafieldType,
2680
4013
  isPublishableStatus,
2681
4014
  isRuleField,
4015
+ isSafeRegex,
2682
4016
  isSettingVisible,
2683
4017
  isUnpublishedStatus,
4018
+ isValidEntryHandle,
2684
4019
  jsonSchema,
2685
4020
  legacyOrderStatusSchema,
2686
4021
  legacyProductStatusSchema,
2687
4022
  legalLinksSchema,
4023
+ measurementInBaseUnit,
2688
4024
  messageOutboxStatusSchema,
4025
+ metafieldIdentifier,
2689
4026
  moneySchema,
4027
+ normalizeDate,
4028
+ normalizeDateTime,
4029
+ normalizeDecimal,
4030
+ normalizeId,
2690
4031
  onHand,
2691
4032
  operatorsForField,
2692
4033
  optionalTimestampSchema,
@@ -2698,6 +4039,7 @@ export {
2698
4039
  paginatedResponseSchema,
2699
4040
  paginationMetaSchema,
2700
4041
  paginationSchema,
4042
+ parseMetafieldIdentifier,
2701
4043
  parseStorageUrl,
2702
4044
  parseThemeSchema,
2703
4045
  paymentMethodSchema,
@@ -2723,6 +4065,7 @@ export {
2723
4065
  resolveThemeSettings,
2724
4066
  reviewStatusSchema,
2725
4067
  rewriteSupabaseUrl,
4068
+ richTextLength,
2726
4069
  safeParseBaseQueryParams,
2727
4070
  safeParsePaginationMeta,
2728
4071
  shippingStatusSchema,
@@ -2734,11 +4077,14 @@ export {
2734
4077
  storeSettingsSchema,
2735
4078
  storeStatusSchema,
2736
4079
  storeWithRelationsSchema,
4080
+ storefrontAccessAllowed,
2737
4081
  strictUrlSchema,
2738
4082
  themeDefaults,
2739
4083
  themeSchemaSchema,
2740
4084
  themeSettings,
2741
4085
  timestampSchema,
4086
+ toEntryHandle,
4087
+ toMetafieldKey,
2742
4088
  toObjectUrl,
2743
4089
  toRenderUrl,
2744
4090
  tocItemSchema,
@@ -2769,8 +4115,14 @@ export {
2769
4115
  updateVariantOptionValueSchema,
2770
4116
  urlSchema,
2771
4117
  uuidSchema,
4118
+ validateMetafieldDefinition,
4119
+ validateMetafieldValue,
4120
+ validateMetaobjectDefinition,
4121
+ validateMetaobjectEntry,
2772
4122
  validatePaginationMeta,
4123
+ validateRichText,
2773
4124
  validateThemeValues,
4125
+ validateValidations,
2774
4126
  valueKindFor,
2775
4127
  variantOptionSchema,
2776
4128
  variantOptionValueSchema,