@01.software/sdk 0.27.0 → 0.28.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.
Files changed (40) hide show
  1. package/README.md +125 -1
  2. package/dist/analytics/react.cjs.map +1 -1
  3. package/dist/analytics/react.js.map +1 -1
  4. package/dist/analytics.cjs.map +1 -1
  5. package/dist/analytics.js.map +1 -1
  6. package/dist/{const-D-xucnw4.d.ts → const-Cz9Ki_I7.d.cts} +4 -4
  7. package/dist/{const-C0GlmeJ_.d.cts → const-mdQQtIOz.d.ts} +4 -4
  8. package/dist/index.cjs +84 -7
  9. package/dist/index.cjs.map +1 -1
  10. package/dist/index.d.cts +19 -8
  11. package/dist/index.d.ts +19 -8
  12. package/dist/index.js +84 -7
  13. package/dist/index.js.map +1 -1
  14. package/dist/{payload-types-BPvUmPAq.d.cts → payload-types-BrSYb-sh.d.cts} +145 -70
  15. package/dist/{payload-types-BPvUmPAq.d.ts → payload-types-BrSYb-sh.d.ts} +145 -70
  16. package/dist/realtime.cjs.map +1 -1
  17. package/dist/realtime.d.cts +2 -2
  18. package/dist/realtime.d.ts +2 -2
  19. package/dist/realtime.js.map +1 -1
  20. package/dist/{server-_zvihptw.d.ts → server-C2Q9R-Lu.d.ts} +228 -9
  21. package/dist/{server-n3xK4Nks.d.cts → server-D369bCVJ.d.cts} +228 -9
  22. package/dist/server.cjs +71 -4
  23. package/dist/server.cjs.map +1 -1
  24. package/dist/server.d.cts +4 -4
  25. package/dist/server.d.ts +4 -4
  26. package/dist/server.js +71 -4
  27. package/dist/server.js.map +1 -1
  28. package/dist/{types-BLdthWiW.d.ts → types-BLUb4cYq.d.ts} +1 -1
  29. package/dist/{types-DzWNu9pw.d.cts → types-CW4PaIL7.d.cts} +1 -1
  30. package/dist/ui/canvas/server.cjs.map +1 -1
  31. package/dist/ui/canvas/server.js.map +1 -1
  32. package/dist/ui/canvas.cjs.map +1 -1
  33. package/dist/ui/canvas.js.map +1 -1
  34. package/dist/ui/form.d.cts +1 -1
  35. package/dist/ui/form.d.ts +1 -1
  36. package/dist/ui/video.d.cts +1 -1
  37. package/dist/ui/video.d.ts +1 -1
  38. package/dist/webhook.d.cts +3 -3
  39. package/dist/webhook.d.ts +3 -3
  40. package/package.json +3 -3
package/dist/server.cjs CHANGED
@@ -1374,6 +1374,32 @@ var ProductApi = class extends BaseApi {
1374
1374
  params
1375
1375
  );
1376
1376
  }
1377
+ /**
1378
+ * Fetch full product detail by slug or id.
1379
+ * Returns `null` on 404 regardless of reason (`not_found` / `not_published` /
1380
+ * `tenant_mismatch` / `feature_disabled`). For the reason behind a null,
1381
+ * inspect `client.lastRequestId` against backend logs.
1382
+ */
1383
+ async detail(params) {
1384
+ try {
1385
+ return await this.request("/api/products/detail", params);
1386
+ } catch (err) {
1387
+ if (err instanceof NotFoundError) return null;
1388
+ throw err;
1389
+ }
1390
+ }
1391
+ /**
1392
+ * Atomically create or update a product together with its options,
1393
+ * option-values, and variants in a single transaction. Mirrors Shopify's
1394
+ * `productSet` shape and is the canonical write path for the MCP
1395
+ * `product-upsert` tool.
1396
+ */
1397
+ upsert(params) {
1398
+ return this.request(
1399
+ "/api/products/upsert",
1400
+ params
1401
+ );
1402
+ }
1377
1403
  };
1378
1404
 
1379
1405
  // src/core/api/discount-api.ts
