@cimplify/sdk 0.9.10 → 0.10.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/dist/{ads-MkGm5l1T.d.mts → ads-BxbWrwqp.d.mts} +0 -8
- package/dist/{ads-MkGm5l1T.d.ts → ads-BxbWrwqp.d.ts} +0 -8
- package/dist/advanced.d.mts +2 -2
- package/dist/advanced.d.ts +2 -2
- package/dist/advanced.js +93 -80
- package/dist/advanced.mjs +93 -80
- package/dist/cli.js +184 -0
- package/dist/{client-BQ1gIg8t.d.mts → client-BSrq89H1.d.mts} +42 -374
- package/dist/{client-C3TQtGuy.d.ts → client-xBhdHLq4.d.ts} +42 -374
- package/dist/index.d.mts +6 -10
- package/dist/index.d.ts +6 -10
- package/dist/index.js +98 -126
- package/dist/index.mjs +98 -126
- package/dist/{payment-CTalZM5l.d.mts → payment-CrNyrc-D.d.mts} +145 -95
- package/dist/{payment-CTalZM5l.d.ts → payment-CrNyrc-D.d.ts} +145 -95
- package/dist/price-C9Z-hr49.d.mts +21 -0
- package/dist/price-RKKoTz-9.d.ts +21 -0
- package/dist/react.d.mts +1285 -35
- package/dist/react.d.ts +1285 -35
- package/dist/react.js +6596 -2598
- package/dist/react.mjs +6550 -2600
- package/dist/utils.d.mts +55 -2
- package/dist/utils.d.ts +55 -2
- package/dist/utils.js +23 -20
- package/dist/utils.mjs +23 -20
- package/package.json +13 -3
- package/registry/add-on-selector.json +15 -0
- package/registry/availability-badge.json +15 -0
- package/registry/booking-card.json +16 -0
- package/registry/booking-list.json +16 -0
- package/registry/booking-page.json +18 -0
- package/registry/bookings-page.json +17 -0
- package/registry/bundle-selector.json +15 -0
- package/registry/cart-page.json +17 -0
- package/registry/cart-summary.json +16 -0
- package/registry/catalogue-page.json +18 -0
- package/registry/category-filter.json +15 -0
- package/registry/category-grid.json +15 -0
- package/registry/checkout-page.json +15 -0
- package/registry/cn.json +13 -0
- package/registry/collection-page.json +16 -0
- package/registry/composite-selector.json +15 -0
- package/registry/date-slot-picker.json +16 -0
- package/registry/deal-banner.json +16 -0
- package/registry/deals-page.json +19 -0
- package/registry/discount-input.json +16 -0
- package/registry/index.json +411 -0
- package/registry/order-detail-page.json +16 -0
- package/registry/order-history-page.json +17 -0
- package/registry/order-history.json +16 -0
- package/registry/order-summary.json +16 -0
- package/registry/price.json +13 -0
- package/registry/product-card.json +17 -0
- package/registry/product-customizer.json +20 -0
- package/registry/product-grid.json +16 -0
- package/registry/product-image-gallery.json +13 -0
- package/registry/product-page.json +19 -0
- package/registry/product-sheet.json +18 -0
- package/registry/quantity-selector.json +13 -0
- package/registry/sale-badge.json +16 -0
- package/registry/search-input.json +15 -0
- package/registry/search-page.json +16 -0
- package/registry/service-card.json +16 -0
- package/registry/service-grid.json +16 -0
- package/registry/slot-picker.json +16 -0
- package/registry/staff-picker.json +15 -0
- package/registry/store-nav.json +15 -0
- package/registry/variant-selector.json +15 -0
- package/dist/index-B_25cFc1.d.ts +0 -320
- package/dist/index-Cd0shhZU.d.mts +0 -320
package/dist/index.mjs
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
// src/types/common.ts
|
|
2
2
|
function money(value) {
|
|
3
|
-
return value;
|
|
3
|
+
return typeof value === "string" ? parseFloat(value) || 0 : value;
|
|
4
4
|
}
|
|
5
5
|
function moneyFromNumber(value) {
|
|
6
|
-
return value
|
|
6
|
+
return value;
|
|
7
7
|
}
|
|
8
|
-
var ZERO =
|
|
8
|
+
var ZERO = 0;
|
|
9
9
|
var SUPPORTED_CURRENCY_CODES = /* @__PURE__ */ new Set([
|
|
10
10
|
"USD",
|
|
11
11
|
"EUR",
|
|
@@ -63,7 +63,6 @@ function currencyCode(value) {
|
|
|
63
63
|
return value;
|
|
64
64
|
}
|
|
65
65
|
var ErrorCode = {
|
|
66
|
-
// General
|
|
67
66
|
UNKNOWN_ERROR: "UNKNOWN_ERROR",
|
|
68
67
|
NETWORK_ERROR: "NETWORK_ERROR",
|
|
69
68
|
TIMEOUT: "TIMEOUT",
|
|
@@ -71,7 +70,6 @@ var ErrorCode = {
|
|
|
71
70
|
FORBIDDEN: "FORBIDDEN",
|
|
72
71
|
NOT_FOUND: "NOT_FOUND",
|
|
73
72
|
VALIDATION_ERROR: "VALIDATION_ERROR",
|
|
74
|
-
// Cart
|
|
75
73
|
CART_EMPTY: "CART_EMPTY",
|
|
76
74
|
CART_EXPIRED: "CART_EXPIRED",
|
|
77
75
|
CART_NOT_FOUND: "CART_NOT_FOUND",
|
|
@@ -80,16 +78,13 @@ var ErrorCode = {
|
|
|
80
78
|
VARIANT_OUT_OF_STOCK: "VARIANT_OUT_OF_STOCK",
|
|
81
79
|
ADDON_REQUIRED: "ADDON_REQUIRED",
|
|
82
80
|
ADDON_MAX_EXCEEDED: "ADDON_MAX_EXCEEDED",
|
|
83
|
-
// Checkout
|
|
84
81
|
CHECKOUT_VALIDATION_FAILED: "CHECKOUT_VALIDATION_FAILED",
|
|
85
82
|
DELIVERY_ADDRESS_REQUIRED: "DELIVERY_ADDRESS_REQUIRED",
|
|
86
83
|
CUSTOMER_INFO_REQUIRED: "CUSTOMER_INFO_REQUIRED",
|
|
87
|
-
// Quote
|
|
88
84
|
QUOTE_NOT_FOUND: "QUOTE_NOT_FOUND",
|
|
89
85
|
QUOTE_EXPIRED: "QUOTE_EXPIRED",
|
|
90
86
|
QUOTE_CONSUMED: "QUOTE_CONSUMED",
|
|
91
87
|
QUOTE_STORAGE_UNAVAILABLE: "QUOTE_STORAGE_UNAVAILABLE",
|
|
92
|
-
// Payment
|
|
93
88
|
PAYMENT_FAILED: "PAYMENT_FAILED",
|
|
94
89
|
PAYMENT_CANCELLED: "PAYMENT_CANCELLED",
|
|
95
90
|
INSUFFICIENT_FUNDS: "INSUFFICIENT_FUNDS",
|
|
@@ -98,11 +93,9 @@ var ErrorCode = {
|
|
|
98
93
|
OTP_EXPIRED: "OTP_EXPIRED",
|
|
99
94
|
AUTHORIZATION_FAILED: "AUTHORIZATION_FAILED",
|
|
100
95
|
PAYMENT_ACTION_NOT_COMPLETED: "PAYMENT_ACTION_NOT_COMPLETED",
|
|
101
|
-
// Scheduling
|
|
102
96
|
SLOT_UNAVAILABLE: "SLOT_UNAVAILABLE",
|
|
103
97
|
BOOKING_CONFLICT: "BOOKING_CONFLICT",
|
|
104
98
|
SERVICE_NOT_FOUND: "SERVICE_NOT_FOUND",
|
|
105
|
-
// Inventory
|
|
106
99
|
OUT_OF_STOCK: "OUT_OF_STOCK",
|
|
107
100
|
INSUFFICIENT_QUANTITY: "INSUFFICIENT_QUANTITY"
|
|
108
101
|
};
|
|
@@ -178,7 +171,6 @@ var CimplifyError = class extends Error {
|
|
|
178
171
|
this.suggestion = suggestion;
|
|
179
172
|
this.name = "CimplifyError";
|
|
180
173
|
}
|
|
181
|
-
/** User-friendly message safe to display */
|
|
182
174
|
get userMessage() {
|
|
183
175
|
return this.message;
|
|
184
176
|
}
|
|
@@ -447,6 +439,7 @@ var CatalogueQueries = class {
|
|
|
447
439
|
async getProducts(options) {
|
|
448
440
|
const path = withQuery("/api/v1/catalogue/products", {
|
|
449
441
|
category_id: options?.category,
|
|
442
|
+
taxonomy_id: options?.taxonomy,
|
|
450
443
|
search: options?.search,
|
|
451
444
|
page: options?.page,
|
|
452
445
|
tags: options?.tags?.join(","),
|
|
@@ -579,6 +572,59 @@ var CatalogueQueries = class {
|
|
|
579
572
|
)
|
|
580
573
|
);
|
|
581
574
|
}
|
|
575
|
+
async getTaxonomies(parentId) {
|
|
576
|
+
const path = withQuery("/api/v1/catalogue/taxonomies", { parent_id: parentId });
|
|
577
|
+
return safe(this.client.get(path));
|
|
578
|
+
}
|
|
579
|
+
async getTaxonomy(id) {
|
|
580
|
+
const encodedId = encodeURIComponent(id);
|
|
581
|
+
return safe(this.client.get(`/api/v1/catalogue/taxonomies/${encodedId}`));
|
|
582
|
+
}
|
|
583
|
+
async getTaxonomyPath(id) {
|
|
584
|
+
const encodedId = encodeURIComponent(id);
|
|
585
|
+
return safe(this.client.get(`/api/v1/catalogue/taxonomies/${encodedId}/path`));
|
|
586
|
+
}
|
|
587
|
+
async searchTaxonomies(query2, limit) {
|
|
588
|
+
const path = withQuery("/api/v1/catalogue/taxonomies/search", { q: query2, limit });
|
|
589
|
+
return safe(this.client.get(path));
|
|
590
|
+
}
|
|
591
|
+
async getProductSchedules(productId) {
|
|
592
|
+
const encodedId = encodeURIComponent(productId);
|
|
593
|
+
return safe(this.client.get(`/api/v1/catalogue/products/${encodedId}/schedules`));
|
|
594
|
+
}
|
|
595
|
+
async checkProductAvailableNow(productId, locationId) {
|
|
596
|
+
const encodedId = encodeURIComponent(productId);
|
|
597
|
+
const path = withQuery(`/api/v1/catalogue/products/${encodedId}/available-now`, { location_id: locationId });
|
|
598
|
+
return safe(this.client.get(path));
|
|
599
|
+
}
|
|
600
|
+
async getDeals(locationId) {
|
|
601
|
+
const path = withQuery("/api/v1/catalogue/deals", { location_id: locationId });
|
|
602
|
+
return safe(this.client.get(path));
|
|
603
|
+
}
|
|
604
|
+
async getProductsOnSale() {
|
|
605
|
+
return safe(this.client.get("/api/v1/catalogue/deals/on-sale"));
|
|
606
|
+
}
|
|
607
|
+
async getProductDeals(productId) {
|
|
608
|
+
const encodedId = encodeURIComponent(productId);
|
|
609
|
+
return safe(this.client.get(`/api/v1/catalogue/products/${encodedId}/deals`));
|
|
610
|
+
}
|
|
611
|
+
async getCategoryDeals(categoryId) {
|
|
612
|
+
const encodedId = encodeURIComponent(categoryId);
|
|
613
|
+
return safe(this.client.get(`/api/v1/catalogue/categories/${encodedId}/deals`));
|
|
614
|
+
}
|
|
615
|
+
async getCollectionDeals(collectionId) {
|
|
616
|
+
const encodedId = encodeURIComponent(collectionId);
|
|
617
|
+
return safe(this.client.get(`/api/v1/catalogue/collections/${encodedId}/deals`));
|
|
618
|
+
}
|
|
619
|
+
async validateDiscountCode(code, orderSubtotal, locationId) {
|
|
620
|
+
return safe(
|
|
621
|
+
this.client.post("/api/v1/catalogue/deals/validate", {
|
|
622
|
+
discount_code: code,
|
|
623
|
+
order_subtotal: orderSubtotal,
|
|
624
|
+
location_id: locationId
|
|
625
|
+
})
|
|
626
|
+
);
|
|
627
|
+
}
|
|
582
628
|
async search(query2, options) {
|
|
583
629
|
const result = await this.getProducts({
|
|
584
630
|
search: query2,
|
|
@@ -606,6 +652,16 @@ var CatalogueQueries = class {
|
|
|
606
652
|
const encodedId = encodeURIComponent(itemId);
|
|
607
653
|
return safe(this.client.get(`/api/v1/catalogue/menu/items/${encodedId}`));
|
|
608
654
|
}
|
|
655
|
+
async getTags(options) {
|
|
656
|
+
const path = withQuery("/api/v1/catalogue/tags", {
|
|
657
|
+
tag_group: options?.tag_group,
|
|
658
|
+
search: options?.search,
|
|
659
|
+
min_usage: options?.min_usage,
|
|
660
|
+
limit: options?.limit,
|
|
661
|
+
offset: options?.offset
|
|
662
|
+
});
|
|
663
|
+
return safe(this.client.get(path));
|
|
664
|
+
}
|
|
609
665
|
};
|
|
610
666
|
|
|
611
667
|
// src/cart.ts
|
|
@@ -835,7 +891,6 @@ var DEFAULT_COUNTRY = "GHA";
|
|
|
835
891
|
|
|
836
892
|
// src/utils/price.ts
|
|
837
893
|
var CURRENCY_SYMBOLS = {
|
|
838
|
-
// Major world currencies
|
|
839
894
|
USD: "$",
|
|
840
895
|
EUR: "\u20AC",
|
|
841
896
|
GBP: "\xA3",
|
|
@@ -868,7 +923,6 @@ var CURRENCY_SYMBOLS = {
|
|
|
868
923
|
IDR: "Rp",
|
|
869
924
|
VND: "\u20AB",
|
|
870
925
|
TWD: "NT$",
|
|
871
|
-
// African currencies
|
|
872
926
|
GHS: "GH\u20B5",
|
|
873
927
|
NGN: "\u20A6",
|
|
874
928
|
KES: "KSh",
|
|
@@ -906,8 +960,8 @@ var CURRENCY_SYMBOLS = {
|
|
|
906
960
|
KMF: "CF",
|
|
907
961
|
BIF: "FBu"
|
|
908
962
|
};
|
|
909
|
-
function getCurrencySymbol(
|
|
910
|
-
return CURRENCY_SYMBOLS[
|
|
963
|
+
function getCurrencySymbol(currencyCode3) {
|
|
964
|
+
return CURRENCY_SYMBOLS[currencyCode3.toUpperCase()] || currencyCode3;
|
|
911
965
|
}
|
|
912
966
|
function formatNumberCompact(value, decimals = 1) {
|
|
913
967
|
const absValue = Math.abs(value);
|
|
@@ -1124,8 +1178,8 @@ function normalizePaymentResponse(response) {
|
|
|
1124
1178
|
}
|
|
1125
1179
|
if (isWebPaymentResponse(response)) {
|
|
1126
1180
|
const authType = response.authorization_type?.toLowerCase();
|
|
1127
|
-
const
|
|
1128
|
-
const safeAuthType = authType &&
|
|
1181
|
+
const validStringAuthTypes = ["otp", "pin", "phone", "birthday"];
|
|
1182
|
+
const safeAuthType = authType && validStringAuthTypes.includes(authType) ? authType : void 0;
|
|
1129
1183
|
return {
|
|
1130
1184
|
provider: response.transaction.provider_type?.toLowerCase() || "unknown",
|
|
1131
1185
|
requires_action: response.requires_action || false,
|
|
@@ -1164,7 +1218,8 @@ var PAYMENT_FAILURE_STATUSES = /* @__PURE__ */ new Set([
|
|
|
1164
1218
|
"declined",
|
|
1165
1219
|
"cancelled",
|
|
1166
1220
|
"voided",
|
|
1167
|
-
"error"
|
|
1221
|
+
"error",
|
|
1222
|
+
"abandoned"
|
|
1168
1223
|
]);
|
|
1169
1224
|
var PAYMENT_REQUIRES_ACTION_STATUSES = /* @__PURE__ */ new Set([
|
|
1170
1225
|
"requires_action",
|
|
@@ -1194,29 +1249,34 @@ var PAYMENT_STATUS_ALIAS_MAP = {
|
|
|
1194
1249
|
unresolved: "pending"
|
|
1195
1250
|
};
|
|
1196
1251
|
var KNOWN_PAYMENT_STATUSES = /* @__PURE__ */ new Set([
|
|
1252
|
+
"initialized",
|
|
1197
1253
|
"pending",
|
|
1198
1254
|
"processing",
|
|
1255
|
+
"authorized",
|
|
1256
|
+
"captured",
|
|
1257
|
+
"failed",
|
|
1258
|
+
"cancelled",
|
|
1259
|
+
"refunded",
|
|
1260
|
+
"unknown",
|
|
1261
|
+
"voided",
|
|
1262
|
+
"requires_action",
|
|
1263
|
+
"abandoned",
|
|
1264
|
+
"reversed",
|
|
1265
|
+
"disputed",
|
|
1266
|
+
"refund_pending",
|
|
1199
1267
|
"created",
|
|
1200
1268
|
"pending_confirmation",
|
|
1201
1269
|
"success",
|
|
1202
1270
|
"succeeded",
|
|
1203
|
-
"failed",
|
|
1204
1271
|
"declined",
|
|
1205
|
-
"authorized",
|
|
1206
|
-
"refunded",
|
|
1207
1272
|
"partially_refunded",
|
|
1208
1273
|
"partially_paid",
|
|
1209
1274
|
"paid",
|
|
1210
1275
|
"unpaid",
|
|
1211
|
-
"requires_action",
|
|
1212
1276
|
"requires_payment_method",
|
|
1213
1277
|
"requires_capture",
|
|
1214
|
-
"captured",
|
|
1215
|
-
"cancelled",
|
|
1216
1278
|
"completed",
|
|
1217
|
-
"
|
|
1218
|
-
"error",
|
|
1219
|
-
"unknown"
|
|
1279
|
+
"error"
|
|
1220
1280
|
]);
|
|
1221
1281
|
function normalizeStatusToken(status) {
|
|
1222
1282
|
return status?.trim().toLowerCase().replace(/[\s-]+/g, "_") ?? "";
|
|
@@ -1245,13 +1305,15 @@ function normalizeStatusResponse(response) {
|
|
|
1245
1305
|
return {
|
|
1246
1306
|
status: "pending",
|
|
1247
1307
|
paid: false,
|
|
1308
|
+
amount: moneyFromNumber(0),
|
|
1309
|
+
currency: "",
|
|
1248
1310
|
message: "No status available"
|
|
1249
1311
|
};
|
|
1250
1312
|
}
|
|
1251
1313
|
const res = response;
|
|
1252
1314
|
const normalizedStatus = normalizePaymentStatusValue(res.status ?? void 0);
|
|
1253
|
-
const normalizedAmount = typeof res.amount === "string" ? money(res.amount) : typeof res.amount === "number" && Number.isFinite(res.amount) ? moneyFromNumber(res.amount) :
|
|
1254
|
-
const normalizedCurrency = typeof res.currency === "string" && res.currency.trim().length > 0 ?
|
|
1315
|
+
const normalizedAmount = typeof res.amount === "string" ? money(res.amount) : typeof res.amount === "number" && Number.isFinite(res.amount) ? moneyFromNumber(res.amount) : moneyFromNumber(0);
|
|
1316
|
+
const normalizedCurrency = typeof res.currency === "string" && res.currency.trim().length > 0 ? res.currency : "";
|
|
1255
1317
|
const paidValue = res.paid === true;
|
|
1256
1318
|
const derivedPaid = paidValue || [
|
|
1257
1319
|
"success",
|
|
@@ -1399,7 +1461,8 @@ function isValidMobileMoneyProvider(value) {
|
|
|
1399
1461
|
return VALID_MOBILE_MONEY_PROVIDERS.has(value);
|
|
1400
1462
|
}
|
|
1401
1463
|
function normalizeAuthorizationType(value) {
|
|
1402
|
-
|
|
1464
|
+
if (typeof value !== "string") return void 0;
|
|
1465
|
+
const lower = value.toLowerCase();
|
|
1403
1466
|
return lower === "otp" || lower === "pin" ? lower : void 0;
|
|
1404
1467
|
}
|
|
1405
1468
|
function formatMoney2(value) {
|
|
@@ -2105,7 +2168,7 @@ var CheckoutService = class {
|
|
|
2105
2168
|
);
|
|
2106
2169
|
const payCurrency = data.pay_currency?.trim().toUpperCase();
|
|
2107
2170
|
const payCurrencyCode = payCurrency ? currencyCode(payCurrency) : void 0;
|
|
2108
|
-
const cartTotalAmount = Number.parseFloat(cart.pricing.total_price || "0");
|
|
2171
|
+
const cartTotalAmount = typeof cart.pricing.total_price === "number" ? cart.pricing.total_price : Number.parseFloat(cart.pricing.total_price || "0");
|
|
2109
2172
|
if (payCurrencyCode && payCurrencyCode !== baseCurrency && !checkoutData.fx_quote_id && Number.isFinite(cartTotalAmount) && cartTotalAmount > 0) {
|
|
2110
2173
|
const fxQuoteResult = await this.client.fx.lockQuote({
|
|
2111
2174
|
from: baseCurrency,
|
|
@@ -2270,7 +2333,7 @@ var LinkService = class {
|
|
|
2270
2333
|
this.client.linkPost("/v1/link/auth/verify-otp", input)
|
|
2271
2334
|
);
|
|
2272
2335
|
if (result.ok && result.value.session_token) {
|
|
2273
|
-
this.client.
|
|
2336
|
+
this.client.setAccessToken(result.value.session_token);
|
|
2274
2337
|
}
|
|
2275
2338
|
return result;
|
|
2276
2339
|
}
|
|
@@ -2384,30 +2447,6 @@ var LinkService = class {
|
|
|
2384
2447
|
async revokeAllSessions() {
|
|
2385
2448
|
return safe5(this.client.linkDelete("/v1/link/sessions"));
|
|
2386
2449
|
}
|
|
2387
|
-
async getAddressesRest() {
|
|
2388
|
-
return this.getAddresses();
|
|
2389
|
-
}
|
|
2390
|
-
async createAddressRest(input) {
|
|
2391
|
-
return this.createAddress(input);
|
|
2392
|
-
}
|
|
2393
|
-
async deleteAddressRest(addressId) {
|
|
2394
|
-
return this.deleteAddress(addressId);
|
|
2395
|
-
}
|
|
2396
|
-
async setDefaultAddressRest(addressId) {
|
|
2397
|
-
return this.setDefaultAddress(addressId);
|
|
2398
|
-
}
|
|
2399
|
-
async getMobileMoneyRest() {
|
|
2400
|
-
return this.getMobileMoney();
|
|
2401
|
-
}
|
|
2402
|
-
async createMobileMoneyRest(input) {
|
|
2403
|
-
return this.createMobileMoney(input);
|
|
2404
|
-
}
|
|
2405
|
-
async deleteMobileMoneyRest(mobileMoneyId) {
|
|
2406
|
-
return this.deleteMobileMoney(mobileMoneyId);
|
|
2407
|
-
}
|
|
2408
|
-
async setDefaultMobileMoneyRest(mobileMoneyId) {
|
|
2409
|
-
return this.setDefaultMobileMoney(mobileMoneyId);
|
|
2410
|
-
}
|
|
2411
2450
|
};
|
|
2412
2451
|
|
|
2413
2452
|
// src/auth.ts
|
|
@@ -2499,9 +2538,6 @@ var BusinessService = class {
|
|
|
2499
2538
|
async getSettings() {
|
|
2500
2539
|
return safe7(this.client.get("/api/v1/business/settings"));
|
|
2501
2540
|
}
|
|
2502
|
-
async getTheme() {
|
|
2503
|
-
return safe7(this.client.get("/api/v1/business/theme"));
|
|
2504
|
-
}
|
|
2505
2541
|
async getLocations() {
|
|
2506
2542
|
return safe7(this.client.get("/api/v1/business/locations"));
|
|
2507
2543
|
}
|
|
@@ -2555,9 +2591,6 @@ var InventoryService = class {
|
|
|
2555
2591
|
const query2 = searchParams.toString();
|
|
2556
2592
|
return query2 ? `${path}?${query2}` : path;
|
|
2557
2593
|
}
|
|
2558
|
-
async getStockLevels() {
|
|
2559
|
-
return safe8(this.client.get("/api/v1/inventory/stock-levels"));
|
|
2560
|
-
}
|
|
2561
2594
|
async getProductStock(productId, locationId) {
|
|
2562
2595
|
const encodedId = encodeURIComponent(productId);
|
|
2563
2596
|
const path = this.withQuery(`/api/v1/inventory/products/${encodedId}/stock`, {
|
|
@@ -2599,9 +2632,6 @@ var InventoryService = class {
|
|
|
2599
2632
|
}
|
|
2600
2633
|
return ok(results.map((r) => r.value));
|
|
2601
2634
|
}
|
|
2602
|
-
async getSummary() {
|
|
2603
|
-
return safe8(this.client.get("/api/v1/inventory/summary"));
|
|
2604
|
-
}
|
|
2605
2635
|
async isInStock(productId, locationId) {
|
|
2606
2636
|
const result = await this.checkProductAvailability(productId, 1, locationId);
|
|
2607
2637
|
if (!result.ok) return result;
|
|
@@ -2638,16 +2668,6 @@ function withQuery2(path, params) {
|
|
|
2638
2668
|
const query2 = searchParams.toString();
|
|
2639
2669
|
return query2 ? `${path}?${query2}` : path;
|
|
2640
2670
|
}
|
|
2641
|
-
function normalizeServiceAvailability(result) {
|
|
2642
|
-
if (Array.isArray(result.days) && result.days.length > 0) {
|
|
2643
|
-
return result;
|
|
2644
|
-
}
|
|
2645
|
-
const days = Array.isArray(result.availability) ? result.availability.map((day) => ({
|
|
2646
|
-
...day,
|
|
2647
|
-
is_fully_booked: day.is_fully_booked ?? (typeof day.has_availability === "boolean" ? !day.has_availability : void 0)
|
|
2648
|
-
})) : [];
|
|
2649
|
-
return { ...result, days };
|
|
2650
|
-
}
|
|
2651
2671
|
function firstScheduledTime(booking) {
|
|
2652
2672
|
return booking.service_items.find((item) => typeof item.scheduled_start === "string")?.scheduled_start || booking.created_at;
|
|
2653
2673
|
}
|
|
@@ -2658,13 +2678,9 @@ var SchedulingService = class {
|
|
|
2658
2678
|
async getServices() {
|
|
2659
2679
|
return safe9(this.client.get("/api/v1/scheduling/services"));
|
|
2660
2680
|
}
|
|
2661
|
-
/**
|
|
2662
|
-
* Get a specific service by ID.
|
|
2663
|
-
*/
|
|
2664
2681
|
async getService(serviceId) {
|
|
2665
|
-
const
|
|
2666
|
-
|
|
2667
|
-
return ok(result.value.find((service) => service.id === serviceId) || null);
|
|
2682
|
+
const encodedId = encodeURIComponent(serviceId);
|
|
2683
|
+
return safe9(this.client.get(`/api/v1/scheduling/services/${encodedId}`));
|
|
2668
2684
|
}
|
|
2669
2685
|
async getAvailableSlots(input) {
|
|
2670
2686
|
const path = withQuery2("/api/v1/scheduling/slots", {
|
|
@@ -2692,9 +2708,7 @@ var SchedulingService = class {
|
|
|
2692
2708
|
location_id: params.location_id,
|
|
2693
2709
|
participant_count: params.participant_count
|
|
2694
2710
|
});
|
|
2695
|
-
return safe9(
|
|
2696
|
-
this.client.get(path).then((result) => normalizeServiceAvailability(result))
|
|
2697
|
-
);
|
|
2711
|
+
return safe9(this.client.get(path));
|
|
2698
2712
|
}
|
|
2699
2713
|
async getBooking(bookingId) {
|
|
2700
2714
|
const encodedId = encodeURIComponent(bookingId);
|
|
@@ -2751,12 +2765,6 @@ var SchedulingService = class {
|
|
|
2751
2765
|
if (!result.ok) return result;
|
|
2752
2766
|
return ok(result.value.some((slot) => slot.is_available));
|
|
2753
2767
|
}
|
|
2754
|
-
// Compatibility alias for callers typed against the older Booking shape.
|
|
2755
|
-
async getBookingLegacy(bookingId) {
|
|
2756
|
-
const result = await this.getBooking(bookingId);
|
|
2757
|
-
if (!result.ok) return result;
|
|
2758
|
-
return ok(result.value);
|
|
2759
|
-
}
|
|
2760
2768
|
};
|
|
2761
2769
|
|
|
2762
2770
|
// src/lite.ts
|
|
@@ -2830,7 +2838,6 @@ var ELEMENT_TYPES = {
|
|
|
2830
2838
|
CHECKOUT: "checkout"
|
|
2831
2839
|
};
|
|
2832
2840
|
var MESSAGE_TYPES = {
|
|
2833
|
-
// Parent → Iframe
|
|
2834
2841
|
INIT: "init",
|
|
2835
2842
|
SET_TOKEN: "set_token",
|
|
2836
2843
|
SET_CART: "set_cart",
|
|
@@ -2839,7 +2846,6 @@ var MESSAGE_TYPES = {
|
|
|
2839
2846
|
LOGOUT: "logout",
|
|
2840
2847
|
PROCESS_CHECKOUT: "process_checkout",
|
|
2841
2848
|
ABORT_CHECKOUT: "abort_checkout",
|
|
2842
|
-
// Iframe → Parent
|
|
2843
2849
|
READY: "ready",
|
|
2844
2850
|
HEIGHT_CHANGE: "height_change",
|
|
2845
2851
|
AUTHENTICATED: "authenticated",
|
|
@@ -3067,7 +3073,6 @@ var CimplifyElements = class {
|
|
|
3067
3073
|
tip_amount: options.tip_amount,
|
|
3068
3074
|
pay_currency: options.pay_currency,
|
|
3069
3075
|
enroll_in_link: options.enroll_in_link ?? true,
|
|
3070
|
-
// Unified checkout has its own address/customer state; only pass if available externally
|
|
3071
3076
|
address: isUnifiedCheckout ? void 0 : this.addressData ?? void 0,
|
|
3072
3077
|
customer: isUnifiedCheckout ? void 0 : this.customerData ? {
|
|
3073
3078
|
name: this.customerData.name,
|
|
@@ -3550,9 +3555,6 @@ function isRetryable(error) {
|
|
|
3550
3555
|
if (error instanceof CimplifyError) {
|
|
3551
3556
|
return error.retryable;
|
|
3552
3557
|
}
|
|
3553
|
-
if (error instanceof CimplifyError && error.code === "SERVER_ERROR") {
|
|
3554
|
-
return true;
|
|
3555
|
-
}
|
|
3556
3558
|
return false;
|
|
3557
3559
|
}
|
|
3558
3560
|
function toNetworkError(error, isTestMode) {
|
|
@@ -3640,7 +3642,6 @@ var CimplifyClient = class {
|
|
|
3640
3642
|
);
|
|
3641
3643
|
}
|
|
3642
3644
|
}
|
|
3643
|
-
/** Build a full URL, appending context params (e.g. location_id) as query parameters. */
|
|
3644
3645
|
buildUrl(base, path) {
|
|
3645
3646
|
const url = `${base}${path}`;
|
|
3646
3647
|
const locationId = this.context.location_id;
|
|
@@ -3648,14 +3649,6 @@ var CimplifyClient = class {
|
|
|
3648
3649
|
const separator = url.includes("?") ? "&" : "?";
|
|
3649
3650
|
return `${url}${separator}location_id=${encodeURIComponent(locationId)}`;
|
|
3650
3651
|
}
|
|
3651
|
-
/** @deprecated Use getAccessToken() instead */
|
|
3652
|
-
getSessionToken() {
|
|
3653
|
-
return this.accessToken;
|
|
3654
|
-
}
|
|
3655
|
-
/** @deprecated Use setAccessToken() instead */
|
|
3656
|
-
setSessionToken(token) {
|
|
3657
|
-
this.setAccessToken(token);
|
|
3658
|
-
}
|
|
3659
3652
|
getAccessToken() {
|
|
3660
3653
|
return this.accessToken;
|
|
3661
3654
|
}
|
|
@@ -3734,11 +3727,9 @@ var CimplifyClient = class {
|
|
|
3734
3727
|
delete this.context.location_id;
|
|
3735
3728
|
}
|
|
3736
3729
|
}
|
|
3737
|
-
/** Get the currently active location ID */
|
|
3738
3730
|
getLocationId() {
|
|
3739
3731
|
return this.context.location_id ?? null;
|
|
3740
3732
|
}
|
|
3741
|
-
/** Cache a resolved business ID for future element/checkouts initialization. */
|
|
3742
3733
|
setBusinessId(businessId) {
|
|
3743
3734
|
const normalized = businessId.trim();
|
|
3744
3735
|
if (!normalized) {
|
|
@@ -3746,14 +3737,9 @@ var CimplifyClient = class {
|
|
|
3746
3737
|
}
|
|
3747
3738
|
this.businessId = normalized;
|
|
3748
3739
|
}
|
|
3749
|
-
/** Get cached business ID if available. */
|
|
3750
3740
|
getBusinessId() {
|
|
3751
3741
|
return this.businessId;
|
|
3752
3742
|
}
|
|
3753
|
-
/**
|
|
3754
|
-
* Resolve business ID from public key once and cache it.
|
|
3755
|
-
* Subsequent calls return the cached value (or shared in-flight promise).
|
|
3756
|
-
*/
|
|
3757
3743
|
async resolveBusinessId() {
|
|
3758
3744
|
if (this.businessId) {
|
|
3759
3745
|
return this.businessId;
|
|
@@ -4136,20 +4122,6 @@ var CimplifyClient = class {
|
|
|
4136
4122
|
}
|
|
4137
4123
|
return this._fx;
|
|
4138
4124
|
}
|
|
4139
|
-
/**
|
|
4140
|
-
* Create a CimplifyElements instance for embedding checkout components.
|
|
4141
|
-
* Like Stripe's stripe.elements().
|
|
4142
|
-
*
|
|
4143
|
-
* @param businessId - The business ID for checkout context
|
|
4144
|
-
* @param options - Optional configuration for elements
|
|
4145
|
-
*
|
|
4146
|
-
* @example
|
|
4147
|
-
* ```ts
|
|
4148
|
-
* const elements = client.elements('bus_xxx');
|
|
4149
|
-
* const authElement = elements.create('auth');
|
|
4150
|
-
* authElement.mount('#auth-container');
|
|
4151
|
-
* ```
|
|
4152
|
-
*/
|
|
4153
4125
|
elements(businessId, options) {
|
|
4154
4126
|
if (businessId) {
|
|
4155
4127
|
this.setBusinessId(businessId);
|