@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.d.cts CHANGED
@@ -1,7 +1,7 @@
1
- export { z as ClientServerConfig, D as CollectionClient, m as CommunityClient, ad as ModerationApi, aL as ServerClient, aM as ServerCollectionClient, aO as ServerCommerceClient, bb as createServerClient } from './server-n3xK4Nks.cjs';
2
- import './payload-types-BPvUmPAq.cjs';
1
+ export { E as ClientServerConfig, F as CollectionClient, o as CommunityClient, af as ModerationApi, aX as ServerClient, aY as ServerCollectionClient, a_ as ServerCommerceClient, bn as createServerClient } from './server-D369bCVJ.cjs';
2
+ import './payload-types-BrSYb-sh.cjs';
3
3
  import '@tanstack/react-query';
4
4
  import 'payload';
5
5
  import 'next';
6
- import './types-DzWNu9pw.cjs';
7
- import './const-C0GlmeJ_.cjs';
6
+ import './types-CW4PaIL7.cjs';
7
+ import './const-Cz9Ki_I7.cjs';
package/dist/server.d.ts CHANGED
@@ -1,7 +1,7 @@
1
- export { z as ClientServerConfig, D as CollectionClient, m as CommunityClient, ad as ModerationApi, aL as ServerClient, aM as ServerCollectionClient, aO as ServerCommerceClient, bb as createServerClient } from './server-_zvihptw.js';
2
- import './payload-types-BPvUmPAq.js';
1
+ export { E as ClientServerConfig, F as CollectionClient, o as CommunityClient, af as ModerationApi, aX as ServerClient, aY as ServerCollectionClient, a_ as ServerCommerceClient, bn as createServerClient } from './server-C2Q9R-Lu.js';
2
+ import './payload-types-BrSYb-sh.js';
3
3
  import '@tanstack/react-query';
4
4
  import 'payload';
5
5
  import 'next';
6
- import './types-BLdthWiW.js';
7
- import './const-D-xucnw4.js';
6
+ import './types-BLUb4cYq.js';
7
+ import './const-mdQQtIOz.js';
package/dist/server.js CHANGED
@@ -1342,6 +1342,32 @@ var ProductApi = class extends BaseApi {
1342
1342
  params
1343
1343
  );
1344
1344
  }
1345
+ /**
1346
+ * Fetch full product detail by slug or id.
1347
+ * Returns `null` on 404 regardless of reason (`not_found` / `not_published` /
1348
+ * `tenant_mismatch` / `feature_disabled`). For the reason behind a null,
1349
+ * inspect `client.lastRequestId` against backend logs.
1350
+ */
1351
+ async detail(params) {
1352
+ try {
1353
+ return await this.request("/api/products/detail", params);
1354
+ } catch (err) {
1355
+ if (err instanceof NotFoundError) return null;
1356
+ throw err;
1357
+ }
1358
+ }
1359
+ /**
1360
+ * Atomically create or update a product together with its options,
1361
+ * option-values, and variants in a single transaction. Mirrors Shopify's
1362
+ * `productSet` shape and is the canonical write path for the MCP
1363
+ * `product-upsert` tool.
1364
+ */
1365
+ upsert(params) {
1366
+ return this.request(
1367
+ "/api/products/upsert",
1368
+ params
1369
+ );
1370
+ }
1345
1371
  };
1346
1372
 
1347
1373
  // src/core/api/discount-api.ts
