@cimplify/sdk 0.2.1 → 0.2.2

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 (2) hide show
  1. package/README.md +175 -0
  2. package/package.json +10 -3
package/README.md ADDED
@@ -0,0 +1,175 @@
1
+ # @cimplify/sdk
2
+
3
+ The official TypeScript SDK for building storefronts with the Cimplify Commerce Engine.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install @cimplify/sdk
9
+ # or
10
+ yarn add @cimplify/sdk
11
+ # or
12
+ bun add @cimplify/sdk
13
+ ```
14
+
15
+ ## Quick Start
16
+
17
+ ```typescript
18
+ import { createCimplifyClient } from '@cimplify/sdk';
19
+
20
+ const cimplify = createCimplifyClient();
21
+
22
+ // Fetch products
23
+ const products = await cimplify.catalogue.getProducts();
24
+
25
+ // Add to cart
26
+ await cimplify.cart.addItem({ item_id: 'product-id', quantity: 1 });
27
+
28
+ // Get cart
29
+ const cart = await cimplify.cart.get();
30
+ ```
31
+
32
+ ## Services
33
+
34
+ ### Catalogue
35
+
36
+ ```typescript
37
+ // Products
38
+ const products = await cimplify.catalogue.getProducts();
39
+ const featured = await cimplify.catalogue.getProducts({ featured: true, limit: 10 });
40
+ const product = await cimplify.catalogue.getProduct('product-id');
41
+ const product = await cimplify.catalogue.getProductBySlug('my-product');
42
+
43
+ // Variants
44
+ const variants = await cimplify.catalogue.getVariants('product-id');
45
+ const variant = await cimplify.catalogue.getVariantByAxisSelections('product-id', {
46
+ Size: 'Large',
47
+ Color: 'Red',
48
+ });
49
+
50
+ // Categories & Collections
51
+ const categories = await cimplify.catalogue.getCategories();
52
+ const collections = await cimplify.catalogue.getCollections();
53
+
54
+ // Bundles & Composites
55
+ const bundles = await cimplify.catalogue.getBundles();
56
+ const composites = await cimplify.catalogue.getComposites();
57
+
58
+ // Search
59
+ const results = await cimplify.catalogue.search('coffee');
60
+ ```
61
+
62
+ ### Cart
63
+
64
+ ```typescript
65
+ const cart = await cimplify.cart.get();
66
+ const count = await cimplify.cart.getCount();
67
+
68
+ await cimplify.cart.addItem({
69
+ item_id: 'product-id',
70
+ quantity: 2,
71
+ configuration: {
72
+ variant: { variant_id: 'variant-id' },
73
+ add_ons: [{ add_on_id: 'addon-id', quantity: 1 }],
74
+ },
75
+ });
76
+
77
+ await cimplify.cart.updateQuantity('cart-item-id', 3);
78
+ await cimplify.cart.removeItem('cart-item-id');
79
+ await cimplify.cart.clear();
80
+
81
+ await cimplify.cart.applyCoupon('SUMMER20');
82
+ await cimplify.cart.removeCoupon();
83
+ ```
84
+
85
+ ### Orders
86
+
87
+ ```typescript
88
+ const orders = await cimplify.orders.getOrders();
89
+ const order = await cimplify.orders.getOrder('order-id');
90
+ ```
91
+
92
+ ### Authentication
93
+
94
+ ```typescript
95
+ const status = await cimplify.auth.getStatus();
96
+ const user = await cimplify.auth.getCurrentUser();
97
+
98
+ await cimplify.auth.requestOtp('+1234567890', 'phone');
99
+ const result = await cimplify.auth.verifyOtp('123456', '+1234567890');
100
+ await cimplify.auth.logout();
101
+ ```
102
+
103
+ ### Business & Locations
104
+
105
+ ```typescript
106
+ const business = await cimplify.business.getBusiness();
107
+ const locations = await cimplify.business.getLocations();
108
+ ```
109
+
110
+ ### Scheduling
111
+
112
+ ```typescript
113
+ const slots = await cimplify.scheduling.getAvailableSlots({
114
+ location_id: 'location-id',
115
+ date: '2025-01-15',
116
+ service_type: 'delivery',
117
+ });
118
+ ```
119
+
120
+ ### Inventory
121
+
122
+ ```typescript
123
+ const stock = await cimplify.inventory.checkStock('product-id', 'location-id');
124
+ ```
125
+
126
+ ## Price Utilities
127
+
128
+ ```typescript
129
+ import { formatPrice, formatPriceCompact, isOnSale, getDiscountPercentage } from '@cimplify/sdk';
130
+
131
+ formatPrice(29.99, 'USD'); // "$29.99"
132
+ formatPrice(29.99, 'GHS'); // "GH₵29.99"
133
+ formatPriceCompact(2500000, 'USD'); // "$2.5M"
134
+
135
+ if (isOnSale(product)) {
136
+ console.log(`${getDiscountPercentage(product)}% off!`);
137
+ }
138
+ ```
139
+
140
+ ## Error Handling
141
+
142
+ ```typescript
143
+ import { CimplifyError } from '@cimplify/sdk';
144
+
145
+ try {
146
+ await cimplify.cart.addItem({ item_id: 'invalid', quantity: 1 });
147
+ } catch (error) {
148
+ if (error instanceof CimplifyError) {
149
+ console.log(error.code); // "PRODUCT_NOT_FOUND"
150
+ console.log(error.message); // "Product not found"
151
+ }
152
+ }
153
+ ```
154
+
155
+ ## TypeScript
156
+
157
+ ```typescript
158
+ import type {
159
+ Product,
160
+ ProductWithDetails,
161
+ ProductVariant,
162
+ Category,
163
+ Collection,
164
+ Bundle,
165
+ Composite,
166
+ Cart,
167
+ CartItem,
168
+ Order,
169
+ Customer,
170
+ } from '@cimplify/sdk';
171
+ ```
172
+
173
+ ## License
174
+
175
+ MIT
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cimplify/sdk",
3
- "version": "0.2.1",
3
+ "version": "0.2.2",
4
4
  "description": "Cimplify Commerce SDK for storefronts",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",
@@ -12,7 +12,9 @@
12
12
  "require": "./dist/index.js"
13
13
  }
14
14
  },
15
- "files": ["dist"],
15
+ "files": [
16
+ "dist"
17
+ ],
16
18
  "scripts": {
17
19
  "build": "tsup",
18
20
  "dev": "tsup --watch",
@@ -24,6 +26,11 @@
24
26
  "tsup": "^8.0.0",
25
27
  "typescript": "5.9.2"
26
28
  },
27
- "keywords": ["cimplify", "commerce", "sdk", "storefront"],
29
+ "keywords": [
30
+ "cimplify",
31
+ "commerce",
32
+ "sdk",
33
+ "storefront"
34
+ ],
28
35
  "license": "MIT"
29
36
  }