@cimplify/sdk 0.2.2 → 0.2.3
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 +30 -30
- package/dist/index.d.mts +3 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +36 -103
- package/dist/index.mjs +36 -103
- package/package.json +19 -16
package/README.md
CHANGED
|
@@ -15,7 +15,7 @@ bun add @cimplify/sdk
|
|
|
15
15
|
## Quick Start
|
|
16
16
|
|
|
17
17
|
```typescript
|
|
18
|
-
import { createCimplifyClient } from
|
|
18
|
+
import { createCimplifyClient } from "@cimplify/sdk";
|
|
19
19
|
|
|
20
20
|
const cimplify = createCimplifyClient();
|
|
21
21
|
|
|
@@ -23,7 +23,7 @@ const cimplify = createCimplifyClient();
|
|
|
23
23
|
const products = await cimplify.catalogue.getProducts();
|
|
24
24
|
|
|
25
25
|
// Add to cart
|
|
26
|
-
await cimplify.cart.addItem({ item_id:
|
|
26
|
+
await cimplify.cart.addItem({ item_id: "product-id", quantity: 1 });
|
|
27
27
|
|
|
28
28
|
// Get cart
|
|
29
29
|
const cart = await cimplify.cart.get();
|
|
@@ -37,14 +37,14 @@ const cart = await cimplify.cart.get();
|
|
|
37
37
|
// Products
|
|
38
38
|
const products = await cimplify.catalogue.getProducts();
|
|
39
39
|
const featured = await cimplify.catalogue.getProducts({ featured: true, limit: 10 });
|
|
40
|
-
const product = await cimplify.catalogue.getProduct(
|
|
41
|
-
const product = await cimplify.catalogue.getProductBySlug(
|
|
40
|
+
const product = await cimplify.catalogue.getProduct("product-id");
|
|
41
|
+
const product = await cimplify.catalogue.getProductBySlug("my-product");
|
|
42
42
|
|
|
43
43
|
// Variants
|
|
44
|
-
const variants = await cimplify.catalogue.getVariants(
|
|
45
|
-
const variant = await cimplify.catalogue.getVariantByAxisSelections(
|
|
46
|
-
Size:
|
|
47
|
-
Color:
|
|
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
48
|
});
|
|
49
49
|
|
|
50
50
|
// Categories & Collections
|
|
@@ -56,7 +56,7 @@ const bundles = await cimplify.catalogue.getBundles();
|
|
|
56
56
|
const composites = await cimplify.catalogue.getComposites();
|
|
57
57
|
|
|
58
58
|
// Search
|
|
59
|
-
const results = await cimplify.catalogue.search(
|
|
59
|
+
const results = await cimplify.catalogue.search("coffee");
|
|
60
60
|
```
|
|
61
61
|
|
|
62
62
|
### Cart
|
|
@@ -66,19 +66,19 @@ const cart = await cimplify.cart.get();
|
|
|
66
66
|
const count = await cimplify.cart.getCount();
|
|
67
67
|
|
|
68
68
|
await cimplify.cart.addItem({
|
|
69
|
-
item_id:
|
|
69
|
+
item_id: "product-id",
|
|
70
70
|
quantity: 2,
|
|
71
71
|
configuration: {
|
|
72
|
-
variant: { variant_id:
|
|
73
|
-
add_ons: [{ add_on_id:
|
|
72
|
+
variant: { variant_id: "variant-id" },
|
|
73
|
+
add_ons: [{ add_on_id: "addon-id", quantity: 1 }],
|
|
74
74
|
},
|
|
75
75
|
});
|
|
76
76
|
|
|
77
|
-
await cimplify.cart.updateQuantity(
|
|
78
|
-
await cimplify.cart.removeItem(
|
|
77
|
+
await cimplify.cart.updateQuantity("cart-item-id", 3);
|
|
78
|
+
await cimplify.cart.removeItem("cart-item-id");
|
|
79
79
|
await cimplify.cart.clear();
|
|
80
80
|
|
|
81
|
-
await cimplify.cart.applyCoupon(
|
|
81
|
+
await cimplify.cart.applyCoupon("SUMMER20");
|
|
82
82
|
await cimplify.cart.removeCoupon();
|
|
83
83
|
```
|
|
84
84
|
|
|
@@ -86,7 +86,7 @@ await cimplify.cart.removeCoupon();
|
|
|
86
86
|
|
|
87
87
|
```typescript
|
|
88
88
|
const orders = await cimplify.orders.getOrders();
|
|
89
|
-
const order = await cimplify.orders.getOrder(
|
|
89
|
+
const order = await cimplify.orders.getOrder("order-id");
|
|
90
90
|
```
|
|
91
91
|
|
|
92
92
|
### Authentication
|
|
@@ -95,8 +95,8 @@ const order = await cimplify.orders.getOrder('order-id');
|
|
|
95
95
|
const status = await cimplify.auth.getStatus();
|
|
96
96
|
const user = await cimplify.auth.getCurrentUser();
|
|
97
97
|
|
|
98
|
-
await cimplify.auth.requestOtp(
|
|
99
|
-
const result = await cimplify.auth.verifyOtp(
|
|
98
|
+
await cimplify.auth.requestOtp("+1234567890", "phone");
|
|
99
|
+
const result = await cimplify.auth.verifyOtp("123456", "+1234567890");
|
|
100
100
|
await cimplify.auth.logout();
|
|
101
101
|
```
|
|
102
102
|
|
|
@@ -111,26 +111,26 @@ const locations = await cimplify.business.getLocations();
|
|
|
111
111
|
|
|
112
112
|
```typescript
|
|
113
113
|
const slots = await cimplify.scheduling.getAvailableSlots({
|
|
114
|
-
location_id:
|
|
115
|
-
date:
|
|
116
|
-
service_type:
|
|
114
|
+
location_id: "location-id",
|
|
115
|
+
date: "2025-01-15",
|
|
116
|
+
service_type: "delivery",
|
|
117
117
|
});
|
|
118
118
|
```
|
|
119
119
|
|
|
120
120
|
### Inventory
|
|
121
121
|
|
|
122
122
|
```typescript
|
|
123
|
-
const stock = await cimplify.inventory.checkStock(
|
|
123
|
+
const stock = await cimplify.inventory.checkStock("product-id", "location-id");
|
|
124
124
|
```
|
|
125
125
|
|
|
126
126
|
## Price Utilities
|
|
127
127
|
|
|
128
128
|
```typescript
|
|
129
|
-
import { formatPrice, formatPriceCompact, isOnSale, getDiscountPercentage } from
|
|
129
|
+
import { formatPrice, formatPriceCompact, isOnSale, getDiscountPercentage } from "@cimplify/sdk";
|
|
130
130
|
|
|
131
|
-
formatPrice(29.99,
|
|
132
|
-
formatPrice(29.99,
|
|
133
|
-
formatPriceCompact(2500000,
|
|
131
|
+
formatPrice(29.99, "USD"); // "$29.99"
|
|
132
|
+
formatPrice(29.99, "GHS"); // "GH₵29.99"
|
|
133
|
+
formatPriceCompact(2500000, "USD"); // "$2.5M"
|
|
134
134
|
|
|
135
135
|
if (isOnSale(product)) {
|
|
136
136
|
console.log(`${getDiscountPercentage(product)}% off!`);
|
|
@@ -140,13 +140,13 @@ if (isOnSale(product)) {
|
|
|
140
140
|
## Error Handling
|
|
141
141
|
|
|
142
142
|
```typescript
|
|
143
|
-
import { CimplifyError } from
|
|
143
|
+
import { CimplifyError } from "@cimplify/sdk";
|
|
144
144
|
|
|
145
145
|
try {
|
|
146
|
-
await cimplify.cart.addItem({ item_id:
|
|
146
|
+
await cimplify.cart.addItem({ item_id: "invalid", quantity: 1 });
|
|
147
147
|
} catch (error) {
|
|
148
148
|
if (error instanceof CimplifyError) {
|
|
149
|
-
console.log(error.code);
|
|
149
|
+
console.log(error.code); // "PRODUCT_NOT_FOUND"
|
|
150
150
|
console.log(error.message); // "Product not found"
|
|
151
151
|
}
|
|
152
152
|
}
|
|
@@ -167,7 +167,7 @@ import type {
|
|
|
167
167
|
CartItem,
|
|
168
168
|
Order,
|
|
169
169
|
Customer,
|
|
170
|
-
} from
|
|
170
|
+
} from "@cimplify/sdk";
|
|
171
171
|
```
|
|
172
172
|
|
|
173
173
|
## License
|
package/dist/index.d.mts
CHANGED
|
@@ -1699,6 +1699,9 @@ interface CheckoutResult {
|
|
|
1699
1699
|
authorization_url?: string;
|
|
1700
1700
|
display_text?: string;
|
|
1701
1701
|
provider?: string;
|
|
1702
|
+
access_code?: string;
|
|
1703
|
+
public_key?: string;
|
|
1704
|
+
client_secret?: string;
|
|
1702
1705
|
}
|
|
1703
1706
|
|
|
1704
1707
|
declare class CheckoutService {
|
package/dist/index.d.ts
CHANGED
|
@@ -1699,6 +1699,9 @@ interface CheckoutResult {
|
|
|
1699
1699
|
authorization_url?: string;
|
|
1700
1700
|
display_text?: string;
|
|
1701
1701
|
provider?: string;
|
|
1702
|
+
access_code?: string;
|
|
1703
|
+
public_key?: string;
|
|
1704
|
+
client_secret?: string;
|
|
1702
1705
|
}
|
|
1703
1706
|
|
|
1704
1707
|
declare class CheckoutService {
|
package/dist/index.js
CHANGED
|
@@ -79,18 +79,15 @@ var CatalogueQueries = class {
|
|
|
79
79
|
* Returns the matching variant or null if no match found.
|
|
80
80
|
*/
|
|
81
81
|
async getVariantByAxisSelections(productId, selections) {
|
|
82
|
-
return this.client.query(
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
);
|
|
82
|
+
return this.client.query(`products.${productId}.variant`, {
|
|
83
|
+
axis_selections: selections
|
|
84
|
+
});
|
|
86
85
|
}
|
|
87
86
|
/**
|
|
88
87
|
* Get a specific variant by its ID
|
|
89
88
|
*/
|
|
90
89
|
async getVariantById(productId, variantId) {
|
|
91
|
-
return this.client.query(
|
|
92
|
-
`products.${productId}.variant.${variantId}`
|
|
93
|
-
);
|
|
90
|
+
return this.client.query(`products.${productId}.variant.${variantId}`);
|
|
94
91
|
}
|
|
95
92
|
// --------------------------------------------------------------------------
|
|
96
93
|
// ADD-ONS
|
|
@@ -108,18 +105,14 @@ var CatalogueQueries = class {
|
|
|
108
105
|
return this.client.query(`categories.${id}`);
|
|
109
106
|
}
|
|
110
107
|
async getCategoryBySlug(slug) {
|
|
111
|
-
const categories = await this.client.query(
|
|
112
|
-
`categories[?(@.slug=='${slug}')]`
|
|
113
|
-
);
|
|
108
|
+
const categories = await this.client.query(`categories[?(@.slug=='${slug}')]`);
|
|
114
109
|
if (!categories.length) {
|
|
115
110
|
throw new Error(`Category not found: ${slug}`);
|
|
116
111
|
}
|
|
117
112
|
return categories[0];
|
|
118
113
|
}
|
|
119
114
|
async getCategoryProducts(categoryId) {
|
|
120
|
-
return this.client.query(
|
|
121
|
-
`products[?(@.category_id=='${categoryId}')]`
|
|
122
|
-
);
|
|
115
|
+
return this.client.query(`products[?(@.category_id=='${categoryId}')]`);
|
|
123
116
|
}
|
|
124
117
|
// --------------------------------------------------------------------------
|
|
125
118
|
// COLLECTIONS
|
|
@@ -131,9 +124,7 @@ var CatalogueQueries = class {
|
|
|
131
124
|
return this.client.query(`collections.${id}`);
|
|
132
125
|
}
|
|
133
126
|
async getCollectionBySlug(slug) {
|
|
134
|
-
const collections = await this.client.query(
|
|
135
|
-
`collections[?(@.slug=='${slug}')]`
|
|
136
|
-
);
|
|
127
|
+
const collections = await this.client.query(`collections[?(@.slug=='${slug}')]`);
|
|
137
128
|
if (!collections.length) {
|
|
138
129
|
throw new Error(`Collection not found: ${slug}`);
|
|
139
130
|
}
|
|
@@ -157,18 +148,14 @@ var CatalogueQueries = class {
|
|
|
157
148
|
return this.client.query(`bundles.${id}`);
|
|
158
149
|
}
|
|
159
150
|
async getBundleBySlug(slug) {
|
|
160
|
-
const bundles = await this.client.query(
|
|
161
|
-
`bundles[?(@.slug=='${slug}')]`
|
|
162
|
-
);
|
|
151
|
+
const bundles = await this.client.query(`bundles[?(@.slug=='${slug}')]`);
|
|
163
152
|
if (!bundles.length) {
|
|
164
153
|
throw new Error(`Bundle not found: ${slug}`);
|
|
165
154
|
}
|
|
166
155
|
return bundles[0];
|
|
167
156
|
}
|
|
168
157
|
async searchBundles(query2, limit = 20) {
|
|
169
|
-
return this.client.query(
|
|
170
|
-
`bundles[?(@.name contains '${query2}')]#limit(${limit})`
|
|
171
|
-
);
|
|
158
|
+
return this.client.query(`bundles[?(@.name contains '${query2}')]#limit(${limit})`);
|
|
172
159
|
}
|
|
173
160
|
// --------------------------------------------------------------------------
|
|
174
161
|
// COMPOSITES (Build-Your-Own)
|
|
@@ -184,19 +171,14 @@ var CatalogueQueries = class {
|
|
|
184
171
|
return this.client.query(`composites.${id}`);
|
|
185
172
|
}
|
|
186
173
|
async getCompositeByProductId(productId) {
|
|
187
|
-
return this.client.query(
|
|
188
|
-
`composites.by_product.${productId}`
|
|
189
|
-
);
|
|
174
|
+
return this.client.query(`composites.by_product.${productId}`);
|
|
190
175
|
}
|
|
191
176
|
async calculateCompositePrice(compositeId, selections, locationId) {
|
|
192
|
-
return this.client.call(
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
location_id: locationId
|
|
198
|
-
}
|
|
199
|
-
);
|
|
177
|
+
return this.client.call("composite.calculatePrice", {
|
|
178
|
+
composite_id: compositeId,
|
|
179
|
+
selections,
|
|
180
|
+
location_id: locationId
|
|
181
|
+
});
|
|
200
182
|
}
|
|
201
183
|
// --------------------------------------------------------------------------
|
|
202
184
|
// SEARCH
|
|
@@ -454,16 +436,10 @@ var CheckoutService = class {
|
|
|
454
436
|
});
|
|
455
437
|
}
|
|
456
438
|
async submitAuthorization(input) {
|
|
457
|
-
return this.client.call(
|
|
458
|
-
PAYMENT_MUTATION.SUBMIT_AUTHORIZATION,
|
|
459
|
-
input
|
|
460
|
-
);
|
|
439
|
+
return this.client.call(PAYMENT_MUTATION.SUBMIT_AUTHORIZATION, input);
|
|
461
440
|
}
|
|
462
441
|
async pollPaymentStatus(orderId) {
|
|
463
|
-
return this.client.call(
|
|
464
|
-
PAYMENT_MUTATION.CHECK_STATUS,
|
|
465
|
-
orderId
|
|
466
|
-
);
|
|
442
|
+
return this.client.call(PAYMENT_MUTATION.CHECK_STATUS, orderId);
|
|
467
443
|
}
|
|
468
444
|
async updateOrderCustomer(orderId, customer) {
|
|
469
445
|
return this.client.call(ORDER_MUTATION.UPDATE_CUSTOMER, {
|
|
@@ -501,9 +477,7 @@ var OrderQueries = class {
|
|
|
501
477
|
return this.client.query(`orders.${orderId}`);
|
|
502
478
|
}
|
|
503
479
|
async getRecent(limit = 5) {
|
|
504
|
-
return this.client.query(
|
|
505
|
-
`orders#sort(created_at,desc)#limit(${limit})`
|
|
506
|
-
);
|
|
480
|
+
return this.client.query(`orders#sort(created_at,desc)#limit(${limit})`);
|
|
507
481
|
}
|
|
508
482
|
async getByStatus(status) {
|
|
509
483
|
return this.client.query(`orders[?(@.status=='${status}')]`);
|
|
@@ -525,10 +499,7 @@ var LinkService = class {
|
|
|
525
499
|
return this.client.linkPost("/v1/link/auth/request-otp", input);
|
|
526
500
|
}
|
|
527
501
|
async verifyOtp(input) {
|
|
528
|
-
const response = await this.client.linkPost(
|
|
529
|
-
"/v1/link/auth/verify-otp",
|
|
530
|
-
input
|
|
531
|
-
);
|
|
502
|
+
const response = await this.client.linkPost("/v1/link/auth/verify-otp", input);
|
|
532
503
|
if (response.session_token) {
|
|
533
504
|
this.client.setSessionToken(response.session_token);
|
|
534
505
|
}
|
|
@@ -560,37 +531,22 @@ var LinkService = class {
|
|
|
560
531
|
return this.client.call(LINK_MUTATION.ENROLL, data);
|
|
561
532
|
}
|
|
562
533
|
async enrollAndLinkOrder(data) {
|
|
563
|
-
return this.client.call(
|
|
564
|
-
LINK_MUTATION.ENROLL_AND_LINK_ORDER,
|
|
565
|
-
data
|
|
566
|
-
);
|
|
534
|
+
return this.client.call(LINK_MUTATION.ENROLL_AND_LINK_ORDER, data);
|
|
567
535
|
}
|
|
568
536
|
async updatePreferences(preferences) {
|
|
569
|
-
return this.client.call(
|
|
570
|
-
LINK_MUTATION.UPDATE_PREFERENCES,
|
|
571
|
-
preferences
|
|
572
|
-
);
|
|
537
|
+
return this.client.call(LINK_MUTATION.UPDATE_PREFERENCES, preferences);
|
|
573
538
|
}
|
|
574
539
|
async createAddress(input) {
|
|
575
|
-
return this.client.call(
|
|
576
|
-
LINK_MUTATION.CREATE_ADDRESS,
|
|
577
|
-
input
|
|
578
|
-
);
|
|
540
|
+
return this.client.call(LINK_MUTATION.CREATE_ADDRESS, input);
|
|
579
541
|
}
|
|
580
542
|
async updateAddress(input) {
|
|
581
543
|
return this.client.call(LINK_MUTATION.UPDATE_ADDRESS, input);
|
|
582
544
|
}
|
|
583
545
|
async deleteAddress(addressId) {
|
|
584
|
-
return this.client.call(
|
|
585
|
-
LINK_MUTATION.DELETE_ADDRESS,
|
|
586
|
-
addressId
|
|
587
|
-
);
|
|
546
|
+
return this.client.call(LINK_MUTATION.DELETE_ADDRESS, addressId);
|
|
588
547
|
}
|
|
589
548
|
async setDefaultAddress(addressId) {
|
|
590
|
-
return this.client.call(
|
|
591
|
-
LINK_MUTATION.SET_DEFAULT_ADDRESS,
|
|
592
|
-
addressId
|
|
593
|
-
);
|
|
549
|
+
return this.client.call(LINK_MUTATION.SET_DEFAULT_ADDRESS, addressId);
|
|
594
550
|
}
|
|
595
551
|
async trackAddressUsage(addressId) {
|
|
596
552
|
return this.client.call(LINK_MUTATION.TRACK_ADDRESS_USAGE, {
|
|
@@ -598,22 +554,13 @@ var LinkService = class {
|
|
|
598
554
|
});
|
|
599
555
|
}
|
|
600
556
|
async createMobileMoney(input) {
|
|
601
|
-
return this.client.call(
|
|
602
|
-
LINK_MUTATION.CREATE_MOBILE_MONEY,
|
|
603
|
-
input
|
|
604
|
-
);
|
|
557
|
+
return this.client.call(LINK_MUTATION.CREATE_MOBILE_MONEY, input);
|
|
605
558
|
}
|
|
606
559
|
async deleteMobileMoney(mobileMoneyId) {
|
|
607
|
-
return this.client.call(
|
|
608
|
-
LINK_MUTATION.DELETE_MOBILE_MONEY,
|
|
609
|
-
mobileMoneyId
|
|
610
|
-
);
|
|
560
|
+
return this.client.call(LINK_MUTATION.DELETE_MOBILE_MONEY, mobileMoneyId);
|
|
611
561
|
}
|
|
612
562
|
async setDefaultMobileMoney(mobileMoneyId) {
|
|
613
|
-
return this.client.call(
|
|
614
|
-
LINK_MUTATION.SET_DEFAULT_MOBILE_MONEY,
|
|
615
|
-
mobileMoneyId
|
|
616
|
-
);
|
|
563
|
+
return this.client.call(LINK_MUTATION.SET_DEFAULT_MOBILE_MONEY, mobileMoneyId);
|
|
617
564
|
}
|
|
618
565
|
async trackMobileMoneyUsage(mobileMoneyId) {
|
|
619
566
|
return this.client.call(LINK_MUTATION.TRACK_MOBILE_MONEY_USAGE, {
|
|
@@ -621,18 +568,13 @@ var LinkService = class {
|
|
|
621
568
|
});
|
|
622
569
|
}
|
|
623
570
|
async verifyMobileMoney(mobileMoneyId) {
|
|
624
|
-
return this.client.call(
|
|
625
|
-
LINK_MUTATION.VERIFY_MOBILE_MONEY,
|
|
626
|
-
mobileMoneyId
|
|
627
|
-
);
|
|
571
|
+
return this.client.call(LINK_MUTATION.VERIFY_MOBILE_MONEY, mobileMoneyId);
|
|
628
572
|
}
|
|
629
573
|
async getSessions() {
|
|
630
574
|
return this.client.linkGet("/v1/link/sessions");
|
|
631
575
|
}
|
|
632
576
|
async revokeSession(sessionId) {
|
|
633
|
-
return this.client.linkDelete(
|
|
634
|
-
`/v1/link/sessions/${sessionId}`
|
|
635
|
-
);
|
|
577
|
+
return this.client.linkDelete(`/v1/link/sessions/${sessionId}`);
|
|
636
578
|
}
|
|
637
579
|
async revokeAllSessions() {
|
|
638
580
|
return this.client.linkDelete("/v1/link/sessions");
|
|
@@ -647,9 +589,7 @@ var LinkService = class {
|
|
|
647
589
|
return this.client.linkDelete(`/v1/link/addresses/${addressId}`);
|
|
648
590
|
}
|
|
649
591
|
async setDefaultAddressRest(addressId) {
|
|
650
|
-
return this.client.linkPost(
|
|
651
|
-
`/v1/link/addresses/${addressId}/default`
|
|
652
|
-
);
|
|
592
|
+
return this.client.linkPost(`/v1/link/addresses/${addressId}/default`);
|
|
653
593
|
}
|
|
654
594
|
async getMobileMoneyRest() {
|
|
655
595
|
return this.client.linkGet("/v1/link/mobile-money");
|
|
@@ -658,14 +598,10 @@ var LinkService = class {
|
|
|
658
598
|
return this.client.linkPost("/v1/link/mobile-money", input);
|
|
659
599
|
}
|
|
660
600
|
async deleteMobileMoneyRest(mobileMoneyId) {
|
|
661
|
-
return this.client.linkDelete(
|
|
662
|
-
`/v1/link/mobile-money/${mobileMoneyId}`
|
|
663
|
-
);
|
|
601
|
+
return this.client.linkDelete(`/v1/link/mobile-money/${mobileMoneyId}`);
|
|
664
602
|
}
|
|
665
603
|
async setDefaultMobileMoneyRest(mobileMoneyId) {
|
|
666
|
-
return this.client.linkPost(
|
|
667
|
-
`/v1/link/mobile-money/${mobileMoneyId}/default`
|
|
668
|
-
);
|
|
604
|
+
return this.client.linkPost(`/v1/link/mobile-money/${mobileMoneyId}/default`);
|
|
669
605
|
}
|
|
670
606
|
};
|
|
671
607
|
|
|
@@ -762,9 +698,7 @@ var BusinessService = class {
|
|
|
762
698
|
return this.client.query("business.hours");
|
|
763
699
|
}
|
|
764
700
|
async getLocationHours(locationId) {
|
|
765
|
-
return this.client.query(
|
|
766
|
-
`business.locations.${locationId}.hours`
|
|
767
|
-
);
|
|
701
|
+
return this.client.query(`business.locations.${locationId}.hours`);
|
|
768
702
|
}
|
|
769
703
|
// --------------------------------------------------------------------------
|
|
770
704
|
// BOOTSTRAP (for storefront initialization)
|
|
@@ -987,10 +921,9 @@ var LiteService = class {
|
|
|
987
921
|
});
|
|
988
922
|
}
|
|
989
923
|
async requestBill(tableId) {
|
|
990
|
-
return this.client.call(
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
);
|
|
924
|
+
return this.client.call("lite.request_bill", {
|
|
925
|
+
table_id: tableId
|
|
926
|
+
});
|
|
994
927
|
}
|
|
995
928
|
// --------------------------------------------------------------------------
|
|
996
929
|
// MENU (optimized for lite/QR experience)
|
package/dist/index.mjs
CHANGED
|
@@ -77,18 +77,15 @@ var CatalogueQueries = class {
|
|
|
77
77
|
* Returns the matching variant or null if no match found.
|
|
78
78
|
*/
|
|
79
79
|
async getVariantByAxisSelections(productId, selections) {
|
|
80
|
-
return this.client.query(
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
);
|
|
80
|
+
return this.client.query(`products.${productId}.variant`, {
|
|
81
|
+
axis_selections: selections
|
|
82
|
+
});
|
|
84
83
|
}
|
|
85
84
|
/**
|
|
86
85
|
* Get a specific variant by its ID
|
|
87
86
|
*/
|
|
88
87
|
async getVariantById(productId, variantId) {
|
|
89
|
-
return this.client.query(
|
|
90
|
-
`products.${productId}.variant.${variantId}`
|
|
91
|
-
);
|
|
88
|
+
return this.client.query(`products.${productId}.variant.${variantId}`);
|
|
92
89
|
}
|
|
93
90
|
// --------------------------------------------------------------------------
|
|
94
91
|
// ADD-ONS
|
|
@@ -106,18 +103,14 @@ var CatalogueQueries = class {
|
|
|
106
103
|
return this.client.query(`categories.${id}`);
|
|
107
104
|
}
|
|
108
105
|
async getCategoryBySlug(slug) {
|
|
109
|
-
const categories = await this.client.query(
|
|
110
|
-
`categories[?(@.slug=='${slug}')]`
|
|
111
|
-
);
|
|
106
|
+
const categories = await this.client.query(`categories[?(@.slug=='${slug}')]`);
|
|
112
107
|
if (!categories.length) {
|
|
113
108
|
throw new Error(`Category not found: ${slug}`);
|
|
114
109
|
}
|
|
115
110
|
return categories[0];
|
|
116
111
|
}
|
|
117
112
|
async getCategoryProducts(categoryId) {
|
|
118
|
-
return this.client.query(
|
|
119
|
-
`products[?(@.category_id=='${categoryId}')]`
|
|
120
|
-
);
|
|
113
|
+
return this.client.query(`products[?(@.category_id=='${categoryId}')]`);
|
|
121
114
|
}
|
|
122
115
|
// --------------------------------------------------------------------------
|
|
123
116
|
// COLLECTIONS
|
|
@@ -129,9 +122,7 @@ var CatalogueQueries = class {
|
|
|
129
122
|
return this.client.query(`collections.${id}`);
|
|
130
123
|
}
|
|
131
124
|
async getCollectionBySlug(slug) {
|
|
132
|
-
const collections = await this.client.query(
|
|
133
|
-
`collections[?(@.slug=='${slug}')]`
|
|
134
|
-
);
|
|
125
|
+
const collections = await this.client.query(`collections[?(@.slug=='${slug}')]`);
|
|
135
126
|
if (!collections.length) {
|
|
136
127
|
throw new Error(`Collection not found: ${slug}`);
|
|
137
128
|
}
|
|
@@ -155,18 +146,14 @@ var CatalogueQueries = class {
|
|
|
155
146
|
return this.client.query(`bundles.${id}`);
|
|
156
147
|
}
|
|
157
148
|
async getBundleBySlug(slug) {
|
|
158
|
-
const bundles = await this.client.query(
|
|
159
|
-
`bundles[?(@.slug=='${slug}')]`
|
|
160
|
-
);
|
|
149
|
+
const bundles = await this.client.query(`bundles[?(@.slug=='${slug}')]`);
|
|
161
150
|
if (!bundles.length) {
|
|
162
151
|
throw new Error(`Bundle not found: ${slug}`);
|
|
163
152
|
}
|
|
164
153
|
return bundles[0];
|
|
165
154
|
}
|
|
166
155
|
async searchBundles(query2, limit = 20) {
|
|
167
|
-
return this.client.query(
|
|
168
|
-
`bundles[?(@.name contains '${query2}')]#limit(${limit})`
|
|
169
|
-
);
|
|
156
|
+
return this.client.query(`bundles[?(@.name contains '${query2}')]#limit(${limit})`);
|
|
170
157
|
}
|
|
171
158
|
// --------------------------------------------------------------------------
|
|
172
159
|
// COMPOSITES (Build-Your-Own)
|
|
@@ -182,19 +169,14 @@ var CatalogueQueries = class {
|
|
|
182
169
|
return this.client.query(`composites.${id}`);
|
|
183
170
|
}
|
|
184
171
|
async getCompositeByProductId(productId) {
|
|
185
|
-
return this.client.query(
|
|
186
|
-
`composites.by_product.${productId}`
|
|
187
|
-
);
|
|
172
|
+
return this.client.query(`composites.by_product.${productId}`);
|
|
188
173
|
}
|
|
189
174
|
async calculateCompositePrice(compositeId, selections, locationId) {
|
|
190
|
-
return this.client.call(
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
location_id: locationId
|
|
196
|
-
}
|
|
197
|
-
);
|
|
175
|
+
return this.client.call("composite.calculatePrice", {
|
|
176
|
+
composite_id: compositeId,
|
|
177
|
+
selections,
|
|
178
|
+
location_id: locationId
|
|
179
|
+
});
|
|
198
180
|
}
|
|
199
181
|
// --------------------------------------------------------------------------
|
|
200
182
|
// SEARCH
|
|
@@ -452,16 +434,10 @@ var CheckoutService = class {
|
|
|
452
434
|
});
|
|
453
435
|
}
|
|
454
436
|
async submitAuthorization(input) {
|
|
455
|
-
return this.client.call(
|
|
456
|
-
PAYMENT_MUTATION.SUBMIT_AUTHORIZATION,
|
|
457
|
-
input
|
|
458
|
-
);
|
|
437
|
+
return this.client.call(PAYMENT_MUTATION.SUBMIT_AUTHORIZATION, input);
|
|
459
438
|
}
|
|
460
439
|
async pollPaymentStatus(orderId) {
|
|
461
|
-
return this.client.call(
|
|
462
|
-
PAYMENT_MUTATION.CHECK_STATUS,
|
|
463
|
-
orderId
|
|
464
|
-
);
|
|
440
|
+
return this.client.call(PAYMENT_MUTATION.CHECK_STATUS, orderId);
|
|
465
441
|
}
|
|
466
442
|
async updateOrderCustomer(orderId, customer) {
|
|
467
443
|
return this.client.call(ORDER_MUTATION.UPDATE_CUSTOMER, {
|
|
@@ -499,9 +475,7 @@ var OrderQueries = class {
|
|
|
499
475
|
return this.client.query(`orders.${orderId}`);
|
|
500
476
|
}
|
|
501
477
|
async getRecent(limit = 5) {
|
|
502
|
-
return this.client.query(
|
|
503
|
-
`orders#sort(created_at,desc)#limit(${limit})`
|
|
504
|
-
);
|
|
478
|
+
return this.client.query(`orders#sort(created_at,desc)#limit(${limit})`);
|
|
505
479
|
}
|
|
506
480
|
async getByStatus(status) {
|
|
507
481
|
return this.client.query(`orders[?(@.status=='${status}')]`);
|
|
@@ -523,10 +497,7 @@ var LinkService = class {
|
|
|
523
497
|
return this.client.linkPost("/v1/link/auth/request-otp", input);
|
|
524
498
|
}
|
|
525
499
|
async verifyOtp(input) {
|
|
526
|
-
const response = await this.client.linkPost(
|
|
527
|
-
"/v1/link/auth/verify-otp",
|
|
528
|
-
input
|
|
529
|
-
);
|
|
500
|
+
const response = await this.client.linkPost("/v1/link/auth/verify-otp", input);
|
|
530
501
|
if (response.session_token) {
|
|
531
502
|
this.client.setSessionToken(response.session_token);
|
|
532
503
|
}
|
|
@@ -558,37 +529,22 @@ var LinkService = class {
|
|
|
558
529
|
return this.client.call(LINK_MUTATION.ENROLL, data);
|
|
559
530
|
}
|
|
560
531
|
async enrollAndLinkOrder(data) {
|
|
561
|
-
return this.client.call(
|
|
562
|
-
LINK_MUTATION.ENROLL_AND_LINK_ORDER,
|
|
563
|
-
data
|
|
564
|
-
);
|
|
532
|
+
return this.client.call(LINK_MUTATION.ENROLL_AND_LINK_ORDER, data);
|
|
565
533
|
}
|
|
566
534
|
async updatePreferences(preferences) {
|
|
567
|
-
return this.client.call(
|
|
568
|
-
LINK_MUTATION.UPDATE_PREFERENCES,
|
|
569
|
-
preferences
|
|
570
|
-
);
|
|
535
|
+
return this.client.call(LINK_MUTATION.UPDATE_PREFERENCES, preferences);
|
|
571
536
|
}
|
|
572
537
|
async createAddress(input) {
|
|
573
|
-
return this.client.call(
|
|
574
|
-
LINK_MUTATION.CREATE_ADDRESS,
|
|
575
|
-
input
|
|
576
|
-
);
|
|
538
|
+
return this.client.call(LINK_MUTATION.CREATE_ADDRESS, input);
|
|
577
539
|
}
|
|
578
540
|
async updateAddress(input) {
|
|
579
541
|
return this.client.call(LINK_MUTATION.UPDATE_ADDRESS, input);
|
|
580
542
|
}
|
|
581
543
|
async deleteAddress(addressId) {
|
|
582
|
-
return this.client.call(
|
|
583
|
-
LINK_MUTATION.DELETE_ADDRESS,
|
|
584
|
-
addressId
|
|
585
|
-
);
|
|
544
|
+
return this.client.call(LINK_MUTATION.DELETE_ADDRESS, addressId);
|
|
586
545
|
}
|
|
587
546
|
async setDefaultAddress(addressId) {
|
|
588
|
-
return this.client.call(
|
|
589
|
-
LINK_MUTATION.SET_DEFAULT_ADDRESS,
|
|
590
|
-
addressId
|
|
591
|
-
);
|
|
547
|
+
return this.client.call(LINK_MUTATION.SET_DEFAULT_ADDRESS, addressId);
|
|
592
548
|
}
|
|
593
549
|
async trackAddressUsage(addressId) {
|
|
594
550
|
return this.client.call(LINK_MUTATION.TRACK_ADDRESS_USAGE, {
|
|
@@ -596,22 +552,13 @@ var LinkService = class {
|
|
|
596
552
|
});
|
|
597
553
|
}
|
|
598
554
|
async createMobileMoney(input) {
|
|
599
|
-
return this.client.call(
|
|
600
|
-
LINK_MUTATION.CREATE_MOBILE_MONEY,
|
|
601
|
-
input
|
|
602
|
-
);
|
|
555
|
+
return this.client.call(LINK_MUTATION.CREATE_MOBILE_MONEY, input);
|
|
603
556
|
}
|
|
604
557
|
async deleteMobileMoney(mobileMoneyId) {
|
|
605
|
-
return this.client.call(
|
|
606
|
-
LINK_MUTATION.DELETE_MOBILE_MONEY,
|
|
607
|
-
mobileMoneyId
|
|
608
|
-
);
|
|
558
|
+
return this.client.call(LINK_MUTATION.DELETE_MOBILE_MONEY, mobileMoneyId);
|
|
609
559
|
}
|
|
610
560
|
async setDefaultMobileMoney(mobileMoneyId) {
|
|
611
|
-
return this.client.call(
|
|
612
|
-
LINK_MUTATION.SET_DEFAULT_MOBILE_MONEY,
|
|
613
|
-
mobileMoneyId
|
|
614
|
-
);
|
|
561
|
+
return this.client.call(LINK_MUTATION.SET_DEFAULT_MOBILE_MONEY, mobileMoneyId);
|
|
615
562
|
}
|
|
616
563
|
async trackMobileMoneyUsage(mobileMoneyId) {
|
|
617
564
|
return this.client.call(LINK_MUTATION.TRACK_MOBILE_MONEY_USAGE, {
|
|
@@ -619,18 +566,13 @@ var LinkService = class {
|
|
|
619
566
|
});
|
|
620
567
|
}
|
|
621
568
|
async verifyMobileMoney(mobileMoneyId) {
|
|
622
|
-
return this.client.call(
|
|
623
|
-
LINK_MUTATION.VERIFY_MOBILE_MONEY,
|
|
624
|
-
mobileMoneyId
|
|
625
|
-
);
|
|
569
|
+
return this.client.call(LINK_MUTATION.VERIFY_MOBILE_MONEY, mobileMoneyId);
|
|
626
570
|
}
|
|
627
571
|
async getSessions() {
|
|
628
572
|
return this.client.linkGet("/v1/link/sessions");
|
|
629
573
|
}
|
|
630
574
|
async revokeSession(sessionId) {
|
|
631
|
-
return this.client.linkDelete(
|
|
632
|
-
`/v1/link/sessions/${sessionId}`
|
|
633
|
-
);
|
|
575
|
+
return this.client.linkDelete(`/v1/link/sessions/${sessionId}`);
|
|
634
576
|
}
|
|
635
577
|
async revokeAllSessions() {
|
|
636
578
|
return this.client.linkDelete("/v1/link/sessions");
|
|
@@ -645,9 +587,7 @@ var LinkService = class {
|
|
|
645
587
|
return this.client.linkDelete(`/v1/link/addresses/${addressId}`);
|
|
646
588
|
}
|
|
647
589
|
async setDefaultAddressRest(addressId) {
|
|
648
|
-
return this.client.linkPost(
|
|
649
|
-
`/v1/link/addresses/${addressId}/default`
|
|
650
|
-
);
|
|
590
|
+
return this.client.linkPost(`/v1/link/addresses/${addressId}/default`);
|
|
651
591
|
}
|
|
652
592
|
async getMobileMoneyRest() {
|
|
653
593
|
return this.client.linkGet("/v1/link/mobile-money");
|
|
@@ -656,14 +596,10 @@ var LinkService = class {
|
|
|
656
596
|
return this.client.linkPost("/v1/link/mobile-money", input);
|
|
657
597
|
}
|
|
658
598
|
async deleteMobileMoneyRest(mobileMoneyId) {
|
|
659
|
-
return this.client.linkDelete(
|
|
660
|
-
`/v1/link/mobile-money/${mobileMoneyId}`
|
|
661
|
-
);
|
|
599
|
+
return this.client.linkDelete(`/v1/link/mobile-money/${mobileMoneyId}`);
|
|
662
600
|
}
|
|
663
601
|
async setDefaultMobileMoneyRest(mobileMoneyId) {
|
|
664
|
-
return this.client.linkPost(
|
|
665
|
-
`/v1/link/mobile-money/${mobileMoneyId}/default`
|
|
666
|
-
);
|
|
602
|
+
return this.client.linkPost(`/v1/link/mobile-money/${mobileMoneyId}/default`);
|
|
667
603
|
}
|
|
668
604
|
};
|
|
669
605
|
|
|
@@ -760,9 +696,7 @@ var BusinessService = class {
|
|
|
760
696
|
return this.client.query("business.hours");
|
|
761
697
|
}
|
|
762
698
|
async getLocationHours(locationId) {
|
|
763
|
-
return this.client.query(
|
|
764
|
-
`business.locations.${locationId}.hours`
|
|
765
|
-
);
|
|
699
|
+
return this.client.query(`business.locations.${locationId}.hours`);
|
|
766
700
|
}
|
|
767
701
|
// --------------------------------------------------------------------------
|
|
768
702
|
// BOOTSTRAP (for storefront initialization)
|
|
@@ -985,10 +919,9 @@ var LiteService = class {
|
|
|
985
919
|
});
|
|
986
920
|
}
|
|
987
921
|
async requestBill(tableId) {
|
|
988
|
-
return this.client.call(
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
);
|
|
922
|
+
return this.client.call("lite.request_bill", {
|
|
923
|
+
table_id: tableId
|
|
924
|
+
});
|
|
992
925
|
}
|
|
993
926
|
// --------------------------------------------------------------------------
|
|
994
927
|
// MENU (optimized for lite/QR experience)
|
package/package.json
CHANGED
|
@@ -1,7 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cimplify/sdk",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.3",
|
|
4
4
|
"description": "Cimplify Commerce SDK for storefronts",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"cimplify",
|
|
7
|
+
"commerce",
|
|
8
|
+
"sdk",
|
|
9
|
+
"storefront"
|
|
10
|
+
],
|
|
11
|
+
"license": "MIT",
|
|
12
|
+
"files": [
|
|
13
|
+
"dist"
|
|
14
|
+
],
|
|
5
15
|
"main": "./dist/index.js",
|
|
6
16
|
"module": "./dist/index.mjs",
|
|
7
17
|
"types": "./dist/index.d.ts",
|
|
@@ -12,25 +22,18 @@
|
|
|
12
22
|
"require": "./dist/index.js"
|
|
13
23
|
}
|
|
14
24
|
},
|
|
15
|
-
"files": [
|
|
16
|
-
"dist"
|
|
17
|
-
],
|
|
18
25
|
"scripts": {
|
|
19
26
|
"build": "tsup",
|
|
20
27
|
"dev": "tsup --watch",
|
|
21
28
|
"typecheck": "tsgo --noEmit",
|
|
22
|
-
"clean": "rm -rf dist"
|
|
29
|
+
"clean": "rm -rf dist",
|
|
30
|
+
"lint:ox": "oxlint --fix .",
|
|
31
|
+
"format": "oxfmt . --write",
|
|
32
|
+
"format:check": "oxfmt . --check"
|
|
23
33
|
},
|
|
24
34
|
"devDependencies": {
|
|
25
|
-
"@typescript/native-preview": "^7.0.0-dev.
|
|
26
|
-
"tsup": "^8.
|
|
27
|
-
"typescript": "5.9.
|
|
28
|
-
}
|
|
29
|
-
"keywords": [
|
|
30
|
-
"cimplify",
|
|
31
|
-
"commerce",
|
|
32
|
-
"sdk",
|
|
33
|
-
"storefront"
|
|
34
|
-
],
|
|
35
|
-
"license": "MIT"
|
|
35
|
+
"@typescript/native-preview": "^7.0.0-dev.20260109.1",
|
|
36
|
+
"tsup": "^8.5.1",
|
|
37
|
+
"typescript": "5.9.3"
|
|
38
|
+
}
|
|
36
39
|
}
|