@@ -1434,7 +1460,9 @@ var ServerCommerceClient = class {
1434
1460
  const orderApi = new OrderApi(serverOptions);
1435
1461
  this.product = {
1436
1462
  stockCheck: productApi.stockCheck.bind(productApi),
1437
- listingGroups: productApi.listingGroups.bind(productApi)
1463
+ listingGroups: productApi.listingGroups.bind(productApi),
1464
+ detail: productApi.detail.bind(productApi),
1465
+ upsert: productApi.upsert.bind(productApi)
1438
1466
  };
1439
1467
  this.cart = {
1440
1468
  get: cartApi.getCart.bind(cartApi),
@@ -1536,10 +1564,24 @@ var customerKeys = {
1536
1564
  };
1537
1565
  var productKeys = {
1538
1566
  listingGroups: (options) => ["products", "listing-groups", "list", options],
1539
- listingGroupsInfinite: (options) => ["products", "listing-groups", "infinite", options]
1567
+ listingGroupsInfinite: (options) => ["products", "listing-groups", "infinite", options],
1568
+ detail: (params) => ["products", "detail", params],
1569
+ detailAll: () => ["products", "detail"]
1540
1570
  };
1541
1571
 
1542
1572
  // src/core/query/collection-hooks.ts
1573
+ var PRODUCT_DETAIL_INVALIDATING_COLLECTIONS = /* @__PURE__ */ new Set([
1574
+ "products",
1575
+ "product-variants",
1576
+ "product-options",
1577
+ "product-option-values",
1578
+ "product-categories",
1579
+ "product-tags",
1580
+ "product-collections",
1581
+ "brands",
1582
+ "brand-logos",
1583
+ "images"
1584
+ ]);
1543
1585
  var DEFAULT_PAGE_SIZE = 20;
1544
1586
  var CollectionHooks = class {
1545
1587
  constructor(queryClient, collectionClient) {
@@ -1697,6 +1739,9 @@ var CollectionHooks = class {
1697
1739
  this.queryClient.invalidateQueries({
1698
1740
  queryKey: collectionKeys(collection).all
1699
1741
  });
1742
+ if (PRODUCT_DETAIL_INVALIDATING_COLLECTIONS.has(collection)) {
1743
+ this.queryClient.invalidateQueries({ queryKey: ["products", "detail"] });
1744
+ }
1700
1745
  options?.onSuccess?.(data);
1701
1746
  },
1702
1747
  onError: options?.onError,
@@ -1717,6 +1762,9 @@ var CollectionHooks = class {
1717
1762
  this.queryClient.invalidateQueries({
1718
1763
  queryKey: collectionKeys(collection).all
1719
1764
  });
1765
+ if (PRODUCT_DETAIL_INVALIDATING_COLLECTIONS.has(collection)) {
1766
+ this.queryClient.invalidateQueries({ queryKey: ["products", "detail"] });
1767
+ }
1720
1768
  options?.onSuccess?.(data);
1721
1769
  },
1722
1770
  onError: options?.onError,
@@ -1733,6 +1781,9 @@ var CollectionHooks = class {
1733
1781
  this.queryClient.invalidateQueries({
1734
1782
  queryKey: collectionKeys(collection).all
1735
1783
  });
1784
+ if (PRODUCT_DETAIL_INVALIDATING_COLLECTIONS.has(collection)) {
1785
+ this.queryClient.invalidateQueries({ queryKey: ["products", "detail"] });
1786
+ }
1736
1787
  options?.onSuccess?.(data);
1737
1788
  },
1738
1789
  onError: options?.onError,
@@ -1888,7 +1939,7 @@ var CustomerHooks = class {
1888
1939
 
1889
1940
  // src/core/query/query-hooks.ts
1890
1941
  var QueryHooks = class extends CollectionHooks {
1891
- constructor(queryClient, collectionClient, customerAuth) {
1942
+ constructor(queryClient, collectionClient, customerAuth, commerceClient) {
1892
1943
  super(queryClient, collectionClient);
1893
1944
  // --- Customer hooks delegation ---
1894
1945
  this.useCustomerMe = (...args) => this._customer.useCustomerMe(...args);
@@ -1905,6 +1956,7 @@ var QueryHooks = class extends CollectionHooks {
1905
1956
  this.getCustomerData = () => this._customer.getCustomerData();
1906
1957
  this.setCustomerData = (data) => this._customer.setCustomerData(data);
1907
1958
  this._customer = new CustomerHooks(queryClient, customerAuth);
1959
+ this._commerce = commerceClient;
1908
1960
  }
1909
1961
  useProductListingGroupsQuery(params, options) {
1910
1962
  const queryOptions = params.options;
@@ -1998,6 +2050,21 @@ var QueryHooks = class extends CollectionHooks {
1998
2050
  staleTime: options?.staleTime
1999
2051
  });
2000
2052
  }
2053
+ useProductDetail(params, options) {
2054
+ const discriminator = "slug" in params ? params.slug : params.id;
2055
+ const enabled = options?.enabled !== false && Boolean(discriminator);
2056
+ return useQueryOriginal3({
2057
+ queryKey: productKeys.detail(params),
2058
+ queryFn: () => this._commerce.product.detail(params),
2059
+ enabled
2060
+ });
2061
+ }
2062
+ useProductDetailBySlug(slug, options) {
2063
+ return this.useProductDetail({ slug }, options);
2064
+ }
2065
+ useProductDetailById(id, options) {
2066
+ return this.useProductDetail({ id }, options);
2067
+ }
2001
2068
  };
2002
2069
 
2003
2070
  // src/core/client/client.server.ts
@@ -2048,7 +2115,7 @@ var ServerClient = class {
2048
2115
  onRequestId
2049
2116
  );
2050
2117
  this.queryClient = getQueryClient();
2051
- this.query = new QueryHooks(this.queryClient, this.collections);
2118
+ this.query = new QueryHooks(this.queryClient, this.collections, void 0, this.commerce);
2052
2119
  }
2053
2120
  getState() {
2054
2121
  return { ...this.state };