@fayz-ai/shop 0.8.3 → 0.9.0-next.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 (47) hide show
  1. package/dist/catalog.js +2 -168
  2. package/dist/catalog.js.map +1 -1
  3. package/dist/{catalog.cjs → chunk-CTKZ6O2J.js} +11 -9
  4. package/dist/chunk-CTKZ6O2J.js.map +1 -0
  5. package/dist/chunk-IYQHKMLB.js +21 -0
  6. package/dist/chunk-IYQHKMLB.js.map +1 -0
  7. package/dist/chunk-JR25TISO.js +3 -0
  8. package/dist/chunk-JR25TISO.js.map +1 -0
  9. package/dist/{mock.cjs → chunk-SVTCJ6HP.js} +62 -103
  10. package/dist/chunk-SVTCJ6HP.js.map +1 -0
  11. package/dist/index.d.ts +1 -1
  12. package/dist/index.d.ts.map +1 -1
  13. package/dist/index.js +73 -579
  14. package/dist/index.js.map +1 -1
  15. package/dist/mock-catalog.d.ts.map +1 -1
  16. package/dist/mock-provider.d.ts +8 -1
  17. package/dist/mock-provider.d.ts.map +1 -1
  18. package/dist/mock.js +2 -476
  19. package/dist/mock.js.map +1 -1
  20. package/dist/provider.d.ts +5 -1
  21. package/dist/provider.d.ts.map +1 -1
  22. package/dist/runtime.js +3 -492
  23. package/dist/runtime.js.map +1 -1
  24. package/dist/supabase-provider.d.ts +5 -1
  25. package/dist/supabase-provider.d.ts.map +1 -1
  26. package/dist/tables.d.ts +1 -0
  27. package/dist/tables.d.ts.map +1 -1
  28. package/dist/types.d.ts +48 -0
  29. package/dist/types.d.ts.map +1 -1
  30. package/package.json +22 -26
  31. package/src/index.ts +1 -0
  32. package/src/mock-catalog.ts +8 -0
  33. package/src/mock-provider.ts +63 -5
  34. package/src/provider.ts +8 -0
  35. package/src/supabase-provider.ts +64 -1
  36. package/src/tables.ts +1 -0
  37. package/src/types.ts +67 -0
  38. package/dist/catalog.cjs.map +0 -1
  39. package/dist/index.cjs +0 -1250
  40. package/dist/index.cjs.map +0 -1
  41. package/dist/mock.cjs.map +0 -1
  42. package/dist/provider.cjs +0 -4
  43. package/dist/provider.cjs.map +0 -1
  44. package/dist/runtime.cjs +0 -498
  45. package/dist/runtime.cjs.map +0 -1
  46. package/dist/types.cjs +0 -4
  47. package/dist/types.cjs.map +0 -1
