@cimplify/sdk 0.9.10 → 0.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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.js
CHANGED
|
@@ -2,12 +2,12 @@
|
|
|
2
2
|
|
|
3
3
|
// src/types/common.ts
|
|
4
4
|
function money(value) {
|
|
5
|
-
return value;
|
|
5
|
+
return typeof value === "string" ? parseFloat(value) || 0 : value;
|
|
6
6
|
}
|
|
7
7
|
function moneyFromNumber(value) {
|
|
8
|
-
return value
|
|
8
|
+
return value;
|
|
9
9
|
}
|
|
10
|
-
var ZERO =
|
|
10
|
+
var ZERO = 0;
|
|
11
11
|
var SUPPORTED_CURRENCY_CODES = /* @__PURE__ */ new Set([
|
|
12
12
|
"USD",
|
|
13
13
|
"EUR",
|
|
@@ -65,7 +65,6 @@ function currencyCode(value) {
|
|
|
65
65
|
return value;
|
|
66
66
|
}
|
|
67
67
|
var ErrorCode = {
|
|
68
|
-
// General
|
|
69
68
|
UNKNOWN_ERROR: "UNKNOWN_ERROR",
|
|
70
69
|
NETWORK_ERROR: "NETWORK_ERROR",
|
|
71
70
|
TIMEOUT: "TIMEOUT",
|
|
@@ -73,7 +72,6 @@ var ErrorCode = {
|
|
|
73
72
|
FORBIDDEN: "FORBIDDEN",
|
|
74
73
|
NOT_FOUND: "NOT_FOUND",
|
|
75
74
|
VALIDATION_ERROR: "VALIDATION_ERROR",
|
|
76
|
-
// Cart
|
|
77
75
|
CART_EMPTY: "CART_EMPTY",
|
|
78
76
|
CART_EXPIRED: "CART_EXPIRED",
|
|
79
77
|
CART_NOT_FOUND: "CART_NOT_FOUND",
|
|
@@ -82,16 +80,13 @@ var ErrorCode = {
|
|
|
82
80
|
VARIANT_OUT_OF_STOCK: "VARIANT_OUT_OF_STOCK",
|
|
83
81
|
ADDON_REQUIRED: "ADDON_REQUIRED",
|
|
84
82
|
ADDON_MAX_EXCEEDED: "ADDON_MAX_EXCEEDED",
|
|
85
|
-
// Checkout
|
|
86
83
|
CHECKOUT_VALIDATION_FAILED: "CHECKOUT_VALIDATION_FAILED",
|
|
87
84
|
DELIVERY_ADDRESS_REQUIRED: "DELIVERY_ADDRESS_REQUIRED",
|
|
88
85
|
CUSTOMER_INFO_REQUIRED: "CUSTOMER_INFO_REQUIRED",
|
|
89
|
-
// Quote
|
|
90
86
|
QUOTE_NOT_FOUND: "QUOTE_NOT_FOUND",
|
|
91
87
|
QUOTE_EXPIRED: "QUOTE_EXPIRED",
|
|
92
88
|
QUOTE_CONSUMED: "QUOTE_CONSUMED",
|
|
93
89
|
QUOTE_STORAGE_UNAVAILABLE: "QUOTE_STORAGE_UNAVAILABLE",
|
|
94
|
-
// Payment
|
|
95
90
|
PAYMENT_FAILED: "PAYMENT_FAILED",
|
|
96
91
|
PAYMENT_CANCELLED: "PAYMENT_CANCELLED",
|
|
97
92
|
INSUFFICIENT_FUNDS: "INSUFFICIENT_FUNDS",
|
|
@@ -100,11 +95,9 @@ var ErrorCode = {
|
|
|
100
95
|
OTP_EXPIRED: "OTP_EXPIRED",
|
|
101
96
|
AUTHORIZATION_FAILED: "AUTHORIZATION_FAILED",
|
|
102
97
|
PAYMENT_ACTION_NOT_COMPLETED: "PAYMENT_ACTION_NOT_COMPLETED",
|
|
103
|
-
// Scheduling
|
|
104
98
|
SLOT_UNAVAILABLE: "SLOT_UNAVAILABLE",
|
|
105
99
|
BOOKING_CONFLICT: "BOOKING_CONFLICT",
|
|
106
100
|
SERVICE_NOT_FOUND: "SERVICE_NOT_FOUND",
|
|
107
|
-
// Inventory
|
|
108
101
|
OUT_OF_STOCK: "OUT_OF_STOCK",
|
|
109
102
|
INSUFFICIENT_QUANTITY: "INSUFFICIENT_QUANTITY"
|
|
110
103
|
};
|
|
@@ -180,7 +173,6 @@ var CimplifyError = class extends Error {
|
|
|
180
173
|
this.suggestion = suggestion;
|
|
181
174
|
this.name = "CimplifyError";
|
|
182
175
|
}
|
|
183
|
-
/** User-friendly message safe to display */
|
|
184
176
|
get userMessage() {
|
|
185
177
|
return this.message;
|
|
186
178
|
}
|
|
@@ -449,6 +441,7 @@ var CatalogueQueries = class {
|
|
|
449
441
|
async getProducts(options) {
|
|
450
442
|
const path = withQuery("/api/v1/catalogue/products", {
|
|
451
443
|
category_id: options?.category,
|
|
444
|
+
taxonomy_id: options?.taxonomy,
|
|
452
445
|
search: options?.search,
|
|
453
446
|
page: options?.page,
|
|
454
447
|
tags: options?.tags?.join(","),
|
|
@@ -581,6 +574,59 @@ var CatalogueQueries = class {
|
|
|
581
574
|
)
|
|
582
575
|
);
|
|
583
576
|
}
|
|
577
|
+
async getTaxonomies(parentId) {
|
|
578
|
+
const path = withQuery("/api/v1/catalogue/taxonomies", { parent_id: parentId });
|
|
579
|
+
return safe(this.client.get(path));
|
|
580
|
+
}
|
|
581
|
+
async getTaxonomy(id) {
|
|
582
|
+
const encodedId = encodeURIComponent(id);
|
|
583
|
+
return safe(this.client.get(`/api/v1/catalogue/taxonomies/${encodedId}`));
|
|
584
|
+
}
|
|
585
|
+
async getTaxonomyPath(id) {
|
|
586
|
+
const encodedId = encodeURIComponent(id);
|
|
587
|
+
return safe(this.client.get(`/api/v1/catalogue/taxonomies/${encodedId}/path`));
|
|
588
|
+
}
|
|
589
|
+
async searchTaxonomies(query2, limit) {
|
|
590
|
+
const path = withQuery("/api/v1/catalogue/taxonomies/search", { q: query2, limit });
|
|
591
|
+
return safe(this.client.get(path));
|
|
592
|
+
}
|
|
593
|
+
async getProductSchedules(productId) {
|
|
594
|
+
const encodedId = encodeURIComponent(productId);
|
|
595
|
+
return safe(this.client.get(`/api/v1/catalogue/products/${encodedId}/schedules`));
|
|
596
|
+
}
|
|
597
|
+
async checkProductAvailableNow(productId, locationId) {
|
|
598
|
+
const encodedId = encodeURIComponent(productId);
|
|
599
|
+
const path = withQuery(`/api/v1/catalogue/products/${encodedId}/available-now`, { location_id: locationId });
|
|
600
|
+
return safe(this.client.get(path));
|
|
601
|
+
}
|
|
602
|
+
async getDeals(locationId) {
|
|
603
|
+
const path = withQuery("/api/v1/catalogue/deals", { location_id: locationId });
|
|
604
|
+
return safe(this.client.get(path));
|
|
605
|
+
}
|
|
606
|
+
async getProductsOnSale() {
|
|
607
|
+
return safe(this.client.get("/api/v1/catalogue/deals/on-sale"));
|
|
608
|
+
}
|
|
609
|
+
async getProductDeals(productId) {
|
|
610
|
+
const encodedId = encodeURIComponent(productId);
|
|
611
|
+
return safe(this.client.get(`/api/v1/catalogue/products/${encodedId}/deals`));
|
|
612
|
+
}
|
|
613
|
+
async getCategoryDeals(categoryId) {
|
|
614
|
+
const encodedId = encodeURIComponent(categoryId);
|
|
615
|
+
return safe(this.client.get(`/api/v1/catalogue/categories/${encodedId}/deals`));
|
|
616
|
+
}
|
|
617
|
+
async getCollectionDeals(collectionId) {
|
|
618
|
+
const encodedId = encodeURIComponent(collectionId);
|
|
619
|
+
return safe(this.client.get(`/api/v1/catalogue/collections/${encodedId}/deals`));
|
|
620
|
+
}
|
|
621
|
+
async validateDiscountCode(code, orderSubtotal, locationId) {
|
|
622
|
+
return safe(
|
|
623
|
+
this.client.post("/api/v1/catalogue/deals/validate", {
|
|
624
|
+
discount_code: code,
|
|
625
|
+
order_subtotal: orderSubtotal,
|
|
626
|
+
location_id: locationId
|
|
627
|
+
})
|
|
628
|
+
);
|
|
629
|
+
}
|
|
584
630
|
async search(query2, options) {
|
|
585
631
|
const result = await this.getProducts({
|
|
586
632
|
search: query2,
|
|
@@ -608,6 +654,16 @@ var CatalogueQueries = class {
|
|
|
608
654
|
const encodedId = encodeURIComponent(itemId);
|
|
609
655
|
return safe(this.client.get(`/api/v1/catalogue/menu/items/${encodedId}`));
|
|
610
656
|
}
|
|
657
|
+
async getTags(options) {
|
|
658
|
+
const path = withQuery("/api/v1/catalogue/tags", {
|
|
659
|
+
tag_group: options?.tag_group,
|
|
660
|
+
search: options?.search,
|
|
661
|
+
min_usage: options?.min_usage,
|
|
662
|
+
limit: options?.limit,
|
|
663
|
+
offset: options?.offset
|
|
664
|
+
});
|
|
665
|
+
return safe(this.client.get(path));
|
|
666
|
+
}
|
|
611
667
|
};
|
|
612
668
|
|
|
613
669
|
// src/cart.ts
|
|
@@ -837,7 +893,6 @@ var DEFAULT_COUNTRY = "GHA";
|
|
|
837
893
|
|
|
838
894
|
// src/utils/price.ts
|
|
839
895
|
var CURRENCY_SYMBOLS = {
|
|
840
|
-
// Major world currencies
|
|
841
896
|
USD: "$",
|
|
842
897
|
EUR: "\u20AC",
|
|
843
898
|
GBP: "\xA3",
|
|
@@ -870,7 +925,6 @@ var CURRENCY_SYMBOLS = {
|
|
|
870
925
|
IDR: "Rp",
|
|
871
926
|
VND: "\u20AB",
|
|
872
927
|
TWD: "NT$",
|
|
873
|
-
// African currencies
|
|
874
928
|
GHS: "GH\u20B5",
|
|
875
929
|
NGN: "\u20A6",
|
|
876
930
|
KES: "KSh",
|
|
@@ -908,8 +962,8 @@ var CURRENCY_SYMBOLS = {
|
|
|
908
962
|
KMF: "CF",
|
|
909
963
|
BIF: "FBu"
|
|
910
964
|
};
|
|
911
|
-
function getCurrencySymbol(
|
|
912
|
-
return CURRENCY_SYMBOLS[
|
|
965
|
+
function getCurrencySymbol(currencyCode3) {
|
|
966
|
+
return CURRENCY_SYMBOLS[currencyCode3.toUpperCase()] || currencyCode3;
|
|
913
967
|
}
|
|
914
968
|
function formatNumberCompact(value, decimals = 1) {
|
|
915
969
|
const absValue = Math.abs(value);
|
|
@@ -1126,8 +1180,8 @@ function normalizePaymentResponse(response) {
|
|
|
1126
1180
|
}
|
|
1127
1181
|
if (isWebPaymentResponse(response)) {
|
|
1128
1182
|
const authType = response.authorization_type?.toLowerCase();
|
|
1129
|
-
const
|
|
1130
|
-
const safeAuthType = authType &&
|
|
1183
|
+
const validStringAuthTypes = ["otp", "pin", "phone", "birthday"];
|
|
1184
|
+
const safeAuthType = authType && validStringAuthTypes.includes(authType) ? authType : void 0;
|
|
1131
1185
|
return {
|
|
1132
1186
|
provider: response.transaction.provider_type?.toLowerCase() || "unknown",
|
|
1133
1187
|
requires_action: response.requires_action || false,
|
|
@@ -1166,7 +1220,8 @@ var PAYMENT_FAILURE_STATUSES = /* @__PURE__ */ new Set([
|
|
|
1166
1220
|
"declined",
|
|
1167
1221
|
"cancelled",
|
|
1168
1222
|
"voided",
|
|
1169
|
-
"error"
|
|
1223
|
+
"error",
|
|
1224
|
+
"abandoned"
|
|
1170
1225
|
]);
|
|
1171
1226
|
var PAYMENT_REQUIRES_ACTION_STATUSES = /* @__PURE__ */ new Set([
|
|
1172
1227
|
"requires_action",
|
|
@@ -1196,29 +1251,34 @@ var PAYMENT_STATUS_ALIAS_MAP = {
|
|
|
1196
1251
|
unresolved: "pending"
|
|
1197
1252
|
};
|
|
1198
1253
|
var KNOWN_PAYMENT_STATUSES = /* @__PURE__ */ new Set([
|
|
1254
|
+
"initialized",
|
|
1199
1255
|
"pending",
|
|
1200
1256
|
"processing",
|
|
1257
|
+
"authorized",
|
|
1258
|
+
"captured",
|
|
1259
|
+
"failed",
|
|
1260
|
+
"cancelled",
|
|
1261
|
+
"refunded",
|
|
1262
|
+
"unknown",
|
|
1263
|
+
"voided",
|
|
1264
|
+
"requires_action",
|
|
1265
|
+
"abandoned",
|
|
1266
|
+
"reversed",
|
|
1267
|
+
"disputed",
|
|
1268
|
+
"refund_pending",
|
|
1201
1269
|
"created",
|
|
1202
1270
|
"pending_confirmation",
|
|
1203
1271
|
"success",
|
|
1204
1272
|
"succeeded",
|
|
1205
|
-
"failed",
|
|
1206
1273
|
"declined",
|
|
1207
|
-
"authorized",
|
|
1208
|
-
"refunded",
|
|
1209
1274
|
"partially_refunded",
|
|
1210
1275
|
"partially_paid",
|
|
1211
1276
|
"paid",
|
|
1212
1277
|
"unpaid",
|
|
1213
|
-
"requires_action",
|
|
1214
1278
|
"requires_payment_method",
|
|
1215
1279
|
"requires_capture",
|
|
1216
|
-
"captured",
|
|
1217
|
-
"cancelled",
|
|
1218
1280
|
"completed",
|
|
1219
|
-
"
|
|
1220
|
-
"error",
|
|
1221
|
-
"unknown"
|
|
1281
|
+
"error"
|
|
1222
1282
|
]);
|
|
1223
1283
|
function normalizeStatusToken(status) {
|
|
1224
1284
|
return status?.trim().toLowerCase().replace(/[\s-]+/g, "_") ?? "";
|
|
@@ -1247,13 +1307,15 @@ function normalizeStatusResponse(response) {
|
|
|
1247
1307
|
return {
|
|
1248
1308
|
status: "pending",
|
|
1249
1309
|
paid: false,
|
|
1310
|
+
amount: moneyFromNumber(0),
|
|
1311
|
+
currency: "",
|
|
1250
1312
|
message: "No status available"
|
|
1251
1313
|
};
|
|
1252
1314
|
}
|
|
1253
1315
|
const res = response;
|
|
1254
1316
|
const normalizedStatus = normalizePaymentStatusValue(res.status ?? void 0);
|
|
1255
|
-
const normalizedAmount = typeof res.amount === "string" ? money(res.amount) : typeof res.amount === "number" && Number.isFinite(res.amount) ? moneyFromNumber(res.amount) :
|
|
1256
|
-
const normalizedCurrency = typeof res.currency === "string" && res.currency.trim().length > 0 ?
|
|
1317
|
+
const normalizedAmount = typeof res.amount === "string" ? money(res.amount) : typeof res.amount === "number" && Number.isFinite(res.amount) ? moneyFromNumber(res.amount) : moneyFromNumber(0);
|
|
1318
|
+
const normalizedCurrency = typeof res.currency === "string" && res.currency.trim().length > 0 ? res.currency : "";
|
|
1257
1319
|
const paidValue = res.paid === true;
|
|
1258
1320
|
const derivedPaid = paidValue || [
|
|
1259
1321
|
"success",
|
|
@@ -1401,7 +1463,8 @@ function isValidMobileMoneyProvider(value) {
|
|
|
1401
1463
|
return VALID_MOBILE_MONEY_PROVIDERS.has(value);
|
|
1402
1464
|
}
|
|
1403
1465
|
function normalizeAuthorizationType(value) {
|
|
1404
|
-
|
|
1466
|
+
if (typeof value !== "string") return void 0;
|
|
1467
|
+
const lower = value.toLowerCase();
|
|
1405
1468
|
return lower === "otp" || lower === "pin" ? lower : void 0;
|
|
1406
1469
|
}
|
|
1407
1470
|
function formatMoney2(value) {
|
|
@@ -2107,7 +2170,7 @@ var CheckoutService = class {
|
|
|
2107
2170
|
);
|
|
2108
2171
|
const payCurrency = data.pay_currency?.trim().toUpperCase();
|
|
2109
2172
|
const payCurrencyCode = payCurrency ? currencyCode(payCurrency) : void 0;
|
|
2110
|
-
const cartTotalAmount = Number.parseFloat(cart.pricing.total_price || "0");
|
|
2173
|
+
const cartTotalAmount = typeof cart.pricing.total_price === "number" ? cart.pricing.total_price : Number.parseFloat(cart.pricing.total_price || "0");
|
|
2111
2174
|
if (payCurrencyCode && payCurrencyCode !== baseCurrency && !checkoutData.fx_quote_id && Number.isFinite(cartTotalAmount) && cartTotalAmount > 0) {
|
|
2112
2175
|
const fxQuoteResult = await this.client.fx.lockQuote({
|
|
2113
2176
|
from: baseCurrency,
|
|
@@ -2272,7 +2335,7 @@ var LinkService = class {
|
|
|
2272
2335
|
this.client.linkPost("/v1/link/auth/verify-otp", input)
|
|
2273
2336
|
);
|
|
2274
2337
|
if (result.ok && result.value.session_token) {
|
|
2275
|
-
this.client.
|
|
2338
|
+
this.client.setAccessToken(result.value.session_token);
|
|
2276
2339
|
}
|
|
2277
2340
|
return result;
|
|
2278
2341
|
}
|
|
@@ -2386,30 +2449,6 @@ var LinkService = class {
|
|
|
2386
2449
|
async revokeAllSessions() {
|
|
2387
2450
|
return safe5(this.client.linkDelete("/v1/link/sessions"));
|
|
2388
2451
|
}
|
|
2389
|
-
async getAddressesRest() {
|
|
2390
|
-
return this.getAddresses();
|
|
2391
|
-
}
|
|
2392
|
-
async createAddressRest(input) {
|
|
2393
|
-
return this.createAddress(input);
|
|
2394
|
-
}
|
|
2395
|
-
async deleteAddressRest(addressId) {
|
|
2396
|
-
return this.deleteAddress(addressId);
|
|
2397
|
-
}
|
|
2398
|
-
async setDefaultAddressRest(addressId) {
|
|
2399
|
-
return this.setDefaultAddress(addressId);
|
|
2400
|
-
}
|
|
2401
|
-
async getMobileMoneyRest() {
|
|
2402
|
-
return this.getMobileMoney();
|
|
2403
|
-
}
|
|
2404
|
-
async createMobileMoneyRest(input) {
|
|
2405
|
-
return this.createMobileMoney(input);
|
|
2406
|
-
}
|
|
2407
|
-
async deleteMobileMoneyRest(mobileMoneyId) {
|
|
2408
|
-
return this.deleteMobileMoney(mobileMoneyId);
|
|
2409
|
-
}
|
|
2410
|
-
async setDefaultMobileMoneyRest(mobileMoneyId) {
|
|
2411
|
-
return this.setDefaultMobileMoney(mobileMoneyId);
|
|
2412
|
-
}
|
|
2413
2452
|
};
|
|
2414
2453
|
|
|
2415
2454
|
// src/auth.ts
|
|
@@ -2501,9 +2540,6 @@ var BusinessService = class {
|
|
|
2501
2540
|
async getSettings() {
|
|
2502
2541
|
return safe7(this.client.get("/api/v1/business/settings"));
|
|
2503
2542
|
}
|
|
2504
|
-
async getTheme() {
|
|
2505
|
-
return safe7(this.client.get("/api/v1/business/theme"));
|
|
2506
|
-
}
|
|
2507
2543
|
async getLocations() {
|
|
2508
2544
|
return safe7(this.client.get("/api/v1/business/locations"));
|
|
2509
2545
|
}
|
|
@@ -2557,9 +2593,6 @@ var InventoryService = class {
|
|
|
2557
2593
|
const query2 = searchParams.toString();
|
|
2558
2594
|
return query2 ? `${path}?${query2}` : path;
|
|
2559
2595
|
}
|
|
2560
|
-
async getStockLevels() {
|
|
2561
|
-
return safe8(this.client.get("/api/v1/inventory/stock-levels"));
|
|
2562
|
-
}
|
|
2563
2596
|
async getProductStock(productId, locationId) {
|
|
2564
2597
|
const encodedId = encodeURIComponent(productId);
|
|
2565
2598
|
const path = this.withQuery(`/api/v1/inventory/products/${encodedId}/stock`, {
|
|
@@ -2601,9 +2634,6 @@ var InventoryService = class {
|
|
|
2601
2634
|
}
|
|
2602
2635
|
return ok(results.map((r) => r.value));
|
|
2603
2636
|
}
|
|
2604
|
-
async getSummary() {
|
|
2605
|
-
return safe8(this.client.get("/api/v1/inventory/summary"));
|
|
2606
|
-
}
|
|
2607
2637
|
async isInStock(productId, locationId) {
|
|
2608
2638
|
const result = await this.checkProductAvailability(productId, 1, locationId);
|
|
2609
2639
|
if (!result.ok) return result;
|
|
@@ -2640,16 +2670,6 @@ function withQuery2(path, params) {
|
|
|
2640
2670
|
const query2 = searchParams.toString();
|
|
2641
2671
|
return query2 ? `${path}?${query2}` : path;
|
|
2642
2672
|
}
|
|
2643
|
-
function normalizeServiceAvailability(result) {
|
|
2644
|
-
if (Array.isArray(result.days) && result.days.length > 0) {
|
|
2645
|
-
return result;
|
|
2646
|
-
}
|
|
2647
|
-
const days = Array.isArray(result.availability) ? result.availability.map((day) => ({
|
|
2648
|
-
...day,
|
|
2649
|
-
is_fully_booked: day.is_fully_booked ?? (typeof day.has_availability === "boolean" ? !day.has_availability : void 0)
|
|
2650
|
-
})) : [];
|
|
2651
|
-
return { ...result, days };
|
|
2652
|
-
}
|
|
2653
2673
|
function firstScheduledTime(booking) {
|
|
2654
2674
|
return booking.service_items.find((item) => typeof item.scheduled_start === "string")?.scheduled_start || booking.created_at;
|
|
2655
2675
|
}
|
|
@@ -2660,13 +2680,9 @@ var SchedulingService = class {
|
|
|
2660
2680
|
async getServices() {
|
|
2661
2681
|
return safe9(this.client.get("/api/v1/scheduling/services"));
|
|
2662
2682
|
}
|
|
2663
|
-
/**
|
|
2664
|
-
* Get a specific service by ID.
|
|
2665
|
-
*/
|
|
2666
2683
|
async getService(serviceId) {
|
|
2667
|
-
const
|
|
2668
|
-
|
|
2669
|
-
return ok(result.value.find((service) => service.id === serviceId) || null);
|
|
2684
|
+
const encodedId = encodeURIComponent(serviceId);
|
|
2685
|
+
return safe9(this.client.get(`/api/v1/scheduling/services/${encodedId}`));
|
|
2670
2686
|
}
|
|
2671
2687
|
async getAvailableSlots(input) {
|
|
2672
2688
|
const path = withQuery2("/api/v1/scheduling/slots", {
|
|
@@ -2694,9 +2710,7 @@ var SchedulingService = class {
|
|
|
2694
2710
|
location_id: params.location_id,
|
|
2695
2711
|
participant_count: params.participant_count
|
|
2696
2712
|
});
|
|
2697
|
-
return safe9(
|
|
2698
|
-
this.client.get(path).then((result) => normalizeServiceAvailability(result))
|
|
2699
|
-
);
|
|
2713
|
+
return safe9(this.client.get(path));
|
|
2700
2714
|
}
|
|
2701
2715
|
async getBooking(bookingId) {
|
|
2702
2716
|
const encodedId = encodeURIComponent(bookingId);
|
|
@@ -2753,12 +2767,6 @@ var SchedulingService = class {
|
|
|
2753
2767
|
if (!result.ok) return result;
|
|
2754
2768
|
return ok(result.value.some((slot) => slot.is_available));
|
|
2755
2769
|
}
|
|
2756
|
-
// Compatibility alias for callers typed against the older Booking shape.
|
|
2757
|
-
async getBookingLegacy(bookingId) {
|
|
2758
|
-
const result = await this.getBooking(bookingId);
|
|
2759
|
-
if (!result.ok) return result;
|
|
2760
|
-
return ok(result.value);
|
|
2761
|
-
}
|
|
2762
2770
|
};
|
|
2763
2771
|
|
|
2764
2772
|
// src/lite.ts
|
|
@@ -2832,7 +2840,6 @@ var ELEMENT_TYPES = {
|
|
|
2832
2840
|
CHECKOUT: "checkout"
|
|
2833
2841
|
};
|
|
2834
2842
|
var MESSAGE_TYPES = {
|
|
2835
|
-
// Parent → Iframe
|
|
2836
2843
|
INIT: "init",
|
|
2837
2844
|
SET_TOKEN: "set_token",
|
|
2838
2845
|
SET_CART: "set_cart",
|
|
@@ -2841,7 +2848,6 @@ var MESSAGE_TYPES = {
|
|
|
2841
2848
|
LOGOUT: "logout",
|
|
2842
2849
|
PROCESS_CHECKOUT: "process_checkout",
|
|
2843
2850
|
ABORT_CHECKOUT: "abort_checkout",
|
|
2844
|
-
// Iframe → Parent
|
|
2845
2851
|
READY: "ready",
|
|
2846
2852
|
HEIGHT_CHANGE: "height_change",
|
|
2847
2853
|
AUTHENTICATED: "authenticated",
|
|
@@ -3069,7 +3075,6 @@ var CimplifyElements = class {
|
|
|
3069
3075
|
tip_amount: options.tip_amount,
|
|
3070
3076
|
pay_currency: options.pay_currency,
|
|
3071
3077
|
enroll_in_link: options.enroll_in_link ?? true,
|
|
3072
|
-
// Unified checkout has its own address/customer state; only pass if available externally
|
|
3073
3078
|
address: isUnifiedCheckout ? void 0 : this.addressData ?? void 0,
|
|
3074
3079
|
customer: isUnifiedCheckout ? void 0 : this.customerData ? {
|
|
3075
3080
|
name: this.customerData.name,
|
|
@@ -3552,9 +3557,6 @@ function isRetryable(error) {
|
|
|
3552
3557
|
if (error instanceof CimplifyError) {
|
|
3553
3558
|
return error.retryable;
|
|
3554
3559
|
}
|
|
3555
|
-
if (error instanceof CimplifyError && error.code === "SERVER_ERROR") {
|
|
3556
|
-
return true;
|
|
3557
|
-
}
|
|
3558
3560
|
return false;
|
|
3559
3561
|
}
|
|
3560
3562
|
function toNetworkError(error, isTestMode) {
|
|
@@ -3642,7 +3644,6 @@ var CimplifyClient = class {
|
|
|
3642
3644
|
);
|
|
3643
3645
|
}
|
|
3644
3646
|
}
|
|
3645
|
-
/** Build a full URL, appending context params (e.g. location_id) as query parameters. */
|
|
3646
3647
|
buildUrl(base, path) {
|
|
3647
3648
|
const url = `${base}${path}`;
|
|
3648
3649
|
const locationId = this.context.location_id;
|
|
@@ -3650,14 +3651,6 @@ var CimplifyClient = class {
|
|
|
3650
3651
|
const separator = url.includes("?") ? "&" : "?";
|
|
3651
3652
|
return `${url}${separator}location_id=${encodeURIComponent(locationId)}`;
|
|
3652
3653
|
}
|
|
3653
|
-
/** @deprecated Use getAccessToken() instead */
|
|
3654
|
-
getSessionToken() {
|
|
3655
|
-
return this.accessToken;
|
|
3656
|
-
}
|
|
3657
|
-
/** @deprecated Use setAccessToken() instead */
|
|
3658
|
-
setSessionToken(token) {
|
|
3659
|
-
this.setAccessToken(token);
|
|
3660
|
-
}
|
|
3661
3654
|
getAccessToken() {
|
|
3662
3655
|
return this.accessToken;
|
|
3663
3656
|
}
|
|
@@ -3736,11 +3729,9 @@ var CimplifyClient = class {
|
|
|
3736
3729
|
delete this.context.location_id;
|
|
3737
3730
|
}
|
|
3738
3731
|
}
|
|
3739
|
-
/** Get the currently active location ID */
|
|
3740
3732
|
getLocationId() {
|
|
3741
3733
|
return this.context.location_id ?? null;
|
|
3742
3734
|
}
|
|
3743
|
-
/** Cache a resolved business ID for future element/checkouts initialization. */
|
|
3744
3735
|
setBusinessId(businessId) {
|
|
3745
3736
|
const normalized = businessId.trim();
|
|
3746
3737
|
if (!normalized) {
|
|
@@ -3748,14 +3739,9 @@ var CimplifyClient = class {
|
|
|
3748
3739
|
}
|
|
3749
3740
|
this.businessId = normalized;
|
|
3750
3741
|
}
|
|
3751
|
-
/** Get cached business ID if available. */
|
|
3752
3742
|
getBusinessId() {
|
|
3753
3743
|
return this.businessId;
|
|
3754
3744
|
}
|
|
3755
|
-
/**
|
|
3756
|
-
* Resolve business ID from public key once and cache it.
|
|
3757
|
-
* Subsequent calls return the cached value (or shared in-flight promise).
|
|
3758
|
-
*/
|
|
3759
3745
|
async resolveBusinessId() {
|
|
3760
3746
|
if (this.businessId) {
|
|
3761
3747
|
return this.businessId;
|
|
@@ -4138,20 +4124,6 @@ var CimplifyClient = class {
|
|
|
4138
4124
|
}
|
|
4139
4125
|
return this._fx;
|
|
4140
4126
|
}
|
|
4141
|
-
/**
|
|
4142
|
-
* Create a CimplifyElements instance for embedding checkout components.
|
|
4143
|
-
* Like Stripe's stripe.elements().
|
|
4144
|
-
*
|
|
4145
|
-
* @param businessId - The business ID for checkout context
|
|
4146
|
-
* @param options - Optional configuration for elements
|
|
4147
|
-
*
|
|
4148
|
-
* @example
|
|
4149
|
-
* ```ts
|
|
4150
|
-
* const elements = client.elements('bus_xxx');
|
|
4151
|
-
* const authElement = elements.create('auth');
|
|
4152
|
-
* authElement.mount('#auth-container');
|
|
4153
|
-
* ```
|
|
4154
|
-
*/
|
|
4155
4127
|
elements(businessId, options) {
|
|
4156
4128
|
if (businessId) {
|
|
4157
4129
|
this.setBusinessId(businessId);
|