@01.software/sdk 0.27.0 → 0.29.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-C0GlmeJ_.d.cts → const-DAjQYNuM.d.ts} +4 -4
  7. package/dist/{const-D-xucnw4.d.ts → const-Dsixdi6z.d.cts} +4 -4
  8. package/dist/index.cjs +626 -13
  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 +626 -13
  13. package/dist/index.js.map +1 -1
  14. package/dist/{payload-types-BPvUmPAq.d.cts → payload-types-Ci-ZA7aM.d.cts} +153 -73
  15. package/dist/{payload-types-BPvUmPAq.d.ts → payload-types-Ci-ZA7aM.d.ts} +153 -73
  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-n3xK4Nks.d.cts → server-C0C8dtms.d.cts} +331 -12
  21. package/dist/{server-_zvihptw.d.ts → server-Cv0Q4dPQ.d.ts} +331 -12
  22. package/dist/server.cjs +68 -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 +68 -4
  27. package/dist/server.js.map +1 -1
  28. package/dist/{types-BLdthWiW.d.ts → types-BWq_WlbB.d.ts} +1 -1
  29. package/dist/{types-DzWNu9pw.d.cts → types-zKjATmDK.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 +1 -1
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, ag as ModerationApi, b4 as ServerClient, b5 as ServerCollectionClient, b7 as ServerCommerceClient, by as createServerClient } from './server-C0C8dtms.cjs';
2
+ import './payload-types-Ci-ZA7aM.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-zKjATmDK.cjs';
7
+ import './const-Dsixdi6z.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, ag as ModerationApi, b4 as ServerClient, b5 as ServerCollectionClient, b7 as ServerCommerceClient, by as createServerClient } from './server-Cv0Q4dPQ.js';
2
+ import './payload-types-Ci-ZA7aM.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-BWq_WlbB.js';
7
+ import './const-DAjQYNuM.js';
package/dist/server.js CHANGED
@@ -1342,6 +1342,29 @@ 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("/api/products/upsert", params);
1367
+ }
1345
1368
  };
1346
1369
 
1347
1370
  // src/core/api/discount-api.ts