package/dist/mock.js CHANGED
@@ -1,478 +1,4 @@
1
- // src/mock-catalog.ts
2
- var T0 = "2026-01-01T12:00:00.000Z";
3
- function svgPlaceholder(label, hueA, hueB) {
4
- const initials = label.split(/\s+/).map((w) => w[0]).slice(0, 2).join("").toUpperCase();
5
- const svg = `<svg xmlns="http://www.w3.org/2000/svg" width="600" height="600"><defs><linearGradient id="g" x1="0" y1="0" x2="1" y2="1"><stop offset="0" stop-color="hsl(${hueA},45%,82%)"/><stop offset="1" stop-color="hsl(${hueB},50%,62%)"/></linearGradient></defs><rect width="600" height="600" fill="url(#g)"/><text x="300" y="330" font-family="sans-serif" font-size="120" font-weight="700" fill="rgba(255,255,255,0.85)" text-anchor="middle">${initials}</text></svg>`;
6
- return `data:image/svg+xml;utf8,${encodeURIComponent(svg)}`;
7
- }
8
- function image(productId, name, hueA, hueB, idx = 0) {
9
- return {
10
- id: `img-${productId}-${idx}`,
11
- productId,
12
- url: svgPlaceholder(name, hueA, hueB),
13
- altText: name,
14
- sortOrder: idx,
15
- isPrimary: idx === 0,
16
- createdAt: T0
17
- };
18
- }
19
- var MOCK_CATEGORIES = [
20
- { id: "cat-apparel", tenantId: "mock", name: "Apparel", slug: "apparel", description: "Clothing and wearables", parentId: null, sortOrder: 0, createdAt: T0 },
21
- { id: "cat-bags", tenantId: "mock", name: "Bags & Accessories", slug: "bags-accessories", description: "Bags, wallets and carry gear", parentId: null, sortOrder: 1, createdAt: T0 },
22
- { id: "cat-home", tenantId: "mock", name: "Home & Kitchen", slug: "home-kitchen", description: "Everyday home goods", parentId: null, sortOrder: 2, createdAt: T0 },
23
- { id: "cat-tech", tenantId: "mock", name: "Stationery & Tech", slug: "stationery-tech", description: "Desk, audio and paper goods", parentId: null, sortOrder: 3, createdAt: T0 }
24
- ];
25
- var SEEDS = [
26
- // --- Apparel ---
27
- { id: "p-01", name: "Classic T-Shirt", slug: "classic-t-shirt", description: "A timeless crew-neck tee in heavyweight combed cotton. Pre-shrunk, breathable, and built to outlast trends.", price: 59.9, compareAtPrice: 79.9, inventoryCount: 50, sku: "TSH-001", categoryId: "cat-apparel", hues: [210, 240], weight: 0.2 },
28
- { id: "p-02", name: "Linen Shirt", slug: "linen-shirt", description: "A relaxed-fit shirt in 100% European linen. Naturally breathable and softer with every wash.", price: 189.9, inventoryCount: 24, sku: "LNS-002", categoryId: "cat-apparel", hues: [35, 20], weight: 0.3 },
29
- { id: "p-03", name: "Denim Jacket", slug: "denim-jacket", description: "A structured trucker jacket in 12oz raw denim. Ages beautifully with hidden interior pockets.", price: 299.9, inventoryCount: 12, sku: "DNJ-003", categoryId: "cat-apparel", hues: [215, 200], weight: 0.8 },
30
- { id: "p-04", name: "Wool Beanie", slug: "wool-beanie", description: "A double-layer merino wool beanie. Warm without itch, with a low-profile cuffed fit.", price: 79.9, inventoryCount: 0, sku: "WBN-004", categoryId: "cat-apparel", hues: [0, 350], weight: 0.1 },
31
- // --- Bags & Accessories ---
32
- { id: "p-05", name: "Canvas Tote Bag", slug: "canvas-tote-bag", description: "An everyday carryall in 16oz waxed canvas with reinforced straps and an interior zip pocket.", price: 39.9, inventoryCount: 30, sku: "BAG-001", categoryId: "cat-bags", hues: [80, 110], weight: 0.3 },
33
- { id: "p-06", name: "Leather Backpack", slug: "leather-backpack", description: 'Full-grain leather backpack with a padded 15" laptop sleeve, magnetic closures and brass hardware.', price: 549.9, inventoryCount: 8, sku: "LBP-006", categoryId: "cat-bags", hues: [25, 15], weight: 1.4 },
34
- { id: "p-07", name: "Leather Card Wallet", slug: "leather-card-wallet", description: "A slim six-card wallet in vegetable-tanned leather. RFID-shielded with a center cash slot.", price: 89.9, compareAtPrice: 119.9, inventoryCount: 45, sku: "LCW-007", categoryId: "cat-bags", hues: [30, 45], weight: 0.08 },
35
- { id: "p-08", name: "Travel Duffel", slug: "travel-duffel", description: "A 40L weekender in ballistic nylon with a trolley sleeve, shoe compartment and detachable strap.", price: 329.9, inventoryCount: 15, sku: "TDF-008", categoryId: "cat-bags", hues: [150, 170], weight: 1.1 },
36
- // --- Home & Kitchen ---
37
- { id: "p-09", name: "Ceramic Coffee Mug", slug: "ceramic-coffee-mug", description: "A 350ml stoneware mug with a matte glaze and comfortable wide handle. Dishwasher and microwave safe.", price: 34.9, inventoryCount: 0, sku: "MUG-001", categoryId: "cat-home", hues: [190, 210], weight: 0.4 },
38
- { id: "p-10", name: "Scented Soy Candle", slug: "scented-soy-candle", description: "Hand-poured soy wax candle with cedar and bergamot notes. 45-hour burn time in a reusable glass jar.", price: 69.9, inventoryCount: 60, sku: "SSC-010", categoryId: "cat-home", hues: [45, 30], weight: 0.5 },
39
- { id: "p-11", name: "Bamboo Cutting Board", slug: "bamboo-cutting-board", description: "An end-grain bamboo board that is gentle on knives, with a juice groove and inset handles.", price: 119.9, inventoryCount: 22, sku: "BCB-011", categoryId: "cat-home", hues: [90, 70], weight: 1.2 },
40
- { id: "p-12", name: "Stoneware Plate Set", slug: "stoneware-plate-set", description: "A set of four reactive-glaze dinner plates. Each piece is unique, oven-safe to 220\xB0C.", price: 249.9, inventoryCount: 10, sku: "SPS-012", categoryId: "cat-home", hues: [200, 180], weight: 2.4 },
41
- // --- Stationery & Tech ---
42
- { id: "p-13", name: "Wireless Headphones", slug: "wireless-headphones", description: "Over-ear headphones with active noise cancelling, 40-hour battery and multipoint Bluetooth 5.3.", price: 899.9, inventoryCount: 18, sku: "WHP-013", categoryId: "cat-tech", hues: [260, 280], weight: 0.35 },
43
- { id: "p-14", name: "Notebook Set", slug: "notebook-set", description: "Three A5 dot-grid notebooks with 120gsm paper, lay-flat binding and numbered pages.", price: 29.9, inventoryCount: 80, sku: "NBS-014", categoryId: "cat-tech", hues: [330, 310], weight: 0.45 },
44
- { id: "p-15", name: "Bluetooth Speaker", slug: "bluetooth-speaker", description: "A pocket-size speaker with surprising low end, IPX7 waterproofing and 14-hour playtime.", price: 199.9, compareAtPrice: 259.9, inventoryCount: 26, sku: "BTS-015", categoryId: "cat-tech", hues: [170, 190], weight: 0.3 },
45
- { id: "p-16", name: "Felt Desk Mat", slug: "felt-desk-mat", description: "A 80x30cm merino felt desk mat with a cork base. Protects the desk and quiets the keyboard.", price: 99.9, inventoryCount: 34, sku: "FDM-016", categoryId: "cat-tech", hues: [220, 230], weight: 0.6 }
46
- ];
47
- var CATEGORY_NAME = Object.fromEntries(
48
- MOCK_CATEGORIES.map((c) => [c.id, c.name])
49
- );
50
- var MOCK_PRODUCTS = SEEDS.map((s, i) => ({
51
- id: s.id,
52
- tenantId: "mock",
53
- name: s.name,
54
- slug: s.slug,
55
- description: s.description,
56
- price: s.price,
57
- compareAtPrice: s.compareAtPrice ?? null,
58
- currency: "BRL",
59
- status: "active",
60
- inventoryCount: s.inventoryCount,
61
- sku: s.sku,
62
- sortOrder: i,
63
- metadata: {},
64
- images: [image(s.id, s.name, s.hues[0], s.hues[1])],
65
- categoryId: s.categoryId,
66
- categoryName: CATEGORY_NAME[s.categoryId] ?? null,
67
- isPhysical: true,
68
- weight: s.weight,
69
- weightUnit: "kg",
70
- // staggered timestamps → deterministic 'newest' sort (p-16 newest)
71
- createdAt: `2026-01-${String(i + 1).padStart(2, "0")}T12:00:00.000Z`,
72
- updatedAt: `2026-01-${String(i + 1).padStart(2, "0")}T12:00:00.000Z`
73
- }));
74
- var MOCK_DISCOUNTS = [
75
- {
76
- id: "disc-welcome",
77
- tenantId: "mock",
78
- title: "Welcome 10%",
79
- code: "BEMVINDO10",
80
- type: "percentage",
81
- method: "code",
82
- value: 10,
83
- usageLimit: null,
84
- oncePerCustomer: false,
85
- startsAt: T0,
86
- endsAt: null,
87
- status: "active",
88
- timesUsed: 0,
89
- createdAt: T0,
90
- updatedAt: T0
91
- }
92
- ];
93
-
94
- // src/mock-provider.ts
95
- function uid() {
96
- return Math.random().toString(36).slice(2);
97
- }
98
- function now() {
99
- return (/* @__PURE__ */ new Date()).toISOString();
100
- }
101
- var ORDERS_KEY = "fayz.shop.mock.orders.v1";
102
- var CUSTOMERS_KEY = "fayz.shop.mock.customers.v1";
103
- var ENQUIRIES_KEY = "fayz.shop.mock.enquiries.v1";
104
- function loadStored(key) {
105
- try {
106
- if (typeof localStorage === "undefined") return [];
107
- const raw = localStorage.getItem(key);
108
- return raw ? JSON.parse(raw) : [];
109
- } catch {
110
- return [];
111
- }
112
- }
113
- function store(key, value) {
114
- try {
115
- if (typeof localStorage === "undefined") return;
116
- localStorage.setItem(key, JSON.stringify(value));
117
- } catch {
118
- }
119
- }
120
- var MockShopProvider = class {
121
- constructor(seed) {
122
- this.orders = loadStored(ORDERS_KEY);
123
- this.customers = loadStored(CUSTOMERS_KEY);
124
- this.enquiries = loadStored(ENQUIRIES_KEY);
125
- this.products = (seed?.products ?? MOCK_PRODUCTS).map((p) => ({ ...p }));
126
- this.categories = (seed?.categories ?? MOCK_CATEGORIES).map((c) => ({ ...c }));
127
- this.discounts = (seed?.discounts ?? MOCK_DISCOUNTS).map((d) => ({ ...d }));
128
- }
129
- // Re-read before mutating: HMR can re-instantiate the provider mid-session
130
- // and a stale in-memory copy must not clobber persisted records.
131
- syncOrders() {
132
- this.orders = loadStored(ORDERS_KEY);
133
- }
134
- syncCustomers() {
135
- this.customers = loadStored(CUSTOMERS_KEY);
136
- }
137
- syncEnquiries() {
138
- this.enquiries = loadStored(ENQUIRIES_KEY);
139
- }
140
- persistOrders() {
141
- store(ORDERS_KEY, this.orders);
142
- }
143
- persistCustomers() {
144
- store(CUSTOMERS_KEY, this.customers);
145
- }
146
- persistEnquiries() {
147
- store(ENQUIRIES_KEY, this.enquiries);
148
- }
149
- // ---------------------------------------------------------------------------
150
- // Products
151
- // ---------------------------------------------------------------------------
152
- async listProducts(opts) {
153
- let list = [...this.products];
154
- if (opts?.status) list = list.filter((p) => p.status === opts.status);
155
- if (opts?.categoryId) list = list.filter((p) => p.categoryId === opts.categoryId);
156
- if (opts?.slug) list = list.filter((p) => p.slug === opts.slug);
157
- if (opts?.search) {
158
- const q = opts.search.toLowerCase();
159
- list = list.filter(
160
- (p) => p.name.toLowerCase().includes(q) || (p.description ?? "").toLowerCase().includes(q) || (p.sku ?? "").toLowerCase().includes(q)
161
- );
162
- }
163
- const orderBy = opts?.orderBy ?? "sort_order";
164
- const dir = opts?.order === "desc" ? -1 : 1;
165
- list.sort((a, b) => {
166
- switch (orderBy) {
167
- case "name":
168
- return a.name.localeCompare(b.name) * dir;
169
- case "price":
170
- return (a.price - b.price) * dir;
171
- case "created_at":
172
- return a.createdAt.localeCompare(b.createdAt) * dir;
173
- default:
174
- return (a.sortOrder - b.sortOrder) * dir;
175
- }
176
- });
177
- const offset = opts?.offset ?? 0;
178
- if (offset || opts?.limit) list = list.slice(offset, opts?.limit ? offset + opts.limit : void 0);
179
- return list;
180
- }
181
- async getProduct(id) {
182
- return this.products.find((p) => p.id === id) ?? null;
183
- }
184
- async createProduct(input) {
185
- const p = { id: uid(), tenantId: "mock", name: input.name, slug: input.slug ?? input.name.toLowerCase().replace(/\s+/g, "-"), description: input.description ?? null, price: input.price, compareAtPrice: input.compareAtPrice ?? null, currency: input.currency ?? "BRL", status: input.status ?? "active", inventoryCount: input.inventoryCount ?? 0, sku: input.sku ?? null, sortOrder: input.sortOrder ?? 0, metadata: input.metadata ?? {}, images: [], categoryId: input.categoryId ?? null, categoryName: null, isPhysical: input.isPhysical ?? true, weight: input.weight ?? null, weightUnit: input.weightUnit ?? "kg", createdAt: now(), updatedAt: now() };
186
- this.products.push(p);
187
- return p;
188
- }
189
- async updateProduct(id, input) {
190
- const i = this.products.findIndex((p) => p.id === id);
191
- if (i < 0) throw new Error("Product not found");
192
- this.products[i] = { ...this.products[i], ...input, updatedAt: now() };
193
- return this.products[i];
194
- }
195
- async deleteProduct(id) {
196
- this.products = this.products.filter((p) => p.id !== id);
197
- }
198
- async uploadProductImage(_productId, _file) {
199
- throw new Error("Image upload not available in mock mode");
200
- }
201
- async deleteProductImage(_imageId) {
202
- }
203
- async createProductEnquiry(input) {
204
- this.syncEnquiries();
205
- const ts = now();
206
- const enquiry = {
207
- id: uid(),
208
- tenantId: "mock",
209
- productId: input.productId ?? null,
210
- productName: input.productName,
211
- productSlug: input.productSlug ?? null,
212
- customerName: input.customerName,
213
- customerEmail: input.customerEmail,
214
- customerPhone: input.customerPhone ?? null,
215
- subject: input.subject ?? null,
216
- message: input.message,
217
- sourceUrl: input.sourceUrl ?? null,
218
- status: "new",
219
- metadata: input.metadata ?? {},
220
- createdAt: ts,
221
- updatedAt: ts
222
- };
223
- this.enquiries.unshift(enquiry);
224
- this.persistEnquiries();
225
- return enquiry;
226
- }
227
- async listProductEnquiries(opts) {
228
- this.syncEnquiries();
229
- let list = [...this.enquiries];
230
- if (opts?.productId) list = list.filter((e) => e.productId === opts.productId);
231
- if (opts?.customerEmail) {
232
- const email = opts.customerEmail.toLowerCase();
233
- list = list.filter((e) => e.customerEmail.toLowerCase() === email);
234
- }
235
- if (opts?.status) list = list.filter((e) => e.status === opts.status);
236
- list.sort((a, b) => b.createdAt.localeCompare(a.createdAt));
237
- const offset = opts?.offset ?? 0;
238
- if (offset || opts?.limit) list = list.slice(offset, opts?.limit ? offset + opts.limit : void 0);
239
- return list;
240
- }
241
- // ---------------------------------------------------------------------------
242
- // Categories
243
- // ---------------------------------------------------------------------------
244
- async listCategories() {
245
- return [...this.categories].sort((a, b) => a.sortOrder - b.sortOrder);
246
- }
247
- async createCategory(input) {
248
- const c = { id: uid(), tenantId: "mock", name: input.name, slug: input.slug ?? input.name.toLowerCase().replace(/\s+/g, "-"), description: input.description ?? null, parentId: input.parentId ?? null, sortOrder: input.sortOrder ?? 0, createdAt: now() };
249
- this.categories.push(c);
250
- return c;
251
- }
252
- async updateCategory(id, input) {
253
- const i = this.categories.findIndex((c) => c.id === id);
254
- if (i < 0) throw new Error("Category not found");
255
- this.categories[i] = { ...this.categories[i], ...input };
256
- return this.categories[i];
257
- }
258
- async deleteCategory(id) {
259
- this.categories = this.categories.filter((c) => c.id !== id);
260
- }
261
- // ---------------------------------------------------------------------------
262
- // Orders
263
- // ---------------------------------------------------------------------------
264
- async listOrders(opts) {
265
- this.syncOrders();
266
- let list = [...this.orders];
267
- if (opts?.status) list = list.filter((o) => o.status === opts.status);
268
- if (opts?.financialStatus) list = list.filter((o) => o.financialStatus === opts.financialStatus);
269
- if (opts?.fulfillmentStatus) list = list.filter((o) => o.fulfillmentStatus === opts.fulfillmentStatus);
270
- if (opts?.customerId) list = list.filter((o) => o.customerId === opts.customerId);
271
- if (opts?.customerEmail) {
272
- const email = opts.customerEmail.toLowerCase();
273
- list = list.filter((o) => (o.customerEmail ?? "").toLowerCase() === email);
274
- }
275
- if (opts?.search) {
276
- const q = opts.search.toLowerCase();
277
- list = list.filter(
278
- (o) => (o.customerName ?? "").toLowerCase().includes(q) || (o.customerEmail ?? "").toLowerCase().includes(q) || String(o.orderNumber).includes(q)
279
- );
280
- }
281
- list.sort((a, b) => b.createdAt.localeCompare(a.createdAt));
282
- if (opts?.limit) list = list.slice(0, opts.limit);
283
- return list;
284
- }
285
- async getOrder(id) {
286
- this.syncOrders();
287
- return this.orders.find((o) => o.id === id) ?? null;
288
- }
289
- async createOrder(input) {
290
- this.syncOrders();
291
- const subtotal = input.items.reduce((s, i) => s + i.quantity * i.unitPrice, 0);
292
- const discountTotal = input.discountTotal ?? 0;
293
- const shippingTotal = input.shippingTotal ?? 0;
294
- const total = Math.round((subtotal - discountTotal + shippingTotal) * 100) / 100;
295
- const orderId = uid();
296
- const maxNumber = this.orders.reduce((m, o2) => Math.max(m, o2.orderNumber), 1e3);
297
- const o = {
298
- id: orderId,
299
- tenantId: "mock",
300
- orderNumber: maxNumber + 1,
301
- status: "open",
302
- financialStatus: "pending",
303
- fulfillmentStatus: "unfulfilled",
304
- currency: input.currency ?? "BRL",
305
- subtotal: Math.round(subtotal * 100) / 100,
306
- taxTotal: 0,
307
- discountTotal,
308
- shippingTotal,
309
- total,
310
- customerId: input.customerId ?? null,
311
- customerName: input.customerName ?? null,
312
- customerEmail: input.customerEmail ?? null,
313
- discountCode: input.discountCode ?? null,
314
- notes: input.notes ?? null,
315
- shippingAddress: null,
316
- // CreateOrderInput has no payment method — that is a PlaceOrderInput
317
- // concern; the mock records none rather than inventing one.
318
- paymentMethodKind: null,
319
- paidAt: null,
320
- items: input.items.map((i) => ({ id: uid(), orderId, productId: i.productId ?? null, name: i.name, sku: i.sku ?? null, quantity: i.quantity, unitPrice: i.unitPrice, total: Math.round(i.quantity * i.unitPrice * 100) / 100, imageUrl: i.imageUrl ?? null })),
321
- createdAt: now(),
322
- updatedAt: now()
323
- };
324
- this.orders.push(o);
325
- this.persistOrders();
326
- return o;
327
- }
328
- async updateOrder(id, input) {
329
- this.syncOrders();
330
- const i = this.orders.findIndex((o) => o.id === id);
331
- if (i < 0) throw new Error("Order not found");
332
- this.orders[i] = { ...this.orders[i], ...input, updatedAt: now() };
333
- this.persistOrders();
334
- return this.orders[i];
335
- }
336
- // Trusted placement (mock parity with the shop_place_order RPC): re-reads
337
- // prices + stock from the catalog, validates the discount, decrements
338
- // inventory. The browser-supplied prices are never used.
339
- async placeOrder(input) {
340
- this.syncOrders();
341
- this.syncCustomers();
342
- let customerId = input.customerId ?? null;
343
- let customerName = input.customer?.name?.trim() || null;
344
- const email = input.customer?.email?.trim().toLowerCase() || null;
345
- if (!customerId && email) {
346
- const existing = this.customers.find((c) => (c.email ?? "").toLowerCase() === email);
347
- if (existing) {
348
- customerId = existing.id;
349
- customerName = customerName ?? `${existing.firstName} ${existing.lastName}`.trim();
350
- } else {
351
- const [first, ...rest] = (customerName ?? email).split(" ");
352
- const created = await this.createCustomer({ firstName: first || email, lastName: rest.join(" "), email });
353
- customerId = created.id;
354
- }
355
- }
356
- const items = [];
357
- let subtotal = 0;
358
- for (const line of input.items) {
359
- const product = this.products.find((p) => p.id === line.productId);
360
- if (!product || product.status !== "active") throw new Error(`Product unavailable: ${line.productId}`);
361
- if (product.inventoryCount < line.quantity) throw new Error(`Insufficient stock for ${product.name}`);
362
- const name = line.optionsLabel ? `${product.name} (${line.optionsLabel})` : product.name;
363
- subtotal += product.price * line.quantity;
364
- items.push({ productId: product.id, name, sku: product.sku ?? void 0, quantity: line.quantity, unitPrice: product.price, imageUrl: product.images[0]?.url });
365
- }
366
- subtotal = Math.round(subtotal * 100) / 100;
367
- let shippingTotal = Math.max(input.shippingTotal ?? 0, 0);
368
- let discountTotal = 0;
369
- let appliedCode = null;
370
- if (input.discountCode) {
371
- const code = input.discountCode.trim().toLowerCase();
372
- const d = this.discounts.find((x) => (x.code ?? "").toLowerCase() === code);
373
- const ts = now();
374
- const valid = !!d && d.status === "active" && d.startsAt <= ts && (!d.endsAt || d.endsAt >= ts) && (d.usageLimit == null || d.timesUsed < d.usageLimit);
375
- if (valid && d) {
376
- appliedCode = d.code;
377
- if (d.type === "percentage") discountTotal = Math.round(subtotal * d.value) / 100;
378
- else if (d.type === "fixed_amount") discountTotal = Math.min(d.value, subtotal);
379
- else if (d.type === "free_shipping") shippingTotal = 0;
380
- d.timesUsed += 1;
381
- }
382
- }
383
- discountTotal = Math.round(Math.min(Math.max(discountTotal, 0), subtotal) * 100) / 100;
384
- const order = await this.createOrder({
385
- customerId: customerId ?? void 0,
386
- customerName: customerName ?? void 0,
387
- customerEmail: input.customer?.email ?? void 0,
388
- currency: input.currency,
389
- notes: input.notes,
390
- discountCode: appliedCode ?? void 0,
391
- discountTotal,
392
- shippingTotal,
393
- items
394
- });
395
- for (const line of input.items) {
396
- const product = this.products.find((p) => p.id === line.productId);
397
- if (product) product.inventoryCount = Math.max(0, product.inventoryCount - line.quantity);
398
- }
399
- return order;
400
- }
401
- // ---------------------------------------------------------------------------
402
- // Customers
403
- // ---------------------------------------------------------------------------
404
- async listCustomers(opts) {
405
- this.syncCustomers();
406
- let list = [...this.customers];
407
- if (opts?.search) list = list.filter((c) => `${c.firstName} ${c.lastName} ${c.email}`.toLowerCase().includes(opts.search.toLowerCase()));
408
- if (opts?.limit) list = list.slice(0, opts.limit);
409
- return list;
410
- }
411
- async getCustomer(id) {
412
- this.syncCustomers();
413
- return this.customers.find((c) => c.id === id) ?? null;
414
- }
415
- async createCustomer(input) {
416
- this.syncCustomers();
417
- const c = { id: uid(), tenantId: "mock", firstName: input.firstName, lastName: input.lastName ?? "", email: input.email ?? null, phone: input.phone ?? null, notes: input.notes ?? null, ordersCount: 0, totalSpent: 0, createdAt: now(), updatedAt: now() };
418
- this.customers.push(c);
419
- this.persistCustomers();
420
- return c;
421
- }
422
- async updateCustomer(id, input) {
423
- this.syncCustomers();
424
- const i = this.customers.findIndex((c) => c.id === id);
425
- if (i < 0) throw new Error("Customer not found");
426
- this.customers[i] = { ...this.customers[i], ...input, updatedAt: now() };
427
- this.persistCustomers();
428
- return this.customers[i];
429
- }
430
- async deleteCustomer(id) {
431
- this.syncCustomers();
432
- this.customers = this.customers.filter((c) => c.id !== id);
433
- this.persistCustomers();
434
- }
435
- async resolveCustomer(input) {
436
- this.syncCustomers();
437
- const email = input.email.trim().toLowerCase();
438
- const existing = this.customers.find((c) => (c.email ?? "").toLowerCase() === email);
439
- if (existing) return existing;
440
- const [first, ...rest] = (input.name?.trim() || email).split(/\s+/);
441
- return this.createCustomer({ firstName: first || email, lastName: rest.join(" "), email });
442
- }
443
- // ---------------------------------------------------------------------------
444
- // Discounts
445
- // ---------------------------------------------------------------------------
446
- async listDiscounts(opts) {
447
- let list = [...this.discounts];
448
- if (opts?.status) list = list.filter((d) => d.status === opts.status);
449
- if (opts?.type) list = list.filter((d) => d.type === opts.type);
450
- if (opts?.search) list = list.filter((d) => d.title.toLowerCase().includes(opts.search.toLowerCase()));
451
- if (opts?.limit) list = list.slice(0, opts.limit);
452
- return list;
453
- }
454
- async getDiscount(id) {
455
- return this.discounts.find((d) => d.id === id) ?? null;
456
- }
457
- async createDiscount(input) {
458
- const d = { id: uid(), tenantId: "mock", title: input.title, code: input.code ?? null, type: input.type, method: input.method ?? "code", value: input.value, usageLimit: input.usageLimit ?? null, oncePerCustomer: input.oncePerCustomer ?? false, startsAt: input.startsAt ?? now(), endsAt: input.endsAt ?? null, status: input.status ?? "active", timesUsed: 0, createdAt: now(), updatedAt: now() };
459
- this.discounts.push(d);
460
- return d;
461
- }
462
- async updateDiscount(id, input) {
463
- const i = this.discounts.findIndex((d) => d.id === id);
464
- if (i < 0) throw new Error("Discount not found");
465
- this.discounts[i] = { ...this.discounts[i], ...input, updatedAt: now() };
466
- return this.discounts[i];
467
- }
468
- async deleteDiscount(id) {
469
- this.discounts = this.discounts.filter((d) => d.id !== id);
470
- }
471
- };
472
- function createMockShopProvider(seed) {
473
- return new MockShopProvider(seed);
474
- }
475
-
476
- export { MockShopProvider, createMockShopProvider };
1
+ export { MockShopProvider, createMockShopProvider } from './chunk-SVTCJ6HP.js';
2
+ import './chunk-CTKZ6O2J.js';
477
3
  //# sourceMappingURL=mock.js.map