@@ -1466,7 +1492,9 @@ var ServerCommerceClient = class {
1466
1492
  const orderApi = new OrderApi(serverOptions);
1467
1493
  this.product = {
1468
1494
  stockCheck: productApi.stockCheck.bind(productApi),
1469
- listingGroups: productApi.listingGroups.bind(productApi)
1495
+ listingGroups: productApi.listingGroups.bind(productApi),
1496
+ detail: productApi.detail.bind(productApi),
1497
+ upsert: productApi.upsert.bind(productApi)
1470
1498
  };
1471
1499
  this.cart = {
1472
1500
  get: cartApi.getCart.bind(cartApi),
@@ -1553,10 +1581,24 @@ var customerKeys = {
1553
1581
  };
1554
1582
  var productKeys = {
1555
1583
  listingGroups: (options) => ["products", "listing-groups", "list", options],
1556
- listingGroupsInfinite: (options) => ["products", "listing-groups", "infinite", options]
1584
+ listingGroupsInfinite: (options) => ["products", "listing-groups", "infinite", options],
1585
+ detail: (params) => ["products", "detail", params],
1586
+ detailAll: () => ["products", "detail"]
1557
1587
  };
1558
1588
 
1559
1589
  // src/core/query/collection-hooks.ts
1590
+ var PRODUCT_DETAIL_INVALIDATING_COLLECTIONS = /* @__PURE__ */ new Set([
1591
+ "products",
1592
+ "product-variants",
1593
+ "product-options",
1594
+ "product-option-values",
1595
+ "product-categories",
1596
+ "product-tags",
1597
+ "product-collections",
1598
+ "brands",
1599
+ "brand-logos",
1600
+ "images"
1601
+ ]);
1560
1602
  var DEFAULT_PAGE_SIZE = 20;
1561
1603
  var CollectionHooks = class {
1562
1604
  constructor(queryClient, collectionClient) {
@@ -1714,6 +1756,9 @@ var CollectionHooks = class {
1714
1756
  this.queryClient.invalidateQueries({
1715
1757
  queryKey: collectionKeys(collection).all
1716
1758
  });
1759
+ if (PRODUCT_DETAIL_INVALIDATING_COLLECTIONS.has(collection)) {
1760
+ this.queryClient.invalidateQueries({ queryKey: ["products", "detail"] });
1761
+ }
1717
1762
  options?.onSuccess?.(data);
1718
1763
  },
1719
1764
  onError: options?.onError,
@@ -1734,6 +1779,9 @@ var CollectionHooks = class {
1734
1779
  this.queryClient.invalidateQueries({
1735
1780
  queryKey: collectionKeys(collection).all
1736
1781
  });
1782
+ if (PRODUCT_DETAIL_INVALIDATING_COLLECTIONS.has(collection)) {
1783
+ this.queryClient.invalidateQueries({ queryKey: ["products", "detail"] });
1784
+ }
1737
1785
  options?.onSuccess?.(data);
1738
1786
  },
1739
1787
  onError: options?.onError,
@@ -1750,6 +1798,9 @@ var CollectionHooks = class {
1750
1798
  this.queryClient.invalidateQueries({
1751
1799
  queryKey: collectionKeys(collection).all
1752
1800
  });
1801
+ if (PRODUCT_DETAIL_INVALIDATING_COLLECTIONS.has(collection)) {
1802
+ this.queryClient.invalidateQueries({ queryKey: ["products", "detail"] });
1803
+ }
1753
1804
  options?.onSuccess?.(data);
1754
1805
  },
1755
1806
  onError: options?.onError,
@@ -1902,7 +1953,7 @@ var CustomerHooks = class {
1902
1953
 
1903
1954
  // src/core/query/query-hooks.ts
1904
1955
  var QueryHooks = class extends CollectionHooks {
1905
- constructor(queryClient, collectionClient, customerAuth) {
1956
+ constructor(queryClient, collectionClient, customerAuth, commerceClient) {
1906
1957
  super(queryClient, collectionClient);
1907
1958
  // --- Customer hooks delegation ---
1908
1959
  this.useCustomerMe = (...args) => this._customer.useCustomerMe(...args);
@@ -1919,6 +1970,7 @@ var QueryHooks = class extends CollectionHooks {
1919
1970
  this.getCustomerData = () => this._customer.getCustomerData();
1920
1971
  this.setCustomerData = (data) => this._customer.setCustomerData(data);
1921
1972
  this._customer = new CustomerHooks(queryClient, customerAuth);
1973
+ this._commerce = commerceClient;
1922
1974
  }
1923
1975
  useProductListingGroupsQuery(params, options) {
1924
1976
  const queryOptions = params.options;
@@ -2012,6 +2064,21 @@ var QueryHooks = class extends CollectionHooks {
2012
2064
  staleTime: options?.staleTime
2013
2065
  });
2014
2066
  }
2067
+ useProductDetail(params, options) {
2068
+ const discriminator = "slug" in params ? params.slug : params.id;
2069
+ const enabled = options?.enabled !== false && Boolean(discriminator);
2070
+ return (0, import_react_query4.useQuery)({
2071
+ queryKey: productKeys.detail(params),
2072
+ queryFn: () => this._commerce.product.detail(params),
2073
+ enabled
2074
+ });
2075
+ }
2076
+ useProductDetailBySlug(slug, options) {
2077
+ return this.useProductDetail({ slug }, options);
2078
+ }
2079
+ useProductDetailById(id, options) {
2080
+ return this.useProductDetail({ id }, options);
2081
+ }
2015
2082
  };
2016
2083
 
2017
2084
  // src/core/client/client.server.ts
@@ -2062,7 +2129,7 @@ var ServerClient = class {
2062
2129
  onRequestId
2063
2130
  );
2064
2131
  this.queryClient = getQueryClient();
2065
- this.query = new QueryHooks(this.queryClient, this.collections);
2132
+ this.query = new QueryHooks(this.queryClient, this.collections, void 0, this.commerce);
2066
2133
  }
2067
2134
  getState() {
2068
2135
  return { ...this.state };