@@ -1434,7 +1457,9 @@ var ServerCommerceClient = class {
1434
1457
  const orderApi = new OrderApi(serverOptions);
1435
1458
  this.product = {
1436
1459
  stockCheck: productApi.stockCheck.bind(productApi),
1437
- listingGroups: productApi.listingGroups.bind(productApi)
1460
+ listingGroups: productApi.listingGroups.bind(productApi),
1461
+ detail: productApi.detail.bind(productApi),
1462
+ upsert: productApi.upsert.bind(productApi)
1438
1463
  };
1439
1464
  this.cart = {
1440
1465
  get: cartApi.getCart.bind(cartApi),
@@ -1536,10 +1561,24 @@ var customerKeys = {
1536
1561
  };
1537
1562
  var productKeys = {
1538
1563
  listingGroups: (options) => ["products", "listing-groups", "list", options],
1539
- listingGroupsInfinite: (options) => ["products", "listing-groups", "infinite", options]
1564
+ listingGroupsInfinite: (options) => ["products", "listing-groups", "infinite", options],
1565
+ detail: (params) => ["products", "detail", params],
1566
+ detailAll: () => ["products", "detail"]
1540
1567
  };
1541
1568
 
1542
1569
  // src/core/query/collection-hooks.ts
1570
+ var PRODUCT_DETAIL_INVALIDATING_COLLECTIONS = /* @__PURE__ */ new Set([
1571
+ "products",
1572
+ "product-variants",
1573
+ "product-options",
1574
+ "product-option-values",
1575
+ "product-categories",
1576
+ "product-tags",
1577
+ "product-collections",
1578
+ "brands",
1579
+ "brand-logos",
1580
+ "images"
1581
+ ]);
1543
1582
  var DEFAULT_PAGE_SIZE = 20;
1544
1583
  var CollectionHooks = class {
1545
1584
  constructor(queryClient, collectionClient) {
@@ -1697,6 +1736,9 @@ var CollectionHooks = class {
1697
1736
  this.queryClient.invalidateQueries({
1698
1737
  queryKey: collectionKeys(collection).all
1699
1738
  });
1739
+ if (PRODUCT_DETAIL_INVALIDATING_COLLECTIONS.has(collection)) {
1740
+ this.queryClient.invalidateQueries({ queryKey: ["products", "detail"] });
1741
+ }
1700
1742
  options?.onSuccess?.(data);
1701
1743
  },
1702
1744
  onError: options?.onError,
@@ -1717,6 +1759,9 @@ var CollectionHooks = class {
1717
1759
  this.queryClient.invalidateQueries({
1718
1760
  queryKey: collectionKeys(collection).all
1719
1761
  });
1762
+ if (PRODUCT_DETAIL_INVALIDATING_COLLECTIONS.has(collection)) {
1763
+ this.queryClient.invalidateQueries({ queryKey: ["products", "detail"] });
1764
+ }
1720
1765
  options?.onSuccess?.(data);
1721
1766
  },
1722
1767
  onError: options?.onError,
@@ -1733,6 +1778,9 @@ var CollectionHooks = class {
1733
1778
  this.queryClient.invalidateQueries({
1734
1779
  queryKey: collectionKeys(collection).all
1735
1780
  });
1781
+ if (PRODUCT_DETAIL_INVALIDATING_COLLECTIONS.has(collection)) {
1782
+ this.queryClient.invalidateQueries({ queryKey: ["products", "detail"] });
1783
+ }
1736
1784
  options?.onSuccess?.(data);
1737
1785
  },
1738
1786
  onError: options?.onError,
@@ -1888,7 +1936,7 @@ var CustomerHooks = class {
1888
1936
 
1889
1937
  // src/core/query/query-hooks.ts
1890
1938
  var QueryHooks = class extends CollectionHooks {
1891
- constructor(queryClient, collectionClient, customerAuth) {
1939
+ constructor(queryClient, collectionClient, customerAuth, commerceClient) {
1892
1940
  super(queryClient, collectionClient);
1893
1941
  // --- Customer hooks delegation ---
1894
1942
  this.useCustomerMe = (...args) => this._customer.useCustomerMe(...args);
@@ -1905,6 +1953,7 @@ var QueryHooks = class extends CollectionHooks {
1905
1953
  this.getCustomerData = () => this._customer.getCustomerData();
1906
1954
  this.setCustomerData = (data) => this._customer.setCustomerData(data);
1907
1955
  this._customer = new CustomerHooks(queryClient, customerAuth);
1956
+ this._commerce = commerceClient;
1908
1957
  }
1909
1958
  useProductListingGroupsQuery(params, options) {
1910
1959
  const queryOptions = params.options;
@@ -1998,6 +2047,21 @@ var QueryHooks = class extends CollectionHooks {
1998
2047
  staleTime: options?.staleTime
1999
2048
  });
2000
2049
  }
2050
+ useProductDetail(params, options) {
2051
+ const discriminator = "slug" in params ? params.slug : params.id;
2052
+ const enabled = options?.enabled !== false && Boolean(discriminator);
2053
+ return useQueryOriginal3({
2054
+ queryKey: productKeys.detail(params),
2055
+ queryFn: () => this._commerce.product.detail(params),
2056
+ enabled
2057
+ });
2058
+ }
2059
+ useProductDetailBySlug(slug, options) {
2060
+ return this.useProductDetail({ slug }, options);
2061
+ }
2062
+ useProductDetailById(id, options) {
2063
+ return this.useProductDetail({ id }, options);
2064
+ }
2001
2065
  };
2002
2066
 
2003
2067
  // src/core/client/client.server.ts
@@ -2048,7 +2112,7 @@ var ServerClient = class {
2048
2112
  onRequestId
2049
2113
  );
2050
2114
  this.queryClient = getQueryClient();
2051
- this.query = new QueryHooks(this.queryClient, this.collections);
2115
+ this.query = new QueryHooks(this.queryClient, this.collections, void 0, this.commerce);
2052
2116
  }
2053
2117
  getState() {
2054
2118
  return { ...this.state };