@withvlibe/base-sdk 1.1.0 → 1.1.1

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.
package/README.md CHANGED
@@ -309,6 +309,290 @@ const products = await db.query<Product>('products', { where: { isActive: true }
309
309
  const orders = await db.query<Order>('orders', { where: { userId: user.id } });
310
310
  ```
311
311
 
312
+ ## E-Commerce
313
+
314
+ The SDK provides specialized e-commerce functionality through `VlibeBaseEcommerce`.
315
+
316
+ ### Setup
317
+
318
+ ```typescript
319
+ import { VlibeBaseEcommerce } from '@withvlibe/base-sdk';
320
+
321
+ // Initialize with database client
322
+ export const ecommerce = new VlibeBaseEcommerce(db);
323
+ ```
324
+
325
+ ### Products
326
+
327
+ ```typescript
328
+ // Create a product
329
+ const product = await ecommerce.createProduct({
330
+ name: 'Premium T-Shirt',
331
+ description: 'High-quality cotton t-shirt',
332
+ price: 2999, // $29.99 in cents
333
+ currency: 'usd',
334
+ stock: 100,
335
+ images: ['https://example.com/tshirt.jpg'],
336
+ category: 'apparel',
337
+ isActive: true,
338
+ });
339
+
340
+ // List products
341
+ const { products, total } = await ecommerce.listProducts({
342
+ category: 'apparel',
343
+ isActive: true,
344
+ sortBy: 'created_at',
345
+ limit: 20,
346
+ });
347
+
348
+ // Update inventory
349
+ await ecommerce.updateInventory(productId, 50, 'set');
350
+ await ecommerce.updateInventory(productId, 5, 'increment');
351
+ await ecommerce.updateInventory(productId, 3, 'decrement');
352
+
353
+ // Get low stock products
354
+ const lowStock = await ecommerce.getLowStockProducts(10); // threshold: 10
355
+ ```
356
+
357
+ ### Shopping Cart
358
+
359
+ ```typescript
360
+ // Add to cart
361
+ await ecommerce.addToCart(userId, {
362
+ productId: 'product-123',
363
+ quantity: 2,
364
+ });
365
+
366
+ // Get cart (lightweight - only IDs and quantities)
367
+ const cart = await ecommerce.getCart(userId);
368
+ // Returns: [{ productId: '...', quantity: 2 }]
369
+
370
+ // Get cart with full product details
371
+ const detailedCart = await ecommerce.getCartWithDetails(userId);
372
+ // Returns: [{ productId: '...', quantity: 2, product: {...}, lineTotal: 5998 }]
373
+
374
+ // Update quantity
375
+ await ecommerce.updateCartItem(userId, productId, 5);
376
+
377
+ // Remove item (set quantity to 0)
378
+ await ecommerce.updateCartItem(userId, productId, 0);
379
+
380
+ // Calculate order totals
381
+ const calculation = await ecommerce.calculateOrderTotal(cart);
382
+ console.log('Subtotal:', calculation.subtotal);
383
+ console.log('Tax:', calculation.tax);
384
+ console.log('Shipping:', calculation.shipping);
385
+ console.log('Total:', calculation.total);
386
+
387
+ // Checkout (creates order and clears cart)
388
+ const order = await ecommerce.checkout(userId, {
389
+ line1: '123 Main St',
390
+ city: 'San Francisco',
391
+ state: 'CA',
392
+ postalCode: '94102',
393
+ country: 'US',
394
+ }, paymentMethodId);
395
+ ```
396
+
397
+ ### Orders
398
+
399
+ ```typescript
400
+ // Create an order directly
401
+ const order = await ecommerce.createOrder({
402
+ userId: 'user-123',
403
+ items: [
404
+ { productId: 'product-1', quantity: 2 },
405
+ { productId: 'product-2', quantity: 1 },
406
+ ],
407
+ shippingAddress: {
408
+ line1: '123 Main St',
409
+ city: 'San Francisco',
410
+ state: 'CA',
411
+ postalCode: '94102',
412
+ country: 'US',
413
+ },
414
+ });
415
+
416
+ // List orders
417
+ const { orders, total } = await ecommerce.listOrders({
418
+ userId: 'user-123',
419
+ status: 'pending',
420
+ limit: 10,
421
+ });
422
+
423
+ // Update order status
424
+ await ecommerce.updateOrderStatus(orderId, 'shipped');
425
+
426
+ // Cancel order (optionally restore inventory)
427
+ await ecommerce.cancelOrder(orderId, true);
428
+ ```
429
+
430
+ ### Analytics
431
+
432
+ ```typescript
433
+ // Revenue stats
434
+ const stats = await ecommerce.getRevenueStats('month');
435
+ console.log('Revenue:', stats.totalRevenue);
436
+ console.log('Orders:', stats.totalOrders);
437
+ console.log('AOV:', stats.averageOrderValue);
438
+ console.log('Trend:', stats.trend.revenue); // % change
439
+
440
+ // Top products
441
+ const topProducts = await ecommerce.getTopProducts(10, 'week');
442
+
443
+ // Order statistics
444
+ const orderStats = await ecommerce.getOrderStats();
445
+ console.log('Pending:', orderStats.pending);
446
+ console.log('Delivered:', orderStats.delivered);
447
+ ```
448
+
449
+ ### React Hooks for E-Commerce
450
+
451
+ ```tsx
452
+ import { useProducts, useCart, useOrders } from '@withvlibe/base-sdk/react';
453
+
454
+ function ProductList() {
455
+ const { products, loading, createProduct, updateProduct } = useProducts(ecommerce, {
456
+ category: 'apparel',
457
+ isActive: true,
458
+ });
459
+
460
+ if (loading) return <div>Loading...</div>;
461
+
462
+ return (
463
+ <div>
464
+ {products.map(product => (
465
+ <div key={product.id}>
466
+ <h3>{product.name}</h3>
467
+ <p>${(product.price / 100).toFixed(2)}</p>
468
+ <p>Stock: {product.stock}</p>
469
+ </div>
470
+ ))}
471
+ </div>
472
+ );
473
+ }
474
+
475
+ function ShoppingCart({ userId }: { userId: string }) {
476
+ const { cart, itemCount, addItem, updateItem, removeItem, checkout, getCartWithDetails } = useCart(ecommerce, userId);
477
+ const [detailedItems, setDetailedItems] = useState([]);
478
+
479
+ useEffect(() => {
480
+ // Load cart with product details
481
+ const loadDetails = async () => {
482
+ const items = await getCartWithDetails();
483
+ setDetailedItems(items);
484
+ };
485
+ loadDetails();
486
+ }, [getCartWithDetails]);
487
+
488
+ return (
489
+ <div>
490
+ <h2>Cart ({itemCount} items)</h2>
491
+ {detailedItems.map(item => (
492
+ <div key={item.productId}>
493
+ <h3>{item.product.name}</h3>
494
+ <p>${(item.product.price / 100).toFixed(2)} x {item.quantity}</p>
495
+ <p>Subtotal: ${(item.lineTotal / 100).toFixed(2)}</p>
496
+ <button onClick={() => updateItem(item.productId, item.quantity + 1)}>+</button>
497
+ <button onClick={() => updateItem(item.productId, item.quantity - 1)}>-</button>
498
+ <button onClick={() => removeItem(item.productId)}>Remove</button>
499
+ </div>
500
+ ))}
501
+ <button onClick={() => checkout(shippingAddress)}>Checkout</button>
502
+ </div>
503
+ );
504
+ }
505
+
506
+ function OrderHistory({ userId }: { userId: string }) {
507
+ const { orders, loading, updateStatus, cancelOrder } = useOrders(ecommerce, { userId });
508
+
509
+ if (loading) return <div>Loading...</div>;
510
+
511
+ return (
512
+ <div>
513
+ {orders.map(order => (
514
+ <div key={order.id}>
515
+ <h3>Order #{order.id}</h3>
516
+ <p>Status: {order.status}</p>
517
+ <p>Total: ${(order.total / 100).toFixed(2)}</p>
518
+ <ul>
519
+ {order.items.map(item => (
520
+ <li key={item.productId}>
521
+ {item.name} x {item.quantity} - ${(item.price / 100).toFixed(2)}
522
+ </li>
523
+ ))}
524
+ </ul>
525
+ </div>
526
+ ))}
527
+ </div>
528
+ );
529
+ }
530
+ ```
531
+
532
+ ### Database Schema
533
+
534
+ Create these tables in your database:
535
+
536
+ ```typescript
537
+ // Products table
538
+ interface ProductRow {
539
+ id: string;
540
+ name: string;
541
+ description?: string;
542
+ sku?: string;
543
+ price: number; // cents
544
+ currency: string;
545
+ images: string[]; // JSON array
546
+ stock: number;
547
+ isActive: boolean;
548
+ category?: string;
549
+ metadata?: Record<string, any>; // JSON
550
+ created_at: string;
551
+ updated_at: string;
552
+ }
553
+
554
+ // Orders table
555
+ interface OrderRow {
556
+ id: string;
557
+ userId: string;
558
+ status: 'pending' | 'processing' | 'shipped' | 'delivered' | 'cancelled';
559
+ items: OrderItem[]; // JSON array
560
+ subtotal: number;
561
+ tax: number;
562
+ shipping: number;
563
+ total: number;
564
+ shippingAddress: Address; // JSON
565
+ billingAddress?: Address; // JSON
566
+ paymentMethodId?: string;
567
+ stripePaymentIntentId?: string;
568
+ notes?: string;
569
+ created_at: string;
570
+ updated_at: string;
571
+ }
572
+
573
+ // Order Items table (for queries)
574
+ interface OrderItemRow {
575
+ id: string;
576
+ orderId: string;
577
+ productId: string;
578
+ name: string;
579
+ quantity: number;
580
+ price: number;
581
+ lineTotal: number;
582
+ created_at: string;
583
+ }
584
+
585
+ // Carts table
586
+ interface CartRow {
587
+ id: string;
588
+ userId: string;
589
+ productId: string;
590
+ quantity: number;
591
+ created_at: string;
592
+ updated_at: string;
593
+ }
594
+ ```
595
+
312
596
  ## API Reference
313
597
 
314
598
  ### VlibeBaseDatabase
@@ -280,6 +280,12 @@ interface CartItem {
280
280
  productId: string;
281
281
  quantity: number;
282
282
  }
283
+ interface CartItemWithProduct {
284
+ productId: string;
285
+ quantity: number;
286
+ product: Product;
287
+ lineTotal: number;
288
+ }
283
289
  interface CreateProductInput {
284
290
  name: string;
285
291
  description?: string;
@@ -730,6 +736,10 @@ declare class VlibeBaseEcommerce {
730
736
  * Get user's cart
731
737
  */
732
738
  getCart(userId: string): Promise<CartItem[]>;
739
+ /**
740
+ * Get user's cart with full product details
741
+ */
742
+ getCartWithDetails(userId: string): Promise<CartItemWithProduct[]>;
733
743
  /**
734
744
  * Clear user's cart
735
745
  */
@@ -754,4 +764,4 @@ declare class VlibeBaseEcommerce {
754
764
  private getPeriodStart;
755
765
  }
756
766
 
757
- export { type AppCategory as A, type BasePlan as B, type ConnectStatus as C, type DatabaseConfig as D, type ApiResponse as E, type FeatureFlag as F, type PaginatedResponse as G, type UseCollectionReturn as H, type UseCollectionOptions as I, type UseKVReturn as J, type UseAuthReturn as K, type UsePaymentsReturn as L, type Media as M, type Order as O, type PaymentsConfig as P, type QueryOptions as Q, type RefundOptions as R, type Subscription as S, type Transaction as T, type UsageMetric as U, VlibeBaseDatabase as V, type CheckoutOptions as a, type CheckoutSession as b, VlibeBaseAuth as c, VlibeBaseEcommerce as d, type VlibeBaseConfig as e, type AuthConfig as f, type ColumnType as g, type TableColumn as h, type TableSchema as i, type TableInfo as j, type BaseRecord as k, type RealtimePayload as l, type VlibeUser as m, type VerifyResponse as n, type AuthSession as o, type Page as p, type Product as q, type OrderItem as r, type Address as s, type CartItem as t, type CreateProductInput as u, type CreateOrderInput as v, type OrderCalculation as w, type RevenueStats as x, type ProductStats as y, type OrderStats as z };
767
+ export { type AppCategory as A, type BasePlan as B, type ConnectStatus as C, type DatabaseConfig as D, type OrderStats as E, type FeatureFlag as F, type ApiResponse as G, type PaginatedResponse as H, type UseCollectionReturn as I, type UseCollectionOptions as J, type UseKVReturn as K, type UseAuthReturn as L, type Media as M, type UsePaymentsReturn as N, type Order as O, type PaymentsConfig as P, type QueryOptions as Q, type RefundOptions as R, type Subscription as S, type Transaction as T, type UsageMetric as U, VlibeBaseDatabase as V, type CheckoutOptions as a, type CheckoutSession as b, VlibeBaseAuth as c, VlibeBaseEcommerce as d, type VlibeBaseConfig as e, type AuthConfig as f, type ColumnType as g, type TableColumn as h, type TableSchema as i, type TableInfo as j, type BaseRecord as k, type RealtimePayload as l, type VlibeUser as m, type VerifyResponse as n, type AuthSession as o, type Page as p, type Product as q, type OrderItem as r, type Address as s, type CartItem as t, type CartItemWithProduct as u, type CreateProductInput as v, type CreateOrderInput as w, type OrderCalculation as x, type RevenueStats as y, type ProductStats as z };
@@ -280,6 +280,12 @@ interface CartItem {
280
280
  productId: string;
281
281
  quantity: number;
282
282
  }
283
+ interface CartItemWithProduct {
284
+ productId: string;
285
+ quantity: number;
286
+ product: Product;
287
+ lineTotal: number;
288
+ }
283
289
  interface CreateProductInput {
284
290
  name: string;
285
291
  description?: string;
@@ -730,6 +736,10 @@ declare class VlibeBaseEcommerce {
730
736
  * Get user's cart
731
737
  */
732
738
  getCart(userId: string): Promise<CartItem[]>;
739
+ /**
740
+ * Get user's cart with full product details
741
+ */
742
+ getCartWithDetails(userId: string): Promise<CartItemWithProduct[]>;
733
743
  /**
734
744
  * Clear user's cart
735
745
  */
@@ -754,4 +764,4 @@ declare class VlibeBaseEcommerce {
754
764
  private getPeriodStart;
755
765
  }
756
766
 
757
- export { type AppCategory as A, type BasePlan as B, type ConnectStatus as C, type DatabaseConfig as D, type ApiResponse as E, type FeatureFlag as F, type PaginatedResponse as G, type UseCollectionReturn as H, type UseCollectionOptions as I, type UseKVReturn as J, type UseAuthReturn as K, type UsePaymentsReturn as L, type Media as M, type Order as O, type PaymentsConfig as P, type QueryOptions as Q, type RefundOptions as R, type Subscription as S, type Transaction as T, type UsageMetric as U, VlibeBaseDatabase as V, type CheckoutOptions as a, type CheckoutSession as b, VlibeBaseAuth as c, VlibeBaseEcommerce as d, type VlibeBaseConfig as e, type AuthConfig as f, type ColumnType as g, type TableColumn as h, type TableSchema as i, type TableInfo as j, type BaseRecord as k, type RealtimePayload as l, type VlibeUser as m, type VerifyResponse as n, type AuthSession as o, type Page as p, type Product as q, type OrderItem as r, type Address as s, type CartItem as t, type CreateProductInput as u, type CreateOrderInput as v, type OrderCalculation as w, type RevenueStats as x, type ProductStats as y, type OrderStats as z };
767
+ export { type AppCategory as A, type BasePlan as B, type ConnectStatus as C, type DatabaseConfig as D, type OrderStats as E, type FeatureFlag as F, type ApiResponse as G, type PaginatedResponse as H, type UseCollectionReturn as I, type UseCollectionOptions as J, type UseKVReturn as K, type UseAuthReturn as L, type Media as M, type UsePaymentsReturn as N, type Order as O, type PaymentsConfig as P, type QueryOptions as Q, type RefundOptions as R, type Subscription as S, type Transaction as T, type UsageMetric as U, VlibeBaseDatabase as V, type CheckoutOptions as a, type CheckoutSession as b, VlibeBaseAuth as c, VlibeBaseEcommerce as d, type VlibeBaseConfig as e, type AuthConfig as f, type ColumnType as g, type TableColumn as h, type TableSchema as i, type TableInfo as j, type BaseRecord as k, type RealtimePayload as l, type VlibeUser as m, type VerifyResponse as n, type AuthSession as o, type Page as p, type Product as q, type OrderItem as r, type Address as s, type CartItem as t, type CartItemWithProduct as u, type CreateProductInput as v, type CreateOrderInput as w, type OrderCalculation as x, type RevenueStats as y, type ProductStats as z };
package/dist/index.d.mts CHANGED
@@ -1,5 +1,5 @@
1
- import { P as PaymentsConfig, C as ConnectStatus, a as CheckoutOptions, b as CheckoutSession, T as Transaction, R as RefundOptions } from './VlibeBaseEcommerce-B6l17uup.mjs';
2
- export { s as Address, E as ApiResponse, A as AppCategory, f as AuthConfig, o as AuthSession, B as BasePlan, k as BaseRecord, t as CartItem, g as ColumnType, v as CreateOrderInput, u as CreateProductInput, D as DatabaseConfig, F as FeatureFlag, M as Media, O as Order, w as OrderCalculation, r as OrderItem, z as OrderStats, p as Page, G as PaginatedResponse, q as Product, y as ProductStats, Q as QueryOptions, l as RealtimePayload, x as RevenueStats, S as Subscription, h as TableColumn, j as TableInfo, i as TableSchema, U as UsageMetric, K as UseAuthReturn, I as UseCollectionOptions, H as UseCollectionReturn, J as UseKVReturn, L as UsePaymentsReturn, n as VerifyResponse, c as VlibeBaseAuth, e as VlibeBaseConfig, V as VlibeBaseDatabase, d as VlibeBaseEcommerce, m as VlibeUser } from './VlibeBaseEcommerce-B6l17uup.mjs';
1
+ import { P as PaymentsConfig, C as ConnectStatus, a as CheckoutOptions, b as CheckoutSession, T as Transaction, R as RefundOptions } from './VlibeBaseEcommerce-DXjHdN_L.mjs';
2
+ export { s as Address, G as ApiResponse, A as AppCategory, f as AuthConfig, o as AuthSession, B as BasePlan, k as BaseRecord, t as CartItem, u as CartItemWithProduct, g as ColumnType, w as CreateOrderInput, v as CreateProductInput, D as DatabaseConfig, F as FeatureFlag, M as Media, O as Order, x as OrderCalculation, r as OrderItem, E as OrderStats, p as Page, H as PaginatedResponse, q as Product, z as ProductStats, Q as QueryOptions, l as RealtimePayload, y as RevenueStats, S as Subscription, h as TableColumn, j as TableInfo, i as TableSchema, U as UsageMetric, L as UseAuthReturn, J as UseCollectionOptions, I as UseCollectionReturn, K as UseKVReturn, N as UsePaymentsReturn, n as VerifyResponse, c as VlibeBaseAuth, e as VlibeBaseConfig, V as VlibeBaseDatabase, d as VlibeBaseEcommerce, m as VlibeUser } from './VlibeBaseEcommerce-DXjHdN_L.mjs';
3
3
 
4
4
  /**
5
5
  * VlibeBasePayments - Payment processing for Vlibe Base Apps
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { P as PaymentsConfig, C as ConnectStatus, a as CheckoutOptions, b as CheckoutSession, T as Transaction, R as RefundOptions } from './VlibeBaseEcommerce-B6l17uup.js';
2
- export { s as Address, E as ApiResponse, A as AppCategory, f as AuthConfig, o as AuthSession, B as BasePlan, k as BaseRecord, t as CartItem, g as ColumnType, v as CreateOrderInput, u as CreateProductInput, D as DatabaseConfig, F as FeatureFlag, M as Media, O as Order, w as OrderCalculation, r as OrderItem, z as OrderStats, p as Page, G as PaginatedResponse, q as Product, y as ProductStats, Q as QueryOptions, l as RealtimePayload, x as RevenueStats, S as Subscription, h as TableColumn, j as TableInfo, i as TableSchema, U as UsageMetric, K as UseAuthReturn, I as UseCollectionOptions, H as UseCollectionReturn, J as UseKVReturn, L as UsePaymentsReturn, n as VerifyResponse, c as VlibeBaseAuth, e as VlibeBaseConfig, V as VlibeBaseDatabase, d as VlibeBaseEcommerce, m as VlibeUser } from './VlibeBaseEcommerce-B6l17uup.js';
1
+ import { P as PaymentsConfig, C as ConnectStatus, a as CheckoutOptions, b as CheckoutSession, T as Transaction, R as RefundOptions } from './VlibeBaseEcommerce-DXjHdN_L.js';
2
+ export { s as Address, G as ApiResponse, A as AppCategory, f as AuthConfig, o as AuthSession, B as BasePlan, k as BaseRecord, t as CartItem, u as CartItemWithProduct, g as ColumnType, w as CreateOrderInput, v as CreateProductInput, D as DatabaseConfig, F as FeatureFlag, M as Media, O as Order, x as OrderCalculation, r as OrderItem, E as OrderStats, p as Page, H as PaginatedResponse, q as Product, z as ProductStats, Q as QueryOptions, l as RealtimePayload, y as RevenueStats, S as Subscription, h as TableColumn, j as TableInfo, i as TableSchema, U as UsageMetric, L as UseAuthReturn, J as UseCollectionOptions, I as UseCollectionReturn, K as UseKVReturn, N as UsePaymentsReturn, n as VerifyResponse, c as VlibeBaseAuth, e as VlibeBaseConfig, V as VlibeBaseDatabase, d as VlibeBaseEcommerce, m as VlibeUser } from './VlibeBaseEcommerce-DXjHdN_L.js';
3
3
 
4
4
  /**
5
5
  * VlibeBasePayments - Payment processing for Vlibe Base Apps
package/dist/index.js CHANGED
@@ -1082,6 +1082,26 @@ var VlibeBaseEcommerce = class {
1082
1082
  quantity: item.quantity
1083
1083
  }));
1084
1084
  }
1085
+ /**
1086
+ * Get user's cart with full product details
1087
+ */
1088
+ async getCartWithDetails(userId) {
1089
+ const cart = await this.getCart(userId);
1090
+ const enriched = [];
1091
+ for (const item of cart) {
1092
+ const product = await this.getProduct(item.productId);
1093
+ if (!product) {
1094
+ throw new Error(`Product not found: ${item.productId}`);
1095
+ }
1096
+ enriched.push({
1097
+ productId: item.productId,
1098
+ quantity: item.quantity,
1099
+ product,
1100
+ lineTotal: product.price * item.quantity
1101
+ });
1102
+ }
1103
+ return enriched;
1104
+ }
1085
1105
  /**
1086
1106
  * Clear user's cart
1087
1107
  */
package/dist/index.mjs CHANGED
@@ -1053,6 +1053,26 @@ var VlibeBaseEcommerce = class {
1053
1053
  quantity: item.quantity
1054
1054
  }));
1055
1055
  }
1056
+ /**
1057
+ * Get user's cart with full product details
1058
+ */
1059
+ async getCartWithDetails(userId) {
1060
+ const cart = await this.getCart(userId);
1061
+ const enriched = [];
1062
+ for (const item of cart) {
1063
+ const product = await this.getProduct(item.productId);
1064
+ if (!product) {
1065
+ throw new Error(`Product not found: ${item.productId}`);
1066
+ }
1067
+ enriched.push({
1068
+ productId: item.productId,
1069
+ quantity: item.quantity,
1070
+ product,
1071
+ lineTotal: product.price * item.quantity
1072
+ });
1073
+ }
1074
+ return enriched;
1075
+ }
1056
1076
  /**
1057
1077
  * Clear user's cart
1058
1078
  */
package/dist/react.d.mts CHANGED
@@ -1,5 +1,5 @@
1
- import { k as BaseRecord, V as VlibeBaseDatabase, I as UseCollectionOptions, H as UseCollectionReturn, J as UseKVReturn, c as VlibeBaseAuth, K as UseAuthReturn, d as VlibeBaseEcommerce, q as Product, u as CreateProductInput, t as CartItem, s as Address, O as Order } from './VlibeBaseEcommerce-B6l17uup.mjs';
2
- export { v as CreateOrderInput, L as UsePaymentsReturn, m as VlibeUser } from './VlibeBaseEcommerce-B6l17uup.mjs';
1
+ import { k as BaseRecord, V as VlibeBaseDatabase, J as UseCollectionOptions, I as UseCollectionReturn, K as UseKVReturn, c as VlibeBaseAuth, L as UseAuthReturn, d as VlibeBaseEcommerce, q as Product, v as CreateProductInput, t as CartItem, s as Address, O as Order, u as CartItemWithProduct } from './VlibeBaseEcommerce-DXjHdN_L.mjs';
2
+ export { w as CreateOrderInput, N as UsePaymentsReturn, m as VlibeUser } from './VlibeBaseEcommerce-DXjHdN_L.mjs';
3
3
 
4
4
  /**
5
5
  * React hook for working with a database collection
@@ -143,6 +143,7 @@ interface UseCartReturn {
143
143
  clear: () => Promise<void>;
144
144
  checkout: (shippingAddress: Address, paymentMethodId?: string) => Promise<Order>;
145
145
  calculateTotal: () => Promise<any>;
146
+ getCartWithDetails: () => Promise<CartItemWithProduct[]>;
146
147
  }
147
148
  /**
148
149
  * React hook for managing shopping cart
@@ -197,4 +198,4 @@ interface UseOrdersReturn {
197
198
  */
198
199
  declare function useOrders(ecommerce: VlibeBaseEcommerce, options?: UseOrdersOptions): UseOrdersReturn;
199
200
 
200
- export { BaseRecord, CartItem, CreateProductInput, Order, Product, UseAuthReturn, type UseCartReturn, UseCollectionOptions, UseCollectionReturn, UseKVReturn, type UseOrdersOptions, type UseOrdersReturn, type UseProductsOptions, type UseProductsReturn, useAuth, useCart, useCollection, useKV, useOrders, useProducts };
201
+ export { BaseRecord, CartItem, CartItemWithProduct, CreateProductInput, Order, Product, UseAuthReturn, type UseCartReturn, UseCollectionOptions, UseCollectionReturn, UseKVReturn, type UseOrdersOptions, type UseOrdersReturn, type UseProductsOptions, type UseProductsReturn, useAuth, useCart, useCollection, useKV, useOrders, useProducts };
package/dist/react.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { k as BaseRecord, V as VlibeBaseDatabase, I as UseCollectionOptions, H as UseCollectionReturn, J as UseKVReturn, c as VlibeBaseAuth, K as UseAuthReturn, d as VlibeBaseEcommerce, q as Product, u as CreateProductInput, t as CartItem, s as Address, O as Order } from './VlibeBaseEcommerce-B6l17uup.js';
2
- export { v as CreateOrderInput, L as UsePaymentsReturn, m as VlibeUser } from './VlibeBaseEcommerce-B6l17uup.js';
1
+ import { k as BaseRecord, V as VlibeBaseDatabase, J as UseCollectionOptions, I as UseCollectionReturn, K as UseKVReturn, c as VlibeBaseAuth, L as UseAuthReturn, d as VlibeBaseEcommerce, q as Product, v as CreateProductInput, t as CartItem, s as Address, O as Order, u as CartItemWithProduct } from './VlibeBaseEcommerce-DXjHdN_L.js';
2
+ export { w as CreateOrderInput, N as UsePaymentsReturn, m as VlibeUser } from './VlibeBaseEcommerce-DXjHdN_L.js';
3
3
 
4
4
  /**
5
5
  * React hook for working with a database collection
@@ -143,6 +143,7 @@ interface UseCartReturn {
143
143
  clear: () => Promise<void>;
144
144
  checkout: (shippingAddress: Address, paymentMethodId?: string) => Promise<Order>;
145
145
  calculateTotal: () => Promise<any>;
146
+ getCartWithDetails: () => Promise<CartItemWithProduct[]>;
146
147
  }
147
148
  /**
148
149
  * React hook for managing shopping cart
@@ -197,4 +198,4 @@ interface UseOrdersReturn {
197
198
  */
198
199
  declare function useOrders(ecommerce: VlibeBaseEcommerce, options?: UseOrdersOptions): UseOrdersReturn;
199
200
 
200
- export { BaseRecord, CartItem, CreateProductInput, Order, Product, UseAuthReturn, type UseCartReturn, UseCollectionOptions, UseCollectionReturn, UseKVReturn, type UseOrdersOptions, type UseOrdersReturn, type UseProductsOptions, type UseProductsReturn, useAuth, useCart, useCollection, useKV, useOrders, useProducts };
201
+ export { BaseRecord, CartItem, CartItemWithProduct, CreateProductInput, Order, Product, UseAuthReturn, type UseCartReturn, UseCollectionOptions, UseCollectionReturn, UseKVReturn, type UseOrdersOptions, type UseOrdersReturn, type UseProductsOptions, type UseProductsReturn, useAuth, useCart, useCollection, useKV, useOrders, useProducts };
package/dist/react.js CHANGED
@@ -375,6 +375,9 @@ function useCart(ecommerce, userId) {
375
375
  const calculateTotal = (0, import_react5.useCallback)(async () => {
376
376
  return ecommerce.calculateOrderTotal(cart);
377
377
  }, [ecommerce, cart]);
378
+ const getCartWithDetails = (0, import_react5.useCallback)(async () => {
379
+ return ecommerce.getCartWithDetails(userId);
380
+ }, [ecommerce, userId]);
378
381
  const itemCount = cart.reduce((sum, item) => sum + item.quantity, 0);
379
382
  return {
380
383
  cart,
@@ -387,7 +390,8 @@ function useCart(ecommerce, userId) {
387
390
  removeItem,
388
391
  clear,
389
392
  checkout,
390
- calculateTotal
393
+ calculateTotal,
394
+ getCartWithDetails
391
395
  };
392
396
  }
393
397
 
package/dist/react.mjs CHANGED
@@ -345,6 +345,9 @@ function useCart(ecommerce, userId) {
345
345
  const calculateTotal = useCallback5(async () => {
346
346
  return ecommerce.calculateOrderTotal(cart);
347
347
  }, [ecommerce, cart]);
348
+ const getCartWithDetails = useCallback5(async () => {
349
+ return ecommerce.getCartWithDetails(userId);
350
+ }, [ecommerce, userId]);
348
351
  const itemCount = cart.reduce((sum, item) => sum + item.quantity, 0);
349
352
  return {
350
353
  cart,
@@ -357,7 +360,8 @@ function useCart(ecommerce, userId) {
357
360
  removeItem,
358
361
  clear,
359
362
  checkout,
360
- calculateTotal
363
+ calculateTotal,
364
+ getCartWithDetails
361
365
  };
362
366
  }
363
367
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@withvlibe/base-sdk",
3
- "version": "1.1.0",
3
+ "version": "1.1.1",
4
4
  "description": "SDK for Vlibe Base Apps - includes authentication, database, payments with transaction fees, and category-specific helpers for websites, SaaS, and e-commerce",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",