@cimplify/sdk 0.38.2 → 0.38.4

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 (53) hide show
  1. package/dist/advanced.js +20 -20
  2. package/dist/advanced.mjs +1 -1
  3. package/dist/{chunk-ZYACIPKO.js → chunk-5VHKZTFJ.js} +35 -35
  4. package/dist/{chunk-HKVRUGM6.js → chunk-BAWKQRIB.js} +6 -1
  5. package/dist/{chunk-TFHKVQLL.mjs → chunk-EZK2FXTM.mjs} +6 -1
  6. package/dist/{chunk-2X6P5WJZ.mjs → chunk-JTU5P6GM.mjs} +1 -1
  7. package/dist/dispatcher.mjs +1 -1
  8. package/dist/index.js +66 -66
  9. package/dist/index.mjs +2 -2
  10. package/dist/mock/cli.mjs +1129 -436
  11. package/dist/mock/library.d.mts +2 -2
  12. package/dist/mock/library.d.ts +2 -2
  13. package/dist/mock/library.js +1129 -436
  14. package/dist/mock/library.mjs +1129 -436
  15. package/dist/mock/msw.d.mts +1 -1
  16. package/dist/mock/msw.d.ts +1 -1
  17. package/dist/mock/msw.js +1129 -436
  18. package/dist/mock/msw.mjs +1129 -436
  19. package/dist/react.js +60 -60
  20. package/dist/react.mjs +3 -3
  21. package/dist/{server-B8TeE2OD.d.mts → server-CVEsjECc.d.mts} +45 -0
  22. package/dist/{server-B8TeE2OD.d.ts → server-CVEsjECc.d.ts} +45 -0
  23. package/dist/styles.css +1 -1
  24. package/package.json +1 -1
  25. package/templates/storefront/.env.example +11 -2
  26. package/templates/storefront/README.md +35 -18
  27. package/templates/storefront/app/cart/page.tsx +9 -0
  28. package/templates/storefront/app/categories/[slug]/page.tsx +80 -0
  29. package/templates/storefront/app/checkout/page.tsx +17 -0
  30. package/templates/storefront/app/collections/[slug]/page.tsx +80 -0
  31. package/templates/storefront/app/globals.css +47 -0
  32. package/templates/storefront/app/layout.tsx +45 -0
  33. package/templates/storefront/app/orders/[id]/page.tsx +21 -0
  34. package/templates/storefront/app/page.tsx +65 -0
  35. package/templates/storefront/app/shop/page.tsx +46 -0
  36. package/templates/storefront/components/category-grid.tsx +28 -0
  37. package/templates/storefront/components/collection-strip.tsx +45 -0
  38. package/templates/storefront/components/footer.tsx +19 -0
  39. package/templates/storefront/components/header.tsx +41 -0
  40. package/templates/storefront/components/hero.tsx +25 -0
  41. package/templates/storefront/components/product-modal.tsx +105 -0
  42. package/templates/storefront/components/providers.tsx +31 -0
  43. package/templates/storefront/components/store-product-card.tsx +99 -0
  44. package/templates/storefront/lib/cart.ts +27 -0
  45. package/templates/storefront/next.config.ts +36 -0
  46. package/templates/storefront/package.json +13 -14
  47. package/templates/storefront/postcss.config.mjs +7 -0
  48. package/templates/storefront/tsconfig.json +15 -11
  49. package/templates/storefront/index.html +0 -12
  50. package/templates/storefront/src/App.tsx +0 -118
  51. package/templates/storefront/src/main.tsx +0 -28
  52. package/templates/storefront/src/styles.css +0 -65
  53. package/templates/storefront/vite.config.ts +0 -8
