@cimplify/sdk 0.6.0 → 0.6.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 +5 -0
- package/dist/{ads-B5jcLFpD.d.mts → ads-DRfobDQ9.d.mts} +297 -216
- package/dist/{ads-B5jcLFpD.d.ts → ads-DRfobDQ9.d.ts} +297 -216
- package/dist/index.d.mts +25 -92
- package/dist/index.d.ts +25 -92
- package/dist/index.js +41 -165
- package/dist/index.mjs +42 -163
- package/dist/react.d.mts +2 -2
- package/dist/react.d.ts +2 -2
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -315,6 +315,19 @@ var CatalogueQueries = class {
|
|
|
315
315
|
})
|
|
316
316
|
);
|
|
317
317
|
}
|
|
318
|
+
async fetchQuote(input) {
|
|
319
|
+
return safe(this.client.call("catalogue.createQuote", input));
|
|
320
|
+
}
|
|
321
|
+
async getQuote(quoteId) {
|
|
322
|
+
return safe(
|
|
323
|
+
this.client.call("catalogue.getQuote", {
|
|
324
|
+
quote_id: quoteId
|
|
325
|
+
})
|
|
326
|
+
);
|
|
327
|
+
}
|
|
328
|
+
async refreshQuote(input) {
|
|
329
|
+
return safe(this.client.call("catalogue.refreshQuote", input));
|
|
330
|
+
}
|
|
318
331
|
async search(query2, options) {
|
|
319
332
|
const limit = options?.limit ?? 20;
|
|
320
333
|
let searchQuery = `products[?(@.name contains '${query2}')]`;
|
|
@@ -366,12 +379,20 @@ async function safe2(promise) {
|
|
|
366
379
|
return err(toCimplifyError2(error));
|
|
367
380
|
}
|
|
368
381
|
}
|
|
382
|
+
function isUICartResponse(value) {
|
|
383
|
+
return "cart" in value;
|
|
384
|
+
}
|
|
385
|
+
function unwrapEnrichedCart(value) {
|
|
386
|
+
return isUICartResponse(value) ? value.cart : value;
|
|
387
|
+
}
|
|
369
388
|
var CartOperations = class {
|
|
370
389
|
constructor(client) {
|
|
371
390
|
this.client = client;
|
|
372
391
|
}
|
|
373
392
|
async get() {
|
|
374
|
-
|
|
393
|
+
const result = await safe2(this.client.query("cart#enriched"));
|
|
394
|
+
if (!result.ok) return result;
|
|
395
|
+
return ok(unwrapEnrichedCart(result.value));
|
|
375
396
|
}
|
|
376
397
|
async getRaw() {
|
|
377
398
|
return safe2(this.client.query("cart"));
|
|
@@ -2275,169 +2296,27 @@ function parsePrice(value) {
|
|
|
2275
2296
|
const parsed = parseFloat(cleaned);
|
|
2276
2297
|
return isNaN(parsed) ? 0 : parsed;
|
|
2277
2298
|
}
|
|
2278
|
-
function
|
|
2279
|
-
|
|
2280
|
-
|
|
2281
|
-
if (parts.length < 4 || parts[0] !== "T") {
|
|
2282
|
-
return void 0;
|
|
2283
|
-
}
|
|
2284
|
-
const taxRate = parseFloat(parts[1]);
|
|
2285
|
-
const taxAmount = parseFloat(parts[2]);
|
|
2286
|
-
const isInclusive = parts[3] === "I";
|
|
2287
|
-
const components = [];
|
|
2288
|
-
if (parts.length > 4 && parts[4]) {
|
|
2289
|
-
const componentPairs = parts[4].split(",");
|
|
2290
|
-
for (const pair of componentPairs) {
|
|
2291
|
-
const [name, rateStr] = pair.split(":");
|
|
2292
|
-
if (name && rateStr) {
|
|
2293
|
-
components.push({
|
|
2294
|
-
name: name.trim(),
|
|
2295
|
-
rate: parseFloat(rateStr)
|
|
2296
|
-
});
|
|
2297
|
-
}
|
|
2298
|
-
}
|
|
2299
|
-
}
|
|
2300
|
-
return {
|
|
2301
|
-
taxRate,
|
|
2302
|
-
taxAmount,
|
|
2303
|
-
isInclusive,
|
|
2304
|
-
components
|
|
2305
|
-
};
|
|
2306
|
-
} catch {
|
|
2307
|
-
return void 0;
|
|
2299
|
+
function getDisplayPrice(product) {
|
|
2300
|
+
if (product.price_info) {
|
|
2301
|
+
return parsePrice(product.price_info.final_price);
|
|
2308
2302
|
}
|
|
2309
|
-
|
|
2310
|
-
|
|
2311
|
-
if (!signedPricePath) {
|
|
2312
|
-
return {
|
|
2313
|
-
basePrice: 0,
|
|
2314
|
-
finalPrice: 0,
|
|
2315
|
-
currency: "GHS",
|
|
2316
|
-
decisionPath: "",
|
|
2317
|
-
isValid: false,
|
|
2318
|
-
isExpired: false
|
|
2319
|
-
};
|
|
2303
|
+
if (product.final_price !== void 0 && product.final_price !== null) {
|
|
2304
|
+
return parsePrice(product.final_price);
|
|
2320
2305
|
}
|
|
2321
|
-
|
|
2322
|
-
|
|
2323
|
-
if (parts.length !== 3) {
|
|
2324
|
-
return {
|
|
2325
|
-
basePrice: 0,
|
|
2326
|
-
finalPrice: 0,
|
|
2327
|
-
currency: "GHS",
|
|
2328
|
-
decisionPath: "",
|
|
2329
|
-
isValid: false,
|
|
2330
|
-
isExpired: false
|
|
2331
|
-
};
|
|
2332
|
-
}
|
|
2333
|
-
const [pricePath, expiryStr, signature] = parts;
|
|
2334
|
-
const expiryTimestamp = parseInt(expiryStr, 10);
|
|
2335
|
-
const now = Math.floor(Date.now() / 1e3);
|
|
2336
|
-
const isExpired = now > expiryTimestamp;
|
|
2337
|
-
const priceComponents = pricePath.split("|");
|
|
2338
|
-
if (priceComponents.length < 5) {
|
|
2339
|
-
return {
|
|
2340
|
-
basePrice: 0,
|
|
2341
|
-
finalPrice: 0,
|
|
2342
|
-
currency: "GHS",
|
|
2343
|
-
decisionPath: "",
|
|
2344
|
-
isValid: false,
|
|
2345
|
-
isExpired
|
|
2346
|
-
};
|
|
2347
|
-
}
|
|
2348
|
-
const basePrice = parseFloat(priceComponents[0]);
|
|
2349
|
-
const finalPrice = parseFloat(priceComponents[1]);
|
|
2350
|
-
const currency = priceComponents[2];
|
|
2351
|
-
const taxInfoStr = priceComponents[3];
|
|
2352
|
-
const decisionPath = priceComponents.slice(4).join("|");
|
|
2353
|
-
let taxInfo;
|
|
2354
|
-
if (taxInfoStr && taxInfoStr.startsWith("T:")) {
|
|
2355
|
-
taxInfo = parseTaxInfo(taxInfoStr);
|
|
2356
|
-
} else if (taxInfoStr === "0" || !taxInfoStr) {
|
|
2357
|
-
taxInfo = {
|
|
2358
|
-
taxRate: 0,
|
|
2359
|
-
taxAmount: 0,
|
|
2360
|
-
isInclusive: false,
|
|
2361
|
-
components: []
|
|
2362
|
-
};
|
|
2363
|
-
}
|
|
2364
|
-
let markupPercentage;
|
|
2365
|
-
let markupAmount;
|
|
2366
|
-
let discountPercentage;
|
|
2367
|
-
if (decisionPath) {
|
|
2368
|
-
const pathParts = decisionPath.split(":");
|
|
2369
|
-
if (pathParts.length > 1 && pathParts[1]) {
|
|
2370
|
-
const adjustments = pathParts[1].split(",");
|
|
2371
|
-
for (const adj of adjustments) {
|
|
2372
|
-
const adjParts = adj.split("|");
|
|
2373
|
-
if (adjParts[0] && adjParts[0].startsWith("ch")) {
|
|
2374
|
-
markupAmount = parseFloat(adjParts[1]) || 0;
|
|
2375
|
-
markupPercentage = parseFloat(adjParts[2]) || 0;
|
|
2376
|
-
break;
|
|
2377
|
-
}
|
|
2378
|
-
}
|
|
2379
|
-
}
|
|
2380
|
-
}
|
|
2381
|
-
if (markupAmount === void 0 && finalPrice > basePrice) {
|
|
2382
|
-
markupAmount = finalPrice - basePrice;
|
|
2383
|
-
markupPercentage = basePrice > 0 ? markupAmount / basePrice * 100 : 0;
|
|
2384
|
-
} else if (basePrice > finalPrice) {
|
|
2385
|
-
discountPercentage = basePrice > 0 ? (basePrice - finalPrice) / basePrice * 100 : 0;
|
|
2386
|
-
}
|
|
2387
|
-
return {
|
|
2388
|
-
basePrice,
|
|
2389
|
-
finalPrice,
|
|
2390
|
-
currency,
|
|
2391
|
-
decisionPath,
|
|
2392
|
-
discountPercentage,
|
|
2393
|
-
markupPercentage,
|
|
2394
|
-
markupAmount,
|
|
2395
|
-
taxInfo,
|
|
2396
|
-
isValid: !isExpired && signature.length > 0,
|
|
2397
|
-
isExpired,
|
|
2398
|
-
expiryTimestamp
|
|
2399
|
-
};
|
|
2400
|
-
} catch {
|
|
2401
|
-
return {
|
|
2402
|
-
basePrice: 0,
|
|
2403
|
-
finalPrice: 0,
|
|
2404
|
-
currency: "GHS",
|
|
2405
|
-
decisionPath: "",
|
|
2406
|
-
isValid: false,
|
|
2407
|
-
isExpired: false
|
|
2408
|
-
};
|
|
2409
|
-
}
|
|
2410
|
-
}
|
|
2411
|
-
function parsedPriceToPriceInfo(parsedPrice) {
|
|
2412
|
-
return {
|
|
2413
|
-
base_price: parsedPrice.basePrice,
|
|
2414
|
-
final_price: parsedPrice.finalPrice,
|
|
2415
|
-
markup_percentage: parsedPrice.markupPercentage,
|
|
2416
|
-
markup_amount: parsedPrice.markupAmount,
|
|
2417
|
-
currency: parsedPrice.currency,
|
|
2418
|
-
tax_info: parsedPrice.taxInfo,
|
|
2419
|
-
decision_path: parsedPrice.decisionPath
|
|
2420
|
-
};
|
|
2421
|
-
}
|
|
2422
|
-
function extractPriceInfo(signedPricePath) {
|
|
2423
|
-
const parsed = parsePricePath(signedPricePath);
|
|
2424
|
-
return parsedPriceToPriceInfo(parsed);
|
|
2425
|
-
}
|
|
2426
|
-
function getDisplayPrice(product) {
|
|
2427
|
-
if (product.price_path) {
|
|
2428
|
-
const priceInfo = extractPriceInfo(product.price_path);
|
|
2429
|
-
return priceInfo.final_price;
|
|
2430
|
-
} else if (product.price_info) {
|
|
2431
|
-
return product.price_info.final_price;
|
|
2306
|
+
if (product.default_price !== void 0 && product.default_price !== null) {
|
|
2307
|
+
return parsePrice(product.default_price);
|
|
2432
2308
|
}
|
|
2433
2309
|
return 0;
|
|
2434
2310
|
}
|
|
2435
2311
|
function getBasePrice(product) {
|
|
2436
|
-
if (product.
|
|
2437
|
-
|
|
2438
|
-
|
|
2439
|
-
|
|
2440
|
-
return product.
|
|
2312
|
+
if (product.price_info) {
|
|
2313
|
+
return parsePrice(product.price_info.base_price);
|
|
2314
|
+
}
|
|
2315
|
+
if (product.base_price !== void 0 && product.base_price !== null) {
|
|
2316
|
+
return parsePrice(product.base_price);
|
|
2317
|
+
}
|
|
2318
|
+
if (product.default_price !== void 0 && product.default_price !== null) {
|
|
2319
|
+
return parsePrice(product.default_price);
|
|
2441
2320
|
}
|
|
2442
2321
|
return 0;
|
|
2443
2322
|
}
|
|
@@ -2463,12 +2342,12 @@ function getMarkupPercentage(product) {
|
|
|
2463
2342
|
return 0;
|
|
2464
2343
|
}
|
|
2465
2344
|
function getProductCurrency(product) {
|
|
2466
|
-
if (product.
|
|
2467
|
-
const parsed = parsePricePath(product.price_path);
|
|
2468
|
-
return parsed.currency || "GHS";
|
|
2469
|
-
} else if (product.price_info?.currency) {
|
|
2345
|
+
if (product.price_info?.currency) {
|
|
2470
2346
|
return product.price_info.currency;
|
|
2471
2347
|
}
|
|
2348
|
+
if (product.currency) {
|
|
2349
|
+
return product.currency;
|
|
2350
|
+
}
|
|
2472
2351
|
return "GHS";
|
|
2473
2352
|
}
|
|
2474
2353
|
function formatProductPrice(product, locale = "en-US") {
|
|
@@ -2664,7 +2543,6 @@ exports.createCimplifyClient = createCimplifyClient;
|
|
|
2664
2543
|
exports.createElements = createElements;
|
|
2665
2544
|
exports.detectMobileMoneyProvider = detectMobileMoneyProvider;
|
|
2666
2545
|
exports.err = err;
|
|
2667
|
-
exports.extractPriceInfo = extractPriceInfo;
|
|
2668
2546
|
exports.flatMap = flatMap;
|
|
2669
2547
|
exports.formatMoney = formatMoney;
|
|
2670
2548
|
exports.formatNumberCompact = formatNumberCompact;
|
|
@@ -2692,8 +2570,6 @@ exports.normalizePaymentResponse = normalizePaymentResponse;
|
|
|
2692
2570
|
exports.normalizeStatusResponse = normalizeStatusResponse;
|
|
2693
2571
|
exports.ok = ok;
|
|
2694
2572
|
exports.parsePrice = parsePrice;
|
|
2695
|
-
exports.parsePricePath = parsePricePath;
|
|
2696
|
-
exports.parsedPriceToPriceInfo = parsedPriceToPriceInfo;
|
|
2697
2573
|
exports.query = query;
|
|
2698
2574
|
exports.toNullable = toNullable;
|
|
2699
2575
|
exports.tryCatch = tryCatch;
|
package/dist/index.mjs
CHANGED
|
@@ -313,6 +313,19 @@ var CatalogueQueries = class {
|
|
|
313
313
|
})
|
|
314
314
|
);
|
|
315
315
|
}
|
|
316
|
+
async fetchQuote(input) {
|
|
317
|
+
return safe(this.client.call("catalogue.createQuote", input));
|
|
318
|
+
}
|
|
319
|
+
async getQuote(quoteId) {
|
|
320
|
+
return safe(
|
|
321
|
+
this.client.call("catalogue.getQuote", {
|
|
322
|
+
quote_id: quoteId
|
|
323
|
+
})
|
|
324
|
+
);
|
|
325
|
+
}
|
|
326
|
+
async refreshQuote(input) {
|
|
327
|
+
return safe(this.client.call("catalogue.refreshQuote", input));
|
|
328
|
+
}
|
|
316
329
|
async search(query2, options) {
|
|
317
330
|
const limit = options?.limit ?? 20;
|
|
318
331
|
let searchQuery = `products[?(@.name contains '${query2}')]`;
|
|
@@ -364,12 +377,20 @@ async function safe2(promise) {
|
|
|
364
377
|
return err(toCimplifyError2(error));
|
|
365
378
|
}
|
|
366
379
|
}
|
|
380
|
+
function isUICartResponse(value) {
|
|
381
|
+
return "cart" in value;
|
|
382
|
+
}
|
|
383
|
+
function unwrapEnrichedCart(value) {
|
|
384
|
+
return isUICartResponse(value) ? value.cart : value;
|
|
385
|
+
}
|
|
367
386
|
var CartOperations = class {
|
|
368
387
|
constructor(client) {
|
|
369
388
|
this.client = client;
|
|
370
389
|
}
|
|
371
390
|
async get() {
|
|
372
|
-
|
|
391
|
+
const result = await safe2(this.client.query("cart#enriched"));
|
|
392
|
+
if (!result.ok) return result;
|
|
393
|
+
return ok(unwrapEnrichedCart(result.value));
|
|
373
394
|
}
|
|
374
395
|
async getRaw() {
|
|
375
396
|
return safe2(this.client.query("cart"));
|
|
@@ -2273,169 +2294,27 @@ function parsePrice(value) {
|
|
|
2273
2294
|
const parsed = parseFloat(cleaned);
|
|
2274
2295
|
return isNaN(parsed) ? 0 : parsed;
|
|
2275
2296
|
}
|
|
2276
|
-
function
|
|
2277
|
-
|
|
2278
|
-
|
|
2279
|
-
if (parts.length < 4 || parts[0] !== "T") {
|
|
2280
|
-
return void 0;
|
|
2281
|
-
}
|
|
2282
|
-
const taxRate = parseFloat(parts[1]);
|
|
2283
|
-
const taxAmount = parseFloat(parts[2]);
|
|
2284
|
-
const isInclusive = parts[3] === "I";
|
|
2285
|
-
const components = [];
|
|
2286
|
-
if (parts.length > 4 && parts[4]) {
|
|
2287
|
-
const componentPairs = parts[4].split(",");
|
|
2288
|
-
for (const pair of componentPairs) {
|
|
2289
|
-
const [name, rateStr] = pair.split(":");
|
|
2290
|
-
if (name && rateStr) {
|
|
2291
|
-
components.push({
|
|
2292
|
-
name: name.trim(),
|
|
2293
|
-
rate: parseFloat(rateStr)
|
|
2294
|
-
});
|
|
2295
|
-
}
|
|
2296
|
-
}
|
|
2297
|
-
}
|
|
2298
|
-
return {
|
|
2299
|
-
taxRate,
|
|
2300
|
-
taxAmount,
|
|
2301
|
-
isInclusive,
|
|
2302
|
-
components
|
|
2303
|
-
};
|
|
2304
|
-
} catch {
|
|
2305
|
-
return void 0;
|
|
2297
|
+
function getDisplayPrice(product) {
|
|
2298
|
+
if (product.price_info) {
|
|
2299
|
+
return parsePrice(product.price_info.final_price);
|
|
2306
2300
|
}
|
|
2307
|
-
|
|
2308
|
-
|
|
2309
|
-
if (!signedPricePath) {
|
|
2310
|
-
return {
|
|
2311
|
-
basePrice: 0,
|
|
2312
|
-
finalPrice: 0,
|
|
2313
|
-
currency: "GHS",
|
|
2314
|
-
decisionPath: "",
|
|
2315
|
-
isValid: false,
|
|
2316
|
-
isExpired: false
|
|
2317
|
-
};
|
|
2301
|
+
if (product.final_price !== void 0 && product.final_price !== null) {
|
|
2302
|
+
return parsePrice(product.final_price);
|
|
2318
2303
|
}
|
|
2319
|
-
|
|
2320
|
-
|
|
2321
|
-
if (parts.length !== 3) {
|
|
2322
|
-
return {
|
|
2323
|
-
basePrice: 0,
|
|
2324
|
-
finalPrice: 0,
|
|
2325
|
-
currency: "GHS",
|
|
2326
|
-
decisionPath: "",
|
|
2327
|
-
isValid: false,
|
|
2328
|
-
isExpired: false
|
|
2329
|
-
};
|
|
2330
|
-
}
|
|
2331
|
-
const [pricePath, expiryStr, signature] = parts;
|
|
2332
|
-
const expiryTimestamp = parseInt(expiryStr, 10);
|
|
2333
|
-
const now = Math.floor(Date.now() / 1e3);
|
|
2334
|
-
const isExpired = now > expiryTimestamp;
|
|
2335
|
-
const priceComponents = pricePath.split("|");
|
|
2336
|
-
if (priceComponents.length < 5) {
|
|
2337
|
-
return {
|
|
2338
|
-
basePrice: 0,
|
|
2339
|
-
finalPrice: 0,
|
|
2340
|
-
currency: "GHS",
|
|
2341
|
-
decisionPath: "",
|
|
2342
|
-
isValid: false,
|
|
2343
|
-
isExpired
|
|
2344
|
-
};
|
|
2345
|
-
}
|
|
2346
|
-
const basePrice = parseFloat(priceComponents[0]);
|
|
2347
|
-
const finalPrice = parseFloat(priceComponents[1]);
|
|
2348
|
-
const currency = priceComponents[2];
|
|
2349
|
-
const taxInfoStr = priceComponents[3];
|
|
2350
|
-
const decisionPath = priceComponents.slice(4).join("|");
|
|
2351
|
-
let taxInfo;
|
|
2352
|
-
if (taxInfoStr && taxInfoStr.startsWith("T:")) {
|
|
2353
|
-
taxInfo = parseTaxInfo(taxInfoStr);
|
|
2354
|
-
} else if (taxInfoStr === "0" || !taxInfoStr) {
|
|
2355
|
-
taxInfo = {
|
|
2356
|
-
taxRate: 0,
|
|
2357
|
-
taxAmount: 0,
|
|
2358
|
-
isInclusive: false,
|
|
2359
|
-
components: []
|
|
2360
|
-
};
|
|
2361
|
-
}
|
|
2362
|
-
let markupPercentage;
|
|
2363
|
-
let markupAmount;
|
|
2364
|
-
let discountPercentage;
|
|
2365
|
-
if (decisionPath) {
|
|
2366
|
-
const pathParts = decisionPath.split(":");
|
|
2367
|
-
if (pathParts.length > 1 && pathParts[1]) {
|
|
2368
|
-
const adjustments = pathParts[1].split(",");
|
|
2369
|
-
for (const adj of adjustments) {
|
|
2370
|
-
const adjParts = adj.split("|");
|
|
2371
|
-
if (adjParts[0] && adjParts[0].startsWith("ch")) {
|
|
2372
|
-
markupAmount = parseFloat(adjParts[1]) || 0;
|
|
2373
|
-
markupPercentage = parseFloat(adjParts[2]) || 0;
|
|
2374
|
-
break;
|
|
2375
|
-
}
|
|
2376
|
-
}
|
|
2377
|
-
}
|
|
2378
|
-
}
|
|
2379
|
-
if (markupAmount === void 0 && finalPrice > basePrice) {
|
|
2380
|
-
markupAmount = finalPrice - basePrice;
|
|
2381
|
-
markupPercentage = basePrice > 0 ? markupAmount / basePrice * 100 : 0;
|
|
2382
|
-
} else if (basePrice > finalPrice) {
|
|
2383
|
-
discountPercentage = basePrice > 0 ? (basePrice - finalPrice) / basePrice * 100 : 0;
|
|
2384
|
-
}
|
|
2385
|
-
return {
|
|
2386
|
-
basePrice,
|
|
2387
|
-
finalPrice,
|
|
2388
|
-
currency,
|
|
2389
|
-
decisionPath,
|
|
2390
|
-
discountPercentage,
|
|
2391
|
-
markupPercentage,
|
|
2392
|
-
markupAmount,
|
|
2393
|
-
taxInfo,
|
|
2394
|
-
isValid: !isExpired && signature.length > 0,
|
|
2395
|
-
isExpired,
|
|
2396
|
-
expiryTimestamp
|
|
2397
|
-
};
|
|
2398
|
-
} catch {
|
|
2399
|
-
return {
|
|
2400
|
-
basePrice: 0,
|
|
2401
|
-
finalPrice: 0,
|
|
2402
|
-
currency: "GHS",
|
|
2403
|
-
decisionPath: "",
|
|
2404
|
-
isValid: false,
|
|
2405
|
-
isExpired: false
|
|
2406
|
-
};
|
|
2407
|
-
}
|
|
2408
|
-
}
|
|
2409
|
-
function parsedPriceToPriceInfo(parsedPrice) {
|
|
2410
|
-
return {
|
|
2411
|
-
base_price: parsedPrice.basePrice,
|
|
2412
|
-
final_price: parsedPrice.finalPrice,
|
|
2413
|
-
markup_percentage: parsedPrice.markupPercentage,
|
|
2414
|
-
markup_amount: parsedPrice.markupAmount,
|
|
2415
|
-
currency: parsedPrice.currency,
|
|
2416
|
-
tax_info: parsedPrice.taxInfo,
|
|
2417
|
-
decision_path: parsedPrice.decisionPath
|
|
2418
|
-
};
|
|
2419
|
-
}
|
|
2420
|
-
function extractPriceInfo(signedPricePath) {
|
|
2421
|
-
const parsed = parsePricePath(signedPricePath);
|
|
2422
|
-
return parsedPriceToPriceInfo(parsed);
|
|
2423
|
-
}
|
|
2424
|
-
function getDisplayPrice(product) {
|
|
2425
|
-
if (product.price_path) {
|
|
2426
|
-
const priceInfo = extractPriceInfo(product.price_path);
|
|
2427
|
-
return priceInfo.final_price;
|
|
2428
|
-
} else if (product.price_info) {
|
|
2429
|
-
return product.price_info.final_price;
|
|
2304
|
+
if (product.default_price !== void 0 && product.default_price !== null) {
|
|
2305
|
+
return parsePrice(product.default_price);
|
|
2430
2306
|
}
|
|
2431
2307
|
return 0;
|
|
2432
2308
|
}
|
|
2433
2309
|
function getBasePrice(product) {
|
|
2434
|
-
if (product.
|
|
2435
|
-
|
|
2436
|
-
|
|
2437
|
-
|
|
2438
|
-
return product.
|
|
2310
|
+
if (product.price_info) {
|
|
2311
|
+
return parsePrice(product.price_info.base_price);
|
|
2312
|
+
}
|
|
2313
|
+
if (product.base_price !== void 0 && product.base_price !== null) {
|
|
2314
|
+
return parsePrice(product.base_price);
|
|
2315
|
+
}
|
|
2316
|
+
if (product.default_price !== void 0 && product.default_price !== null) {
|
|
2317
|
+
return parsePrice(product.default_price);
|
|
2439
2318
|
}
|
|
2440
2319
|
return 0;
|
|
2441
2320
|
}
|
|
@@ -2461,12 +2340,12 @@ function getMarkupPercentage(product) {
|
|
|
2461
2340
|
return 0;
|
|
2462
2341
|
}
|
|
2463
2342
|
function getProductCurrency(product) {
|
|
2464
|
-
if (product.
|
|
2465
|
-
const parsed = parsePricePath(product.price_path);
|
|
2466
|
-
return parsed.currency || "GHS";
|
|
2467
|
-
} else if (product.price_info?.currency) {
|
|
2343
|
+
if (product.price_info?.currency) {
|
|
2468
2344
|
return product.price_info.currency;
|
|
2469
2345
|
}
|
|
2346
|
+
if (product.currency) {
|
|
2347
|
+
return product.currency;
|
|
2348
|
+
}
|
|
2470
2349
|
return "GHS";
|
|
2471
2350
|
}
|
|
2472
2351
|
function formatProductPrice(product, locale = "en-US") {
|
|
@@ -2614,4 +2493,4 @@ function detectMobileMoneyProvider(phoneNumber) {
|
|
|
2614
2493
|
return null;
|
|
2615
2494
|
}
|
|
2616
2495
|
|
|
2617
|
-
export { AUTHORIZATION_TYPE, AUTH_MUTATION, AuthService, BusinessService, CHECKOUT_MODE, CHECKOUT_MUTATION, CHECKOUT_STEP, CONTACT_TYPE, CURRENCY_SYMBOLS, CartOperations, CatalogueQueries, CheckoutService as CheckoutOperations, CheckoutService, CimplifyClient, CimplifyElement, CimplifyElements, CimplifyError, DEFAULT_COUNTRY, DEFAULT_CURRENCY, DEVICE_TYPE, ELEMENT_TYPES, EVENT_TYPES, ErrorCode, FxService, InventoryService, LINK_MUTATION, LINK_QUERY, LinkService, LiteService, MESSAGE_TYPES, MOBILE_MONEY_PROVIDER, MOBILE_MONEY_PROVIDERS, ORDER_MUTATION, ORDER_TYPE, OrderQueries, PAYMENT_METHOD, PAYMENT_MUTATION, PAYMENT_STATE, PICKUP_TIME_TYPE, QueryBuilder, SchedulingService, categorizePaymentError, combine, combineObject, createCimplifyClient, createElements, detectMobileMoneyProvider, err,
|
|
2496
|
+
export { AUTHORIZATION_TYPE, AUTH_MUTATION, AuthService, BusinessService, CHECKOUT_MODE, CHECKOUT_MUTATION, CHECKOUT_STEP, CONTACT_TYPE, CURRENCY_SYMBOLS, CartOperations, CatalogueQueries, CheckoutService as CheckoutOperations, CheckoutService, CimplifyClient, CimplifyElement, CimplifyElements, CimplifyError, DEFAULT_COUNTRY, DEFAULT_CURRENCY, DEVICE_TYPE, ELEMENT_TYPES, EVENT_TYPES, ErrorCode, FxService, InventoryService, LINK_MUTATION, LINK_QUERY, LinkService, LiteService, MESSAGE_TYPES, MOBILE_MONEY_PROVIDER, MOBILE_MONEY_PROVIDERS, ORDER_MUTATION, ORDER_TYPE, OrderQueries, PAYMENT_METHOD, PAYMENT_MUTATION, PAYMENT_STATE, PICKUP_TIME_TYPE, QueryBuilder, SchedulingService, categorizePaymentError, combine, combineObject, createCimplifyClient, createElements, detectMobileMoneyProvider, err, flatMap, formatMoney, formatNumberCompact, formatPrice, formatPriceAdjustment, formatPriceCompact, formatProductPrice, fromPromise, generateIdempotencyKey, getBasePrice, getCurrencySymbol, getDiscountPercentage, getDisplayPrice, getMarkupPercentage, getOrElse, getProductCurrency, isCimplifyError, isErr, isOk, isOnSale, isRetryableError, mapError, mapResult, normalizePaymentResponse, normalizeStatusResponse, ok, parsePrice, query, toNullable, tryCatch, unwrap };
|
package/dist/react.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export {
|
|
1
|
+
import { eB as AdSlot, eC as AdPosition, eG as AdContextValue, y as CimplifyElements, C as CimplifyClient, J as ElementsOptions, ev as AuthenticatedData, et as AddressInfo, eu as PaymentMethodInfo, ex as ElementsCheckoutResult } from './ads-DRfobDQ9.mjs';
|
|
2
|
+
export { eE as AdConfig } from './ads-DRfobDQ9.mjs';
|
|
3
3
|
import React, { ReactNode } from 'react';
|
|
4
4
|
|
|
5
5
|
interface UserIdentity {
|
package/dist/react.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export {
|
|
1
|
+
import { eB as AdSlot, eC as AdPosition, eG as AdContextValue, y as CimplifyElements, C as CimplifyClient, J as ElementsOptions, ev as AuthenticatedData, et as AddressInfo, eu as PaymentMethodInfo, ex as ElementsCheckoutResult } from './ads-DRfobDQ9.js';
|
|
2
|
+
export { eE as AdConfig } from './ads-DRfobDQ9.js';
|
|
3
3
|
import React, { ReactNode } from 'react';
|
|
4
4
|
|
|
5
5
|
interface UserIdentity {
|