@cimplify/sdk 0.22.2 → 0.22.4
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/advanced.js +20 -20
- package/dist/advanced.mjs +1 -1
- package/dist/{chunk-VYSXEDBV.js → chunk-4M2D57C3.js} +51 -3
- package/dist/{chunk-W3DMONZR.mjs → chunk-JD3ZHI4S.mjs} +1 -1
- package/dist/{chunk-S6TU55KP.js → chunk-L5GKVQVJ.js} +16 -0
- package/dist/{chunk-A7IQN5EK.js → chunk-RRO6ZDZI.js} +17 -17
- package/dist/{chunk-R4EYMPSN.mjs → chunk-WX54U6Y2.mjs} +51 -3
- package/dist/{chunk-WDIMISRC.mjs → chunk-YOIVZ6OA.mjs} +16 -0
- package/dist/index.js +62 -62
- package/dist/index.mjs +3 -3
- package/dist/react.js +44 -19
- package/dist/react.mjs +28 -3
- package/dist/utils.js +4 -4
- package/dist/utils.mjs +1 -1
- package/package.json +1 -1
package/dist/advanced.js
CHANGED
|
@@ -1,83 +1,83 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunk4M2D57C3_js = require('./chunk-4M2D57C3.js');
|
|
4
4
|
require('./chunk-64OCG2TJ.js');
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
|
|
8
8
|
Object.defineProperty(exports, "AuthService", {
|
|
9
9
|
enumerable: true,
|
|
10
|
-
get: function () { return
|
|
10
|
+
get: function () { return chunk4M2D57C3_js.AuthService; }
|
|
11
11
|
});
|
|
12
12
|
Object.defineProperty(exports, "BusinessService", {
|
|
13
13
|
enumerable: true,
|
|
14
|
-
get: function () { return
|
|
14
|
+
get: function () { return chunk4M2D57C3_js.BusinessService; }
|
|
15
15
|
});
|
|
16
16
|
Object.defineProperty(exports, "CartOperations", {
|
|
17
17
|
enumerable: true,
|
|
18
|
-
get: function () { return
|
|
18
|
+
get: function () { return chunk4M2D57C3_js.CartOperations; }
|
|
19
19
|
});
|
|
20
20
|
Object.defineProperty(exports, "CatalogueQueries", {
|
|
21
21
|
enumerable: true,
|
|
22
|
-
get: function () { return
|
|
22
|
+
get: function () { return chunk4M2D57C3_js.CatalogueQueries; }
|
|
23
23
|
});
|
|
24
24
|
Object.defineProperty(exports, "CheckoutOperations", {
|
|
25
25
|
enumerable: true,
|
|
26
|
-
get: function () { return
|
|
26
|
+
get: function () { return chunk4M2D57C3_js.CheckoutService; }
|
|
27
27
|
});
|
|
28
28
|
Object.defineProperty(exports, "CheckoutService", {
|
|
29
29
|
enumerable: true,
|
|
30
|
-
get: function () { return
|
|
30
|
+
get: function () { return chunk4M2D57C3_js.CheckoutService; }
|
|
31
31
|
});
|
|
32
32
|
Object.defineProperty(exports, "CimplifyElement", {
|
|
33
33
|
enumerable: true,
|
|
34
|
-
get: function () { return
|
|
34
|
+
get: function () { return chunk4M2D57C3_js.CimplifyElement; }
|
|
35
35
|
});
|
|
36
36
|
Object.defineProperty(exports, "CimplifyElements", {
|
|
37
37
|
enumerable: true,
|
|
38
|
-
get: function () { return
|
|
38
|
+
get: function () { return chunk4M2D57C3_js.CimplifyElements; }
|
|
39
39
|
});
|
|
40
40
|
Object.defineProperty(exports, "ELEMENT_TYPES", {
|
|
41
41
|
enumerable: true,
|
|
42
|
-
get: function () { return
|
|
42
|
+
get: function () { return chunk4M2D57C3_js.ELEMENT_TYPES; }
|
|
43
43
|
});
|
|
44
44
|
Object.defineProperty(exports, "EVENT_TYPES", {
|
|
45
45
|
enumerable: true,
|
|
46
|
-
get: function () { return
|
|
46
|
+
get: function () { return chunk4M2D57C3_js.EVENT_TYPES; }
|
|
47
47
|
});
|
|
48
48
|
Object.defineProperty(exports, "FxService", {
|
|
49
49
|
enumerable: true,
|
|
50
|
-
get: function () { return
|
|
50
|
+
get: function () { return chunk4M2D57C3_js.FxService; }
|
|
51
51
|
});
|
|
52
52
|
Object.defineProperty(exports, "InventoryService", {
|
|
53
53
|
enumerable: true,
|
|
54
|
-
get: function () { return
|
|
54
|
+
get: function () { return chunk4M2D57C3_js.InventoryService; }
|
|
55
55
|
});
|
|
56
56
|
Object.defineProperty(exports, "LinkService", {
|
|
57
57
|
enumerable: true,
|
|
58
|
-
get: function () { return
|
|
58
|
+
get: function () { return chunk4M2D57C3_js.LinkService; }
|
|
59
59
|
});
|
|
60
60
|
Object.defineProperty(exports, "LiteService", {
|
|
61
61
|
enumerable: true,
|
|
62
|
-
get: function () { return
|
|
62
|
+
get: function () { return chunk4M2D57C3_js.LiteService; }
|
|
63
63
|
});
|
|
64
64
|
Object.defineProperty(exports, "MESSAGE_TYPES", {
|
|
65
65
|
enumerable: true,
|
|
66
|
-
get: function () { return
|
|
66
|
+
get: function () { return chunk4M2D57C3_js.MESSAGE_TYPES; }
|
|
67
67
|
});
|
|
68
68
|
Object.defineProperty(exports, "OrderQueries", {
|
|
69
69
|
enumerable: true,
|
|
70
|
-
get: function () { return
|
|
70
|
+
get: function () { return chunk4M2D57C3_js.OrderQueries; }
|
|
71
71
|
});
|
|
72
72
|
Object.defineProperty(exports, "SchedulingService", {
|
|
73
73
|
enumerable: true,
|
|
74
|
-
get: function () { return
|
|
74
|
+
get: function () { return chunk4M2D57C3_js.SchedulingService; }
|
|
75
75
|
});
|
|
76
76
|
Object.defineProperty(exports, "createElements", {
|
|
77
77
|
enumerable: true,
|
|
78
|
-
get: function () { return
|
|
78
|
+
get: function () { return chunk4M2D57C3_js.createElements; }
|
|
79
79
|
});
|
|
80
80
|
Object.defineProperty(exports, "generateIdempotencyKey", {
|
|
81
81
|
enumerable: true,
|
|
82
|
-
get: function () { return
|
|
82
|
+
get: function () { return chunk4M2D57C3_js.generateIdempotencyKey; }
|
|
83
83
|
});
|
package/dist/advanced.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { AuthService, BusinessService, CartOperations, CatalogueQueries, CheckoutService as CheckoutOperations, CheckoutService, CimplifyElement, CimplifyElements, ELEMENT_TYPES, EVENT_TYPES, FxService, InventoryService, LinkService, LiteService, MESSAGE_TYPES, OrderQueries, SchedulingService, createElements, generateIdempotencyKey } from './chunk-
|
|
1
|
+
export { AuthService, BusinessService, CartOperations, CatalogueQueries, CheckoutService as CheckoutOperations, CheckoutService, CimplifyElement, CimplifyElements, ELEMENT_TYPES, EVENT_TYPES, FxService, InventoryService, LinkService, LiteService, MESSAGE_TYPES, OrderQueries, SchedulingService, createElements, generateIdempotencyKey } from './chunk-WX54U6Y2.mjs';
|
|
2
2
|
import './chunk-JFT63H34.mjs';
|
|
@@ -274,7 +274,20 @@ var CatalogueQueries = class {
|
|
|
274
274
|
const encodedId = encodeURIComponent(id);
|
|
275
275
|
const result = await safe(this.client.get(`/api/v1/catalogue/products/${encodedId}`));
|
|
276
276
|
if (!result.ok) return result;
|
|
277
|
-
|
|
277
|
+
const payload = result.value;
|
|
278
|
+
const rawProduct = isRecord(payload.item) ? payload.item : payload;
|
|
279
|
+
const product = normalizeCatalogueProductPayload(rawProduct);
|
|
280
|
+
if (isRecord(payload.category)) {
|
|
281
|
+
product.category = payload.category;
|
|
282
|
+
}
|
|
283
|
+
const addOnIds = rawProduct.add_on_ids;
|
|
284
|
+
if (Array.isArray(addOnIds) && addOnIds.length > 0) {
|
|
285
|
+
const addOnsResult = await this.getAddOns(product.id);
|
|
286
|
+
if (addOnsResult.ok) {
|
|
287
|
+
product.add_ons = addOnsResult.value;
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
return ok(product);
|
|
278
291
|
}
|
|
279
292
|
async getProductBySlug(slug) {
|
|
280
293
|
return this.getProduct(slug);
|
|
@@ -2254,14 +2267,49 @@ function isAllowedOrigin(origin) {
|
|
|
2254
2267
|
return false;
|
|
2255
2268
|
}
|
|
2256
2269
|
}
|
|
2270
|
+
var KNOWN_IFRAME_TYPES = new Set(Object.values(MESSAGE_TYPES));
|
|
2257
2271
|
function parseIframeMessage(data) {
|
|
2258
2272
|
if (!data || typeof data !== "object") {
|
|
2259
2273
|
return null;
|
|
2260
2274
|
}
|
|
2261
|
-
const
|
|
2262
|
-
if (typeof
|
|
2275
|
+
const record = data;
|
|
2276
|
+
if (typeof record.type !== "string" || !KNOWN_IFRAME_TYPES.has(record.type)) {
|
|
2263
2277
|
return null;
|
|
2264
2278
|
}
|
|
2279
|
+
switch (record.type) {
|
|
2280
|
+
case MESSAGE_TYPES.AUTHENTICATED:
|
|
2281
|
+
if (typeof record.token !== "string") return null;
|
|
2282
|
+
break;
|
|
2283
|
+
case MESSAGE_TYPES.TOKEN_REFRESHED:
|
|
2284
|
+
if (typeof record.token !== "string") return null;
|
|
2285
|
+
break;
|
|
2286
|
+
case MESSAGE_TYPES.ADDRESS_CHANGED:
|
|
2287
|
+
case MESSAGE_TYPES.ADDRESS_SELECTED:
|
|
2288
|
+
if (!record.address || typeof record.address !== "object") return null;
|
|
2289
|
+
break;
|
|
2290
|
+
case MESSAGE_TYPES.PAYMENT_METHOD_SELECTED:
|
|
2291
|
+
if (!record.method || typeof record.method !== "object") return null;
|
|
2292
|
+
break;
|
|
2293
|
+
case MESSAGE_TYPES.CONTACT_PROVIDED:
|
|
2294
|
+
if (typeof record.contact !== "string" || typeof record.contactType !== "string") return null;
|
|
2295
|
+
break;
|
|
2296
|
+
case MESSAGE_TYPES.ERROR:
|
|
2297
|
+
if (typeof record.code !== "string" || typeof record.message !== "string") return null;
|
|
2298
|
+
break;
|
|
2299
|
+
case MESSAGE_TYPES.CHECKOUT_COMPLETE:
|
|
2300
|
+
if (typeof record.success !== "boolean") return null;
|
|
2301
|
+
break;
|
|
2302
|
+
case MESSAGE_TYPES.READY:
|
|
2303
|
+
case MESSAGE_TYPES.HEIGHT_CHANGE:
|
|
2304
|
+
if (typeof record.height !== "number") return null;
|
|
2305
|
+
break;
|
|
2306
|
+
case MESSAGE_TYPES.REQUIRES_OTP:
|
|
2307
|
+
if (typeof record.contactMasked !== "string") return null;
|
|
2308
|
+
break;
|
|
2309
|
+
case MESSAGE_TYPES.ORDER_TYPE_CHANGED:
|
|
2310
|
+
if (typeof record.orderType !== "string") return null;
|
|
2311
|
+
break;
|
|
2312
|
+
}
|
|
2265
2313
|
return data;
|
|
2266
2314
|
}
|
|
2267
2315
|
var CimplifyElements = class {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { safe, CatalogueQueries, CartOperations, CheckoutService, OrderQueries, LinkService, AuthService, BusinessService, InventoryService, SchedulingService, LiteService, FxService, createElements } from './chunk-
|
|
1
|
+
import { safe, CatalogueQueries, CartOperations, CheckoutService, OrderQueries, LinkService, AuthService, BusinessService, InventoryService, SchedulingService, LiteService, FxService, createElements } from './chunk-WX54U6Y2.mjs';
|
|
2
2
|
import { CimplifyError, ErrorCode, enrichError } from './chunk-JFT63H34.mjs';
|
|
3
3
|
|
|
4
4
|
// src/activity.ts
|
|
@@ -97,6 +97,12 @@ var CURRENCY_TO_COUNTRY_CODE = {
|
|
|
97
97
|
ZAR: "ZA",
|
|
98
98
|
ZMW: "ZM"
|
|
99
99
|
};
|
|
100
|
+
var CURRENCY_TO_CANDIDATE_COUNTRIES = {
|
|
101
|
+
EUR: ["DE", "FR", "IT", "ES", "NL", "BE", "AT", "PT", "IE", "FI", "GR"],
|
|
102
|
+
USD: ["US", "EC", "PA", "SV"],
|
|
103
|
+
XOF: ["SN", "CI", "BF", "ML", "NE", "TG", "BJ", "GW"],
|
|
104
|
+
XAF: ["CM", "GA", "CG", "TD", "CF", "GQ"]
|
|
105
|
+
};
|
|
100
106
|
function normalizeCountryCode(value) {
|
|
101
107
|
const normalized = value?.trim().toUpperCase();
|
|
102
108
|
if (!normalized) {
|
|
@@ -153,6 +159,16 @@ function normalizePhoneToE164(raw, options = {}) {
|
|
|
153
159
|
if (internationalDigits) {
|
|
154
160
|
addAttempt(`+${internationalDigits}`);
|
|
155
161
|
}
|
|
162
|
+
const currency = options.currency?.trim().toUpperCase();
|
|
163
|
+
if (currency) {
|
|
164
|
+
const candidates = CURRENCY_TO_CANDIDATE_COUNTRIES[currency];
|
|
165
|
+
if (candidates) {
|
|
166
|
+
for (const candidate of candidates) {
|
|
167
|
+
addAttempt(trimmed, candidate);
|
|
168
|
+
if (digits) addAttempt(digits, candidate);
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
}
|
|
156
172
|
for (const attempt of attempts) {
|
|
157
173
|
const parsed = parsePhoneCandidate(attempt.value, attempt.country);
|
|
158
174
|
if (parsed?.isValid()) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunk4M2D57C3_js = require('./chunk-4M2D57C3.js');
|
|
4
4
|
var chunk64OCG2TJ_js = require('./chunk-64OCG2TJ.js');
|
|
5
5
|
|
|
6
6
|
// src/activity.ts
|
|
@@ -29,7 +29,7 @@ var ActivityService = class {
|
|
|
29
29
|
this.sendEvents([event]);
|
|
30
30
|
}
|
|
31
31
|
async getState() {
|
|
32
|
-
return
|
|
32
|
+
return chunk4M2D57C3_js.safe(this.client.get("/api/v1/activity/state"));
|
|
33
33
|
}
|
|
34
34
|
async getRecommendations(options) {
|
|
35
35
|
const params = new URLSearchParams();
|
|
@@ -37,10 +37,10 @@ var ActivityService = class {
|
|
|
37
37
|
if (options?.limit) params.set("limit", String(options.limit));
|
|
38
38
|
const query = params.toString();
|
|
39
39
|
const path = query ? `/api/v1/activity/recommendations?${query}` : "/api/v1/activity/recommendations";
|
|
40
|
-
return
|
|
40
|
+
return chunk4M2D57C3_js.safe(this.client.get(path));
|
|
41
41
|
}
|
|
42
42
|
async dismissMessage(code) {
|
|
43
|
-
return
|
|
43
|
+
return chunk4M2D57C3_js.safe(
|
|
44
44
|
this.client.post("/api/v1/activity/messages/dismiss", { code })
|
|
45
45
|
);
|
|
46
46
|
}
|
|
@@ -66,7 +66,7 @@ var DeliveryService = class {
|
|
|
66
66
|
params.set("dropoff_lat", String(dropoffLat));
|
|
67
67
|
params.set("dropoff_lng", String(dropoffLng));
|
|
68
68
|
if (country) params.set("country", country);
|
|
69
|
-
return
|
|
69
|
+
return chunk4M2D57C3_js.safe(
|
|
70
70
|
this.client.get(`/api/v1/delivery/fee?${params.toString()}`)
|
|
71
71
|
);
|
|
72
72
|
}
|
|
@@ -597,67 +597,67 @@ var CimplifyClient = class {
|
|
|
597
597
|
}
|
|
598
598
|
get catalogue() {
|
|
599
599
|
if (!this._catalogue) {
|
|
600
|
-
this._catalogue = new
|
|
600
|
+
this._catalogue = new chunk4M2D57C3_js.CatalogueQueries(this);
|
|
601
601
|
}
|
|
602
602
|
return this._catalogue;
|
|
603
603
|
}
|
|
604
604
|
get cart() {
|
|
605
605
|
if (!this._cart) {
|
|
606
|
-
this._cart = new
|
|
606
|
+
this._cart = new chunk4M2D57C3_js.CartOperations(this);
|
|
607
607
|
}
|
|
608
608
|
return this._cart;
|
|
609
609
|
}
|
|
610
610
|
get checkout() {
|
|
611
611
|
if (!this._checkout) {
|
|
612
|
-
this._checkout = new
|
|
612
|
+
this._checkout = new chunk4M2D57C3_js.CheckoutService(this);
|
|
613
613
|
}
|
|
614
614
|
return this._checkout;
|
|
615
615
|
}
|
|
616
616
|
get orders() {
|
|
617
617
|
if (!this._orders) {
|
|
618
|
-
this._orders = new
|
|
618
|
+
this._orders = new chunk4M2D57C3_js.OrderQueries(this);
|
|
619
619
|
}
|
|
620
620
|
return this._orders;
|
|
621
621
|
}
|
|
622
622
|
get link() {
|
|
623
623
|
if (!this._link) {
|
|
624
|
-
this._link = new
|
|
624
|
+
this._link = new chunk4M2D57C3_js.LinkService(this);
|
|
625
625
|
}
|
|
626
626
|
return this._link;
|
|
627
627
|
}
|
|
628
628
|
get auth() {
|
|
629
629
|
if (!this._auth) {
|
|
630
|
-
this._auth = new
|
|
630
|
+
this._auth = new chunk4M2D57C3_js.AuthService(this);
|
|
631
631
|
}
|
|
632
632
|
return this._auth;
|
|
633
633
|
}
|
|
634
634
|
get business() {
|
|
635
635
|
if (!this._business) {
|
|
636
|
-
this._business = new
|
|
636
|
+
this._business = new chunk4M2D57C3_js.BusinessService(this);
|
|
637
637
|
}
|
|
638
638
|
return this._business;
|
|
639
639
|
}
|
|
640
640
|
get inventory() {
|
|
641
641
|
if (!this._inventory) {
|
|
642
|
-
this._inventory = new
|
|
642
|
+
this._inventory = new chunk4M2D57C3_js.InventoryService(this);
|
|
643
643
|
}
|
|
644
644
|
return this._inventory;
|
|
645
645
|
}
|
|
646
646
|
get scheduling() {
|
|
647
647
|
if (!this._scheduling) {
|
|
648
|
-
this._scheduling = new
|
|
648
|
+
this._scheduling = new chunk4M2D57C3_js.SchedulingService(this);
|
|
649
649
|
}
|
|
650
650
|
return this._scheduling;
|
|
651
651
|
}
|
|
652
652
|
get lite() {
|
|
653
653
|
if (!this._lite) {
|
|
654
|
-
this._lite = new
|
|
654
|
+
this._lite = new chunk4M2D57C3_js.LiteService(this);
|
|
655
655
|
}
|
|
656
656
|
return this._lite;
|
|
657
657
|
}
|
|
658
658
|
get fx() {
|
|
659
659
|
if (!this._fx) {
|
|
660
|
-
this._fx = new
|
|
660
|
+
this._fx = new chunk4M2D57C3_js.FxService(this);
|
|
661
661
|
}
|
|
662
662
|
return this._fx;
|
|
663
663
|
}
|
|
@@ -677,7 +677,7 @@ var CimplifyClient = class {
|
|
|
677
677
|
if (businessId) {
|
|
678
678
|
this.setBusinessId(businessId);
|
|
679
679
|
}
|
|
680
|
-
return
|
|
680
|
+
return chunk4M2D57C3_js.createElements(this, businessId ?? this.businessId ?? void 0, options);
|
|
681
681
|
}
|
|
682
682
|
};
|
|
683
683
|
function createCimplifyClient(config = {}) {
|
|
@@ -272,7 +272,20 @@ var CatalogueQueries = class {
|
|
|
272
272
|
const encodedId = encodeURIComponent(id);
|
|
273
273
|
const result = await safe(this.client.get(`/api/v1/catalogue/products/${encodedId}`));
|
|
274
274
|
if (!result.ok) return result;
|
|
275
|
-
|
|
275
|
+
const payload = result.value;
|
|
276
|
+
const rawProduct = isRecord(payload.item) ? payload.item : payload;
|
|
277
|
+
const product = normalizeCatalogueProductPayload(rawProduct);
|
|
278
|
+
if (isRecord(payload.category)) {
|
|
279
|
+
product.category = payload.category;
|
|
280
|
+
}
|
|
281
|
+
const addOnIds = rawProduct.add_on_ids;
|
|
282
|
+
if (Array.isArray(addOnIds) && addOnIds.length > 0) {
|
|
283
|
+
const addOnsResult = await this.getAddOns(product.id);
|
|
284
|
+
if (addOnsResult.ok) {
|
|
285
|
+
product.add_ons = addOnsResult.value;
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
return ok(product);
|
|
276
289
|
}
|
|
277
290
|
async getProductBySlug(slug) {
|
|
278
291
|
return this.getProduct(slug);
|
|
@@ -2252,14 +2265,49 @@ function isAllowedOrigin(origin) {
|
|
|
2252
2265
|
return false;
|
|
2253
2266
|
}
|
|
2254
2267
|
}
|
|
2268
|
+
var KNOWN_IFRAME_TYPES = new Set(Object.values(MESSAGE_TYPES));
|
|
2255
2269
|
function parseIframeMessage(data) {
|
|
2256
2270
|
if (!data || typeof data !== "object") {
|
|
2257
2271
|
return null;
|
|
2258
2272
|
}
|
|
2259
|
-
const
|
|
2260
|
-
if (typeof
|
|
2273
|
+
const record = data;
|
|
2274
|
+
if (typeof record.type !== "string" || !KNOWN_IFRAME_TYPES.has(record.type)) {
|
|
2261
2275
|
return null;
|
|
2262
2276
|
}
|
|
2277
|
+
switch (record.type) {
|
|
2278
|
+
case MESSAGE_TYPES.AUTHENTICATED:
|
|
2279
|
+
if (typeof record.token !== "string") return null;
|
|
2280
|
+
break;
|
|
2281
|
+
case MESSAGE_TYPES.TOKEN_REFRESHED:
|
|
2282
|
+
if (typeof record.token !== "string") return null;
|
|
2283
|
+
break;
|
|
2284
|
+
case MESSAGE_TYPES.ADDRESS_CHANGED:
|
|
2285
|
+
case MESSAGE_TYPES.ADDRESS_SELECTED:
|
|
2286
|
+
if (!record.address || typeof record.address !== "object") return null;
|
|
2287
|
+
break;
|
|
2288
|
+
case MESSAGE_TYPES.PAYMENT_METHOD_SELECTED:
|
|
2289
|
+
if (!record.method || typeof record.method !== "object") return null;
|
|
2290
|
+
break;
|
|
2291
|
+
case MESSAGE_TYPES.CONTACT_PROVIDED:
|
|
2292
|
+
if (typeof record.contact !== "string" || typeof record.contactType !== "string") return null;
|
|
2293
|
+
break;
|
|
2294
|
+
case MESSAGE_TYPES.ERROR:
|
|
2295
|
+
if (typeof record.code !== "string" || typeof record.message !== "string") return null;
|
|
2296
|
+
break;
|
|
2297
|
+
case MESSAGE_TYPES.CHECKOUT_COMPLETE:
|
|
2298
|
+
if (typeof record.success !== "boolean") return null;
|
|
2299
|
+
break;
|
|
2300
|
+
case MESSAGE_TYPES.READY:
|
|
2301
|
+
case MESSAGE_TYPES.HEIGHT_CHANGE:
|
|
2302
|
+
if (typeof record.height !== "number") return null;
|
|
2303
|
+
break;
|
|
2304
|
+
case MESSAGE_TYPES.REQUIRES_OTP:
|
|
2305
|
+
if (typeof record.contactMasked !== "string") return null;
|
|
2306
|
+
break;
|
|
2307
|
+
case MESSAGE_TYPES.ORDER_TYPE_CHANGED:
|
|
2308
|
+
if (typeof record.orderType !== "string") return null;
|
|
2309
|
+
break;
|
|
2310
|
+
}
|
|
2263
2311
|
return data;
|
|
2264
2312
|
}
|
|
2265
2313
|
var CimplifyElements = class {
|
|
@@ -95,6 +95,12 @@ var CURRENCY_TO_COUNTRY_CODE = {
|
|
|
95
95
|
ZAR: "ZA",
|
|
96
96
|
ZMW: "ZM"
|
|
97
97
|
};
|
|
98
|
+
var CURRENCY_TO_CANDIDATE_COUNTRIES = {
|
|
99
|
+
EUR: ["DE", "FR", "IT", "ES", "NL", "BE", "AT", "PT", "IE", "FI", "GR"],
|
|
100
|
+
USD: ["US", "EC", "PA", "SV"],
|
|
101
|
+
XOF: ["SN", "CI", "BF", "ML", "NE", "TG", "BJ", "GW"],
|
|
102
|
+
XAF: ["CM", "GA", "CG", "TD", "CF", "GQ"]
|
|
103
|
+
};
|
|
98
104
|
function normalizeCountryCode(value) {
|
|
99
105
|
const normalized = value?.trim().toUpperCase();
|
|
100
106
|
if (!normalized) {
|
|
@@ -151,6 +157,16 @@ function normalizePhoneToE164(raw, options = {}) {
|
|
|
151
157
|
if (internationalDigits) {
|
|
152
158
|
addAttempt(`+${internationalDigits}`);
|
|
153
159
|
}
|
|
160
|
+
const currency = options.currency?.trim().toUpperCase();
|
|
161
|
+
if (currency) {
|
|
162
|
+
const candidates = CURRENCY_TO_CANDIDATE_COUNTRIES[currency];
|
|
163
|
+
if (candidates) {
|
|
164
|
+
for (const candidate of candidates) {
|
|
165
|
+
addAttempt(trimmed, candidate);
|
|
166
|
+
if (digits) addAttempt(digits, candidate);
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
}
|
|
154
170
|
for (const attempt of attempts) {
|
|
155
171
|
const parsed = parsePhoneCandidate(attempt.value, attempt.country);
|
|
156
172
|
if (parsed?.isValid()) {
|
package/dist/index.js
CHANGED
|
@@ -1,247 +1,247 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var
|
|
5
|
-
var
|
|
3
|
+
var chunkRRO6ZDZI_js = require('./chunk-RRO6ZDZI.js');
|
|
4
|
+
var chunkL5GKVQVJ_js = require('./chunk-L5GKVQVJ.js');
|
|
5
|
+
var chunk4M2D57C3_js = require('./chunk-4M2D57C3.js');
|
|
6
6
|
var chunk64OCG2TJ_js = require('./chunk-64OCG2TJ.js');
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
|
|
10
10
|
Object.defineProperty(exports, "ActivityService", {
|
|
11
11
|
enumerable: true,
|
|
12
|
-
get: function () { return
|
|
12
|
+
get: function () { return chunkRRO6ZDZI_js.ActivityService; }
|
|
13
13
|
});
|
|
14
14
|
Object.defineProperty(exports, "CimplifyClient", {
|
|
15
15
|
enumerable: true,
|
|
16
|
-
get: function () { return
|
|
16
|
+
get: function () { return chunkRRO6ZDZI_js.CimplifyClient; }
|
|
17
17
|
});
|
|
18
18
|
Object.defineProperty(exports, "DeliveryService", {
|
|
19
19
|
enumerable: true,
|
|
20
|
-
get: function () { return
|
|
20
|
+
get: function () { return chunkRRO6ZDZI_js.DeliveryService; }
|
|
21
21
|
});
|
|
22
22
|
Object.defineProperty(exports, "createCimplifyClient", {
|
|
23
23
|
enumerable: true,
|
|
24
|
-
get: function () { return
|
|
24
|
+
get: function () { return chunkRRO6ZDZI_js.createCimplifyClient; }
|
|
25
25
|
});
|
|
26
26
|
Object.defineProperty(exports, "getVariantDisplayName", {
|
|
27
27
|
enumerable: true,
|
|
28
|
-
get: function () { return
|
|
28
|
+
get: function () { return chunkRRO6ZDZI_js.getVariantDisplayName; }
|
|
29
29
|
});
|
|
30
30
|
Object.defineProperty(exports, "isValidPhoneForContext", {
|
|
31
31
|
enumerable: true,
|
|
32
|
-
get: function () { return
|
|
32
|
+
get: function () { return chunkL5GKVQVJ_js.isValidPhoneForContext; }
|
|
33
33
|
});
|
|
34
34
|
Object.defineProperty(exports, "normalizePhoneToE164", {
|
|
35
35
|
enumerable: true,
|
|
36
|
-
get: function () { return
|
|
36
|
+
get: function () { return chunkL5GKVQVJ_js.normalizePhoneToE164; }
|
|
37
37
|
});
|
|
38
38
|
Object.defineProperty(exports, "resolvePhoneCountryCode", {
|
|
39
39
|
enumerable: true,
|
|
40
|
-
get: function () { return
|
|
40
|
+
get: function () { return chunkL5GKVQVJ_js.resolvePhoneCountryCode; }
|
|
41
41
|
});
|
|
42
42
|
Object.defineProperty(exports, "AUTHORIZATION_TYPE", {
|
|
43
43
|
enumerable: true,
|
|
44
|
-
get: function () { return
|
|
44
|
+
get: function () { return chunk4M2D57C3_js.AUTHORIZATION_TYPE; }
|
|
45
45
|
});
|
|
46
46
|
Object.defineProperty(exports, "AUTH_MUTATION", {
|
|
47
47
|
enumerable: true,
|
|
48
|
-
get: function () { return
|
|
48
|
+
get: function () { return chunk4M2D57C3_js.AUTH_MUTATION; }
|
|
49
49
|
});
|
|
50
50
|
Object.defineProperty(exports, "AuthService", {
|
|
51
51
|
enumerable: true,
|
|
52
|
-
get: function () { return
|
|
52
|
+
get: function () { return chunk4M2D57C3_js.AuthService; }
|
|
53
53
|
});
|
|
54
54
|
Object.defineProperty(exports, "BusinessService", {
|
|
55
55
|
enumerable: true,
|
|
56
|
-
get: function () { return
|
|
56
|
+
get: function () { return chunk4M2D57C3_js.BusinessService; }
|
|
57
57
|
});
|
|
58
58
|
Object.defineProperty(exports, "CHECKOUT_MODE", {
|
|
59
59
|
enumerable: true,
|
|
60
|
-
get: function () { return
|
|
60
|
+
get: function () { return chunk4M2D57C3_js.CHECKOUT_MODE; }
|
|
61
61
|
});
|
|
62
62
|
Object.defineProperty(exports, "CHECKOUT_MUTATION", {
|
|
63
63
|
enumerable: true,
|
|
64
|
-
get: function () { return
|
|
64
|
+
get: function () { return chunk4M2D57C3_js.CHECKOUT_MUTATION; }
|
|
65
65
|
});
|
|
66
66
|
Object.defineProperty(exports, "CHECKOUT_STEP", {
|
|
67
67
|
enumerable: true,
|
|
68
|
-
get: function () { return
|
|
68
|
+
get: function () { return chunk4M2D57C3_js.CHECKOUT_STEP; }
|
|
69
69
|
});
|
|
70
70
|
Object.defineProperty(exports, "CONTACT_TYPE", {
|
|
71
71
|
enumerable: true,
|
|
72
|
-
get: function () { return
|
|
72
|
+
get: function () { return chunk4M2D57C3_js.CONTACT_TYPE; }
|
|
73
73
|
});
|
|
74
74
|
Object.defineProperty(exports, "CartOperations", {
|
|
75
75
|
enumerable: true,
|
|
76
|
-
get: function () { return
|
|
76
|
+
get: function () { return chunk4M2D57C3_js.CartOperations; }
|
|
77
77
|
});
|
|
78
78
|
Object.defineProperty(exports, "CatalogueQueries", {
|
|
79
79
|
enumerable: true,
|
|
80
|
-
get: function () { return
|
|
80
|
+
get: function () { return chunk4M2D57C3_js.CatalogueQueries; }
|
|
81
81
|
});
|
|
82
82
|
Object.defineProperty(exports, "CheckoutOperations", {
|
|
83
83
|
enumerable: true,
|
|
84
|
-
get: function () { return
|
|
84
|
+
get: function () { return chunk4M2D57C3_js.CheckoutService; }
|
|
85
85
|
});
|
|
86
86
|
Object.defineProperty(exports, "CheckoutService", {
|
|
87
87
|
enumerable: true,
|
|
88
|
-
get: function () { return
|
|
88
|
+
get: function () { return chunk4M2D57C3_js.CheckoutService; }
|
|
89
89
|
});
|
|
90
90
|
Object.defineProperty(exports, "CimplifyElement", {
|
|
91
91
|
enumerable: true,
|
|
92
|
-
get: function () { return
|
|
92
|
+
get: function () { return chunk4M2D57C3_js.CimplifyElement; }
|
|
93
93
|
});
|
|
94
94
|
Object.defineProperty(exports, "CimplifyElements", {
|
|
95
95
|
enumerable: true,
|
|
96
|
-
get: function () { return
|
|
96
|
+
get: function () { return chunk4M2D57C3_js.CimplifyElements; }
|
|
97
97
|
});
|
|
98
98
|
Object.defineProperty(exports, "DEFAULT_COUNTRY", {
|
|
99
99
|
enumerable: true,
|
|
100
|
-
get: function () { return
|
|
100
|
+
get: function () { return chunk4M2D57C3_js.DEFAULT_COUNTRY; }
|
|
101
101
|
});
|
|
102
102
|
Object.defineProperty(exports, "DEFAULT_CURRENCY", {
|
|
103
103
|
enumerable: true,
|
|
104
|
-
get: function () { return
|
|
104
|
+
get: function () { return chunk4M2D57C3_js.DEFAULT_CURRENCY; }
|
|
105
105
|
});
|
|
106
106
|
Object.defineProperty(exports, "DEVICE_TYPE", {
|
|
107
107
|
enumerable: true,
|
|
108
|
-
get: function () { return
|
|
108
|
+
get: function () { return chunk4M2D57C3_js.DEVICE_TYPE; }
|
|
109
109
|
});
|
|
110
110
|
Object.defineProperty(exports, "ELEMENT_TYPES", {
|
|
111
111
|
enumerable: true,
|
|
112
|
-
get: function () { return
|
|
112
|
+
get: function () { return chunk4M2D57C3_js.ELEMENT_TYPES; }
|
|
113
113
|
});
|
|
114
114
|
Object.defineProperty(exports, "EVENT_TYPES", {
|
|
115
115
|
enumerable: true,
|
|
116
|
-
get: function () { return
|
|
116
|
+
get: function () { return chunk4M2D57C3_js.EVENT_TYPES; }
|
|
117
117
|
});
|
|
118
118
|
Object.defineProperty(exports, "FxService", {
|
|
119
119
|
enumerable: true,
|
|
120
|
-
get: function () { return
|
|
120
|
+
get: function () { return chunk4M2D57C3_js.FxService; }
|
|
121
121
|
});
|
|
122
122
|
Object.defineProperty(exports, "InventoryService", {
|
|
123
123
|
enumerable: true,
|
|
124
|
-
get: function () { return
|
|
124
|
+
get: function () { return chunk4M2D57C3_js.InventoryService; }
|
|
125
125
|
});
|
|
126
126
|
Object.defineProperty(exports, "LINK_MUTATION", {
|
|
127
127
|
enumerable: true,
|
|
128
|
-
get: function () { return
|
|
128
|
+
get: function () { return chunk4M2D57C3_js.LINK_MUTATION; }
|
|
129
129
|
});
|
|
130
130
|
Object.defineProperty(exports, "LINK_QUERY", {
|
|
131
131
|
enumerable: true,
|
|
132
|
-
get: function () { return
|
|
132
|
+
get: function () { return chunk4M2D57C3_js.LINK_QUERY; }
|
|
133
133
|
});
|
|
134
134
|
Object.defineProperty(exports, "LinkService", {
|
|
135
135
|
enumerable: true,
|
|
136
|
-
get: function () { return
|
|
136
|
+
get: function () { return chunk4M2D57C3_js.LinkService; }
|
|
137
137
|
});
|
|
138
138
|
Object.defineProperty(exports, "LiteService", {
|
|
139
139
|
enumerable: true,
|
|
140
|
-
get: function () { return
|
|
140
|
+
get: function () { return chunk4M2D57C3_js.LiteService; }
|
|
141
141
|
});
|
|
142
142
|
Object.defineProperty(exports, "MESSAGE_TYPES", {
|
|
143
143
|
enumerable: true,
|
|
144
|
-
get: function () { return
|
|
144
|
+
get: function () { return chunk4M2D57C3_js.MESSAGE_TYPES; }
|
|
145
145
|
});
|
|
146
146
|
Object.defineProperty(exports, "MOBILE_MONEY_PROVIDER", {
|
|
147
147
|
enumerable: true,
|
|
148
|
-
get: function () { return
|
|
148
|
+
get: function () { return chunk4M2D57C3_js.MOBILE_MONEY_PROVIDER; }
|
|
149
149
|
});
|
|
150
150
|
Object.defineProperty(exports, "ORDER_MUTATION", {
|
|
151
151
|
enumerable: true,
|
|
152
|
-
get: function () { return
|
|
152
|
+
get: function () { return chunk4M2D57C3_js.ORDER_MUTATION; }
|
|
153
153
|
});
|
|
154
154
|
Object.defineProperty(exports, "ORDER_TYPE", {
|
|
155
155
|
enumerable: true,
|
|
156
|
-
get: function () { return
|
|
156
|
+
get: function () { return chunk4M2D57C3_js.ORDER_TYPE; }
|
|
157
157
|
});
|
|
158
158
|
Object.defineProperty(exports, "OrderQueries", {
|
|
159
159
|
enumerable: true,
|
|
160
|
-
get: function () { return
|
|
160
|
+
get: function () { return chunk4M2D57C3_js.OrderQueries; }
|
|
161
161
|
});
|
|
162
162
|
Object.defineProperty(exports, "PAYMENT_METHOD", {
|
|
163
163
|
enumerable: true,
|
|
164
|
-
get: function () { return
|
|
164
|
+
get: function () { return chunk4M2D57C3_js.PAYMENT_METHOD; }
|
|
165
165
|
});
|
|
166
166
|
Object.defineProperty(exports, "PAYMENT_MUTATION", {
|
|
167
167
|
enumerable: true,
|
|
168
|
-
get: function () { return
|
|
168
|
+
get: function () { return chunk4M2D57C3_js.PAYMENT_MUTATION; }
|
|
169
169
|
});
|
|
170
170
|
Object.defineProperty(exports, "PAYMENT_STATE", {
|
|
171
171
|
enumerable: true,
|
|
172
|
-
get: function () { return
|
|
172
|
+
get: function () { return chunk4M2D57C3_js.PAYMENT_STATE; }
|
|
173
173
|
});
|
|
174
174
|
Object.defineProperty(exports, "PICKUP_TIME_TYPE", {
|
|
175
175
|
enumerable: true,
|
|
176
|
-
get: function () { return
|
|
176
|
+
get: function () { return chunk4M2D57C3_js.PICKUP_TIME_TYPE; }
|
|
177
177
|
});
|
|
178
178
|
Object.defineProperty(exports, "SchedulingService", {
|
|
179
179
|
enumerable: true,
|
|
180
|
-
get: function () { return
|
|
180
|
+
get: function () { return chunk4M2D57C3_js.SchedulingService; }
|
|
181
181
|
});
|
|
182
182
|
Object.defineProperty(exports, "combine", {
|
|
183
183
|
enumerable: true,
|
|
184
|
-
get: function () { return
|
|
184
|
+
get: function () { return chunk4M2D57C3_js.combine; }
|
|
185
185
|
});
|
|
186
186
|
Object.defineProperty(exports, "combineObject", {
|
|
187
187
|
enumerable: true,
|
|
188
|
-
get: function () { return
|
|
188
|
+
get: function () { return chunk4M2D57C3_js.combineObject; }
|
|
189
189
|
});
|
|
190
190
|
Object.defineProperty(exports, "createElements", {
|
|
191
191
|
enumerable: true,
|
|
192
|
-
get: function () { return
|
|
192
|
+
get: function () { return chunk4M2D57C3_js.createElements; }
|
|
193
193
|
});
|
|
194
194
|
Object.defineProperty(exports, "err", {
|
|
195
195
|
enumerable: true,
|
|
196
|
-
get: function () { return
|
|
196
|
+
get: function () { return chunk4M2D57C3_js.err; }
|
|
197
197
|
});
|
|
198
198
|
Object.defineProperty(exports, "flatMap", {
|
|
199
199
|
enumerable: true,
|
|
200
|
-
get: function () { return
|
|
200
|
+
get: function () { return chunk4M2D57C3_js.flatMap; }
|
|
201
201
|
});
|
|
202
202
|
Object.defineProperty(exports, "fromPromise", {
|
|
203
203
|
enumerable: true,
|
|
204
|
-
get: function () { return
|
|
204
|
+
get: function () { return chunk4M2D57C3_js.fromPromise; }
|
|
205
205
|
});
|
|
206
206
|
Object.defineProperty(exports, "generateIdempotencyKey", {
|
|
207
207
|
enumerable: true,
|
|
208
|
-
get: function () { return
|
|
208
|
+
get: function () { return chunk4M2D57C3_js.generateIdempotencyKey; }
|
|
209
209
|
});
|
|
210
210
|
Object.defineProperty(exports, "getOrElse", {
|
|
211
211
|
enumerable: true,
|
|
212
|
-
get: function () { return
|
|
212
|
+
get: function () { return chunk4M2D57C3_js.getOrElse; }
|
|
213
213
|
});
|
|
214
214
|
Object.defineProperty(exports, "isErr", {
|
|
215
215
|
enumerable: true,
|
|
216
|
-
get: function () { return
|
|
216
|
+
get: function () { return chunk4M2D57C3_js.isErr; }
|
|
217
217
|
});
|
|
218
218
|
Object.defineProperty(exports, "isOk", {
|
|
219
219
|
enumerable: true,
|
|
220
|
-
get: function () { return
|
|
220
|
+
get: function () { return chunk4M2D57C3_js.isOk; }
|
|
221
221
|
});
|
|
222
222
|
Object.defineProperty(exports, "mapError", {
|
|
223
223
|
enumerable: true,
|
|
224
|
-
get: function () { return
|
|
224
|
+
get: function () { return chunk4M2D57C3_js.mapError; }
|
|
225
225
|
});
|
|
226
226
|
Object.defineProperty(exports, "mapResult", {
|
|
227
227
|
enumerable: true,
|
|
228
|
-
get: function () { return
|
|
228
|
+
get: function () { return chunk4M2D57C3_js.mapResult; }
|
|
229
229
|
});
|
|
230
230
|
Object.defineProperty(exports, "ok", {
|
|
231
231
|
enumerable: true,
|
|
232
|
-
get: function () { return
|
|
232
|
+
get: function () { return chunk4M2D57C3_js.ok; }
|
|
233
233
|
});
|
|
234
234
|
Object.defineProperty(exports, "toNullable", {
|
|
235
235
|
enumerable: true,
|
|
236
|
-
get: function () { return
|
|
236
|
+
get: function () { return chunk4M2D57C3_js.toNullable; }
|
|
237
237
|
});
|
|
238
238
|
Object.defineProperty(exports, "tryCatch", {
|
|
239
239
|
enumerable: true,
|
|
240
|
-
get: function () { return
|
|
240
|
+
get: function () { return chunk4M2D57C3_js.tryCatch; }
|
|
241
241
|
});
|
|
242
242
|
Object.defineProperty(exports, "unwrap", {
|
|
243
243
|
enumerable: true,
|
|
244
|
-
get: function () { return
|
|
244
|
+
get: function () { return chunk4M2D57C3_js.unwrap; }
|
|
245
245
|
});
|
|
246
246
|
Object.defineProperty(exports, "CURRENCY_SYMBOLS", {
|
|
247
247
|
enumerable: true,
|
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { ActivityService, CimplifyClient, DeliveryService, createCimplifyClient, getVariantDisplayName } from './chunk-
|
|
2
|
-
export { isValidPhoneForContext, normalizePhoneToE164, resolvePhoneCountryCode } from './chunk-
|
|
3
|
-
export { AUTHORIZATION_TYPE, AUTH_MUTATION, AuthService, BusinessService, CHECKOUT_MODE, CHECKOUT_MUTATION, CHECKOUT_STEP, CONTACT_TYPE, CartOperations, CatalogueQueries, CheckoutService as CheckoutOperations, CheckoutService, CimplifyElement, CimplifyElements, DEFAULT_COUNTRY, DEFAULT_CURRENCY, DEVICE_TYPE, ELEMENT_TYPES, EVENT_TYPES, FxService, InventoryService, LINK_MUTATION, LINK_QUERY, LinkService, LiteService, MESSAGE_TYPES, MOBILE_MONEY_PROVIDER, ORDER_MUTATION, ORDER_TYPE, OrderQueries, PAYMENT_METHOD, PAYMENT_MUTATION, PAYMENT_STATE, PICKUP_TIME_TYPE, SchedulingService, combine, combineObject, createElements, err, flatMap, fromPromise, generateIdempotencyKey, getOrElse, isErr, isOk, mapError, mapResult, ok, toNullable, tryCatch, unwrap } from './chunk-
|
|
1
|
+
export { ActivityService, CimplifyClient, DeliveryService, createCimplifyClient, getVariantDisplayName } from './chunk-JD3ZHI4S.mjs';
|
|
2
|
+
export { isValidPhoneForContext, normalizePhoneToE164, resolvePhoneCountryCode } from './chunk-YOIVZ6OA.mjs';
|
|
3
|
+
export { AUTHORIZATION_TYPE, AUTH_MUTATION, AuthService, BusinessService, CHECKOUT_MODE, CHECKOUT_MUTATION, CHECKOUT_STEP, CONTACT_TYPE, CartOperations, CatalogueQueries, CheckoutService as CheckoutOperations, CheckoutService, CimplifyElement, CimplifyElements, DEFAULT_COUNTRY, DEFAULT_CURRENCY, DEVICE_TYPE, ELEMENT_TYPES, EVENT_TYPES, FxService, InventoryService, LINK_MUTATION, LINK_QUERY, LinkService, LiteService, MESSAGE_TYPES, MOBILE_MONEY_PROVIDER, ORDER_MUTATION, ORDER_TYPE, OrderQueries, PAYMENT_METHOD, PAYMENT_MUTATION, PAYMENT_STATE, PICKUP_TIME_TYPE, SchedulingService, combine, combineObject, createElements, err, flatMap, fromPromise, generateIdempotencyKey, getOrElse, isErr, isOk, mapError, mapResult, ok, toNullable, tryCatch, unwrap } from './chunk-WX54U6Y2.mjs';
|
|
4
4
|
export { CURRENCY_SYMBOLS, CimplifyError, ERROR_HINTS, ErrorCode, MOBILE_MONEY_PROVIDERS, ZERO, categorizePaymentError, currencyCode, detectMobileMoneyProvider, enrichError, formatMoney, formatNumberCompact, formatPrice, formatPriceAdjustment, formatPriceCompact, formatPriceWithTax, formatProductPrice, getBasePrice, getCurrencySymbol, getDiscountPercentage, getDisplayPrice, getErrorHint, getMarkupPercentage, getProductCurrency, getTaxAmount, hasTaxInfo, isCimplifyError, isOnSale, isPaymentStatusFailure, isPaymentStatusRequiresAction, isPaymentStatusSuccess, isRetryableError, isSupportedCurrency, isTaxInclusive, money, moneyFromNumber, normalizePaymentResponse, normalizeStatusResponse, parsePrice } from './chunk-JFT63H34.mjs';
|
package/dist/react.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
'use strict';
|
|
3
3
|
|
|
4
|
-
var
|
|
5
|
-
var
|
|
4
|
+
var chunkRRO6ZDZI_js = require('./chunk-RRO6ZDZI.js');
|
|
5
|
+
var chunk4M2D57C3_js = require('./chunk-4M2D57C3.js');
|
|
6
6
|
var chunk64OCG2TJ_js = require('./chunk-64OCG2TJ.js');
|
|
7
7
|
var React3 = require('react');
|
|
8
8
|
var jsxRuntime = require('react/jsx-runtime');
|
|
@@ -77,7 +77,19 @@ function getUserIdentity(authenticatedAccountId) {
|
|
|
77
77
|
signals
|
|
78
78
|
};
|
|
79
79
|
}
|
|
80
|
+
function getUserAgentData() {
|
|
81
|
+
if (typeof navigator === "undefined") return null;
|
|
82
|
+
const nav = navigator;
|
|
83
|
+
return nav.userAgentData ?? null;
|
|
84
|
+
}
|
|
80
85
|
function getDeviceType(signals) {
|
|
86
|
+
const uaData = getUserAgentData();
|
|
87
|
+
if (uaData) {
|
|
88
|
+
if (uaData.mobile) {
|
|
89
|
+
return signals.screenWidth >= 768 ? "tablet" : "mobile";
|
|
90
|
+
}
|
|
91
|
+
return "desktop";
|
|
92
|
+
}
|
|
81
93
|
const ua = signals.userAgent.toLowerCase();
|
|
82
94
|
const width = signals.screenWidth;
|
|
83
95
|
if (/mobile|android|iphone|ipod/.test(ua) || width < 768) {
|
|
@@ -89,6 +101,15 @@ function getDeviceType(signals) {
|
|
|
89
101
|
return "desktop";
|
|
90
102
|
}
|
|
91
103
|
function getBrowserInfo(signals) {
|
|
104
|
+
const uaData = getUserAgentData();
|
|
105
|
+
if (uaData && uaData.brands.length > 0) {
|
|
106
|
+
const real = uaData.brands.find(
|
|
107
|
+
(b) => !/not/i.test(b.brand) && !/brand/i.test(b.brand)
|
|
108
|
+
);
|
|
109
|
+
if (real) {
|
|
110
|
+
return { name: real.brand, version: real.version };
|
|
111
|
+
}
|
|
112
|
+
}
|
|
92
113
|
const ua = signals.userAgent;
|
|
93
114
|
const browsers = [
|
|
94
115
|
{ name: "Chrome", regex: /Chrome\/(\d+)/ },
|
|
@@ -106,6 +127,10 @@ function getBrowserInfo(signals) {
|
|
|
106
127
|
return { name: "Unknown", version: "0" };
|
|
107
128
|
}
|
|
108
129
|
function getOSInfo(signals) {
|
|
130
|
+
const uaData = getUserAgentData();
|
|
131
|
+
if (uaData && uaData.platform) {
|
|
132
|
+
return { name: uaData.platform, version: "" };
|
|
133
|
+
}
|
|
109
134
|
const ua = signals.userAgent;
|
|
110
135
|
if (/Windows NT 10/.test(ua)) return { name: "Windows", version: "10" };
|
|
111
136
|
if (/Windows NT 6.3/.test(ua)) return { name: "Windows", version: "8.1" };
|
|
@@ -1036,7 +1061,7 @@ var DEFAULT_COUNTRY = "US";
|
|
|
1036
1061
|
function createDefaultClient() {
|
|
1037
1062
|
const processRef = globalThis.process;
|
|
1038
1063
|
const envPublicKey = processRef?.env?.NEXT_PUBLIC_CIMPLIFY_PUBLIC_KEY || "";
|
|
1039
|
-
return
|
|
1064
|
+
return chunkRRO6ZDZI_js.createCimplifyClient({ publicKey: envPublicKey });
|
|
1040
1065
|
}
|
|
1041
1066
|
function getStoredLocationId() {
|
|
1042
1067
|
if (typeof window === "undefined" || !window.localStorage) {
|
|
@@ -3187,19 +3212,19 @@ function AuthElement({
|
|
|
3187
3212
|
}, [onReady, onAuthenticated, onRequiresOtp, onError]);
|
|
3188
3213
|
React3.useEffect(() => {
|
|
3189
3214
|
if (!elements || !containerRef.current) return;
|
|
3190
|
-
const element = elements.create(
|
|
3215
|
+
const element = elements.create(chunk4M2D57C3_js.ELEMENT_TYPES.AUTH, { prefillEmail });
|
|
3191
3216
|
elementRef.current = element;
|
|
3192
|
-
element.on(
|
|
3217
|
+
element.on(chunk4M2D57C3_js.EVENT_TYPES.READY, () => onReadyRef.current?.());
|
|
3193
3218
|
element.on(
|
|
3194
|
-
|
|
3219
|
+
chunk4M2D57C3_js.EVENT_TYPES.AUTHENTICATED,
|
|
3195
3220
|
(data) => onAuthenticatedRef.current?.(data)
|
|
3196
3221
|
);
|
|
3197
3222
|
element.on(
|
|
3198
|
-
|
|
3223
|
+
chunk4M2D57C3_js.EVENT_TYPES.REQUIRES_OTP,
|
|
3199
3224
|
(data) => onRequiresOtpRef.current?.(data)
|
|
3200
3225
|
);
|
|
3201
3226
|
element.on(
|
|
3202
|
-
|
|
3227
|
+
chunk4M2D57C3_js.EVENT_TYPES.ERROR,
|
|
3203
3228
|
(data) => onErrorRef.current?.(data)
|
|
3204
3229
|
);
|
|
3205
3230
|
element.mount(containerRef.current);
|
|
@@ -3228,15 +3253,15 @@ function AddressElement({
|
|
|
3228
3253
|
}, [onReady, onChange, onError]);
|
|
3229
3254
|
React3.useEffect(() => {
|
|
3230
3255
|
if (!elements || !containerRef.current) return;
|
|
3231
|
-
const element = elements.create(
|
|
3256
|
+
const element = elements.create(chunk4M2D57C3_js.ELEMENT_TYPES.ADDRESS, { mode });
|
|
3232
3257
|
elementRef.current = element;
|
|
3233
|
-
element.on(
|
|
3258
|
+
element.on(chunk4M2D57C3_js.EVENT_TYPES.READY, () => onReadyRef.current?.());
|
|
3234
3259
|
element.on(
|
|
3235
|
-
|
|
3260
|
+
chunk4M2D57C3_js.EVENT_TYPES.CHANGE,
|
|
3236
3261
|
(data) => onChangeRef.current?.(data)
|
|
3237
3262
|
);
|
|
3238
3263
|
element.on(
|
|
3239
|
-
|
|
3264
|
+
chunk4M2D57C3_js.EVENT_TYPES.ERROR,
|
|
3240
3265
|
(data) => onErrorRef.current?.(data)
|
|
3241
3266
|
);
|
|
3242
3267
|
element.mount(containerRef.current);
|
|
@@ -3266,15 +3291,15 @@ function PaymentElement({
|
|
|
3266
3291
|
}, [onReady, onChange, onError]);
|
|
3267
3292
|
React3.useEffect(() => {
|
|
3268
3293
|
if (!elements || !containerRef.current) return;
|
|
3269
|
-
const element = elements.create(
|
|
3294
|
+
const element = elements.create(chunk4M2D57C3_js.ELEMENT_TYPES.PAYMENT, { amount, currency });
|
|
3270
3295
|
elementRef.current = element;
|
|
3271
|
-
element.on(
|
|
3296
|
+
element.on(chunk4M2D57C3_js.EVENT_TYPES.READY, () => onReadyRef.current?.());
|
|
3272
3297
|
element.on(
|
|
3273
|
-
|
|
3298
|
+
chunk4M2D57C3_js.EVENT_TYPES.CHANGE,
|
|
3274
3299
|
(data) => onChangeRef.current?.(data)
|
|
3275
3300
|
);
|
|
3276
3301
|
element.on(
|
|
3277
|
-
|
|
3302
|
+
chunk4M2D57C3_js.EVENT_TYPES.ERROR,
|
|
3278
3303
|
(data) => onErrorRef.current?.(data)
|
|
3279
3304
|
);
|
|
3280
3305
|
element.mount(containerRef.current);
|
|
@@ -3537,7 +3562,7 @@ function VariantSelector({
|
|
|
3537
3562
|
{
|
|
3538
3563
|
"data-cimplify-variant-name": true,
|
|
3539
3564
|
className: cn("flex-1 min-w-0 text-sm", classNames?.name),
|
|
3540
|
-
children:
|
|
3565
|
+
children: chunkRRO6ZDZI_js.getVariantDisplayName(variant, productName)
|
|
3541
3566
|
}
|
|
3542
3567
|
),
|
|
3543
3568
|
/* @__PURE__ */ jsxRuntime.jsxs("span", { "data-cimplify-variant-pricing": true, className: cn("text-sm text-muted-foreground", classNames?.pricing), children: [
|
|
@@ -4851,7 +4876,7 @@ function CartLineItemRow({
|
|
|
4851
4876
|
return /* @__PURE__ */ jsxRuntime.jsxs("div", { "data-cimplify-cart-item": true, className: classNames?.item, children: [
|
|
4852
4877
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { "data-cimplify-cart-item-info": true, children: [
|
|
4853
4878
|
/* @__PURE__ */ jsxRuntime.jsx("span", { "data-cimplify-cart-item-name": true, className: classNames?.itemName, children: item.product.name }),
|
|
4854
|
-
item.variant && /* @__PURE__ */ jsxRuntime.jsx("span", { "data-cimplify-cart-item-variant": true, children:
|
|
4879
|
+
item.variant && /* @__PURE__ */ jsxRuntime.jsx("span", { "data-cimplify-cart-item-variant": true, children: chunkRRO6ZDZI_js.getVariantDisplayName(item.variant, item.product.name) }),
|
|
4855
4880
|
item.addOnOptions && item.addOnOptions.length > 0 && /* @__PURE__ */ jsxRuntime.jsxs("span", { "data-cimplify-cart-item-addons": true, children: [
|
|
4856
4881
|
"+ ",
|
|
4857
4882
|
item.addOnOptions.map((opt) => opt.name).join(", ")
|
|
@@ -8576,7 +8601,7 @@ function CurrencySelector({
|
|
|
8576
8601
|
|
|
8577
8602
|
Object.defineProperty(exports, "getVariantDisplayName", {
|
|
8578
8603
|
enumerable: true,
|
|
8579
|
-
get: function () { return
|
|
8604
|
+
get: function () { return chunkRRO6ZDZI_js.getVariantDisplayName; }
|
|
8580
8605
|
});
|
|
8581
8606
|
exports.Ad = Ad;
|
|
8582
8607
|
exports.AdProvider = AdProvider;
|
package/dist/react.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { getVariantDisplayName, createCimplifyClient } from './chunk-
|
|
3
|
-
export { getVariantDisplayName } from './chunk-
|
|
4
|
-
import { ELEMENT_TYPES, EVENT_TYPES } from './chunk-
|
|
2
|
+
import { getVariantDisplayName, createCimplifyClient } from './chunk-JD3ZHI4S.mjs';
|
|
3
|
+
export { getVariantDisplayName } from './chunk-JD3ZHI4S.mjs';
|
|
4
|
+
import { ELEMENT_TYPES, EVENT_TYPES } from './chunk-WX54U6Y2.mjs';
|
|
5
5
|
import { isSupportedCurrency, formatPrice, parsePrice, isOnSale, getDiscountPercentage, getBasePrice } from './chunk-JFT63H34.mjs';
|
|
6
6
|
import React3, { createContext, useRef, useState, useCallback, useEffect, useContext, useMemo, useSyncExternalStore, useId } from 'react';
|
|
7
7
|
import { jsx, Fragment, jsxs } from 'react/jsx-runtime';
|
|
@@ -72,7 +72,19 @@ function getUserIdentity(authenticatedAccountId) {
|
|
|
72
72
|
signals
|
|
73
73
|
};
|
|
74
74
|
}
|
|
75
|
+
function getUserAgentData() {
|
|
76
|
+
if (typeof navigator === "undefined") return null;
|
|
77
|
+
const nav = navigator;
|
|
78
|
+
return nav.userAgentData ?? null;
|
|
79
|
+
}
|
|
75
80
|
function getDeviceType(signals) {
|
|
81
|
+
const uaData = getUserAgentData();
|
|
82
|
+
if (uaData) {
|
|
83
|
+
if (uaData.mobile) {
|
|
84
|
+
return signals.screenWidth >= 768 ? "tablet" : "mobile";
|
|
85
|
+
}
|
|
86
|
+
return "desktop";
|
|
87
|
+
}
|
|
76
88
|
const ua = signals.userAgent.toLowerCase();
|
|
77
89
|
const width = signals.screenWidth;
|
|
78
90
|
if (/mobile|android|iphone|ipod/.test(ua) || width < 768) {
|
|
@@ -84,6 +96,15 @@ function getDeviceType(signals) {
|
|
|
84
96
|
return "desktop";
|
|
85
97
|
}
|
|
86
98
|
function getBrowserInfo(signals) {
|
|
99
|
+
const uaData = getUserAgentData();
|
|
100
|
+
if (uaData && uaData.brands.length > 0) {
|
|
101
|
+
const real = uaData.brands.find(
|
|
102
|
+
(b) => !/not/i.test(b.brand) && !/brand/i.test(b.brand)
|
|
103
|
+
);
|
|
104
|
+
if (real) {
|
|
105
|
+
return { name: real.brand, version: real.version };
|
|
106
|
+
}
|
|
107
|
+
}
|
|
87
108
|
const ua = signals.userAgent;
|
|
88
109
|
const browsers = [
|
|
89
110
|
{ name: "Chrome", regex: /Chrome\/(\d+)/ },
|
|
@@ -101,6 +122,10 @@ function getBrowserInfo(signals) {
|
|
|
101
122
|
return { name: "Unknown", version: "0" };
|
|
102
123
|
}
|
|
103
124
|
function getOSInfo(signals) {
|
|
125
|
+
const uaData = getUserAgentData();
|
|
126
|
+
if (uaData && uaData.platform) {
|
|
127
|
+
return { name: uaData.platform, version: "" };
|
|
128
|
+
}
|
|
104
129
|
const ua = signals.userAgent;
|
|
105
130
|
if (/Windows NT 10/.test(ua)) return { name: "Windows", version: "10" };
|
|
106
131
|
if (/Windows NT 6.3/.test(ua)) return { name: "Windows", version: "8.1" };
|
package/dist/utils.js
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunkL5GKVQVJ_js = require('./chunk-L5GKVQVJ.js');
|
|
4
4
|
var chunk64OCG2TJ_js = require('./chunk-64OCG2TJ.js');
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
|
|
8
8
|
Object.defineProperty(exports, "isValidPhoneForContext", {
|
|
9
9
|
enumerable: true,
|
|
10
|
-
get: function () { return
|
|
10
|
+
get: function () { return chunkL5GKVQVJ_js.isValidPhoneForContext; }
|
|
11
11
|
});
|
|
12
12
|
Object.defineProperty(exports, "normalizePhoneToE164", {
|
|
13
13
|
enumerable: true,
|
|
14
|
-
get: function () { return
|
|
14
|
+
get: function () { return chunkL5GKVQVJ_js.normalizePhoneToE164; }
|
|
15
15
|
});
|
|
16
16
|
Object.defineProperty(exports, "resolvePhoneCountryCode", {
|
|
17
17
|
enumerable: true,
|
|
18
|
-
get: function () { return
|
|
18
|
+
get: function () { return chunkL5GKVQVJ_js.resolvePhoneCountryCode; }
|
|
19
19
|
});
|
|
20
20
|
Object.defineProperty(exports, "CURRENCY_SYMBOLS", {
|
|
21
21
|
enumerable: true,
|
package/dist/utils.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { isValidPhoneForContext, normalizePhoneToE164, resolvePhoneCountryCode } from './chunk-
|
|
1
|
+
export { isValidPhoneForContext, normalizePhoneToE164, resolvePhoneCountryCode } from './chunk-YOIVZ6OA.mjs';
|
|
2
2
|
export { CURRENCY_SYMBOLS, MOBILE_MONEY_PROVIDERS, categorizePaymentError, detectMobileMoneyProvider, formatMoney, formatNumberCompact, formatPrice, formatPriceAdjustment, formatPriceCompact, formatPriceWithTax, formatProductPrice, getBasePrice, getCurrencySymbol, getDiscountPercentage, getDisplayPrice, getMarkupPercentage, getProductCurrency, getTaxAmount, hasTaxInfo, isOnSale, isPaymentStatusFailure, isPaymentStatusRequiresAction, isPaymentStatusSuccess, isTaxInclusive, normalizePaymentResponse, normalizeStatusResponse, parsePrice } from './chunk-JFT63H34.mjs';
|