@@ -1,118 +0,0 @@
1
- import { useEffect, useState } from "react";
2
- import { Routes, Route, NavLink, useNavigate } from "react-router-dom";
3
- import { CataloguePage, CartPage, CheckoutPage, useCimplifyClient } from "@cimplify/sdk/react";
4
- import type { Product, Category } from "@cimplify/sdk";
5
-
6
- function CartPill({ count }: { count: number }) {
7
- return <span className="cimplify-storefront__cart-pill">Cart · {count}</span>;
8
- }
9
-
10
- function Catalogue() {
11
- const navigate = useNavigate();
12
- const { client } = useCimplifyClient();
13
- const [products, setProducts] = useState<Product[] | undefined>(undefined);
14
- const [categories, setCategories] = useState<Category[] | undefined>(undefined);
15
- const [loading, setLoading] = useState(true);
16
-
17
- useEffect(() => {
18
- let cancelled = false;
19
- void (async () => {
20
- try {
21
- const [p, c] = await Promise.all([
22
- client.catalogue.getProducts({ limit: 50 }),
23
- client.catalogue.getCategories(),
24
- ]);
25
- if (cancelled) return;
26
- if (p.ok) setProducts(p.value.items);
27
- if (c.ok) setCategories(c.value);
28
- } finally {
29
- if (!cancelled) setLoading(false);
30
- }
31
- })();
32
- return () => {
33
- cancelled = true;
34
- };
35
- }, [client]);
36
-
37
- if (loading) return <p>Loading shop…</p>;
38
- return (
39
- <CataloguePage
40
- title="Shop"
41
- products={products}
42
- categories={categories}
43
- onProductClick={(p: Product) => navigate(`/products/${p.id}`)}
44
- />
45
- );
46
- }
47
-
48
- function ProductDetail() {
49
- return (
50
- <div>
51
- <p>Product detail page — wire up your favourite ProductPage layout here.</p>
52
- <p>The SDK ships <code>&lt;ProductPage&gt;</code>, <code>&lt;DefaultProductLayout&gt;</code>, <code>&lt;FoodProductLayout&gt;</code> etc. — pick one.</p>
53
- </div>
54
- );
55
- }
56
-
57
- function Cart() {
58
- const navigate = useNavigate();
59
- return <CartPage onCheckout={() => navigate("/checkout")} />;
60
- }
61
-
62
- function Checkout() {
63
- const navigate = useNavigate();
64
- return (
65
- <CheckoutPage
66
- onSuccess={(orderId: string) => navigate(`/orders/${orderId}`)}
67
- onCancel={() => navigate("/cart")}
68
- />
69
- );
70
- }
71
-
72
- function OrderConfirmation() {
73
- return (
74
- <div>
75
- <h2>Thanks — your order is confirmed.</h2>
76
- <p>This is the page shoppers land on after checkout.</p>
77
- </div>
78
- );
79
- }
80
-
81
- export function App() {
82
- const [cartCount, setCartCount] = useState(0);
83
- const { client } = useCimplifyClient();
84
-
85
- useEffect(() => {
86
- void client.cart.getCount().then((r) => {
87
- if (r.ok) setCartCount(r.value);
88
- });
89
- }, [client]);
90
-
91
- return (
92
- <div className="cimplify-storefront">
93
- <header className="cimplify-storefront__nav">
94
- <NavLink to="/"><h1>cimplify-store</h1></NavLink>
95
- <nav>
96
- <NavLink to="/" end>Shop</NavLink>
97
- <NavLink to="/cart">Cart</NavLink>
98
- <CartPill count={cartCount} />
99
- </nav>
100
- </header>
101
-
102
- <main className="cimplify-storefront__main">
103
- <Routes>
104
- <Route path="/" element={<Catalogue />} />
105
- <Route path="/products/:productId" element={<ProductDetail />} />
106
- <Route path="/cart" element={<Cart />} />
107
- <Route path="/checkout" element={<Checkout />} />
108
- <Route path="/orders/:orderId" element={<OrderConfirmation />} />
109
- </Routes>
110
- </main>
111
-
112
- <footer className="cimplify-storefront__footer">
113
- Built with <a href="https://github.com/cimplify/cimplify">@cimplify/sdk</a> ·{" "}
114
- Mock API at <code>{import.meta.env.VITE_CIMPLIFY_API_URL ?? "http://127.0.0.1:8787"}</code>
115
- </footer>
116
- </div>
117
- );
118
- }
@@ -1,28 +0,0 @@
1
- import React from "react";
2
- import ReactDOM from "react-dom/client";
3
- import { BrowserRouter } from "react-router-dom";
4
- import { createCimplifyClient } from "@cimplify/sdk";
5
- import { CimplifyProvider } from "@cimplify/sdk/react";
6
- import { App } from "./App";
7
-
8
- import "@cimplify/sdk/styles.css";
9
- import "./styles.css";
10
-
11
- const baseUrl = import.meta.env.VITE_CIMPLIFY_API_URL ?? "http://127.0.0.1:8787";
12
- const publicKey = import.meta.env.VITE_CIMPLIFY_PUBLIC_KEY ?? "mock-dev";
13
-
14
- const client = createCimplifyClient({
15
- baseUrl,
16
- publicKey,
17
- suppressPublicKeyWarning: true,
18
- });
19
-
20
- ReactDOM.createRoot(document.getElementById("root")!).render(
21
- <React.StrictMode>
22
- <BrowserRouter>
23
- <CimplifyProvider client={client}>
24
- <App />
25
- </CimplifyProvider>
26
- </BrowserRouter>
27
- </React.StrictMode>,
28
- );
@@ -1,65 +0,0 @@
1
- @import "tailwindcss";
2
-
3
- html, body {
4
- margin: 0;
5
- padding: 0;
6
- font-family: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", Roboto, sans-serif;
7
- background: #fafaf9;
8
- color: #0f172a;
9
- }
10
-
11
- * { box-sizing: border-box; }
12
- a { color: inherit; text-decoration: none; }
13
-
14
- .cimplify-storefront {
15
- min-height: 100vh;
16
- display: flex;
17
- flex-direction: column;
18
- }
19
-
20
- .cimplify-storefront__nav {
21
- display: flex;
22
- align-items: center;
23
- justify-content: space-between;
24
- padding: 16px 24px;
25
- background: white;
26
- border-bottom: 1px solid #e2e8f0;
27
- position: sticky;
28
- top: 0;
29
- z-index: 10;
30
- }
31
-
32
- .cimplify-storefront__nav h1 { font-size: 18px; margin: 0; }
33
- .cimplify-storefront__nav nav a { margin-left: 16px; font-size: 14px; }
34
- .cimplify-storefront__nav nav a.active { color: #2563eb; font-weight: 600; }
35
- .cimplify-storefront__cart-pill {
36
- margin-left: 16px;
37
- padding: 6px 12px;
38
- border-radius: 999px;
39
- background: #0f172a;
40
- color: white;
41
- font-size: 13px;
42
- font-weight: 600;
43
- }
44
-
45
- .cimplify-storefront__main {
46
- flex: 1;
47
- padding: 24px;
48
- max-width: 1200px;
49
- margin: 0 auto;
50
- width: 100%;
51
- }
52
-
53
- .cimplify-storefront__footer {
54
- padding: 24px;
55
- text-align: center;
56
- font-size: 12px;
57
- color: #64748b;
58
- border-top: 1px solid #e2e8f0;
59
- background: white;
60
- }
61
-
62
- .cimplify-storefront__main svg {
63
- max-width: 64px;
64
- max-height: 64px;
65
- }
@@ -1,8 +0,0 @@
1
- import { defineConfig } from "vite";
2
- import react from "@vitejs/plugin-react";
3
- import tailwindcss from "@tailwindcss/vite";
4
-
5
- export default defineConfig({
6
- plugins: [react(), tailwindcss()],
7
- server: { port: 5173, open: false, strictPort: false },
8
- });