478
4
  //# sourceMappingURL=mock.js.map
package/dist/mock.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/mock-catalog.ts","../src/mock-provider.ts"],"names":["o"],"mappings":";AASA,IAAM,EAAA,GAAK,0BAAA;AAGJ,SAAS,cAAA,CAAe,KAAA,EAAe,IAAA,EAAc,IAAA,EAAsB;AAChF,EAAA,MAAM,WAAW,KAAA,CACd,KAAA,CAAM,KAAK,CAAA,CACX,GAAA,CAAI,CAAC,CAAA,KAAM,CAAA,CAAE,CAAC,CAAC,CAAA,CACf,MAAM,CAAA,EAAG,CAAC,EACV,IAAA,CAAK,EAAE,EACP,WAAA,EAAY;AACf,EAAA,MAAM,MACJ,CAAA,2JAAA,EAEoC,IAAI,CAAA,6CAAA,EACJ,IAAI,0NAIc,QAAQ,CAAA,aAAA,CAAA;AAEhE,EAAA,OAAO,CAAA,wBAAA,EAA2B,kBAAA,CAAmB,GAAG,CAAC,CAAA,CA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AAQ,KAAA,CAAM,MAAA,IAAU,QAAA,EAAU,SAAA,EAAW,CAAA,EAAG,WAAW,GAAA,EAAI,EAAG,SAAA,EAAW,GAAA,EAAI,EAAE;AAClZ,IAAA,IAAA,CAAK,SAAA,CAAU,KAAK,CAAC,CAAA;AAAG,IAAA,OAAO,CAAA;AAAA,EACjC;AAAA,EAEA,MAAM,cAAA,CAAe,EAAA,EAAY,KAAA,EAA+C;AAC9E,IAAA,MAAM,IAAI,IAAA,CAAK,SAAA,CAAU,UAAU,CAAA,CAAA,KAAK,CAAA,CAAE,OAAO,EAAE,CAAA;AACnD,IAAA,IAAI,CAAA,GAAI,CAAA,EAAG,MAAM,IAAI,MAAM,oBAAoB,CAAA;AAC/C,IAAA,IAAA,CAAK,SAAA,CAAU,CAAC,CAAA,GAAI,EAAE,GAAG,IAAA,CAAK,SAAA,CAAU,CAAC,CAAA,EAAG,GAAG,KAAA,EAAO,SAAA,EAAW,KAAI,EAAE;AACvE,IAAA,OAAO,IAAA,CAAK,UAAU,CAAC,CAAA;AAAA,EACzB;AAAA,EAEA,MAAM,eAAe,EAAA,EAAY;AAAE,IAAA,IAAA,CAAK,YAAY,IAAA,CAAK,SAAA,CAAU,OAAO,CAAA,CAAA,KAAK,CAAA,CAAE,OAAO,EAAE,CAAA;AAAA,EAAE;AAC9F;AAEO,SAAS,uBAAuB,IAAA,EAAmC;AACxE,EAAA,OAAO,IAAI,iBAAiB,IAAI,CAAA;AAClC","file":"mock.js","sourcesContent":["import type { Product, ProductImage, Category, Discount } from './types'\n\n// ---------------------------------------------------------------------------\n// Deterministic, offline product catalog for the mock provider.\n// Product names sourced from the Fayz client repo references\n// (apps/web ShopSection mockups + original shop seeds), expanded to a\n// 16-product / 4-category Shopify-style catalog.\n// ---------------------------------------------------------------------------\n\nconst T0 = '2026-01-01T12:00:00.000Z'\n\n/** 600x600 gradient SVG with product initials — no network, e2e-stable. */\nexport function svgPlaceholder(label: string, hueA: number, hueB: number): string {\n const initials = label\n .split(/\\s+/)\n .map((w) => w[0])\n .slice(0, 2)\n .join('')\n .toUpperCase()\n const svg =\n `<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"600\" height=\"600\">` +\n `<defs><linearGradient id=\"g\" x1=\"0\" y1=\"0\" x2=\"1\" y2=\"1\">` +\n `<stop offset=\"0\" stop-color=\"hsl(${hueA},45%,82%)\"/>` +\n `<stop offset=\"1\" stop-color=\"hsl(${hueB},50%,62%)\"/>` +\n `</linearGradient></defs>` +\n `<rect width=\"600\" height=\"600\" fill=\"url(#g)\"/>` +\n `<text x=\"300\" y=\"330\" font-family=\"sans-serif\" font-size=\"120\" font-weight=\"700\" ` +\n `fill=\"rgba(255,255,255,0.85)\" text-anchor=\"middle\">${initials}</text>` +\n `</svg>`\n return `data:image/svg+xml;utf8,${encodeURIComponent(svg)}`\n}\n\nfunction image(productId: string, name: string, hueA: number, hueB: number, idx = 0): ProductImage {\n return {\n id: `img-${productId}-${idx}`,\n productId,\n url: svgPlaceholder(name, hueA, hueB),\n altText: name,\n sortOrder: idx,\n isPrimary: idx === 0,\n createdAt: T0,\n }\n}\n\nexport const MOCK_CATEGORIES: Category[] = [\n { id: 'cat-apparel', tenantId: 'mock', name: 'Apparel', slug: 'apparel', description: 'Clothing and wearables', parentId: null, sortOrder: 0, createdAt: T0 },\n { id: 'cat-bags', tenantId: 'mock', name: 'Bags & Accessories', slug: 'bags-accessories', description: 'Bags, wallets and carry gear', parentId: null, sortOrder: 1, createdAt: T0 },\n { id: 'cat-home', tenantId: 'mock', name: 'Home & Kitchen', slug: 'home-kitchen', description: 'Everyday home goods', parentId: null, sortOrder: 2, createdAt: T0 },\n { id: 'cat-tech', tenantId: 'mock', name: 'Stationery & Tech', slug: 'stationery-tech', description: 'Desk, audio and paper goods', parentId: null, sortOrder: 3, createdAt: T0 },\n]\n\ninterface SeedProduct {\n id: string\n name: string\n slug: string\n description: string\n price: number\n compareAtPrice?: number\n inventoryCount: number\n sku: string\n categoryId: string\n hues: [number, number]\n weight: number\n}\n\nconst SEEDS: SeedProduct[] = [\n // --- Apparel ---\n { id: 'p-01', name: 'Classic T-Shirt', slug: 'classic-t-shirt', description: 'A timeless crew-neck tee in heavyweight combed cotton. Pre-shrunk, breathable, and built to outlast trends.', price: 59.9, compareAtPrice: 79.9, inventoryCount: 50, sku: 'TSH-001', categoryId: 'cat-apparel', hues: [210, 240], weight: 0.2 },\n { id: 'p-02', name: 'Linen Shirt', slug: 'linen-shirt', description: 'A relaxed-fit shirt in 100% European linen. Naturally breathable and softer with every wash.', price: 189.9, inventoryCount: 24, sku: 'LNS-002', categoryId: 'cat-apparel', hues: [35, 20], weight: 0.3 },\n { id: 'p-03', name: 'Denim Jacket', slug: 'denim-jacket', description: 'A structured trucker jacket in 12oz raw denim. Ages beautifully with hidden interior pockets.', price: 299.9, inventoryCount: 12, sku: 'DNJ-003', categoryId: 'cat-apparel', hues: [215, 200], weight: 0.8 },\n { id: 'p-04', name: 'Wool Beanie', slug: 'wool-beanie', description: 'A double-layer merino wool beanie. Warm without itch, with a low-profile cuffed fit.', price: 79.9, inventoryCount: 0, sku: 'WBN-004', categoryId: 'cat-apparel', hues: [0, 350], weight: 0.1 },\n\n // --- Bags & Accessories ---\n { id: 'p-05', name: 'Canvas Tote Bag', slug: 'canvas-tote-bag', description: 'An everyday carryall in 16oz waxed canvas with reinforced straps and an interior zip pocket.', price: 39.9, inventoryCount: 30, sku: 'BAG-001', categoryId: 'cat-bags', hues: [80, 110], weight: 0.3 },\n { id: 'p-06', name: 'Leather Backpack', slug: 'leather-backpack', description: 'Full-grain leather backpack with a padded 15\" laptop sleeve, magnetic closures and brass hardware.', price: 549.9, inventoryCount: 8, sku: 'LBP-006', categoryId: 'cat-bags', hues: [25, 15], weight: 1.4 },\n { id: 'p-07', name: 'Leather Card Wallet', slug: 'leather-card-wallet', description: 'A slim six-card wallet in vegetable-tanned leather. RFID-shielded with a center cash slot.', price: 89.9, compareAtPrice: 119.9, inventoryCount: 45, sku: 'LCW-007', categoryId: 'cat-bags', hues: [30, 45], weight: 0.08 },\n { id: 'p-08', name: 'Travel Duffel', slug: 'travel-duffel', description: 'A 40L weekender in ballistic nylon with a trolley sleeve, shoe compartment and detachable strap.', price: 329.9, inventoryCount: 15, sku: 'TDF-008', categoryId: 'cat-bags', hues: [150, 170], weight: 1.1 },\n\n // --- Home & Kitchen ---\n { id: 'p-09', name: 'Ceramic Coffee Mug', slug: 'ceramic-coffee-mug', description: 'A 350ml stoneware mug with a matte glaze and comfortable wide handle. Dishwasher and microwave safe.', price: 34.9, inventoryCount: 0, sku: 'MUG-001', categoryId: 'cat-home', hues: [190, 210], weight: 0.4 },\n { id: 'p-10', name: 'Scented Soy Candle', slug: 'scented-soy-candle', description: 'Hand-poured soy wax candle with cedar and bergamot notes. 45-hour burn time in a reusable glass jar.', price: 69.9, inventoryCount: 60, sku: 'SSC-010', categoryId: 'cat-home', hues: [45, 30], weight: 0.5 },\n { id: 'p-11', name: 'Bamboo Cutting Board', slug: 'bamboo-cutting-board', description: 'An end-grain bamboo board that is gentle on knives, with a juice groove and inset handles.', price: 119.9, inventoryCount: 22, sku: 'BCB-011', categoryId: 'cat-home', hues: [90, 70], weight: 1.2 },\n { id: 'p-12', name: 'Stoneware Plate Set', slug: 'stoneware-plate-set', description: 'A set of four reactive-glaze dinner plates. Each piece is unique, oven-safe to 220°C.', price: 249.9, inventoryCount: 10, sku: 'SPS-012', categoryId: 'cat-home', hues: [200, 180], weight: 2.4 },\n\n // --- Stationery & Tech ---\n { id: 'p-13', name: 'Wireless Headphones', slug: 'wireless-headphones', description: 'Over-ear headphones with active noise cancelling, 40-hour battery and multipoint Bluetooth 5.3.', price: 899.9, inventoryCount: 18, sku: 'WHP-013', categoryId: 'cat-tech', hues: [260, 280], weight: 0.35 },\n { id: 'p-14', name: 'Notebook Set', slug: 'notebook-set', description: 'Three A5 dot-grid notebooks with 120gsm paper, lay-flat binding and numbered pages.', price: 29.9, inventoryCount: 80, sku: 'NBS-014', categoryId: 'cat-tech', hues: [330, 310], weight: 0.45 },\n { id: 'p-15', name: 'Bluetooth Speaker', slug: 'bluetooth-speaker', description: 'A pocket-size speaker with surprising low end, IPX7 waterproofing and 14-hour playtime.', price: 199.9, compareAtPrice: 259.9, inventoryCount: 26, sku: 'BTS-015', categoryId: 'cat-tech', hues: [170, 190], weight: 0.3 },\n { id: 'p-16', name: 'Felt Desk Mat', slug: 'felt-desk-mat', description: 'A 80x30cm merino felt desk mat with a cork base. Protects the desk and quiets the keyboard.', price: 99.9, inventoryCount: 34, sku: 'FDM-016', categoryId: 'cat-tech', hues: [220, 230], weight: 0.6 },\n]\n\nconst CATEGORY_NAME: Record<string, string> = Object.fromEntries(\n MOCK_CATEGORIES.map((c) => [c.id, c.name]),\n)\n\nexport const MOCK_PRODUCTS: Product[] = SEEDS.map((s, i) => ({\n id: s.id,\n tenantId: 'mock',\n name: s.name,\n slug: s.slug,\n description: s.description,\n price: s.price,\n compareAtPrice: s.compareAtPrice ?? null,\n currency: 'BRL',\n status: 'active',\n inventoryCount: s.inventoryCount,\n sku: s.sku,\n sortOrder: i,\n metadata: {},\n images: [image(s.id, s.name, s.hues[0], s.hues[1])],\n categoryId: s.categoryId,\n categoryName: CATEGORY_NAME[s.categoryId] ?? null,\n isPhysical: true,\n weight: s.weight,\n weightUnit: 'kg',\n // staggered timestamps → deterministic 'newest' sort (p-16 newest)\n createdAt: `2026-01-${String(i + 1).padStart(2, '0')}T12:00:00.000Z`,\n updatedAt: `2026-01-${String(i + 1).padStart(2, '0')}T12:00:00.000Z`,\n}))\n\nexport const MOCK_DISCOUNTS: Discount[] = [\n {\n id: 'disc-welcome',\n tenantId: 'mock',\n title: 'Welcome 10%',\n code: 'BEMVINDO10',\n type: 'percentage',\n method: 'code',\n value: 10,\n usageLimit: null,\n oncePerCustomer: false,\n startsAt: T0,\n endsAt: null,\n status: 'active',\n timesUsed: 0,\n createdAt: T0,\n updatedAt: T0,\n },\n]\n\n// ---------------------------------------------------------------------------\n// buildMockCatalog — terse per-store catalog definition. Generates ids,\n// slugs, SVG imagery and staggered timestamps so every store gets a\n// deterministic, e2e-stable catalog from a few lines of data.\n// ---------------------------------------------------------------------------\n\nexport interface CatalogCategoryInput {\n name: string\n description?: string\n image?: string\n}\n\nexport interface CatalogProductInput {\n name: string\n description: string\n price: number\n compareAtPrice?: number\n inventory: number\n sku: string\n /** Category name — must match one of the categories */\n category: string\n hues?: [number, number]\n weight?: number\n image?: string\n metadata?: Record<string, unknown>\n}\n\nexport interface CatalogInput {\n categories: CatalogCategoryInput[]\n products: CatalogProductInput[]\n /** Percentage discount codes, e.g. [{ code: 'BEMVINDO10', percent: 10 }] */\n discounts?: Array<{ code: string; percent: number; title?: string }>\n currency?: string\n}\n\nfunction slugifyName(name: string): string {\n return name\n .toLowerCase()\n .normalize('NFD')\n .replace(/[̀-ͯ]/g, '')\n .replace(/[^a-z0-9]+/g, '-')\n .replace(/^-|-$/g, '')\n}\n\nexport function buildMockCatalog(input: CatalogInput): { products: Product[]; categories: Category[]; discounts: Discount[] } {\n const categories: Category[] = input.categories.map((c, i) => ({\n id: `cat-${slugifyName(c.name)}`,\n tenantId: 'mock',\n name: c.name,\n slug: slugifyName(c.name),\n description: c.description ?? null,\n parentId: null,\n sortOrder: i,\n imageUrl: c.image ?? null,\n createdAt: T0,\n }))\n const byName = Object.fromEntries(categories.map((c) => [c.name, c]))\n\n const products: Product[] = input.products.map((p, i) => {\n const cat = byName[p.category]\n const id = `p-${String(i + 1).padStart(2, '0')}`\n const hues = p.hues ?? [(i * 47) % 360, (i * 47 + 50) % 360]\n const stamp = `2026-01-${String((i % 27) + 1).padStart(2, '0')}T12:00:00.000Z`\n return {\n id,\n tenantId: 'mock',\n name: p.name,\n slug: slugifyName(p.name),\n description: p.description,\n price: p.price,\n compareAtPrice: p.compareAtPrice ?? null,\n currency: input.currency ?? 'BRL',\n status: 'active',\n inventoryCount: p.inventory,\n sku: p.sku,\n sortOrder: i,\n metadata: p.metadata ?? {},\n images: [\n {\n id: `img-${id}-0`,\n productId: id,\n url: p.image ?? svgPlaceholder(p.name, hues[0], hues[1]),\n altText: p.name,\n sortOrder: 0,\n isPrimary: true,\n createdAt: T0,\n },\n ],\n categoryId: cat?.id ?? null,\n categoryName: cat?.name ?? null,\n isPhysical: true,\n weight: p.weight ?? 0.5,\n weightUnit: 'kg',\n createdAt: stamp,\n updatedAt: stamp,\n }\n })\n\n const discounts: Discount[] = (input.discounts ?? []).map((d, i) => ({\n id: `disc-${slugifyName(d.code)}`,\n tenantId: 'mock',\n title: d.title ?? `${d.percent}% off`,\n code: d.code,\n type: 'percentage',\n method: 'code',\n value: d.percent,\n usageLimit: null,\n oncePerCustomer: false,\n startsAt: T0,\n endsAt: null,\n status: 'active',\n timesUsed: 0,\n createdAt: T0,\n updatedAt: T0,\n }))\n\n return { products, categories, discounts }\n}\n","import type { ShopProvider } from './provider'\nimport type {\n Product, ProductImage, Category, Order, ShopCustomer, Discount, ProductEnquiry,\n CreateProductInput, UpdateProductInput, ListProductsOptions,\n CreateProductEnquiryInput, ListProductEnquiriesOptions,\n CreateCategoryInput, UpdateCategoryInput,\n CreateOrderInput, UpdateOrderInput, ListOrdersOptions, PlaceOrderInput,\n CreateCustomerInput, UpdateCustomerInput, ListCustomersOptions, ResolveCustomerInput,\n CreateDiscountInput, UpdateDiscountInput, ListDiscountsOptions,\n} from './types'\nimport { MOCK_PRODUCTS, MOCK_CATEGORIES, MOCK_DISCOUNTS } from './mock-catalog'\n\nfunction uid() { return Math.random().toString(36).slice(2) }\nfunction now() { return new Date().toISOString() }\n\n// Orders/customers persist to localStorage so \"my purchases\" survives a page\n// reload. Products/categories/discounts always reseed from the catalog —\n// the storefront sees a deterministic catalog on every load.\nconst ORDERS_KEY = 'fayz.shop.mock.orders.v1'\nconst CUSTOMERS_KEY = 'fayz.shop.mock.customers.v1'\nconst ENQUIRIES_KEY = 'fayz.shop.mock.enquiries.v1'\n\nfunction loadStored<T>(key: string): T[] {\n try {\n if (typeof localStorage === 'undefined') return []\n const raw = localStorage.getItem(key)\n return raw ? (JSON.parse(raw) as T[]) : []\n } catch {\n return []\n }\n}\n\nfunction store<T>(key: string, value: T[]): void {\n try {\n if (typeof localStorage === 'undefined') return\n localStorage.setItem(key, JSON.stringify(value))\n } catch {\n /* quota/serialization failures are non-fatal in mock mode */\n }\n}\n\nexport interface MockShopSeed {\n products?: Product[]\n categories?: Category[]\n discounts?: Discount[]\n}\n\nexport class MockShopProvider implements ShopProvider {\n private products: Product[]\n private categories: Category[]\n private discounts: Discount[]\n private orders: Order[] = loadStored<Order>(ORDERS_KEY)\n private customers: ShopCustomer[] = loadStored<ShopCustomer>(CUSTOMERS_KEY)\n private enquiries: ProductEnquiry[] = loadStored<ProductEnquiry>(ENQUIRIES_KEY)\n\n constructor(seed?: MockShopSeed) {\n this.products = (seed?.products ?? MOCK_PRODUCTS).map(p => ({ ...p }))\n this.categories = (seed?.categories ?? MOCK_CATEGORIES).map(c => ({ ...c }))\n this.discounts = (seed?.discounts ?? MOCK_DISCOUNTS).map(d => ({ ...d }))\n }\n\n // Re-read before mutating: HMR can re-instantiate the provider mid-session\n // and a stale in-memory copy must not clobber persisted records.\n private syncOrders() { this.orders = loadStored<Order>(ORDERS_KEY) }\n private syncCustomers() { this.customers = loadStored<ShopCustomer>(CUSTOMERS_KEY) }\n private syncEnquiries() { this.enquiries = loadStored<ProductEnquiry>(ENQUIRIES_KEY) }\n private persistOrders() { store(ORDERS_KEY, this.orders) }\n private persistCustomers() { store(CUSTOMERS_KEY, this.customers) }\n private persistEnquiries() { store(ENQUIRIES_KEY, this.enquiries) }\n\n // ---------------------------------------------------------------------------\n // Products\n // ---------------------------------------------------------------------------\n\n async listProducts(opts?: ListProductsOptions): Promise<Product[]> {\n let list = [...this.products]\n if (opts?.status) list = list.filter(p => p.status === opts.status)\n if (opts?.categoryId) list = list.filter(p => p.categoryId === opts.categoryId)\n if (opts?.slug) list = list.filter(p => p.slug === opts.slug)\n if (opts?.search) {\n const q = opts.search.toLowerCase()\n list = list.filter(p =>\n p.name.toLowerCase().includes(q) ||\n (p.description ?? '').toLowerCase().includes(q) ||\n (p.sku ?? '').toLowerCase().includes(q),\n )\n }\n const orderBy = opts?.orderBy ?? 'sort_order'\n const dir = opts?.order === 'desc' ? -1 : 1\n list.sort((a, b) => {\n switch (orderBy) {\n case 'name': return a.name.localeCompare(b.name) * dir\n case 'price': return (a.price - b.price) * dir\n case 'created_at': return a.createdAt.localeCompare(b.createdAt) * dir\n default: return (a.sortOrder - b.sortOrder) * dir\n }\n })\n const offset = opts?.offset ?? 0\n if (offset || opts?.limit) list = list.slice(offset, opts?.limit ? offset + opts.limit : undefined)\n return list\n }\n\n async getProduct(id: string) { return this.products.find(p => p.id === id) ?? null }\n\n async createProduct(input: CreateProductInput): Promise<Product> {\n const p: Product = { id: uid(), tenantId: 'mock', name: input.name, slug: input.slug ?? input.name.toLowerCase().replace(/\\s+/g, '-'), description: input.description ?? null, price: input.price, compareAtPrice: input.compareAtPrice ?? null, currency: input.currency ?? 'BRL', status: input.status ?? 'active', inventoryCount: input.inventoryCount ?? 0, sku: input.sku ?? null, sortOrder: input.sortOrder ?? 0, metadata: input.metadata ?? {}, images: [], categoryId: input.categoryId ?? null, categoryName: null, isPhysical: input.isPhysical ?? true, weight: input.weight ?? null, weightUnit: input.weightUnit ?? 'kg', createdAt: now(), updatedAt: now() }\n this.products.push(p); return p\n }\n\n async updateProduct(id: string, input: UpdateProductInput): Promise<Product> {\n const i = this.products.findIndex(p => p.id === id)\n if (i < 0) throw new Error('Product not found')\n this.products[i] = { ...this.products[i], ...input, updatedAt: now() }\n return this.products[i]\n }\n\n async deleteProduct(id: string) { this.products = this.products.filter(p => p.id !== id) }\n async uploadProductImage(_productId: string, _file: File): Promise<ProductImage> { throw new Error('Image upload not available in mock mode') }\n async deleteProductImage(_imageId: string) {}\n\n async createProductEnquiry(input: CreateProductEnquiryInput): Promise<ProductEnquiry> {\n this.syncEnquiries()\n const ts = now()\n const enquiry: ProductEnquiry = {\n id: uid(),\n tenantId: 'mock',\n productId: input.productId ?? null,\n productName: input.productName,\n productSlug: input.productSlug ?? null,\n customerName: input.customerName,\n customerEmail: input.customerEmail,\n customerPhone: input.customerPhone ?? null,\n subject: input.subject ?? null,\n message: input.message,\n sourceUrl: input.sourceUrl ?? null,\n status: 'new',\n metadata: input.metadata ?? {},\n createdAt: ts,\n updatedAt: ts,\n }\n this.enquiries.unshift(enquiry)\n this.persistEnquiries()\n return enquiry\n }\n\n async listProductEnquiries(opts?: ListProductEnquiriesOptions): Promise<ProductEnquiry[]> {\n this.syncEnquiries()\n let list = [...this.enquiries]\n if (opts?.productId) list = list.filter((e) => e.productId === opts.productId)\n if (opts?.customerEmail) {\n const email = opts.customerEmail.toLowerCase()\n list = list.filter((e) => e.customerEmail.toLowerCase() === email)\n }\n if (opts?.status) list = list.filter((e) => e.status === opts.status)\n list.sort((a, b) => b.createdAt.localeCompare(a.createdAt))\n const offset = opts?.offset ?? 0\n if (offset || opts?.limit) list = list.slice(offset, opts?.limit ? offset + opts.limit : undefined)\n return list\n }\n\n // ---------------------------------------------------------------------------\n // Categories\n // ---------------------------------------------------------------------------\n\n async listCategories() { return [...this.categories].sort((a, b) => a.sortOrder - b.sortOrder) }\n\n async createCategory(input: CreateCategoryInput): Promise<Category> {\n const c: Category = { id: uid(), tenantId: 'mock', name: input.name, slug: input.slug ?? input.name.toLowerCase().replace(/\\s+/g, '-'), description: input.description ?? null, parentId: input.parentId ?? null, sortOrder: input.sortOrder ?? 0, createdAt: now() }\n this.categories.push(c); return c\n }\n\n async updateCategory(id: string, input: UpdateCategoryInput): Promise<Category> {\n const i = this.categories.findIndex(c => c.id === id)\n if (i < 0) throw new Error('Category not found')\n this.categories[i] = { ...this.categories[i], ...input }\n return this.categories[i]\n }\n\n async deleteCategory(id: string) { this.categories = this.categories.filter(c => c.id !== id) }\n\n // ---------------------------------------------------------------------------\n // Orders\n // ---------------------------------------------------------------------------\n\n async listOrders(opts?: ListOrdersOptions): Promise<Order[]> {\n this.syncOrders()\n let list = [...this.orders]\n if (opts?.status) list = list.filter(o => o.status === opts.status)\n if (opts?.financialStatus) list = list.filter(o => o.financialStatus === opts.financialStatus)\n if (opts?.fulfillmentStatus) list = list.filter(o => o.fulfillmentStatus === opts.fulfillmentStatus)\n if (opts?.customerId) list = list.filter(o => o.customerId === opts.customerId)\n if (opts?.customerEmail) {\n const email = opts.customerEmail.toLowerCase()\n list = list.filter(o => (o.customerEmail ?? '').toLowerCase() === email)\n }\n if (opts?.search) {\n const q = opts.search.toLowerCase()\n list = list.filter(o =>\n (o.customerName ?? '').toLowerCase().includes(q) ||\n (o.customerEmail ?? '').toLowerCase().includes(q) ||\n String(o.orderNumber).includes(q),\n )\n }\n list.sort((a, b) => b.createdAt.localeCompare(a.createdAt))\n if (opts?.limit) list = list.slice(0, opts.limit)\n return list\n }\n\n async getOrder(id: string) {\n this.syncOrders()\n return this.orders.find(o => o.id === id) ?? null\n }\n\n async createOrder(input: CreateOrderInput): Promise<Order> {\n this.syncOrders()\n const subtotal = input.items.reduce((s, i) => s + i.quantity * i.unitPrice, 0)\n const discountTotal = input.discountTotal ?? 0\n const shippingTotal = input.shippingTotal ?? 0\n const total = Math.round((subtotal - discountTotal + shippingTotal) * 100) / 100\n const orderId = uid()\n const maxNumber = this.orders.reduce((m, o) => Math.max(m, o.orderNumber), 1000)\n const o: Order = {\n id: orderId,\n tenantId: 'mock',\n orderNumber: maxNumber + 1,\n status: 'open',\n financialStatus: 'pending',\n fulfillmentStatus: 'unfulfilled',\n currency: input.currency ?? 'BRL',\n subtotal: Math.round(subtotal * 100) / 100,\n taxTotal: 0,\n discountTotal,\n shippingTotal,\n total,\n customerId: input.customerId ?? null,\n customerName: input.customerName ?? null,\n customerEmail: input.customerEmail ?? null,\n discountCode: input.discountCode ?? null,\n notes: input.notes ?? null,\n shippingAddress: null,\n // CreateOrderInput has no payment method — that is a PlaceOrderInput\n // concern; the mock records none rather than inventing one.\n paymentMethodKind: null,\n paidAt: null,\n items: input.items.map(i => ({ id: uid(), orderId, productId: i.productId ?? null, name: i.name, sku: i.sku ?? null, quantity: i.quantity, unitPrice: i.unitPrice, total: Math.round(i.quantity * i.unitPrice * 100) / 100, imageUrl: i.imageUrl ?? null })),\n createdAt: now(),\n updatedAt: now(),\n }\n this.orders.push(o)\n this.persistOrders()\n return o\n }\n\n async updateOrder(id: string, input: UpdateOrderInput): Promise<Order> {\n this.syncOrders()\n const i = this.orders.findIndex(o => o.id === id)\n if (i < 0) throw new Error('Order not found')\n this.orders[i] = { ...this.orders[i], ...input, updatedAt: now() }\n this.persistOrders()\n return this.orders[i]\n }\n\n // Trusted placement (mock parity with the shop_place_order RPC): re-reads\n // prices + stock from the catalog, validates the discount, decrements\n // inventory. The browser-supplied prices are never used.\n async placeOrder(input: PlaceOrderInput): Promise<Order> {\n this.syncOrders()\n this.syncCustomers()\n\n // Resolve / create the customer (find-or-create by email).\n let customerId = input.customerId ?? null\n let customerName = input.customer?.name?.trim() || null\n const email = input.customer?.email?.trim().toLowerCase() || null\n if (!customerId && email) {\n const existing = this.customers.find(c => (c.email ?? '').toLowerCase() === email)\n if (existing) {\n customerId = existing.id\n customerName = customerName ?? `${existing.firstName} ${existing.lastName}`.trim()\n } else {\n const [first, ...rest] = (customerName ?? email).split(' ')\n const created = await this.createCustomer({ firstName: first || email, lastName: rest.join(' '), email })\n customerId = created.id\n }\n }\n\n // Re-read price + guard stock from the catalog (never trust the client).\n const items: CreateOrderInput['items'] = []\n let subtotal = 0\n for (const line of input.items) {\n const product = this.products.find(p => p.id === line.productId)\n if (!product || product.status !== 'active') throw new Error(`Product unavailable: ${line.productId}`)\n if (product.inventoryCount < line.quantity) throw new Error(`Insufficient stock for ${product.name}`)\n const name = line.optionsLabel ? `${product.name} (${line.optionsLabel})` : product.name\n subtotal += product.price * line.quantity\n items.push({ productId: product.id, name, sku: product.sku ?? undefined, quantity: line.quantity, unitPrice: product.price, imageUrl: product.images[0]?.url })\n }\n subtotal = Math.round(subtotal * 100) / 100\n\n // Validate + apply the discount server-side.\n let shippingTotal = Math.max(input.shippingTotal ?? 0, 0)\n let discountTotal = 0\n let appliedCode: string | null = null\n if (input.discountCode) {\n const code = input.discountCode.trim().toLowerCase()\n const d = this.discounts.find(x => (x.code ?? '').toLowerCase() === code)\n const ts = now()\n const valid = !!d && d.status === 'active' && d.startsAt <= ts && (!d.endsAt || d.endsAt >= ts) && (d.usageLimit == null || d.timesUsed < d.usageLimit)\n if (valid && d) {\n appliedCode = d.code\n if (d.type === 'percentage') discountTotal = Math.round(subtotal * d.value) / 100\n else if (d.type === 'fixed_amount') discountTotal = Math.min(d.value, subtotal)\n else if (d.type === 'free_shipping') shippingTotal = 0\n // buy_x_get_y unsupported in v1: code recorded, no monetary effect\n d.timesUsed += 1\n }\n }\n discountTotal = Math.round(Math.min(Math.max(discountTotal, 0), subtotal) * 100) / 100\n\n // Persist via createOrder (recomputes total from these trusted values).\n const order = await this.createOrder({\n customerId: customerId ?? undefined,\n customerName: customerName ?? undefined,\n customerEmail: input.customer?.email ?? undefined,\n currency: input.currency,\n notes: input.notes,\n discountCode: appliedCode ?? undefined,\n discountTotal,\n shippingTotal,\n items,\n })\n\n // Decrement inventory (in-memory; the mock catalog reseeds on reload).\n for (const line of input.items) {\n const product = this.products.find(p => p.id === line.productId)\n if (product) product.inventoryCount = Math.max(0, product.inventoryCount - line.quantity)\n }\n\n return order\n }\n\n // ---------------------------------------------------------------------------\n // Customers\n // ---------------------------------------------------------------------------\n\n async listCustomers(opts?: ListCustomersOptions) {\n this.syncCustomers()\n let list = [...this.customers]\n if (opts?.search) list = list.filter(c => `${c.firstName} ${c.lastName} ${c.email}`.toLowerCase().includes(opts.search!.toLowerCase()))\n if (opts?.limit) list = list.slice(0, opts.limit)\n return list\n }\n\n async getCustomer(id: string) {\n this.syncCustomers()\n return this.customers.find(c => c.id === id) ?? null\n }\n\n async createCustomer(input: CreateCustomerInput): Promise<ShopCustomer> {\n this.syncCustomers()\n const c: ShopCustomer = { id: uid(), tenantId: 'mock', firstName: input.firstName, lastName: input.lastName ?? '', email: input.email ?? null, phone: input.phone ?? null, notes: input.notes ?? null, ordersCount: 0, totalSpent: 0, createdAt: now(), updatedAt: now() }\n this.customers.push(c)\n this.persistCustomers()\n return c\n }\n\n async updateCustomer(id: string, input: UpdateCustomerInput): Promise<ShopCustomer> {\n this.syncCustomers()\n const i = this.customers.findIndex(c => c.id === id)\n if (i < 0) throw new Error('Customer not found')\n this.customers[i] = { ...this.customers[i], ...input, updatedAt: now() }\n this.persistCustomers()\n return this.customers[i]\n }\n\n async deleteCustomer(id: string) {\n this.syncCustomers()\n this.customers = this.customers.filter(c => c.id !== id)\n this.persistCustomers()\n }\n\n async resolveCustomer(input: ResolveCustomerInput): Promise<ShopCustomer> {\n this.syncCustomers()\n const email = input.email.trim().toLowerCase()\n const existing = this.customers.find(c => (c.email ?? '').toLowerCase() === email)\n if (existing) return existing\n const [first, ...rest] = (input.name?.trim() || email).split(/\\s+/)\n return this.createCustomer({ firstName: first || email, lastName: rest.join(' '), email })\n }\n\n // ---------------------------------------------------------------------------\n // Discounts\n // ---------------------------------------------------------------------------\n\n async listDiscounts(opts?: ListDiscountsOptions) {\n let list = [...this.discounts]\n if (opts?.status) list = list.filter(d => d.status === opts.status)\n if (opts?.type) list = list.filter(d => d.type === opts.type)\n if (opts?.search) list = list.filter(d => d.title.toLowerCase().includes(opts.search!.toLowerCase()))\n if (opts?.limit) list = list.slice(0, opts.limit)\n return list\n }\n\n async getDiscount(id: string) { return this.discounts.find(d => d.id === id) ?? null }\n\n async createDiscount(input: CreateDiscountInput): Promise<Discount> {\n const d: Discount = { id: uid(), tenantId: 'mock', title: input.title, code: input.code ?? null, type: input.type, method: input.method ?? 'code', value: input.value, usageLimit: input.usageLimit ?? null, oncePerCustomer: input.oncePerCustomer ?? false, startsAt: input.startsAt ?? now(), endsAt: input.endsAt ?? null, status: input.status ?? 'active', timesUsed: 0, createdAt: now(), updatedAt: now() }\n this.discounts.push(d); return d\n }\n\n async updateDiscount(id: string, input: UpdateDiscountInput): Promise<Discount> {\n const i = this.discounts.findIndex(d => d.id === id)\n if (i < 0) throw new Error('Discount not found')\n this.discounts[i] = { ...this.discounts[i], ...input, updatedAt: now() }\n return this.discounts[i]\n }\n\n async deleteDiscount(id: string) { this.discounts = this.discounts.filter(d => d.id !== id) }\n}\n\nexport function createMockShopProvider(seed?: MockShopSeed): ShopProvider {\n return new MockShopProvider(seed)\n}\n"]}
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"mock.js"}
@@ -1,4 +1,4 @@
1
- import type { Product, ProductImage, Category, Order, ShopCustomer, Discount, ProductEnquiry, CreateProductInput, UpdateProductInput, ListProductsOptions, CreateProductEnquiryInput, ListProductEnquiriesOptions, CreateCategoryInput, UpdateCategoryInput, CreateOrderInput, UpdateOrderInput, ListOrdersOptions, PlaceOrderInput, CreateCustomerInput, UpdateCustomerInput, ListCustomersOptions, ResolveCustomerInput, CustomerAddress, ShippingQuoteOption, ShippingZone, CreateShippingZoneInput, UpdateShippingZoneInput, CreateDiscountInput, UpdateDiscountInput, ListDiscountsOptions } from './types';
1
+ import type { Product, ProductImage, Category, Order, ShopCustomer, Discount, ProductEnquiry, CreateProductInput, UpdateProductInput, ListProductsOptions, CreateProductEnquiryInput, ListProductEnquiriesOptions, CreateCategoryInput, UpdateCategoryInput, CreateOrderInput, UpdateOrderInput, ListOrdersOptions, PlaceOrderInput, CreateCustomerInput, UpdateCustomerInput, ListCustomersOptions, ResolveCustomerInput, CustomerAddress, ShippingQuoteOption, ShippingZone, CreateShippingZoneInput, UpdateShippingZoneInput, CreateDiscountInput, UpdateDiscountInput, ListDiscountsOptions, SalesChannel, CreateSalesChannelInput, UpdateSalesChannelInput } from './types';
2
2
  export interface ShopProvider {
3
3
  listProducts(options?: ListProductsOptions): Promise<Product[]>;
4
4
  getProduct(id: string): Promise<Product | null>;
@@ -81,5 +81,9 @@ export interface ShopProvider {
81
81
  createDiscount(input: CreateDiscountInput): Promise<Discount>;
82
82
  updateDiscount(id: string, input: UpdateDiscountInput): Promise<Discount>;
83
83
  deleteDiscount(id: string): Promise<void>;
84
+ listSalesChannels?(): Promise<SalesChannel[]>;
85
+ createSalesChannel?(input: CreateSalesChannelInput): Promise<SalesChannel>;
86
+ updateSalesChannel?(id: string, input: UpdateSalesChannelInput): Promise<SalesChannel>;
87
+ deleteSalesChannel?(id: string): Promise<void>;
84
88
  }
85
89
  //# sourceMappingURL=provider.d.ts.map