@cimplify/sdk 0.100.6 → 0.101.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/advanced.d.mts +3 -3
- package/dist/advanced.d.ts +3 -3
- package/dist/advanced.js +20 -20
- package/dist/advanced.mjs +1 -1
- package/dist/{chunk-KLJLKT6C.mjs → chunk-7H6IL7CX.mjs} +2 -2
- package/dist/{chunk-BMFWQNYZ.mjs → chunk-DKLHCZ5M.mjs} +4 -1
- package/dist/{chunk-PNTINRAU.js → chunk-H5SSGN7W.js} +28 -0
- package/dist/{chunk-BSZJSR62.js → chunk-ICCCSVN3.js} +4 -4
- package/dist/{chunk-D3FWJB7Y.js → chunk-YDA46OZ6.js} +50 -47
- package/dist/{chunk-3HU5I5VG.js → chunk-YER7DIOM.js} +15 -0
- package/dist/{chunk-RQPXLXB2.mjs → chunk-YHPMFTMN.mjs} +28 -0
- package/dist/{chunk-Z7M6GAHS.mjs → chunk-Z3K2D3TE.mjs} +15 -0
- package/dist/{client-CrPglBBz.d.ts → client-CdTx7X_X.d.mts} +12 -2
- package/dist/{client-CPcZIrjC.d.ts → client-D40kI8z2.d.ts} +2 -2
- package/dist/{client-BwRAAk4y.d.mts → client-Db554902.d.ts} +12 -2
- package/dist/{client-DGrvLiJv.d.mts → client-WkUcvRvO.d.mts} +2 -2
- package/dist/{index-D-LUYk1Y.d.mts → index-BjWUkYgY.d.mts} +3 -3
- package/dist/{index-B_RYmvlF.d.ts → index-D3UXgAYl.d.ts} +3 -3
- package/dist/index.d.mts +7 -7
- package/dist/index.d.ts +7 -7
- package/dist/index.js +69 -69
- package/dist/index.mjs +3 -3
- package/dist/mock/cli.mjs +28 -0
- package/dist/mock/library.js +28 -0
- package/dist/mock/library.mjs +28 -0
- package/dist/mock/msw.js +28 -0
- package/dist/mock/msw.mjs +28 -0
- package/dist/{payment-BSzy7sly.d.mts → payment-CRqjGrx6.d.mts} +1 -1
- package/dist/{payment-jK8ztICx.d.ts → payment-DO1Z1Ip6.d.ts} +1 -1
- package/dist/{price-D96h6c6L.d.mts → price-CiQUd_XX.d.mts} +1 -1
- package/dist/{price-CJLfcYKd.d.ts → price-D9EOj8y8.d.ts} +1 -1
- package/dist/{product-CeV8euw4.d.mts → product-DwKdC_to.d.mts} +727 -625
- package/dist/{product-CeV8euw4.d.ts → product-DwKdC_to.d.ts} +727 -625
- package/dist/react.d.mts +7 -4
- package/dist/react.d.ts +7 -4
- package/dist/react.js +75 -34
- package/dist/react.mjs +52 -11
- package/dist/server/evict.d.mts +12 -8
- package/dist/server/evict.d.ts +12 -8
- package/dist/server/evict.js +53 -7
- package/dist/server/evict.mjs +53 -7
- package/dist/server/tanstack.d.mts +4 -2
- package/dist/server/tanstack.d.ts +4 -2
- package/dist/server/tanstack.js +53 -14
- package/dist/server/tanstack.mjs +53 -14
- package/dist/{server-zyrpzJVn.d.ts → server-CeDb93WA.d.ts} +13 -1
- package/dist/{server-DRAW2OOX.d.mts → server-D-nSkrUr.d.mts} +13 -1
- package/dist/server.d.mts +4 -4
- package/dist/server.d.ts +4 -4
- package/dist/server.js +7 -7
- package/dist/server.mjs +2 -2
- package/dist/testing/msw.d.mts +2 -2
- package/dist/testing/msw.d.ts +2 -2
- package/dist/testing/msw.js +2 -2
- package/dist/testing/msw.mjs +1 -1
- package/dist/testing/suite.d.mts +6 -6
- package/dist/testing/suite.d.ts +6 -6
- package/dist/testing/suite.js +23 -23
- package/dist/testing/suite.mjs +4 -4
- package/dist/testing.d.mts +5 -5
- package/dist/testing.d.ts +5 -5
- package/dist/testing.js +79 -79
- package/dist/testing.mjs +5 -5
- package/dist/utils.d.mts +4 -4
- package/dist/utils.d.ts +4 -4
- package/package.json +1 -1
- package/registry/cart-summary.json +1 -1
- package/registry/chat-widget.json +1 -1
package/dist/advanced.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export { k as AuthService, C as BusinessService, O as CartOperations, P as CatalogueQueries, ab as CheckoutOperations, ab as CheckoutService, ah as CimplifyElement, ai as CimplifyElements, aL as ELEMENT_TYPES, aM as EVENT_TYPES, aP as ElementEventType, aQ as ElementOptions, aR as ElementType, aZ as ElementsOptions, b5 as FetchQuoteInput, be as FxService, bi as GetProductsOptions, bl as InventoryService, bt as LinkService, bz as LiteService, bG as MESSAGE_TYPES, c6 as OrderQueries, cs as PriceQuote, cy as QuoteBundleSelectionInput, cz as QuoteCompositeSelectionInput, cA as QuoteDynamicBuckets, cB as QuoteStatus, cC as QuoteUiMessage, cE as RefreshQuoteInput, cF as RefreshQuoteResult, d5 as SchedulingService, dL as createElements } from './client-
|
|
2
|
-
import './product-
|
|
3
|
-
import './payment-
|
|
1
|
+
export { k as AuthService, C as BusinessService, O as CartOperations, P as CatalogueQueries, ab as CheckoutOperations, ab as CheckoutService, ah as CimplifyElement, ai as CimplifyElements, aL as ELEMENT_TYPES, aM as EVENT_TYPES, aP as ElementEventType, aQ as ElementOptions, aR as ElementType, aZ as ElementsOptions, b5 as FetchQuoteInput, be as FxService, bi as GetProductsOptions, bl as InventoryService, bt as LinkService, bz as LiteService, bG as MESSAGE_TYPES, c6 as OrderQueries, cs as PriceQuote, cy as QuoteBundleSelectionInput, cz as QuoteCompositeSelectionInput, cA as QuoteDynamicBuckets, cB as QuoteStatus, cC as QuoteUiMessage, cE as RefreshQuoteInput, cF as RefreshQuoteResult, d5 as SchedulingService, dL as createElements } from './client-CdTx7X_X.mjs';
|
|
2
|
+
import './product-DwKdC_to.mjs';
|
|
3
|
+
import './payment-CRqjGrx6.mjs';
|
|
4
4
|
|
|
5
5
|
declare function generateIdempotencyKey(prefix?: string): string;
|
|
6
6
|
|
package/dist/advanced.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export { k as AuthService, C as BusinessService, O as CartOperations, P as CatalogueQueries, ab as CheckoutOperations, ab as CheckoutService, ah as CimplifyElement, ai as CimplifyElements, aL as ELEMENT_TYPES, aM as EVENT_TYPES, aP as ElementEventType, aQ as ElementOptions, aR as ElementType, aZ as ElementsOptions, b5 as FetchQuoteInput, be as FxService, bi as GetProductsOptions, bl as InventoryService, bt as LinkService, bz as LiteService, bG as MESSAGE_TYPES, c6 as OrderQueries, cs as PriceQuote, cy as QuoteBundleSelectionInput, cz as QuoteCompositeSelectionInput, cA as QuoteDynamicBuckets, cB as QuoteStatus, cC as QuoteUiMessage, cE as RefreshQuoteInput, cF as RefreshQuoteResult, d5 as SchedulingService, dL as createElements } from './client-
|
|
2
|
-
import './product-
|
|
3
|
-
import './payment-
|
|
1
|
+
export { k as AuthService, C as BusinessService, O as CartOperations, P as CatalogueQueries, ab as CheckoutOperations, ab as CheckoutService, ah as CimplifyElement, ai as CimplifyElements, aL as ELEMENT_TYPES, aM as EVENT_TYPES, aP as ElementEventType, aQ as ElementOptions, aR as ElementType, aZ as ElementsOptions, b5 as FetchQuoteInput, be as FxService, bi as GetProductsOptions, bl as InventoryService, bt as LinkService, bz as LiteService, bG as MESSAGE_TYPES, c6 as OrderQueries, cs as PriceQuote, cy as QuoteBundleSelectionInput, cz as QuoteCompositeSelectionInput, cA as QuoteDynamicBuckets, cB as QuoteStatus, cC as QuoteUiMessage, cE as RefreshQuoteInput, cF as RefreshQuoteResult, d5 as SchedulingService, dL as createElements } from './client-Db554902.js';
|
|
2
|
+
import './product-DwKdC_to.js';
|
|
3
|
+
import './payment-DO1Z1Ip6.js';
|
|
4
4
|
|
|
5
5
|
declare function generateIdempotencyKey(prefix?: string): string;
|
|
6
6
|
|
package/dist/advanced.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunkYER7DIOM_js = require('./chunk-YER7DIOM.js');
|
|
4
4
|
require('./chunk-WMEC5JWN.js');
|
|
5
5
|
require('./chunk-NIOUSKQQ.js');
|
|
6
6
|
require('./chunk-OWW5GUSB.js');
|
|
@@ -9,77 +9,77 @@ require('./chunk-OWW5GUSB.js');
|
|
|
9
9
|
|
|
10
10
|
Object.defineProperty(exports, "AuthService", {
|
|
11
11
|
enumerable: true,
|
|
12
|
-
get: function () { return
|
|
12
|
+
get: function () { return chunkYER7DIOM_js.AuthService; }
|
|
13
13
|
});
|
|
14
14
|
Object.defineProperty(exports, "BusinessService", {
|
|
15
15
|
enumerable: true,
|
|
16
|
-
get: function () { return
|
|
16
|
+
get: function () { return chunkYER7DIOM_js.BusinessService; }
|
|
17
17
|
});
|
|
18
18
|
Object.defineProperty(exports, "CartOperations", {
|
|
19
19
|
enumerable: true,
|
|
20
|
-
get: function () { return
|
|
20
|
+
get: function () { return chunkYER7DIOM_js.CartOperations; }
|
|
21
21
|
});
|
|
22
22
|
Object.defineProperty(exports, "CatalogueQueries", {
|
|
23
23
|
enumerable: true,
|
|
24
|
-
get: function () { return
|
|
24
|
+
get: function () { return chunkYER7DIOM_js.CatalogueQueries; }
|
|
25
25
|
});
|
|
26
26
|
Object.defineProperty(exports, "CheckoutOperations", {
|
|
27
27
|
enumerable: true,
|
|
28
|
-
get: function () { return
|
|
28
|
+
get: function () { return chunkYER7DIOM_js.CheckoutService; }
|
|
29
29
|
});
|
|
30
30
|
Object.defineProperty(exports, "CheckoutService", {
|
|
31
31
|
enumerable: true,
|
|
32
|
-
get: function () { return
|
|
32
|
+
get: function () { return chunkYER7DIOM_js.CheckoutService; }
|
|
33
33
|
});
|
|
34
34
|
Object.defineProperty(exports, "CimplifyElement", {
|
|
35
35
|
enumerable: true,
|
|
36
|
-
get: function () { return
|
|
36
|
+
get: function () { return chunkYER7DIOM_js.CimplifyElement; }
|
|
37
37
|
});
|
|
38
38
|
Object.defineProperty(exports, "CimplifyElements", {
|
|
39
39
|
enumerable: true,
|
|
40
|
-
get: function () { return
|
|
40
|
+
get: function () { return chunkYER7DIOM_js.CimplifyElements; }
|
|
41
41
|
});
|
|
42
42
|
Object.defineProperty(exports, "ELEMENT_TYPES", {
|
|
43
43
|
enumerable: true,
|
|
44
|
-
get: function () { return
|
|
44
|
+
get: function () { return chunkYER7DIOM_js.ELEMENT_TYPES; }
|
|
45
45
|
});
|
|
46
46
|
Object.defineProperty(exports, "EVENT_TYPES", {
|
|
47
47
|
enumerable: true,
|
|
48
|
-
get: function () { return
|
|
48
|
+
get: function () { return chunkYER7DIOM_js.EVENT_TYPES; }
|
|
49
49
|
});
|
|
50
50
|
Object.defineProperty(exports, "FxService", {
|
|
51
51
|
enumerable: true,
|
|
52
|
-
get: function () { return
|
|
52
|
+
get: function () { return chunkYER7DIOM_js.FxService; }
|
|
53
53
|
});
|
|
54
54
|
Object.defineProperty(exports, "InventoryService", {
|
|
55
55
|
enumerable: true,
|
|
56
|
-
get: function () { return
|
|
56
|
+
get: function () { return chunkYER7DIOM_js.InventoryService; }
|
|
57
57
|
});
|
|
58
58
|
Object.defineProperty(exports, "LinkService", {
|
|
59
59
|
enumerable: true,
|
|
60
|
-
get: function () { return
|
|
60
|
+
get: function () { return chunkYER7DIOM_js.LinkService; }
|
|
61
61
|
});
|
|
62
62
|
Object.defineProperty(exports, "LiteService", {
|
|
63
63
|
enumerable: true,
|
|
64
|
-
get: function () { return
|
|
64
|
+
get: function () { return chunkYER7DIOM_js.LiteService; }
|
|
65
65
|
});
|
|
66
66
|
Object.defineProperty(exports, "MESSAGE_TYPES", {
|
|
67
67
|
enumerable: true,
|
|
68
|
-
get: function () { return
|
|
68
|
+
get: function () { return chunkYER7DIOM_js.MESSAGE_TYPES; }
|
|
69
69
|
});
|
|
70
70
|
Object.defineProperty(exports, "OrderQueries", {
|
|
71
71
|
enumerable: true,
|
|
72
|
-
get: function () { return
|
|
72
|
+
get: function () { return chunkYER7DIOM_js.OrderQueries; }
|
|
73
73
|
});
|
|
74
74
|
Object.defineProperty(exports, "SchedulingService", {
|
|
75
75
|
enumerable: true,
|
|
76
|
-
get: function () { return
|
|
76
|
+
get: function () { return chunkYER7DIOM_js.SchedulingService; }
|
|
77
77
|
});
|
|
78
78
|
Object.defineProperty(exports, "createElements", {
|
|
79
79
|
enumerable: true,
|
|
80
|
-
get: function () { return
|
|
80
|
+
get: function () { return chunkYER7DIOM_js.createElements; }
|
|
81
81
|
});
|
|
82
82
|
Object.defineProperty(exports, "generateIdempotencyKey", {
|
|
83
83
|
enumerable: true,
|
|
84
|
-
get: function () { return
|
|
84
|
+
get: function () { return chunkYER7DIOM_js.generateIdempotencyKey; }
|
|
85
85
|
});
|
package/dist/advanced.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
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-Z3K2D3TE.mjs';
|
|
2
2
|
import './chunk-DLW3RWRK.mjs';
|
|
3
3
|
import './chunk-O3YUHLZL.mjs';
|
|
4
4
|
import './chunk-3G6RQLXK.mjs';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { createMockApp } from './chunk-
|
|
2
|
-
import { createCimplifyClient } from './chunk-
|
|
1
|
+
import { createMockApp } from './chunk-YHPMFTMN.mjs';
|
|
2
|
+
import { createCimplifyClient } from './chunk-DKLHCZ5M.mjs';
|
|
3
3
|
import { z } from 'zod';
|
|
4
4
|
|
|
5
5
|
var cimplifyRegistry = z.registry();
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { safe, generateIdempotencyKey, err, ok, CatalogueQueries, CartOperations, CheckoutService, OrderQueries, LinkService, AuthService, BusinessService, InventoryService, SchedulingService, LiteService, FxService, createElements } from './chunk-
|
|
1
|
+
import { safe, generateIdempotencyKey, err, ok, CatalogueQueries, CartOperations, CheckoutService, OrderQueries, LinkService, AuthService, BusinessService, InventoryService, SchedulingService, LiteService, FxService, createElements } from './chunk-Z3K2D3TE.mjs';
|
|
2
2
|
import { CimplifyError, ErrorCode, IdempotencyMismatchError, enrichError } from './chunk-O3YUHLZL.mjs';
|
|
3
3
|
|
|
4
4
|
// src/store-credit.ts
|
|
@@ -970,6 +970,9 @@ var CimplifyClient = class {
|
|
|
970
970
|
getSessionEpoch() {
|
|
971
971
|
return this.sessionEpoch;
|
|
972
972
|
}
|
|
973
|
+
getSessionToken() {
|
|
974
|
+
return this.sessionToken;
|
|
975
|
+
}
|
|
973
976
|
publishSessionClaimed(customerName) {
|
|
974
977
|
if (!this.sessionToken) return;
|
|
975
978
|
this.broadcastSessionSync({
|
|
@@ -2308,6 +2308,10 @@ function buildV1(deps) {
|
|
|
2308
2308
|
app.delete("/cart/items/:cart_item_id", (c) => tryRoute(c, () => deps.cart.removeItem(c.var.session, c.req.param("cart_item_id"))));
|
|
2309
2309
|
app.get("/cart/count", (c) => tryRoute(c, () => deps.cart.getCount(c.var.session)));
|
|
2310
2310
|
app.get("/cart/total", (c) => tryRoute(c, () => deps.cart.getTotal(c.var.session)));
|
|
2311
|
+
app.post("/cart/destination-quote", async (c) => {
|
|
2312
|
+
const body = await c.req.json();
|
|
2313
|
+
return tryRoute(c, () => deps.cart.quoteDestination(c.var.session, body));
|
|
2314
|
+
});
|
|
2311
2315
|
app.post("/cart/coupons", async (c) => {
|
|
2312
2316
|
const body = await c.req.json().catch(() => ({}));
|
|
2313
2317
|
return tryRoute(c, () => deps.cart.applyCoupon(c.var.session, body.coupon_code ?? ""));
|
|
@@ -4796,6 +4800,30 @@ function createCartService(opts) {
|
|
|
4796
4800
|
getTotal(session) {
|
|
4797
4801
|
return findOrCreate(session).total_price;
|
|
4798
4802
|
},
|
|
4803
|
+
quoteDestination(session, body) {
|
|
4804
|
+
const cart = findOrCreate(session);
|
|
4805
|
+
const city = body.address_info.city?.trim();
|
|
4806
|
+
const region = body.address_info.region?.trim();
|
|
4807
|
+
const label = city && region ? `${city}, ${region}` : city ?? region ?? "";
|
|
4808
|
+
const deliveryFee = body.order_type === "delivery" ? "5.00" : "0.00";
|
|
4809
|
+
const total = (Number(cart.total_price) + Number(deliveryFee)).toFixed(2);
|
|
4810
|
+
return {
|
|
4811
|
+
subtotal: cart.subtotal,
|
|
4812
|
+
tax_amount: cart.tax_amount,
|
|
4813
|
+
service_charge: cart.service_charge,
|
|
4814
|
+
total_discounts: cart.total_discounts,
|
|
4815
|
+
delivery_fee: deliveryFee,
|
|
4816
|
+
statutory_charge_total: "0.00",
|
|
4817
|
+
statutory_charges: [],
|
|
4818
|
+
total,
|
|
4819
|
+
currency: cart.currency,
|
|
4820
|
+
tax_jurisdiction_label: label,
|
|
4821
|
+
tax_inclusive: false,
|
|
4822
|
+
tax_rate: cart.tax_rate,
|
|
4823
|
+
delivery_fee_details: null,
|
|
4824
|
+
address_info: body.address_info
|
|
4825
|
+
};
|
|
4826
|
+
},
|
|
4799
4827
|
toUICart(cart) {
|
|
4800
4828
|
return toUICart(registry, cart);
|
|
4801
4829
|
},
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var
|
|
3
|
+
var chunkH5SSGN7W_js = require('./chunk-H5SSGN7W.js');
|
|
4
|
+
var chunkYDA46OZ6_js = require('./chunk-YDA46OZ6.js');
|
|
5
5
|
var zod = require('zod');
|
|
6
6
|
|
|
7
7
|
var cimplifyRegistry = zod.z.registry();
|
|
@@ -600,7 +600,7 @@ async function toForwardedRequest(input, init) {
|
|
|
600
600
|
};
|
|
601
601
|
}
|
|
602
602
|
function createTestClient(options = {}) {
|
|
603
|
-
const mock =
|
|
603
|
+
const mock = chunkH5SSGN7W_js.createMockApp(options);
|
|
604
604
|
let sessionToken;
|
|
605
605
|
const fetchImpl = async (input, init) => {
|
|
606
606
|
const url = typeof input === "string" ? input : input instanceof URL ? input.toString() : input.url;
|
|
@@ -619,7 +619,7 @@ function createTestClient(options = {}) {
|
|
|
619
619
|
if (echoed) sessionToken = echoed;
|
|
620
620
|
return res;
|
|
621
621
|
};
|
|
622
|
-
const client =
|
|
622
|
+
const client = chunkYDA46OZ6_js.createCimplifyClient({
|
|
623
623
|
baseUrl: TEST_BASE_URL,
|
|
624
624
|
// Link mock lives at /v1/link on the same Hono app, so point the SDK's
|
|
625
625
|
// separate Link transport at the same TEST_BASE_URL.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunkYER7DIOM_js = require('./chunk-YER7DIOM.js');
|
|
4
4
|
var chunkNIOUSKQQ_js = require('./chunk-NIOUSKQQ.js');
|
|
5
5
|
|
|
6
6
|
// src/store-credit.ts
|
|
@@ -13,7 +13,7 @@ var StoreCreditQueries = class {
|
|
|
13
13
|
* currency. Requires a signed-in customer; returns an error otherwise.
|
|
14
14
|
*/
|
|
15
15
|
async balance() {
|
|
16
|
-
return
|
|
16
|
+
return chunkYER7DIOM_js.safe(this.client.get("/api/v1/store-credit/balance"));
|
|
17
17
|
}
|
|
18
18
|
};
|
|
19
19
|
|
|
@@ -262,7 +262,7 @@ var ActivityService = class {
|
|
|
262
262
|
this.sendEvents([event]);
|
|
263
263
|
}
|
|
264
264
|
async getState() {
|
|
265
|
-
return
|
|
265
|
+
return chunkYER7DIOM_js.safe(this.client.get("/api/v1/activity/state"));
|
|
266
266
|
}
|
|
267
267
|
async getRecommendations(options) {
|
|
268
268
|
const params = new URLSearchParams();
|
|
@@ -270,10 +270,10 @@ var ActivityService = class {
|
|
|
270
270
|
if (options?.limit) params.set("limit", String(options.limit));
|
|
271
271
|
const query = params.toString();
|
|
272
272
|
const path = query ? `/api/v1/activity/recommendations?${query}` : "/api/v1/activity/recommendations";
|
|
273
|
-
return
|
|
273
|
+
return chunkYER7DIOM_js.safe(this.client.get(path));
|
|
274
274
|
}
|
|
275
275
|
async dismissMessage(code) {
|
|
276
|
-
return
|
|
276
|
+
return chunkYER7DIOM_js.safe(
|
|
277
277
|
this.client.post("/api/v1/activity/messages/dismiss", { code })
|
|
278
278
|
);
|
|
279
279
|
}
|
|
@@ -369,16 +369,16 @@ var SubscriptionService = class {
|
|
|
369
369
|
this.client = client;
|
|
370
370
|
}
|
|
371
371
|
async list() {
|
|
372
|
-
return
|
|
372
|
+
return chunkYER7DIOM_js.safe(this.client.get("/api/v1/subscriptions"));
|
|
373
373
|
}
|
|
374
374
|
async get(id) {
|
|
375
375
|
const encodedId = encodeURIComponent(id);
|
|
376
|
-
return
|
|
376
|
+
return chunkYER7DIOM_js.safe(this.client.get(`/api/v1/subscriptions/${encodedId}`));
|
|
377
377
|
}
|
|
378
378
|
async cancel(id, reason, opts) {
|
|
379
379
|
const encodedId = encodeURIComponent(id);
|
|
380
|
-
const idempotencyKey = opts?.idempotencyKey ??
|
|
381
|
-
return
|
|
380
|
+
const idempotencyKey = opts?.idempotencyKey ?? chunkYER7DIOM_js.generateIdempotencyKey();
|
|
381
|
+
return chunkYER7DIOM_js.safe(
|
|
382
382
|
this.client.post(
|
|
383
383
|
`/api/v1/subscriptions/${encodedId}/cancel`,
|
|
384
384
|
{ reason },
|
|
@@ -388,20 +388,20 @@ var SubscriptionService = class {
|
|
|
388
388
|
}
|
|
389
389
|
async pause(id) {
|
|
390
390
|
const encodedId = encodeURIComponent(id);
|
|
391
|
-
return
|
|
391
|
+
return chunkYER7DIOM_js.safe(
|
|
392
392
|
this.client.post(`/api/v1/subscriptions/${encodedId}/pause`)
|
|
393
393
|
);
|
|
394
394
|
}
|
|
395
395
|
async resume(id) {
|
|
396
396
|
const encodedId = encodeURIComponent(id);
|
|
397
|
-
return
|
|
397
|
+
return chunkYER7DIOM_js.safe(
|
|
398
398
|
this.client.post(`/api/v1/subscriptions/${encodedId}/resume`)
|
|
399
399
|
);
|
|
400
400
|
}
|
|
401
401
|
async skipNextRenewal(id, opts) {
|
|
402
402
|
const encodedId = encodeURIComponent(id);
|
|
403
|
-
const idempotencyKey = opts?.idempotencyKey ??
|
|
404
|
-
return
|
|
403
|
+
const idempotencyKey = opts?.idempotencyKey ?? chunkYER7DIOM_js.generateIdempotencyKey();
|
|
404
|
+
return chunkYER7DIOM_js.safe(
|
|
405
405
|
this.client.post(
|
|
406
406
|
`/api/v1/subscriptions/${encodedId}/skip`,
|
|
407
407
|
void 0,
|
|
@@ -417,8 +417,8 @@ var UploadService = class {
|
|
|
417
417
|
this.client = client;
|
|
418
418
|
}
|
|
419
419
|
async init(filename, contentType, sizeBytes, opts) {
|
|
420
|
-
const idempotencyKey = opts?.idempotencyKey ??
|
|
421
|
-
return
|
|
420
|
+
const idempotencyKey = opts?.idempotencyKey ?? chunkYER7DIOM_js.generateIdempotencyKey();
|
|
421
|
+
return chunkYER7DIOM_js.safe(
|
|
422
422
|
this.client.post(
|
|
423
423
|
"/api/v1/uploads/init",
|
|
424
424
|
{
|
|
@@ -431,7 +431,7 @@ var UploadService = class {
|
|
|
431
431
|
);
|
|
432
432
|
}
|
|
433
433
|
async confirm(uploadId) {
|
|
434
|
-
return
|
|
434
|
+
return chunkYER7DIOM_js.safe(
|
|
435
435
|
this.client.post("/api/v1/uploads/confirm", {
|
|
436
436
|
upload_id: uploadId
|
|
437
437
|
})
|
|
@@ -477,7 +477,7 @@ var PlacesService = class {
|
|
|
477
477
|
this.client = client;
|
|
478
478
|
}
|
|
479
479
|
async autocomplete(input, sessionToken) {
|
|
480
|
-
return
|
|
480
|
+
return chunkYER7DIOM_js.safe(
|
|
481
481
|
this.client.post("/api/v1/places/autocomplete", {
|
|
482
482
|
input,
|
|
483
483
|
sessionToken
|
|
@@ -485,7 +485,7 @@ var PlacesService = class {
|
|
|
485
485
|
);
|
|
486
486
|
}
|
|
487
487
|
async details(placeId, sessionToken) {
|
|
488
|
-
return
|
|
488
|
+
return chunkYER7DIOM_js.safe(
|
|
489
489
|
this.client.post("/api/v1/places/details", {
|
|
490
490
|
place_id: placeId,
|
|
491
491
|
sessionToken
|
|
@@ -504,7 +504,7 @@ var DeliveryService = class {
|
|
|
504
504
|
params.set("dropoff_lat", String(dropoffLat));
|
|
505
505
|
params.set("dropoff_lng", String(dropoffLng));
|
|
506
506
|
if (country) params.set("country", country);
|
|
507
|
-
return
|
|
507
|
+
return chunkYER7DIOM_js.safe(this.client.get(`/api/v1/delivery/fee?${params.toString()}`));
|
|
508
508
|
}
|
|
509
509
|
async getOptions(queryOrLatitude, longitude, legacyOptions) {
|
|
510
510
|
const query = typeof queryOrLatitude === "number" ? {
|
|
@@ -518,7 +518,7 @@ var DeliveryService = class {
|
|
|
518
518
|
if (query.country) params.set("country", query.country);
|
|
519
519
|
if (query.currency) params.set("currency", query.currency);
|
|
520
520
|
if (query.orderValue != null) params.set("order_value", String(query.orderValue));
|
|
521
|
-
return
|
|
521
|
+
return chunkYER7DIOM_js.safe(
|
|
522
522
|
this.client.get(`/api/v1/delivery/options?${params.toString()}`)
|
|
523
523
|
);
|
|
524
524
|
}
|
|
@@ -595,7 +595,7 @@ var SupportService = class {
|
|
|
595
595
|
async claimConversation() {
|
|
596
596
|
const accessToken = this.client.getAccessToken();
|
|
597
597
|
if (!accessToken) {
|
|
598
|
-
return
|
|
598
|
+
return chunkYER7DIOM_js.err(new chunkNIOUSKQQ_js.CimplifyError("not_authenticated", "No access token to claim with"));
|
|
599
599
|
}
|
|
600
600
|
if (this.claimInFlight) {
|
|
601
601
|
if (this.claimInFlightToken === accessToken) return this.claimInFlight;
|
|
@@ -603,12 +603,12 @@ var SupportService = class {
|
|
|
603
603
|
return this.claimConversation();
|
|
604
604
|
}
|
|
605
605
|
if (this.lastClaimedAccessToken === accessToken) {
|
|
606
|
-
return
|
|
606
|
+
return chunkYER7DIOM_js.err(new chunkNIOUSKQQ_js.CimplifyError("already_claimed", "Session already claimed for this token"));
|
|
607
607
|
}
|
|
608
608
|
const epoch = this.client.getSessionEpoch();
|
|
609
609
|
this.claimInFlightToken = accessToken;
|
|
610
610
|
this.claimInFlight = (async () => {
|
|
611
|
-
const result = await
|
|
611
|
+
const result = await chunkYER7DIOM_js.safe(
|
|
612
612
|
this.client.post(
|
|
613
613
|
"/api/v1/support/conversation/claim",
|
|
614
614
|
{ access_token: accessToken },
|
|
@@ -617,7 +617,7 @@ var SupportService = class {
|
|
|
617
617
|
);
|
|
618
618
|
if (result.ok) {
|
|
619
619
|
if (this.client.getSessionEpoch() !== epoch) {
|
|
620
|
-
return
|
|
620
|
+
return chunkYER7DIOM_js.err(
|
|
621
621
|
new chunkNIOUSKQQ_js.CimplifyError("session_cleared", "Session was cleared during the claim")
|
|
622
622
|
);
|
|
623
623
|
}
|
|
@@ -646,20 +646,20 @@ var SupportService = class {
|
|
|
646
646
|
* the inbox with empty threads.
|
|
647
647
|
*/
|
|
648
648
|
async peekConversation() {
|
|
649
|
-
const result = await
|
|
649
|
+
const result = await chunkYER7DIOM_js.safe(
|
|
650
650
|
this.client.get("/api/v1/support/conversation")
|
|
651
651
|
);
|
|
652
652
|
if (!result.ok) return result;
|
|
653
|
-
if (!result.value.conversation) return
|
|
654
|
-
return
|
|
653
|
+
if (!result.value.conversation) return chunkYER7DIOM_js.ok(null);
|
|
654
|
+
return chunkYER7DIOM_js.ok({
|
|
655
655
|
conversation: result.value.conversation,
|
|
656
656
|
messages: result.value.messages
|
|
657
657
|
});
|
|
658
658
|
}
|
|
659
659
|
/** Open (or resume) the customer's widget conversation. */
|
|
660
660
|
async openConversation(opts) {
|
|
661
|
-
const idempotencyKey = opts?.idempotencyKey ??
|
|
662
|
-
return
|
|
661
|
+
const idempotencyKey = opts?.idempotencyKey ?? chunkYER7DIOM_js.generateIdempotencyKey();
|
|
662
|
+
return chunkYER7DIOM_js.safe(
|
|
663
663
|
this.client.post("/api/v1/support/conversation", void 0, {
|
|
664
664
|
idempotencyKey
|
|
665
665
|
})
|
|
@@ -674,8 +674,8 @@ var SupportService = class {
|
|
|
674
674
|
* server resolves it thread-scoped and echoes the quote as `reply_to`.
|
|
675
675
|
*/
|
|
676
676
|
async sendMessage(content, opts) {
|
|
677
|
-
const idempotencyKey = opts?.idempotencyKey ??
|
|
678
|
-
return
|
|
677
|
+
const idempotencyKey = opts?.idempotencyKey ?? chunkYER7DIOM_js.generateIdempotencyKey();
|
|
678
|
+
return chunkYER7DIOM_js.safe(
|
|
679
679
|
this.client.post(
|
|
680
680
|
"/api/v1/support/conversation/messages",
|
|
681
681
|
{
|
|
@@ -699,11 +699,11 @@ var SupportService = class {
|
|
|
699
699
|
if (options.limit) params.set("limit", String(options.limit));
|
|
700
700
|
const query = params.toString();
|
|
701
701
|
const path = query ? `/api/v1/support/conversation/messages?${query}` : "/api/v1/support/conversation/messages";
|
|
702
|
-
return
|
|
702
|
+
return chunkYER7DIOM_js.safe(this.client.get(path));
|
|
703
703
|
}
|
|
704
704
|
/** React to a message in the active conversation by its `ChatMessage.id`. */
|
|
705
705
|
async reactToMessage(messageId, emoji) {
|
|
706
|
-
return
|
|
706
|
+
return chunkYER7DIOM_js.safe(
|
|
707
707
|
this.client.post(
|
|
708
708
|
`/api/v1/support/conversation/messages/${messageId}/reactions`,
|
|
709
709
|
{ emoji }
|
|
@@ -712,8 +712,8 @@ var SupportService = class {
|
|
|
712
712
|
}
|
|
713
713
|
/** Ask for a person: flags the thread for the merchant's inbox. */
|
|
714
714
|
async requestHuman(opts) {
|
|
715
|
-
const idempotencyKey = opts?.idempotencyKey ??
|
|
716
|
-
return
|
|
715
|
+
const idempotencyKey = opts?.idempotencyKey ?? chunkYER7DIOM_js.generateIdempotencyKey();
|
|
716
|
+
return chunkYER7DIOM_js.safe(
|
|
717
717
|
this.client.post(
|
|
718
718
|
"/api/v1/support/conversation/handoff",
|
|
719
719
|
void 0,
|
|
@@ -972,6 +972,9 @@ var CimplifyClient = class {
|
|
|
972
972
|
getSessionEpoch() {
|
|
973
973
|
return this.sessionEpoch;
|
|
974
974
|
}
|
|
975
|
+
getSessionToken() {
|
|
976
|
+
return this.sessionToken;
|
|
977
|
+
}
|
|
975
978
|
publishSessionClaimed(customerName) {
|
|
976
979
|
if (!this.sessionToken) return;
|
|
977
980
|
this.broadcastSessionSync({
|
|
@@ -1445,25 +1448,25 @@ var CimplifyClient = class {
|
|
|
1445
1448
|
}
|
|
1446
1449
|
get catalogue() {
|
|
1447
1450
|
if (!this._catalogue) {
|
|
1448
|
-
this._catalogue = new
|
|
1451
|
+
this._catalogue = new chunkYER7DIOM_js.CatalogueQueries(this);
|
|
1449
1452
|
}
|
|
1450
1453
|
return this._catalogue;
|
|
1451
1454
|
}
|
|
1452
1455
|
get cart() {
|
|
1453
1456
|
if (!this._cart) {
|
|
1454
|
-
this._cart = new
|
|
1457
|
+
this._cart = new chunkYER7DIOM_js.CartOperations(this);
|
|
1455
1458
|
}
|
|
1456
1459
|
return this._cart;
|
|
1457
1460
|
}
|
|
1458
1461
|
get checkout() {
|
|
1459
1462
|
if (!this._checkout) {
|
|
1460
|
-
this._checkout = new
|
|
1463
|
+
this._checkout = new chunkYER7DIOM_js.CheckoutService(this);
|
|
1461
1464
|
}
|
|
1462
1465
|
return this._checkout;
|
|
1463
1466
|
}
|
|
1464
1467
|
get orders() {
|
|
1465
1468
|
if (!this._orders) {
|
|
1466
|
-
this._orders = new
|
|
1469
|
+
this._orders = new chunkYER7DIOM_js.OrderQueries(this);
|
|
1467
1470
|
}
|
|
1468
1471
|
return this._orders;
|
|
1469
1472
|
}
|
|
@@ -1493,43 +1496,43 @@ var CimplifyClient = class {
|
|
|
1493
1496
|
}
|
|
1494
1497
|
get link() {
|
|
1495
1498
|
if (!this._link) {
|
|
1496
|
-
this._link = new
|
|
1499
|
+
this._link = new chunkYER7DIOM_js.LinkService(this);
|
|
1497
1500
|
}
|
|
1498
1501
|
return this._link;
|
|
1499
1502
|
}
|
|
1500
1503
|
get auth() {
|
|
1501
1504
|
if (!this._auth) {
|
|
1502
|
-
this._auth = new
|
|
1505
|
+
this._auth = new chunkYER7DIOM_js.AuthService(this);
|
|
1503
1506
|
}
|
|
1504
1507
|
return this._auth;
|
|
1505
1508
|
}
|
|
1506
1509
|
get business() {
|
|
1507
1510
|
if (!this._business) {
|
|
1508
|
-
this._business = new
|
|
1511
|
+
this._business = new chunkYER7DIOM_js.BusinessService(this);
|
|
1509
1512
|
}
|
|
1510
1513
|
return this._business;
|
|
1511
1514
|
}
|
|
1512
1515
|
get inventory() {
|
|
1513
1516
|
if (!this._inventory) {
|
|
1514
|
-
this._inventory = new
|
|
1517
|
+
this._inventory = new chunkYER7DIOM_js.InventoryService(this);
|
|
1515
1518
|
}
|
|
1516
1519
|
return this._inventory;
|
|
1517
1520
|
}
|
|
1518
1521
|
get scheduling() {
|
|
1519
1522
|
if (!this._scheduling) {
|
|
1520
|
-
this._scheduling = new
|
|
1523
|
+
this._scheduling = new chunkYER7DIOM_js.SchedulingService(this);
|
|
1521
1524
|
}
|
|
1522
1525
|
return this._scheduling;
|
|
1523
1526
|
}
|
|
1524
1527
|
get lite() {
|
|
1525
1528
|
if (!this._lite) {
|
|
1526
|
-
this._lite = new
|
|
1529
|
+
this._lite = new chunkYER7DIOM_js.LiteService(this);
|
|
1527
1530
|
}
|
|
1528
1531
|
return this._lite;
|
|
1529
1532
|
}
|
|
1530
1533
|
get fx() {
|
|
1531
1534
|
if (!this._fx) {
|
|
1532
|
-
this._fx = new
|
|
1535
|
+
this._fx = new chunkYER7DIOM_js.FxService(this);
|
|
1533
1536
|
}
|
|
1534
1537
|
return this._fx;
|
|
1535
1538
|
}
|
|
@@ -1564,7 +1567,7 @@ var CimplifyClient = class {
|
|
|
1564
1567
|
if (businessId) {
|
|
1565
1568
|
this.setBusinessId(businessId);
|
|
1566
1569
|
}
|
|
1567
|
-
return
|
|
1570
|
+
return chunkYER7DIOM_js.createElements(this, businessId ?? this.businessId ?? void 0, options);
|
|
1568
1571
|
}
|
|
1569
1572
|
};
|
|
1570
1573
|
function createCimplifyClient(config = {}) {
|
|
@@ -668,6 +668,9 @@ var CartOperations = class {
|
|
|
668
668
|
async getTotal() {
|
|
669
669
|
return safe(this.client.get("/api/v1/cart/total"));
|
|
670
670
|
}
|
|
671
|
+
async quoteDestination(input) {
|
|
672
|
+
return safe(this.client.post("/api/v1/cart/destination-quote", input));
|
|
673
|
+
}
|
|
671
674
|
async getSummary() {
|
|
672
675
|
const cartResult = await this.get();
|
|
673
676
|
if (!cartResult.ok) return cartResult;
|
|
@@ -2370,6 +2373,7 @@ var ELEMENT_TYPES = {
|
|
|
2370
2373
|
var MESSAGE_TYPES = {
|
|
2371
2374
|
INIT: "init",
|
|
2372
2375
|
SET_TOKEN: "set_token",
|
|
2376
|
+
SET_SESSION: "set_session",
|
|
2373
2377
|
SET_CART: "set_cart",
|
|
2374
2378
|
GET_DATA: "get_data",
|
|
2375
2379
|
NAVIGATE: "navigate",
|
|
@@ -3132,6 +3136,9 @@ var CimplifyElements = class {
|
|
|
3132
3136
|
getPublicKey() {
|
|
3133
3137
|
return this.client.getPublicKey();
|
|
3134
3138
|
}
|
|
3139
|
+
getSessionToken() {
|
|
3140
|
+
return this.client.getSessionToken();
|
|
3141
|
+
}
|
|
3135
3142
|
getBusinessId() {
|
|
3136
3143
|
return this.businessId;
|
|
3137
3144
|
}
|
|
@@ -3239,8 +3246,12 @@ var CimplifyElements = class {
|
|
|
3239
3246
|
};
|
|
3240
3247
|
}
|
|
3241
3248
|
broadcastAccessToken(token) {
|
|
3249
|
+
const sessionToken = this.client.getSessionToken();
|
|
3242
3250
|
this.elements.forEach((element) => {
|
|
3243
3251
|
element.sendMessage({ type: MESSAGE_TYPES.SET_TOKEN, token });
|
|
3252
|
+
if (sessionToken) {
|
|
3253
|
+
element.sendMessage({ type: MESSAGE_TYPES.SET_SESSION, sessionToken });
|
|
3254
|
+
}
|
|
3244
3255
|
});
|
|
3245
3256
|
}
|
|
3246
3257
|
startEmbeddedAuth(sourceElement, request) {
|
|
@@ -3582,6 +3593,10 @@ var CimplifyElement = class {
|
|
|
3582
3593
|
if (token) {
|
|
3583
3594
|
this.sendMessage({ type: MESSAGE_TYPES.SET_TOKEN, token });
|
|
3584
3595
|
}
|
|
3596
|
+
const sessionToken = this.parent.getSessionToken();
|
|
3597
|
+
if (sessionToken) {
|
|
3598
|
+
this.sendMessage({ type: MESSAGE_TYPES.SET_SESSION, sessionToken });
|
|
3599
|
+
}
|
|
3585
3600
|
this.pendingInit = null;
|
|
3586
3601
|
}
|
|
3587
3602
|
this.flushPending();
|
|
@@ -2306,6 +2306,10 @@ function buildV1(deps) {
|
|
|
2306
2306
|
app.delete("/cart/items/:cart_item_id", (c) => tryRoute(c, () => deps.cart.removeItem(c.var.session, c.req.param("cart_item_id"))));
|
|
2307
2307
|
app.get("/cart/count", (c) => tryRoute(c, () => deps.cart.getCount(c.var.session)));
|
|
2308
2308
|
app.get("/cart/total", (c) => tryRoute(c, () => deps.cart.getTotal(c.var.session)));
|
|
2309
|
+
app.post("/cart/destination-quote", async (c) => {
|
|
2310
|
+
const body = await c.req.json();
|
|
2311
|
+
return tryRoute(c, () => deps.cart.quoteDestination(c.var.session, body));
|
|
2312
|
+
});
|
|
2309
2313
|
app.post("/cart/coupons", async (c) => {
|
|
2310
2314
|
const body = await c.req.json().catch(() => ({}));
|
|
2311
2315
|
return tryRoute(c, () => deps.cart.applyCoupon(c.var.session, body.coupon_code ?? ""));
|
|
@@ -4794,6 +4798,30 @@ function createCartService(opts) {
|
|
|
4794
4798
|
getTotal(session) {
|
|
4795
4799
|
return findOrCreate(session).total_price;
|
|
4796
4800
|
},
|
|
4801
|
+
quoteDestination(session, body) {
|
|
4802
|
+
const cart = findOrCreate(session);
|
|
4803
|
+
const city = body.address_info.city?.trim();
|
|
4804
|
+
const region = body.address_info.region?.trim();
|
|
4805
|
+
const label = city && region ? `${city}, ${region}` : city ?? region ?? "";
|
|
4806
|
+
const deliveryFee = body.order_type === "delivery" ? "5.00" : "0.00";
|
|
4807
|
+
const total = (Number(cart.total_price) + Number(deliveryFee)).toFixed(2);
|
|
4808
|
+
return {
|
|
4809
|
+
subtotal: cart.subtotal,
|
|
4810
|
+
tax_amount: cart.tax_amount,
|
|
4811
|
+
service_charge: cart.service_charge,
|
|
4812
|
+
total_discounts: cart.total_discounts,
|
|
4813
|
+
delivery_fee: deliveryFee,
|
|
4814
|
+
statutory_charge_total: "0.00",
|
|
4815
|
+
statutory_charges: [],
|
|
4816
|
+
total,
|
|
4817
|
+
currency: cart.currency,
|
|
4818
|
+
tax_jurisdiction_label: label,
|
|
4819
|
+
tax_inclusive: false,
|
|
4820
|
+
tax_rate: cart.tax_rate,
|
|
4821
|
+
delivery_fee_details: null,
|
|
4822
|
+
address_info: body.address_info
|
|
4823
|
+
};
|
|
4824
|
+
},
|
|
4797
4825
|
toUICart(cart) {
|
|
4798
4826
|
return toUICart(registry, cart);
|
|
4799
4827
|
},
|