@cimplify/sdk 0.6.7 → 0.6.9
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 +19 -0
- package/dist/advanced.d.mts +2 -2
- package/dist/advanced.d.ts +2 -2
- package/dist/advanced.js +127 -98
- package/dist/advanced.mjs +127 -98
- package/dist/{client-B4etj3AD.d.mts → client-COpV6Yuu.d.ts} +39 -34
- package/dist/{client-CYVVuP5J.d.ts → client-vmXPt1j0.d.mts} +39 -34
- package/dist/{index-DzNb32O3.d.mts → index-DaKJxoEh.d.mts} +13 -12
- package/dist/{index-BOYF-efj.d.ts → index-pztT_bcJ.d.ts} +13 -12
- package/dist/index.d.mts +4 -4
- package/dist/index.d.ts +4 -4
- package/dist/index.js +165 -99
- package/dist/index.mjs +162 -100
- package/dist/{payment-pjpfIKX8.d.mts → payment-Cu75tmUc.d.mts} +22 -7
- package/dist/{payment-pjpfIKX8.d.ts → payment-Cu75tmUc.d.ts} +22 -7
- package/dist/react.d.mts +99 -4
- package/dist/react.d.ts +99 -4
- package/dist/react.js +845 -39
- package/dist/react.mjs +840 -40
- package/dist/utils.d.mts +2 -2
- package/dist/utils.d.ts +2 -2
- package/dist/utils.js +76 -4
- package/dist/utils.mjs +76 -4
- package/package.json +1 -1
package/dist/advanced.mjs
CHANGED
|
@@ -7,6 +7,15 @@ function err(error) {
|
|
|
7
7
|
}
|
|
8
8
|
|
|
9
9
|
// src/types/common.ts
|
|
10
|
+
function money(value) {
|
|
11
|
+
return value;
|
|
12
|
+
}
|
|
13
|
+
function moneyFromNumber(value) {
|
|
14
|
+
return value.toFixed(2);
|
|
15
|
+
}
|
|
16
|
+
function currencyCode(value) {
|
|
17
|
+
return value;
|
|
18
|
+
}
|
|
10
19
|
var ErrorCode = {
|
|
11
20
|
// General
|
|
12
21
|
UNKNOWN_ERROR: "UNKNOWN_ERROR"};
|
|
@@ -106,6 +115,74 @@ function enrichError(error, options = {}) {
|
|
|
106
115
|
return error;
|
|
107
116
|
}
|
|
108
117
|
|
|
118
|
+
// src/query/builder.ts
|
|
119
|
+
function escapeQueryValue(value) {
|
|
120
|
+
return value.replace(/'/g, "\\'");
|
|
121
|
+
}
|
|
122
|
+
var QueryBuilder = class {
|
|
123
|
+
constructor(entity) {
|
|
124
|
+
this.filters = [];
|
|
125
|
+
this.modifiers = [];
|
|
126
|
+
this.pathSegments = [];
|
|
127
|
+
this.entity = entity;
|
|
128
|
+
}
|
|
129
|
+
path(segment) {
|
|
130
|
+
this.pathSegments.push(segment);
|
|
131
|
+
return this;
|
|
132
|
+
}
|
|
133
|
+
where(field, op, value) {
|
|
134
|
+
const v = typeof value === "string" ? `'${escapeQueryValue(value)}'` : value;
|
|
135
|
+
if (op === "contains" || op === "startsWith") {
|
|
136
|
+
this.filters.push(`@.${field} ${op} ${v}`);
|
|
137
|
+
} else {
|
|
138
|
+
this.filters.push(`@.${field}${op}${v}`);
|
|
139
|
+
}
|
|
140
|
+
return this;
|
|
141
|
+
}
|
|
142
|
+
and(field, op, value) {
|
|
143
|
+
return this.where(field, op, value);
|
|
144
|
+
}
|
|
145
|
+
sort(field, order = "asc") {
|
|
146
|
+
this.modifiers.push(`sort(${field},${order})`);
|
|
147
|
+
return this;
|
|
148
|
+
}
|
|
149
|
+
limit(n) {
|
|
150
|
+
this.modifiers.push(`limit(${n})`);
|
|
151
|
+
return this;
|
|
152
|
+
}
|
|
153
|
+
offset(n) {
|
|
154
|
+
this.modifiers.push(`offset(${n})`);
|
|
155
|
+
return this;
|
|
156
|
+
}
|
|
157
|
+
count() {
|
|
158
|
+
this.modifiers.push("count");
|
|
159
|
+
return this;
|
|
160
|
+
}
|
|
161
|
+
enriched() {
|
|
162
|
+
this.modifiers.push("enriched");
|
|
163
|
+
return this;
|
|
164
|
+
}
|
|
165
|
+
build() {
|
|
166
|
+
let query2 = this.entity;
|
|
167
|
+
if (this.pathSegments.length > 0) {
|
|
168
|
+
query2 += "." + this.pathSegments.join(".");
|
|
169
|
+
}
|
|
170
|
+
if (this.filters.length > 0) {
|
|
171
|
+
query2 += `[?(${this.filters.join(" && ")})]`;
|
|
172
|
+
}
|
|
173
|
+
for (const mod of this.modifiers) {
|
|
174
|
+
query2 += `#${mod}`;
|
|
175
|
+
}
|
|
176
|
+
return query2;
|
|
177
|
+
}
|
|
178
|
+
toString() {
|
|
179
|
+
return this.build();
|
|
180
|
+
}
|
|
181
|
+
};
|
|
182
|
+
function query(entity) {
|
|
183
|
+
return new QueryBuilder(entity);
|
|
184
|
+
}
|
|
185
|
+
|
|
109
186
|
// src/catalogue.ts
|
|
110
187
|
function toCimplifyError(error) {
|
|
111
188
|
if (error instanceof CimplifyError) return enrichError(error);
|
|
@@ -186,7 +263,7 @@ var CatalogueQueries = class {
|
|
|
186
263
|
let query2 = "products";
|
|
187
264
|
const filters = [];
|
|
188
265
|
if (options?.category) {
|
|
189
|
-
filters.push(`@.category_id=='${options.category}'`);
|
|
266
|
+
filters.push(`@.category_id=='${escapeQueryValue(options.category)}'`);
|
|
190
267
|
}
|
|
191
268
|
if (options?.featured !== void 0) {
|
|
192
269
|
filters.push(`@.featured==${options.featured}`);
|
|
@@ -195,7 +272,7 @@ var CatalogueQueries = class {
|
|
|
195
272
|
filters.push(`@.in_stock==${options.in_stock}`);
|
|
196
273
|
}
|
|
197
274
|
if (options?.search) {
|
|
198
|
-
filters.push(`@.name contains '${options.search}'`);
|
|
275
|
+
filters.push(`@.name contains '${escapeQueryValue(options.search)}'`);
|
|
199
276
|
}
|
|
200
277
|
if (options?.min_price !== void 0) {
|
|
201
278
|
filters.push(`@.price>=${options.min_price}`);
|
|
@@ -226,7 +303,9 @@ var CatalogueQueries = class {
|
|
|
226
303
|
}
|
|
227
304
|
async getProductBySlug(slug) {
|
|
228
305
|
const filteredResult = await safe(
|
|
229
|
-
this.client.query(
|
|
306
|
+
this.client.query(
|
|
307
|
+
`products[?(@.slug=='${escapeQueryValue(slug)}')]`
|
|
308
|
+
)
|
|
230
309
|
);
|
|
231
310
|
if (!filteredResult.ok) return filteredResult;
|
|
232
311
|
const exactMatch = findProductBySlug(filteredResult.value, slug);
|
|
@@ -278,7 +357,7 @@ var CatalogueQueries = class {
|
|
|
278
357
|
}
|
|
279
358
|
async getCategoryBySlug(slug) {
|
|
280
359
|
const result = await safe(
|
|
281
|
-
this.client.query(`categories[?(@.slug=='${slug}')]`)
|
|
360
|
+
this.client.query(`categories[?(@.slug=='${escapeQueryValue(slug)}')]`)
|
|
282
361
|
);
|
|
283
362
|
if (!result.ok) return result;
|
|
284
363
|
if (!result.value.length) {
|
|
@@ -287,7 +366,11 @@ var CatalogueQueries = class {
|
|
|
287
366
|
return ok(result.value[0]);
|
|
288
367
|
}
|
|
289
368
|
async getCategoryProducts(categoryId) {
|
|
290
|
-
return safe(
|
|
369
|
+
return safe(
|
|
370
|
+
this.client.query(
|
|
371
|
+
`products[?(@.category_id=='${escapeQueryValue(categoryId)}')]`
|
|
372
|
+
)
|
|
373
|
+
);
|
|
291
374
|
}
|
|
292
375
|
async getCollections() {
|
|
293
376
|
return safe(this.client.query("collections"));
|
|
@@ -297,7 +380,9 @@ var CatalogueQueries = class {
|
|
|
297
380
|
}
|
|
298
381
|
async getCollectionBySlug(slug) {
|
|
299
382
|
const result = await safe(
|
|
300
|
-
this.client.query(
|
|
383
|
+
this.client.query(
|
|
384
|
+
`collections[?(@.slug=='${escapeQueryValue(slug)}')]`
|
|
385
|
+
)
|
|
301
386
|
);
|
|
302
387
|
if (!result.ok) return result;
|
|
303
388
|
if (!result.value.length) {
|
|
@@ -310,7 +395,9 @@ var CatalogueQueries = class {
|
|
|
310
395
|
}
|
|
311
396
|
async searchCollections(query2, limit = 20) {
|
|
312
397
|
return safe(
|
|
313
|
-
this.client.query(
|
|
398
|
+
this.client.query(
|
|
399
|
+
`collections[?(@.name contains '${escapeQueryValue(query2)}')]#limit(${limit})`
|
|
400
|
+
)
|
|
314
401
|
);
|
|
315
402
|
}
|
|
316
403
|
async getBundles() {
|
|
@@ -321,7 +408,9 @@ var CatalogueQueries = class {
|
|
|
321
408
|
}
|
|
322
409
|
async getBundleBySlug(slug) {
|
|
323
410
|
const result = await safe(
|
|
324
|
-
this.client.query(
|
|
411
|
+
this.client.query(
|
|
412
|
+
`bundles[?(@.slug=='${escapeQueryValue(slug)}')]`
|
|
413
|
+
)
|
|
325
414
|
);
|
|
326
415
|
if (!result.ok) return result;
|
|
327
416
|
if (!result.value.length) {
|
|
@@ -331,7 +420,9 @@ var CatalogueQueries = class {
|
|
|
331
420
|
}
|
|
332
421
|
async searchBundles(query2, limit = 20) {
|
|
333
422
|
return safe(
|
|
334
|
-
this.client.query(
|
|
423
|
+
this.client.query(
|
|
424
|
+
`bundles[?(@.name contains '${escapeQueryValue(query2)}')]#limit(${limit})`
|
|
425
|
+
)
|
|
335
426
|
);
|
|
336
427
|
}
|
|
337
428
|
async getComposites(options) {
|
|
@@ -371,9 +462,9 @@ var CatalogueQueries = class {
|
|
|
371
462
|
}
|
|
372
463
|
async search(query2, options) {
|
|
373
464
|
const limit = options?.limit ?? 20;
|
|
374
|
-
let searchQuery = `products[?(@.name contains '${query2}')]`;
|
|
465
|
+
let searchQuery = `products[?(@.name contains '${escapeQueryValue(query2)}')]`;
|
|
375
466
|
if (options?.category) {
|
|
376
|
-
searchQuery = `products[?(@.name contains '${query2}' && @.category_id=='${options.category}')]`;
|
|
467
|
+
searchQuery = `products[?(@.name contains '${escapeQueryValue(query2)}' && @.category_id=='${escapeQueryValue(options.category)}')]`;
|
|
377
468
|
}
|
|
378
469
|
searchQuery += `#limit(${limit})`;
|
|
379
470
|
return safe(this.client.query(searchQuery));
|
|
@@ -390,7 +481,7 @@ var CatalogueQueries = class {
|
|
|
390
481
|
async getMenu(options) {
|
|
391
482
|
let query2 = "menu";
|
|
392
483
|
if (options?.category) {
|
|
393
|
-
query2 = `menu[?(@.category=='${options.category}')]`;
|
|
484
|
+
query2 = `menu[?(@.category=='${escapeQueryValue(options.category)}')]`;
|
|
394
485
|
}
|
|
395
486
|
if (options?.limit) {
|
|
396
487
|
query2 += `#limit(${options.limit})`;
|
|
@@ -537,9 +628,6 @@ var CartOperations = class {
|
|
|
537
628
|
|
|
538
629
|
// src/constants.ts
|
|
539
630
|
var LINK_QUERY = {
|
|
540
|
-
DATA: "link.data",
|
|
541
|
-
ADDRESSES: "link.addresses",
|
|
542
|
-
MOBILE_MONEY: "link.mobile_money",
|
|
543
631
|
PREFERENCES: "link.preferences"};
|
|
544
632
|
var LINK_MUTATION = {
|
|
545
633
|
CHECK_STATUS: "link.check_status",
|
|
@@ -548,12 +636,8 @@ var LINK_MUTATION = {
|
|
|
548
636
|
UPDATE_PREFERENCES: "link.update_preferences",
|
|
549
637
|
CREATE_ADDRESS: "link.create_address",
|
|
550
638
|
UPDATE_ADDRESS: "link.update_address",
|
|
551
|
-
DELETE_ADDRESS: "link.delete_address",
|
|
552
|
-
SET_DEFAULT_ADDRESS: "link.set_default_address",
|
|
553
639
|
TRACK_ADDRESS_USAGE: "link.track_address_usage",
|
|
554
640
|
CREATE_MOBILE_MONEY: "link.create_mobile_money",
|
|
555
|
-
DELETE_MOBILE_MONEY: "link.delete_mobile_money",
|
|
556
|
-
SET_DEFAULT_MOBILE_MONEY: "link.set_default_mobile_money",
|
|
557
641
|
TRACK_MOBILE_MONEY_USAGE: "link.track_mobile_money_usage",
|
|
558
642
|
VERIFY_MOBILE_MONEY: "link.verify_mobile_money"};
|
|
559
643
|
var AUTH_MUTATION = {
|
|
@@ -671,6 +755,8 @@ function normalizeStatusResponse(response) {
|
|
|
671
755
|
}
|
|
672
756
|
const res = response;
|
|
673
757
|
const normalizedStatus = normalizePaymentStatusValue(res.status ?? void 0);
|
|
758
|
+
const normalizedAmount = typeof res.amount === "string" ? money(res.amount) : typeof res.amount === "number" && Number.isFinite(res.amount) ? moneyFromNumber(res.amount) : void 0;
|
|
759
|
+
const normalizedCurrency = typeof res.currency === "string" && res.currency.trim().length > 0 ? currencyCode(res.currency) : void 0;
|
|
674
760
|
const paidValue = res.paid === true;
|
|
675
761
|
const derivedPaid = paidValue || [
|
|
676
762
|
"success",
|
|
@@ -683,8 +769,8 @@ function normalizeStatusResponse(response) {
|
|
|
683
769
|
return {
|
|
684
770
|
status: normalizedStatus,
|
|
685
771
|
paid: derivedPaid,
|
|
686
|
-
amount:
|
|
687
|
-
currency:
|
|
772
|
+
amount: normalizedAmount,
|
|
773
|
+
currency: normalizedCurrency,
|
|
688
774
|
reference: res.reference,
|
|
689
775
|
message: res.message || ""
|
|
690
776
|
};
|
|
@@ -1376,14 +1462,17 @@ var CheckoutService = class {
|
|
|
1376
1462
|
pay_currency: data.pay_currency,
|
|
1377
1463
|
fx_quote_id: data.fx_quote_id
|
|
1378
1464
|
};
|
|
1379
|
-
const baseCurrency = (
|
|
1465
|
+
const baseCurrency = currencyCode(
|
|
1466
|
+
(cart.pricing.currency || checkoutData.pay_currency || "GHS").toUpperCase()
|
|
1467
|
+
);
|
|
1380
1468
|
const payCurrency = data.pay_currency?.trim().toUpperCase();
|
|
1469
|
+
const payCurrencyCode = payCurrency ? currencyCode(payCurrency) : void 0;
|
|
1381
1470
|
const cartTotalAmount = Number.parseFloat(cart.pricing.total_price || "0");
|
|
1382
|
-
if (
|
|
1471
|
+
if (payCurrencyCode && payCurrencyCode !== baseCurrency && !checkoutData.fx_quote_id && Number.isFinite(cartTotalAmount) && cartTotalAmount > 0) {
|
|
1383
1472
|
const fxQuoteResult = await this.client.fx.lockQuote({
|
|
1384
1473
|
from: baseCurrency,
|
|
1385
|
-
to:
|
|
1386
|
-
amount:
|
|
1474
|
+
to: payCurrencyCode,
|
|
1475
|
+
amount: cart.pricing.total_price
|
|
1387
1476
|
});
|
|
1388
1477
|
if (!fxQuoteResult.ok) {
|
|
1389
1478
|
return ok(
|
|
@@ -1394,7 +1483,7 @@ var CheckoutService = class {
|
|
|
1394
1483
|
)
|
|
1395
1484
|
);
|
|
1396
1485
|
}
|
|
1397
|
-
checkoutData.pay_currency =
|
|
1486
|
+
checkoutData.pay_currency = payCurrencyCode;
|
|
1398
1487
|
checkoutData.fx_quote_id = fxQuoteResult.value.id;
|
|
1399
1488
|
}
|
|
1400
1489
|
data.on_status_change?.("processing", {});
|
|
@@ -1499,6 +1588,9 @@ var LinkService = class {
|
|
|
1499
1588
|
constructor(client) {
|
|
1500
1589
|
this.client = client;
|
|
1501
1590
|
}
|
|
1591
|
+
async getProfile() {
|
|
1592
|
+
return safe5(this.client.linkGet("/v1/link/profile"));
|
|
1593
|
+
}
|
|
1502
1594
|
async requestOtp(input) {
|
|
1503
1595
|
return safe5(this.client.linkPost("/v1/link/auth/request-otp", input));
|
|
1504
1596
|
}
|
|
@@ -1526,13 +1618,13 @@ var LinkService = class {
|
|
|
1526
1618
|
);
|
|
1527
1619
|
}
|
|
1528
1620
|
async getLinkData() {
|
|
1529
|
-
return safe5(this.client.
|
|
1621
|
+
return safe5(this.client.linkGet("/v1/link/data"));
|
|
1530
1622
|
}
|
|
1531
1623
|
async getAddresses() {
|
|
1532
|
-
return safe5(this.client.
|
|
1624
|
+
return safe5(this.client.linkGet("/v1/link/addresses"));
|
|
1533
1625
|
}
|
|
1534
1626
|
async getMobileMoney() {
|
|
1535
|
-
return safe5(this.client.
|
|
1627
|
+
return safe5(this.client.linkGet("/v1/link/mobile-money"));
|
|
1536
1628
|
}
|
|
1537
1629
|
async getPreferences() {
|
|
1538
1630
|
return safe5(this.client.query(LINK_QUERY.PREFERENCES));
|
|
@@ -1555,10 +1647,10 @@ var LinkService = class {
|
|
|
1555
1647
|
return safe5(this.client.call(LINK_MUTATION.UPDATE_ADDRESS, input));
|
|
1556
1648
|
}
|
|
1557
1649
|
async deleteAddress(addressId) {
|
|
1558
|
-
return safe5(this.client.
|
|
1650
|
+
return safe5(this.client.linkDelete(`/v1/link/addresses/${addressId}`));
|
|
1559
1651
|
}
|
|
1560
1652
|
async setDefaultAddress(addressId) {
|
|
1561
|
-
return safe5(this.client.
|
|
1653
|
+
return safe5(this.client.linkPost(`/v1/link/addresses/${addressId}/default`));
|
|
1562
1654
|
}
|
|
1563
1655
|
async trackAddressUsage(addressId) {
|
|
1564
1656
|
return safe5(
|
|
@@ -1571,11 +1663,13 @@ var LinkService = class {
|
|
|
1571
1663
|
return safe5(this.client.call(LINK_MUTATION.CREATE_MOBILE_MONEY, input));
|
|
1572
1664
|
}
|
|
1573
1665
|
async deleteMobileMoney(mobileMoneyId) {
|
|
1574
|
-
return safe5(
|
|
1666
|
+
return safe5(
|
|
1667
|
+
this.client.linkDelete(`/v1/link/mobile-money/${mobileMoneyId}`)
|
|
1668
|
+
);
|
|
1575
1669
|
}
|
|
1576
1670
|
async setDefaultMobileMoney(mobileMoneyId) {
|
|
1577
1671
|
return safe5(
|
|
1578
|
-
this.client.
|
|
1672
|
+
this.client.linkPost(`/v1/link/mobile-money/${mobileMoneyId}/default`)
|
|
1579
1673
|
);
|
|
1580
1674
|
}
|
|
1581
1675
|
async trackMobileMoneyUsage(mobileMoneyId) {
|
|
@@ -2645,69 +2739,4 @@ function createElements(client, businessId, options) {
|
|
|
2645
2739
|
return new CimplifyElements(client, businessId, options);
|
|
2646
2740
|
}
|
|
2647
2741
|
|
|
2648
|
-
// src/query/builder.ts
|
|
2649
|
-
var QueryBuilder = class {
|
|
2650
|
-
constructor(entity) {
|
|
2651
|
-
this.filters = [];
|
|
2652
|
-
this.modifiers = [];
|
|
2653
|
-
this.pathSegments = [];
|
|
2654
|
-
this.entity = entity;
|
|
2655
|
-
}
|
|
2656
|
-
path(segment) {
|
|
2657
|
-
this.pathSegments.push(segment);
|
|
2658
|
-
return this;
|
|
2659
|
-
}
|
|
2660
|
-
where(field, op, value) {
|
|
2661
|
-
const v = typeof value === "string" ? `'${value}'` : value;
|
|
2662
|
-
if (op === "contains" || op === "startsWith") {
|
|
2663
|
-
this.filters.push(`@.${field} ${op} ${v}`);
|
|
2664
|
-
} else {
|
|
2665
|
-
this.filters.push(`@.${field}${op}${v}`);
|
|
2666
|
-
}
|
|
2667
|
-
return this;
|
|
2668
|
-
}
|
|
2669
|
-
and(field, op, value) {
|
|
2670
|
-
return this.where(field, op, value);
|
|
2671
|
-
}
|
|
2672
|
-
sort(field, order = "asc") {
|
|
2673
|
-
this.modifiers.push(`sort(${field},${order})`);
|
|
2674
|
-
return this;
|
|
2675
|
-
}
|
|
2676
|
-
limit(n) {
|
|
2677
|
-
this.modifiers.push(`limit(${n})`);
|
|
2678
|
-
return this;
|
|
2679
|
-
}
|
|
2680
|
-
offset(n) {
|
|
2681
|
-
this.modifiers.push(`offset(${n})`);
|
|
2682
|
-
return this;
|
|
2683
|
-
}
|
|
2684
|
-
count() {
|
|
2685
|
-
this.modifiers.push("count");
|
|
2686
|
-
return this;
|
|
2687
|
-
}
|
|
2688
|
-
enriched() {
|
|
2689
|
-
this.modifiers.push("enriched");
|
|
2690
|
-
return this;
|
|
2691
|
-
}
|
|
2692
|
-
build() {
|
|
2693
|
-
let query2 = this.entity;
|
|
2694
|
-
if (this.pathSegments.length > 0) {
|
|
2695
|
-
query2 += "." + this.pathSegments.join(".");
|
|
2696
|
-
}
|
|
2697
|
-
if (this.filters.length > 0) {
|
|
2698
|
-
query2 += `[?(${this.filters.join(" && ")})]`;
|
|
2699
|
-
}
|
|
2700
|
-
for (const mod of this.modifiers) {
|
|
2701
|
-
query2 += `#${mod}`;
|
|
2702
|
-
}
|
|
2703
|
-
return query2;
|
|
2704
|
-
}
|
|
2705
|
-
toString() {
|
|
2706
|
-
return this.build();
|
|
2707
|
-
}
|
|
2708
|
-
};
|
|
2709
|
-
function query(entity) {
|
|
2710
|
-
return new QueryBuilder(entity);
|
|
2711
|
-
}
|
|
2712
|
-
|
|
2713
2742
|
export { AuthService, BusinessService, CartOperations, CatalogueQueries, CheckoutService as CheckoutOperations, CheckoutService, CimplifyElement, CimplifyElements, ELEMENT_TYPES, EVENT_TYPES, FxService, InventoryService, LinkService, LiteService, MESSAGE_TYPES, OrderQueries, QueryBuilder, SchedulingService, createElements, generateIdempotencyKey, query };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { M as Money,
|
|
1
|
+
import { M as Money, C as CurrencyCode, h as CimplifyError, q as AuthorizationType, s as PaymentMethod, I as InitializePaymentResult, S as SubmitAuthorizationInput, v as PaymentStatusResponse } from './payment-Cu75tmUc.js';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Observability hooks for monitoring SDK behavior.
|
|
@@ -50,6 +50,8 @@ interface RequestSuccessEvent extends RequestContext {
|
|
|
50
50
|
interface RequestErrorEvent extends RequestContext {
|
|
51
51
|
/** The error that occurred */
|
|
52
52
|
error: Error;
|
|
53
|
+
/** HTTP status code (when available) */
|
|
54
|
+
status?: number;
|
|
53
55
|
/** Duration in milliseconds */
|
|
54
56
|
durationMs: number;
|
|
55
57
|
/** Number of retries attempted before giving up */
|
|
@@ -84,7 +86,7 @@ interface ObservabilityHooks {
|
|
|
84
86
|
onRequestStart?: (event: RequestStartEvent) => void;
|
|
85
87
|
/** Called when a request completes successfully */
|
|
86
88
|
onRequestSuccess?: (event: RequestSuccessEvent) => void;
|
|
87
|
-
/** Called when a request fails (after
|
|
89
|
+
/** Called when a request fails (4xx/5xx responses or network errors after retries) */
|
|
88
90
|
onRequestError?: (event: RequestErrorEvent) => void;
|
|
89
91
|
/** Called before each retry attempt */
|
|
90
92
|
onRetry?: (event: RetryEvent) => void;
|
|
@@ -152,7 +154,7 @@ interface Product {
|
|
|
152
154
|
access_duration_days?: number;
|
|
153
155
|
code_type?: string;
|
|
154
156
|
code_value?: Money;
|
|
155
|
-
code_currency?:
|
|
157
|
+
code_currency?: CurrencyCode;
|
|
156
158
|
duration_minutes?: number;
|
|
157
159
|
preparation_time_minutes?: number;
|
|
158
160
|
staff_required_count?: number;
|
|
@@ -613,7 +615,7 @@ interface ChosenPrice {
|
|
|
613
615
|
markup_amount: Money;
|
|
614
616
|
markup_discount_percentage: Money;
|
|
615
617
|
markup_discount_amount: Money;
|
|
616
|
-
currency?:
|
|
618
|
+
currency?: CurrencyCode;
|
|
617
619
|
custom_fields?: Record<string, unknown>;
|
|
618
620
|
decision_path?: PriceDecisionPath;
|
|
619
621
|
tax_info?: PricePathTaxInfo;
|
|
@@ -758,7 +760,7 @@ interface Cart {
|
|
|
758
760
|
applied_discount_ids: string[];
|
|
759
761
|
applied_discount_codes: string[];
|
|
760
762
|
discount_details?: DiscountDetails;
|
|
761
|
-
currency:
|
|
763
|
+
currency: CurrencyCode;
|
|
762
764
|
customer_name?: string;
|
|
763
765
|
customer_email?: string;
|
|
764
766
|
customer_phone?: string;
|
|
@@ -813,7 +815,7 @@ interface DisplayCart {
|
|
|
813
815
|
total_items: number;
|
|
814
816
|
tax_rate?: Money;
|
|
815
817
|
service_charge_rate?: Money;
|
|
816
|
-
currency:
|
|
818
|
+
currency: CurrencyCode;
|
|
817
819
|
channel: string;
|
|
818
820
|
status: string;
|
|
819
821
|
business_name: string;
|
|
@@ -888,7 +890,7 @@ interface UICartPricing {
|
|
|
888
890
|
total_price: Money;
|
|
889
891
|
tax_rate?: Money;
|
|
890
892
|
service_charge_rate?: Money;
|
|
891
|
-
currency:
|
|
893
|
+
currency: CurrencyCode;
|
|
892
894
|
}
|
|
893
895
|
interface AddOnOptionDetails {
|
|
894
896
|
id: string;
|
|
@@ -1015,7 +1017,7 @@ interface CartSummary {
|
|
|
1015
1017
|
discount_amount: Money;
|
|
1016
1018
|
tax_amount: Money;
|
|
1017
1019
|
total: Money;
|
|
1018
|
-
currency:
|
|
1020
|
+
currency: CurrencyCode;
|
|
1019
1021
|
}
|
|
1020
1022
|
|
|
1021
1023
|
/**
|
|
@@ -1442,7 +1444,7 @@ interface Order {
|
|
|
1442
1444
|
service_charge?: Money;
|
|
1443
1445
|
tax?: Money;
|
|
1444
1446
|
price_info: ChosenPrice;
|
|
1445
|
-
currency:
|
|
1447
|
+
currency: CurrencyCode;
|
|
1446
1448
|
bill_token?: string;
|
|
1447
1449
|
order_group_id?: string;
|
|
1448
1450
|
paid_via_group: boolean;
|
|
@@ -1490,7 +1492,7 @@ interface OrderGroup {
|
|
|
1490
1492
|
payment_status: OrderGroupPaymentState;
|
|
1491
1493
|
split_method?: string;
|
|
1492
1494
|
max_orders?: number;
|
|
1493
|
-
currency?:
|
|
1495
|
+
currency?: CurrencyCode;
|
|
1494
1496
|
amount_to_pay: AmountToPay;
|
|
1495
1497
|
metadata?: Record<string, unknown>;
|
|
1496
1498
|
}
|
|
@@ -2004,7 +2006,7 @@ interface CheckoutFormData {
|
|
|
2004
2006
|
idempotency_key?: string;
|
|
2005
2007
|
/** Optional metadata passed through to the payment provider (e.g. success_url, cancel_url) */
|
|
2006
2008
|
metadata?: Record<string, unknown>;
|
|
2007
|
-
pay_currency?:
|
|
2009
|
+
pay_currency?: CurrencyCode;
|
|
2008
2010
|
fx_quote_id?: string;
|
|
2009
2011
|
}
|
|
2010
2012
|
interface CheckoutResult {
|
|
@@ -2020,10 +2022,10 @@ interface CheckoutResult {
|
|
|
2020
2022
|
client_secret?: string;
|
|
2021
2023
|
public_key?: string;
|
|
2022
2024
|
fx?: {
|
|
2023
|
-
base_currency:
|
|
2024
|
-
base_amount:
|
|
2025
|
-
pay_currency:
|
|
2026
|
-
pay_amount:
|
|
2025
|
+
base_currency: CurrencyCode;
|
|
2026
|
+
base_amount: Money;
|
|
2027
|
+
pay_currency: CurrencyCode;
|
|
2028
|
+
pay_amount: Money;
|
|
2027
2029
|
rate: number;
|
|
2028
2030
|
quote_id: string;
|
|
2029
2031
|
};
|
|
@@ -2046,7 +2048,7 @@ interface ProcessCheckoutOptions {
|
|
|
2046
2048
|
scheduled_time?: string;
|
|
2047
2049
|
tip_amount?: number;
|
|
2048
2050
|
enroll_in_link?: boolean;
|
|
2049
|
-
pay_currency?:
|
|
2051
|
+
pay_currency?: CurrencyCode;
|
|
2050
2052
|
timeout_ms?: number;
|
|
2051
2053
|
on_status_change?: (status: CheckoutStatus, context: CheckoutStatusContext) => void;
|
|
2052
2054
|
}
|
|
@@ -2057,7 +2059,7 @@ interface ProcessCheckoutResult {
|
|
|
2057
2059
|
order_number: string;
|
|
2058
2060
|
status: string;
|
|
2059
2061
|
total: string;
|
|
2060
|
-
currency:
|
|
2062
|
+
currency: CurrencyCode;
|
|
2061
2063
|
};
|
|
2062
2064
|
error?: {
|
|
2063
2065
|
code: string;
|
|
@@ -2139,6 +2141,7 @@ interface SuccessResult$2 {
|
|
|
2139
2141
|
declare class LinkService {
|
|
2140
2142
|
private client;
|
|
2141
2143
|
constructor(client: CimplifyClient);
|
|
2144
|
+
getProfile(): Promise<Result<LinkData["customer"], CimplifyError>>;
|
|
2142
2145
|
requestOtp(input: RequestOtpInput): Promise<Result<SuccessResult$2, CimplifyError>>;
|
|
2143
2146
|
verifyOtp(input: VerifyOtpInput): Promise<Result<AuthResponse, CimplifyError>>;
|
|
2144
2147
|
logout(): Promise<Result<SuccessResult$2, CimplifyError>>;
|
|
@@ -2218,7 +2221,7 @@ interface Business {
|
|
|
2218
2221
|
handle: string;
|
|
2219
2222
|
business_type: BusinessType;
|
|
2220
2223
|
email: string;
|
|
2221
|
-
default_currency:
|
|
2224
|
+
default_currency: CurrencyCode;
|
|
2222
2225
|
default_phone?: string;
|
|
2223
2226
|
default_address?: string;
|
|
2224
2227
|
default_offers_table_service: boolean;
|
|
@@ -2256,7 +2259,7 @@ interface Location {
|
|
|
2256
2259
|
phone?: string;
|
|
2257
2260
|
address?: string;
|
|
2258
2261
|
service_charge_rate?: number;
|
|
2259
|
-
currency:
|
|
2262
|
+
currency: CurrencyCode;
|
|
2260
2263
|
capacity: number;
|
|
2261
2264
|
status: string;
|
|
2262
2265
|
enabled_payment_types?: string[];
|
|
@@ -2323,7 +2326,7 @@ interface StorefrontBootstrap {
|
|
|
2323
2326
|
location?: Location;
|
|
2324
2327
|
locations: Location[];
|
|
2325
2328
|
categories: CategoryInfo[];
|
|
2326
|
-
currency:
|
|
2329
|
+
currency: CurrencyCode;
|
|
2327
2330
|
is_open: boolean;
|
|
2328
2331
|
accepts_orders: boolean;
|
|
2329
2332
|
time_profiles?: LocationTimeProfile[];
|
|
@@ -2653,7 +2656,7 @@ interface Service {
|
|
|
2653
2656
|
buffer_after_minutes: number;
|
|
2654
2657
|
max_participants: number;
|
|
2655
2658
|
price: Money;
|
|
2656
|
-
currency:
|
|
2659
|
+
currency: CurrencyCode;
|
|
2657
2660
|
requires_staff: boolean;
|
|
2658
2661
|
is_active: boolean;
|
|
2659
2662
|
image_url?: string;
|
|
@@ -2873,24 +2876,24 @@ declare class LiteService {
|
|
|
2873
2876
|
}
|
|
2874
2877
|
|
|
2875
2878
|
interface FxQuoteRequest {
|
|
2876
|
-
from:
|
|
2877
|
-
to:
|
|
2878
|
-
amount:
|
|
2879
|
+
from: CurrencyCode;
|
|
2880
|
+
to: CurrencyCode;
|
|
2881
|
+
amount: Money;
|
|
2879
2882
|
}
|
|
2880
2883
|
interface FxQuote {
|
|
2881
2884
|
id: string;
|
|
2882
|
-
base_currency:
|
|
2883
|
-
pay_currency:
|
|
2885
|
+
base_currency: CurrencyCode;
|
|
2886
|
+
pay_currency: CurrencyCode;
|
|
2884
2887
|
rate: number;
|
|
2885
2888
|
inverse_rate: number;
|
|
2886
|
-
base_amount:
|
|
2887
|
-
converted_amount:
|
|
2889
|
+
base_amount: Money;
|
|
2890
|
+
converted_amount: Money;
|
|
2888
2891
|
quoted_at: string;
|
|
2889
2892
|
valid_until: string;
|
|
2890
2893
|
}
|
|
2891
2894
|
interface FxRateResponse {
|
|
2892
|
-
from:
|
|
2893
|
-
to:
|
|
2895
|
+
from: CurrencyCode;
|
|
2896
|
+
to: CurrencyCode;
|
|
2894
2897
|
rate: number;
|
|
2895
2898
|
inverse_rate: number;
|
|
2896
2899
|
quoted_at: string;
|
|
@@ -2900,7 +2903,7 @@ interface FxRateResponse {
|
|
|
2900
2903
|
declare class FxService {
|
|
2901
2904
|
private client;
|
|
2902
2905
|
constructor(client: CimplifyClient);
|
|
2903
|
-
getRate(from:
|
|
2906
|
+
getRate(from: CurrencyCode, to: CurrencyCode): Promise<Result<FxRateResponse, CimplifyError>>;
|
|
2904
2907
|
lockQuote(request: FxQuoteRequest): Promise<Result<FxQuote, CimplifyError>>;
|
|
2905
2908
|
}
|
|
2906
2909
|
|
|
@@ -2947,7 +2950,7 @@ interface ElementOptions {
|
|
|
2947
2950
|
mode?: "shipping" | "billing";
|
|
2948
2951
|
prefillEmail?: string;
|
|
2949
2952
|
amount?: number;
|
|
2950
|
-
currency?:
|
|
2953
|
+
currency?: CurrencyCode;
|
|
2951
2954
|
}
|
|
2952
2955
|
interface AddressInfo {
|
|
2953
2956
|
id?: string;
|
|
@@ -3028,7 +3031,7 @@ type ParentToIframeMessage = {
|
|
|
3028
3031
|
notes?: string;
|
|
3029
3032
|
scheduled_time?: string;
|
|
3030
3033
|
tip_amount?: number;
|
|
3031
|
-
pay_currency?:
|
|
3034
|
+
pay_currency?: CurrencyCode;
|
|
3032
3035
|
enroll_in_link?: boolean;
|
|
3033
3036
|
address?: AddressInfo;
|
|
3034
3037
|
customer: ElementsCustomerInfo;
|
|
@@ -3084,7 +3087,7 @@ type IframeToParentMessage = {
|
|
|
3084
3087
|
order_number: string;
|
|
3085
3088
|
status: string;
|
|
3086
3089
|
total: string;
|
|
3087
|
-
currency:
|
|
3090
|
+
currency: CurrencyCode;
|
|
3088
3091
|
};
|
|
3089
3092
|
error?: {
|
|
3090
3093
|
code: string;
|
|
@@ -3170,6 +3173,8 @@ declare function createElements(client: CimplifyClient, businessId?: string, opt
|
|
|
3170
3173
|
interface CimplifyConfig {
|
|
3171
3174
|
publicKey?: string;
|
|
3172
3175
|
credentials?: RequestCredentials;
|
|
3176
|
+
/** Disable console warning when no public key is provided (for Link REST-only portal usage). */
|
|
3177
|
+
suppressPublicKeyWarning?: boolean;
|
|
3173
3178
|
/** Request timeout in milliseconds (default: 30000) */
|
|
3174
3179
|
timeout?: number;
|
|
3175
3180
|
/** Maximum retry attempts for retryable errors (default: 3) */
|