@cimplify/sdk 0.66.0 → 0.68.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/advanced.d.mts +1 -1
- package/dist/advanced.d.ts +1 -1
- package/dist/advanced.js +20 -20
- package/dist/advanced.mjs +1 -1
- package/dist/{chunk-J3MGY6AU.js → chunk-5HAUJBOK.js} +36 -82
- package/dist/chunk-E6T5VJMG.mjs +156 -0
- package/dist/{chunk-3G4QCENX.mjs → chunk-FVGVJ4TC.mjs} +12 -50
- package/dist/chunk-IQLJJW2H.js +168 -0
- package/dist/{chunk-227XTAEB.mjs → chunk-KNPE4WCQ.mjs} +2 -48
- package/dist/{chunk-H6DBPHMZ.js → chunk-NGQCWFKF.js} +4 -4
- package/dist/{chunk-R6363CC7.mjs → chunk-SOV4H6PQ.mjs} +509 -79
- package/dist/{chunk-HCZTBWU4.js → chunk-SXGFJEME.js} +12 -50
- package/dist/{chunk-MWI5GAUF.mjs → chunk-TAKORJP4.mjs} +2 -2
- package/dist/{chunk-AVQL3TSJ.js → chunk-WCSAZRNC.js} +519 -78
- package/dist/{client-CUrA1uQ0.d.mts → client-CBE7ksYC.d.mts} +1 -1
- package/dist/{client-Bo5rujc2.d.ts → client-CfeQRwhl.d.ts} +55 -21
- package/dist/{client-DasPHOJh.d.ts → client-DlXfZy7N.d.ts} +1 -1
- package/dist/{client-Dka2cGhu.d.mts → client-Dyo3dvNy.d.mts} +55 -21
- package/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +104 -88
- package/dist/index.mjs +16 -12
- package/dist/mock/cli.mjs +12 -50
- package/dist/mock/library.js +12 -50
- package/dist/mock/library.mjs +12 -50
- package/dist/mock/msw.js +12 -50
- package/dist/mock/msw.mjs +12 -50
- package/dist/react.d.mts +44 -44
- package/dist/react.d.ts +44 -44
- package/dist/react.js +298 -175
- package/dist/react.mjs +240 -117
- package/dist/server.d.mts +2 -2
- package/dist/server.d.ts +2 -2
- package/dist/server.js +16 -9
- package/dist/server.mjs +11 -4
- package/dist/{sign-in-dr7m09nm.d.ts → sign-in-DQlIdqsi.d.mts} +14 -1
- package/dist/{sign-in-dr7m09nm.d.mts → sign-in-DQlIdqsi.d.ts} +14 -1
- package/dist/styles.css +1 -1
- package/dist/testing/msw.js +2 -2
- package/dist/testing/msw.mjs +1 -1
- package/dist/testing/suite.d.mts +2 -2
- package/dist/testing/suite.d.ts +2 -2
- package/dist/testing/suite.js +23 -23
- package/dist/testing/suite.mjs +4 -4
- package/dist/testing.d.mts +17 -17
- package/dist/testing.d.ts +17 -17
- package/dist/testing.js +79 -79
- package/dist/testing.mjs +5 -5
- package/package.json +1 -1
- package/registry/index.json +0 -9
- package/dist/chunk-3Z3FQH7X.mjs +0 -323
- package/dist/chunk-7BKKBJQM.mjs +0 -52
- package/dist/chunk-GDAGM26J.js +0 -338
- package/dist/chunk-KWYI2TTA.js +0 -60
- package/registry/account.json +0 -15
package/dist/advanced.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { k as AuthService, z as BusinessService, O as CartOperations, P as CatalogueQueries, a8 as CheckoutOperations, a8 as CheckoutService, ae as CimplifyElement, af as CimplifyElements,
|
|
1
|
+
export { k as AuthService, z as BusinessService, O as CartOperations, P as CatalogueQueries, a8 as CheckoutOperations, a8 as CheckoutService, ae as CimplifyElement, af as CimplifyElements, aE as ELEMENT_TYPES, aF as EVENT_TYPES, aI as ElementEventType, aJ as ElementOptions, aK as ElementType, aS as ElementsOptions, aY as FetchQuoteInput, b3 as FxService, b6 as GetProductsOptions, b8 as InventoryService, bf as LinkService, bj as LiteService, bq as MESSAGE_TYPES, bP as OrderQueries, c3 as PriceQuote, c9 as QuoteBundleSelectionInput, ca as QuoteCompositeSelectionInput, cb as QuoteDynamicBuckets, cc as QuoteStatus, cd as QuoteUiMessage, cf as RefreshQuoteInput, cg as RefreshQuoteResult, cH as SchedulingService, dj as createElements } from './client-Dyo3dvNy.mjs';
|
|
2
2
|
import './product-B_kS4Oxa.mjs';
|
|
3
3
|
import './payment-DVS7ZUEp.mjs';
|
|
4
4
|
|
package/dist/advanced.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { k as AuthService, z as BusinessService, O as CartOperations, P as CatalogueQueries, a8 as CheckoutOperations, a8 as CheckoutService, ae as CimplifyElement, af as CimplifyElements,
|
|
1
|
+
export { k as AuthService, z as BusinessService, O as CartOperations, P as CatalogueQueries, a8 as CheckoutOperations, a8 as CheckoutService, ae as CimplifyElement, af as CimplifyElements, aE as ELEMENT_TYPES, aF as EVENT_TYPES, aI as ElementEventType, aJ as ElementOptions, aK as ElementType, aS as ElementsOptions, aY as FetchQuoteInput, b3 as FxService, b6 as GetProductsOptions, b8 as InventoryService, bf as LinkService, bj as LiteService, bq as MESSAGE_TYPES, bP as OrderQueries, c3 as PriceQuote, c9 as QuoteBundleSelectionInput, ca as QuoteCompositeSelectionInput, cb as QuoteDynamicBuckets, cc as QuoteStatus, cd as QuoteUiMessage, cf as RefreshQuoteInput, cg as RefreshQuoteResult, cH as SchedulingService, dj as createElements } from './client-CfeQRwhl.js';
|
|
2
2
|
import './product-B_kS4Oxa.js';
|
|
3
3
|
import './payment-sn-yGL7v.js';
|
|
4
4
|
|
package/dist/advanced.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunkWCSAZRNC_js = require('./chunk-WCSAZRNC.js');
|
|
4
4
|
require('./chunk-7Y2O3E4D.js');
|
|
5
5
|
require('./chunk-XA3ZNR75.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 chunkWCSAZRNC_js.AuthService; }
|
|
13
13
|
});
|
|
14
14
|
Object.defineProperty(exports, "BusinessService", {
|
|
15
15
|
enumerable: true,
|
|
16
|
-
get: function () { return
|
|
16
|
+
get: function () { return chunkWCSAZRNC_js.BusinessService; }
|
|
17
17
|
});
|
|
18
18
|
Object.defineProperty(exports, "CartOperations", {
|
|
19
19
|
enumerable: true,
|
|
20
|
-
get: function () { return
|
|
20
|
+
get: function () { return chunkWCSAZRNC_js.CartOperations; }
|
|
21
21
|
});
|
|
22
22
|
Object.defineProperty(exports, "CatalogueQueries", {
|
|
23
23
|
enumerable: true,
|
|
24
|
-
get: function () { return
|
|
24
|
+
get: function () { return chunkWCSAZRNC_js.CatalogueQueries; }
|
|
25
25
|
});
|
|
26
26
|
Object.defineProperty(exports, "CheckoutOperations", {
|
|
27
27
|
enumerable: true,
|
|
28
|
-
get: function () { return
|
|
28
|
+
get: function () { return chunkWCSAZRNC_js.CheckoutService; }
|
|
29
29
|
});
|
|
30
30
|
Object.defineProperty(exports, "CheckoutService", {
|
|
31
31
|
enumerable: true,
|
|
32
|
-
get: function () { return
|
|
32
|
+
get: function () { return chunkWCSAZRNC_js.CheckoutService; }
|
|
33
33
|
});
|
|
34
34
|
Object.defineProperty(exports, "CimplifyElement", {
|
|
35
35
|
enumerable: true,
|
|
36
|
-
get: function () { return
|
|
36
|
+
get: function () { return chunkWCSAZRNC_js.CimplifyElement; }
|
|
37
37
|
});
|
|
38
38
|
Object.defineProperty(exports, "CimplifyElements", {
|
|
39
39
|
enumerable: true,
|
|
40
|
-
get: function () { return
|
|
40
|
+
get: function () { return chunkWCSAZRNC_js.CimplifyElements; }
|
|
41
41
|
});
|
|
42
42
|
Object.defineProperty(exports, "ELEMENT_TYPES", {
|
|
43
43
|
enumerable: true,
|
|
44
|
-
get: function () { return
|
|
44
|
+
get: function () { return chunkWCSAZRNC_js.ELEMENT_TYPES; }
|
|
45
45
|
});
|
|
46
46
|
Object.defineProperty(exports, "EVENT_TYPES", {
|
|
47
47
|
enumerable: true,
|
|
48
|
-
get: function () { return
|
|
48
|
+
get: function () { return chunkWCSAZRNC_js.EVENT_TYPES; }
|
|
49
49
|
});
|
|
50
50
|
Object.defineProperty(exports, "FxService", {
|
|
51
51
|
enumerable: true,
|
|
52
|
-
get: function () { return
|
|
52
|
+
get: function () { return chunkWCSAZRNC_js.FxService; }
|
|
53
53
|
});
|
|
54
54
|
Object.defineProperty(exports, "InventoryService", {
|
|
55
55
|
enumerable: true,
|
|
56
|
-
get: function () { return
|
|
56
|
+
get: function () { return chunkWCSAZRNC_js.InventoryService; }
|
|
57
57
|
});
|
|
58
58
|
Object.defineProperty(exports, "LinkService", {
|
|
59
59
|
enumerable: true,
|
|
60
|
-
get: function () { return
|
|
60
|
+
get: function () { return chunkWCSAZRNC_js.LinkService; }
|
|
61
61
|
});
|
|
62
62
|
Object.defineProperty(exports, "LiteService", {
|
|
63
63
|
enumerable: true,
|
|
64
|
-
get: function () { return
|
|
64
|
+
get: function () { return chunkWCSAZRNC_js.LiteService; }
|
|
65
65
|
});
|
|
66
66
|
Object.defineProperty(exports, "MESSAGE_TYPES", {
|
|
67
67
|
enumerable: true,
|
|
68
|
-
get: function () { return
|
|
68
|
+
get: function () { return chunkWCSAZRNC_js.MESSAGE_TYPES; }
|
|
69
69
|
});
|
|
70
70
|
Object.defineProperty(exports, "OrderQueries", {
|
|
71
71
|
enumerable: true,
|
|
72
|
-
get: function () { return
|
|
72
|
+
get: function () { return chunkWCSAZRNC_js.OrderQueries; }
|
|
73
73
|
});
|
|
74
74
|
Object.defineProperty(exports, "SchedulingService", {
|
|
75
75
|
enumerable: true,
|
|
76
|
-
get: function () { return
|
|
76
|
+
get: function () { return chunkWCSAZRNC_js.SchedulingService; }
|
|
77
77
|
});
|
|
78
78
|
Object.defineProperty(exports, "createElements", {
|
|
79
79
|
enumerable: true,
|
|
80
|
-
get: function () { return
|
|
80
|
+
get: function () { return chunkWCSAZRNC_js.createElements; }
|
|
81
81
|
});
|
|
82
82
|
Object.defineProperty(exports, "generateIdempotencyKey", {
|
|
83
83
|
enumerable: true,
|
|
84
|
-
get: function () { return
|
|
84
|
+
get: function () { return chunkWCSAZRNC_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-SOV4H6PQ.mjs';
|
|
2
2
|
import './chunk-TD3AY34U.mjs';
|
|
3
3
|
import './chunk-AMZXALF6.mjs';
|
|
4
4
|
import './chunk-3G6RQLXK.mjs';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunkWCSAZRNC_js = require('./chunk-WCSAZRNC.js');
|
|
4
4
|
var chunkXA3ZNR75_js = require('./chunk-XA3ZNR75.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 chunkWCSAZRNC_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 chunkWCSAZRNC_js.safe(this.client.get(path));
|
|
41
41
|
}
|
|
42
42
|
async dismissMessage(code) {
|
|
43
|
-
return
|
|
43
|
+
return chunkWCSAZRNC_js.safe(
|
|
44
44
|
this.client.post("/api/v1/activity/messages/dismiss", { code })
|
|
45
45
|
);
|
|
46
46
|
}
|
|
@@ -62,16 +62,16 @@ var SubscriptionService = class {
|
|
|
62
62
|
this.client = client;
|
|
63
63
|
}
|
|
64
64
|
async list() {
|
|
65
|
-
return
|
|
65
|
+
return chunkWCSAZRNC_js.safe(this.client.get("/api/v1/subscriptions"));
|
|
66
66
|
}
|
|
67
67
|
async get(id) {
|
|
68
68
|
const encodedId = encodeURIComponent(id);
|
|
69
|
-
return
|
|
69
|
+
return chunkWCSAZRNC_js.safe(this.client.get(`/api/v1/subscriptions/${encodedId}`));
|
|
70
70
|
}
|
|
71
71
|
async cancel(id, reason, opts) {
|
|
72
72
|
const encodedId = encodeURIComponent(id);
|
|
73
|
-
const idempotencyKey = opts?.idempotencyKey ??
|
|
74
|
-
return
|
|
73
|
+
const idempotencyKey = opts?.idempotencyKey ?? chunkWCSAZRNC_js.generateIdempotencyKey();
|
|
74
|
+
return chunkWCSAZRNC_js.safe(
|
|
75
75
|
this.client.post(
|
|
76
76
|
`/api/v1/subscriptions/${encodedId}/cancel`,
|
|
77
77
|
{ reason },
|
|
@@ -81,20 +81,20 @@ var SubscriptionService = class {
|
|
|
81
81
|
}
|
|
82
82
|
async pause(id) {
|
|
83
83
|
const encodedId = encodeURIComponent(id);
|
|
84
|
-
return
|
|
84
|
+
return chunkWCSAZRNC_js.safe(
|
|
85
85
|
this.client.post(`/api/v1/subscriptions/${encodedId}/pause`)
|
|
86
86
|
);
|
|
87
87
|
}
|
|
88
88
|
async resume(id) {
|
|
89
89
|
const encodedId = encodeURIComponent(id);
|
|
90
|
-
return
|
|
90
|
+
return chunkWCSAZRNC_js.safe(
|
|
91
91
|
this.client.post(`/api/v1/subscriptions/${encodedId}/resume`)
|
|
92
92
|
);
|
|
93
93
|
}
|
|
94
94
|
async skipNextRenewal(id, opts) {
|
|
95
95
|
const encodedId = encodeURIComponent(id);
|
|
96
|
-
const idempotencyKey = opts?.idempotencyKey ??
|
|
97
|
-
return
|
|
96
|
+
const idempotencyKey = opts?.idempotencyKey ?? chunkWCSAZRNC_js.generateIdempotencyKey();
|
|
97
|
+
return chunkWCSAZRNC_js.safe(
|
|
98
98
|
this.client.post(
|
|
99
99
|
`/api/v1/subscriptions/${encodedId}/skip`,
|
|
100
100
|
void 0,
|
|
@@ -110,8 +110,8 @@ var UploadService = class {
|
|
|
110
110
|
this.client = client;
|
|
111
111
|
}
|
|
112
112
|
async init(filename, contentType, sizeBytes, opts) {
|
|
113
|
-
const idempotencyKey = opts?.idempotencyKey ??
|
|
114
|
-
return
|
|
113
|
+
const idempotencyKey = opts?.idempotencyKey ?? chunkWCSAZRNC_js.generateIdempotencyKey();
|
|
114
|
+
return chunkWCSAZRNC_js.safe(
|
|
115
115
|
this.client.post(
|
|
116
116
|
"/api/v1/uploads/init",
|
|
117
117
|
{
|
|
@@ -124,7 +124,7 @@ var UploadService = class {
|
|
|
124
124
|
);
|
|
125
125
|
}
|
|
126
126
|
async confirm(uploadId) {
|
|
127
|
-
return
|
|
127
|
+
return chunkWCSAZRNC_js.safe(
|
|
128
128
|
this.client.post("/api/v1/uploads/confirm", {
|
|
129
129
|
upload_id: uploadId
|
|
130
130
|
})
|
|
@@ -170,7 +170,7 @@ var PlacesService = class {
|
|
|
170
170
|
this.client = client;
|
|
171
171
|
}
|
|
172
172
|
async autocomplete(input, sessionToken) {
|
|
173
|
-
return
|
|
173
|
+
return chunkWCSAZRNC_js.safe(
|
|
174
174
|
this.client.post("/api/v1/places/autocomplete", {
|
|
175
175
|
input,
|
|
176
176
|
sessionToken
|
|
@@ -178,7 +178,7 @@ var PlacesService = class {
|
|
|
178
178
|
);
|
|
179
179
|
}
|
|
180
180
|
async details(placeId, sessionToken) {
|
|
181
|
-
return
|
|
181
|
+
return chunkWCSAZRNC_js.safe(
|
|
182
182
|
this.client.post("/api/v1/places/details", {
|
|
183
183
|
place_id: placeId,
|
|
184
184
|
sessionToken
|
|
@@ -197,7 +197,7 @@ var DeliveryService = class {
|
|
|
197
197
|
params.set("dropoff_lat", String(dropoffLat));
|
|
198
198
|
params.set("dropoff_lng", String(dropoffLng));
|
|
199
199
|
if (country) params.set("country", country);
|
|
200
|
-
return
|
|
200
|
+
return chunkWCSAZRNC_js.safe(
|
|
201
201
|
this.client.get(`/api/v1/delivery/fee?${params.toString()}`)
|
|
202
202
|
);
|
|
203
203
|
}
|
|
@@ -210,8 +210,8 @@ var SupportService = class {
|
|
|
210
210
|
}
|
|
211
211
|
/** Open (or resume) the customer's widget conversation. */
|
|
212
212
|
async openConversation(opts) {
|
|
213
|
-
const idempotencyKey = opts?.idempotencyKey ??
|
|
214
|
-
return
|
|
213
|
+
const idempotencyKey = opts?.idempotencyKey ?? chunkWCSAZRNC_js.generateIdempotencyKey();
|
|
214
|
+
return chunkWCSAZRNC_js.safe(
|
|
215
215
|
this.client.post("/api/v1/support/conversation", void 0, {
|
|
216
216
|
idempotencyKey
|
|
217
217
|
})
|
|
@@ -219,8 +219,8 @@ var SupportService = class {
|
|
|
219
219
|
}
|
|
220
220
|
/** Send a message in the active conversation. */
|
|
221
221
|
async sendMessage(content, opts) {
|
|
222
|
-
const idempotencyKey = opts?.idempotencyKey ??
|
|
223
|
-
return
|
|
222
|
+
const idempotencyKey = opts?.idempotencyKey ?? chunkWCSAZRNC_js.generateIdempotencyKey();
|
|
223
|
+
return chunkWCSAZRNC_js.safe(
|
|
224
224
|
this.client.post(
|
|
225
225
|
"/api/v1/support/conversation/messages",
|
|
226
226
|
{ content },
|
|
@@ -235,7 +235,7 @@ var SupportService = class {
|
|
|
235
235
|
if (options.limit) params.set("limit", String(options.limit));
|
|
236
236
|
const query = params.toString();
|
|
237
237
|
const path = query ? `/api/v1/support/conversation/messages?${query}` : "/api/v1/support/conversation/messages";
|
|
238
|
-
return
|
|
238
|
+
return chunkWCSAZRNC_js.safe(this.client.get(path));
|
|
239
239
|
}
|
|
240
240
|
};
|
|
241
241
|
|
|
@@ -276,7 +276,6 @@ function createClientEvents() {
|
|
|
276
276
|
var SESSION_TOKEN_STORAGE_KEY = "cimplify_session_token";
|
|
277
277
|
var ORDER_TOKEN_PREFIX = "cimplify_ot_";
|
|
278
278
|
var SESSION_TOKEN_HEADER = "x-session-token";
|
|
279
|
-
var REFRESH_ENDPOINT = "/v1/link/elements/refresh";
|
|
280
279
|
var ORDER_TOKEN_TTL_MS = 24 * 60 * 60 * 1e3;
|
|
281
280
|
var DEFAULT_TIMEOUT_MS = 5e3;
|
|
282
281
|
var DEFAULT_MAX_RETRIES = 3;
|
|
@@ -384,7 +383,6 @@ var CimplifyClient = class {
|
|
|
384
383
|
this.context = {};
|
|
385
384
|
this.businessId = null;
|
|
386
385
|
this.businessIdResolvePromise = null;
|
|
387
|
-
this.refreshInflight = null;
|
|
388
386
|
this.inflightRequests = /* @__PURE__ */ new Map();
|
|
389
387
|
/**
|
|
390
388
|
* App-level event channel. Subscribe to surface mutation rollbacks, outbox
|
|
@@ -531,52 +529,8 @@ var CimplifyClient = class {
|
|
|
531
529
|
this.businessIdResolvePromise = null;
|
|
532
530
|
}
|
|
533
531
|
}
|
|
534
|
-
// Browser-only (the server is handed a token directly). Concurrent 401s share
|
|
535
|
-
// one in-flight refresh so the rotating cookie rotates once, not N times.
|
|
536
|
-
async refreshAccessToken() {
|
|
537
|
-
if (typeof window === "undefined") return false;
|
|
538
|
-
if (this.refreshInflight) return this.refreshInflight;
|
|
539
|
-
this.refreshInflight = (async () => {
|
|
540
|
-
try {
|
|
541
|
-
const headers = { "Content-Type": "application/json" };
|
|
542
|
-
const trimmedPublicKey = this.publicKey.trim();
|
|
543
|
-
if (trimmedPublicKey) headers["X-API-Key"] = trimmedPublicKey;
|
|
544
|
-
const res = await this.fetchImpl(`${this.linkApiUrl}${REFRESH_ENDPOINT}`, {
|
|
545
|
-
method: "POST",
|
|
546
|
-
credentials: this.credentials,
|
|
547
|
-
headers,
|
|
548
|
-
body: "{}"
|
|
549
|
-
});
|
|
550
|
-
if (!res.ok) return false;
|
|
551
|
-
const json = await res.json();
|
|
552
|
-
const token = json?.data?.token ?? json?.token;
|
|
553
|
-
if (typeof token === "string" && token.length > 0) {
|
|
554
|
-
this.setAccessToken(token);
|
|
555
|
-
return true;
|
|
556
|
-
}
|
|
557
|
-
return false;
|
|
558
|
-
} catch {
|
|
559
|
-
return false;
|
|
560
|
-
} finally {
|
|
561
|
-
this.refreshInflight = null;
|
|
562
|
-
}
|
|
563
|
-
})();
|
|
564
|
-
return this.refreshInflight;
|
|
565
|
-
}
|
|
566
|
-
// On 401, refresh from the session cookie once and retry — re-establishes a
|
|
567
|
-
// session after a reload without persisting any token.
|
|
568
532
|
async authedFetch(url, options) {
|
|
569
|
-
|
|
570
|
-
if (response.status !== 401 || typeof window === "undefined" || url.includes(REFRESH_ENDPOINT)) {
|
|
571
|
-
return response;
|
|
572
|
-
}
|
|
573
|
-
const refreshed = await this.refreshAccessToken();
|
|
574
|
-
if (!refreshed) return response;
|
|
575
|
-
const retryHeaders = {
|
|
576
|
-
...options.headers,
|
|
577
|
-
Authorization: `Bearer ${this.accessToken}`
|
|
578
|
-
};
|
|
579
|
-
return this.resilientFetch(url, { ...options, headers: retryHeaders });
|
|
533
|
+
return this.resilientFetch(url, options);
|
|
580
534
|
}
|
|
581
535
|
loadSessionToken() {
|
|
582
536
|
if (typeof window !== "undefined" && window.localStorage) {
|
|
@@ -860,25 +814,25 @@ var CimplifyClient = class {
|
|
|
860
814
|
}
|
|
861
815
|
get catalogue() {
|
|
862
816
|
if (!this._catalogue) {
|
|
863
|
-
this._catalogue = new
|
|
817
|
+
this._catalogue = new chunkWCSAZRNC_js.CatalogueQueries(this);
|
|
864
818
|
}
|
|
865
819
|
return this._catalogue;
|
|
866
820
|
}
|
|
867
821
|
get cart() {
|
|
868
822
|
if (!this._cart) {
|
|
869
|
-
this._cart = new
|
|
823
|
+
this._cart = new chunkWCSAZRNC_js.CartOperations(this);
|
|
870
824
|
}
|
|
871
825
|
return this._cart;
|
|
872
826
|
}
|
|
873
827
|
get checkout() {
|
|
874
828
|
if (!this._checkout) {
|
|
875
|
-
this._checkout = new
|
|
829
|
+
this._checkout = new chunkWCSAZRNC_js.CheckoutService(this);
|
|
876
830
|
}
|
|
877
831
|
return this._checkout;
|
|
878
832
|
}
|
|
879
833
|
get orders() {
|
|
880
834
|
if (!this._orders) {
|
|
881
|
-
this._orders = new
|
|
835
|
+
this._orders = new chunkWCSAZRNC_js.OrderQueries(this);
|
|
882
836
|
}
|
|
883
837
|
return this._orders;
|
|
884
838
|
}
|
|
@@ -902,43 +856,43 @@ var CimplifyClient = class {
|
|
|
902
856
|
}
|
|
903
857
|
get link() {
|
|
904
858
|
if (!this._link) {
|
|
905
|
-
this._link = new
|
|
859
|
+
this._link = new chunkWCSAZRNC_js.LinkService(this);
|
|
906
860
|
}
|
|
907
861
|
return this._link;
|
|
908
862
|
}
|
|
909
863
|
get auth() {
|
|
910
864
|
if (!this._auth) {
|
|
911
|
-
this._auth = new
|
|
865
|
+
this._auth = new chunkWCSAZRNC_js.AuthService(this);
|
|
912
866
|
}
|
|
913
867
|
return this._auth;
|
|
914
868
|
}
|
|
915
869
|
get business() {
|
|
916
870
|
if (!this._business) {
|
|
917
|
-
this._business = new
|
|
871
|
+
this._business = new chunkWCSAZRNC_js.BusinessService(this);
|
|
918
872
|
}
|
|
919
873
|
return this._business;
|
|
920
874
|
}
|
|
921
875
|
get inventory() {
|
|
922
876
|
if (!this._inventory) {
|
|
923
|
-
this._inventory = new
|
|
877
|
+
this._inventory = new chunkWCSAZRNC_js.InventoryService(this);
|
|
924
878
|
}
|
|
925
879
|
return this._inventory;
|
|
926
880
|
}
|
|
927
881
|
get scheduling() {
|
|
928
882
|
if (!this._scheduling) {
|
|
929
|
-
this._scheduling = new
|
|
883
|
+
this._scheduling = new chunkWCSAZRNC_js.SchedulingService(this);
|
|
930
884
|
}
|
|
931
885
|
return this._scheduling;
|
|
932
886
|
}
|
|
933
887
|
get lite() {
|
|
934
888
|
if (!this._lite) {
|
|
935
|
-
this._lite = new
|
|
889
|
+
this._lite = new chunkWCSAZRNC_js.LiteService(this);
|
|
936
890
|
}
|
|
937
891
|
return this._lite;
|
|
938
892
|
}
|
|
939
893
|
get fx() {
|
|
940
894
|
if (!this._fx) {
|
|
941
|
-
this._fx = new
|
|
895
|
+
this._fx = new chunkWCSAZRNC_js.FxService(this);
|
|
942
896
|
}
|
|
943
897
|
return this._fx;
|
|
944
898
|
}
|
|
@@ -973,7 +927,7 @@ var CimplifyClient = class {
|
|
|
973
927
|
if (businessId) {
|
|
974
928
|
this.setBusinessId(businessId);
|
|
975
929
|
}
|
|
976
|
-
return
|
|
930
|
+
return chunkWCSAZRNC_js.createElements(this, businessId ?? this.businessId ?? void 0, options);
|
|
977
931
|
}
|
|
978
932
|
};
|
|
979
933
|
function createCimplifyClient(config = {}) {
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
// src/gallery.ts
|
|
2
|
+
function dedupe(urls) {
|
|
3
|
+
const seen = /* @__PURE__ */ new Set();
|
|
4
|
+
const out = [];
|
|
5
|
+
for (const url of urls) {
|
|
6
|
+
if (url && !seen.has(url)) {
|
|
7
|
+
seen.add(url);
|
|
8
|
+
out.push(url);
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
return out;
|
|
12
|
+
}
|
|
13
|
+
function resolveGallery(product, selectedVariantId) {
|
|
14
|
+
const variant = selectedVariantId ? product.variants?.find((v) => v.id === selectedVariantId) : void 0;
|
|
15
|
+
if (variant?.images?.length) return dedupe(variant.images);
|
|
16
|
+
if (product.images?.length) return dedupe(product.images);
|
|
17
|
+
const firstWithImages = product.variants?.find((v) => v.images?.length);
|
|
18
|
+
if (firstWithImages?.images?.length) return dedupe(firstWithImages.images);
|
|
19
|
+
return product.image_url ? [product.image_url] : [];
|
|
20
|
+
}
|
|
21
|
+
function allGalleryImages(product) {
|
|
22
|
+
const seen = /* @__PURE__ */ new Set();
|
|
23
|
+
const out = [];
|
|
24
|
+
const push = (url, variantId) => {
|
|
25
|
+
if (url && !seen.has(url)) {
|
|
26
|
+
seen.add(url);
|
|
27
|
+
out.push({ url, variantId });
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
push(product.image_url, null);
|
|
31
|
+
for (const url of product.images ?? []) push(url, null);
|
|
32
|
+
for (const variant of product.variants ?? []) {
|
|
33
|
+
for (const url of variant.images ?? []) push(url, variant.id);
|
|
34
|
+
}
|
|
35
|
+
return out;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
// src/utils/variant.ts
|
|
39
|
+
function stripProductPrefix(variantName, productName) {
|
|
40
|
+
if (!variantName || !productName) return variantName || productName;
|
|
41
|
+
const lower = variantName.toLowerCase().trim();
|
|
42
|
+
if (lower === "default" || lower === "standard") return productName;
|
|
43
|
+
if (lower.endsWith("-default") || lower.endsWith("-standard")) return productName;
|
|
44
|
+
if (variantName.startsWith(productName)) {
|
|
45
|
+
const rest = variantName.slice(productName.length);
|
|
46
|
+
const match = rest.match(/^\s*[-–—]\s*(.*)/);
|
|
47
|
+
if (match && match[1].length > 0) return match[1];
|
|
48
|
+
}
|
|
49
|
+
const lowerProduct = productName.toLowerCase().trim();
|
|
50
|
+
if (lower.startsWith(lowerProduct)) {
|
|
51
|
+
const rest = variantName.slice(productName.length);
|
|
52
|
+
const match = rest.match(/^\s*[-–—]\s*(.*)/);
|
|
53
|
+
if (match && match[1].length > 0) return match[1];
|
|
54
|
+
}
|
|
55
|
+
const lastDash = variantName.lastIndexOf("-");
|
|
56
|
+
if (lastDash > 0 && lastDash < variantName.length - 1) {
|
|
57
|
+
const prefix = variantName.slice(0, lastDash).trim();
|
|
58
|
+
const suffix = variantName.slice(lastDash + 1).trim();
|
|
59
|
+
if (suffix.length > 0 && prefix.length > suffix.length * 2) {
|
|
60
|
+
return suffix;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
return variantName;
|
|
64
|
+
}
|
|
65
|
+
function getVariantDisplayName(variant, productName) {
|
|
66
|
+
if (variant.display_attributes?.length) {
|
|
67
|
+
return variant.display_attributes.map((a) => a.value_name).join(" / ");
|
|
68
|
+
}
|
|
69
|
+
if (variant.name) {
|
|
70
|
+
return productName ? stripProductPrefix(variant.name, productName) : variant.name;
|
|
71
|
+
}
|
|
72
|
+
return productName || (variant.is_default ? "Default" : "Option");
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
// src/types/product.ts
|
|
76
|
+
var PRODUCT_TYPE = {
|
|
77
|
+
Product: "product",
|
|
78
|
+
Service: "service",
|
|
79
|
+
Digital: "digital",
|
|
80
|
+
Bundle: "bundle",
|
|
81
|
+
Composite: "composite"
|
|
82
|
+
};
|
|
83
|
+
var RENDER_HINT = {
|
|
84
|
+
Food: "food",
|
|
85
|
+
Physical: "physical",
|
|
86
|
+
General: "general"
|
|
87
|
+
};
|
|
88
|
+
var DURATION_UNIT = {
|
|
89
|
+
Minutes: "minutes",
|
|
90
|
+
Hours: "hours",
|
|
91
|
+
Days: "days",
|
|
92
|
+
Nights: "nights",
|
|
93
|
+
Weeks: "weeks",
|
|
94
|
+
Months: "months",
|
|
95
|
+
Years: "years"
|
|
96
|
+
};
|
|
97
|
+
var INPUT_FIELD_TYPE = {
|
|
98
|
+
Text: "text",
|
|
99
|
+
Textarea: "textarea",
|
|
100
|
+
Number: "number",
|
|
101
|
+
Select: "select",
|
|
102
|
+
Radio: "radio",
|
|
103
|
+
Checkbox: "checkbox",
|
|
104
|
+
Color: "color",
|
|
105
|
+
Date: "date",
|
|
106
|
+
File: "file",
|
|
107
|
+
Image: "image",
|
|
108
|
+
Url: "url",
|
|
109
|
+
Address: "address",
|
|
110
|
+
Phone: "phone",
|
|
111
|
+
Email: "email",
|
|
112
|
+
DateTime: "date_time",
|
|
113
|
+
Time: "time",
|
|
114
|
+
Signature: "signature",
|
|
115
|
+
MultiSelect: "multi_select",
|
|
116
|
+
DateRange: "date_range",
|
|
117
|
+
Location: "location"
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
// src/assets/url.ts
|
|
121
|
+
var DEFAULT_CDN_BASE_URL = "https://storefrontassetscdn.cimplify.io";
|
|
122
|
+
var CIMPLIFY_CDN_HOSTS = [
|
|
123
|
+
"storefrontassetscdn.cimplify.io",
|
|
124
|
+
"cdn.cimplify.io",
|
|
125
|
+
"static-tmp.cimplify.io"
|
|
126
|
+
];
|
|
127
|
+
var ABSOLUTE_URL_RE = /^https?:\/\//i;
|
|
128
|
+
var MOCK_PASSTHROUGH_RE = /^\/(img|elements|_mock)\//;
|
|
129
|
+
function assetUrl(path, opts = {}) {
|
|
130
|
+
if (!path) return path;
|
|
131
|
+
if (ABSOLUTE_URL_RE.test(path)) return appendTransform(path, opts);
|
|
132
|
+
if (MOCK_PASSTHROUGH_RE.test(path)) return appendTransform(path, opts);
|
|
133
|
+
const base = (opts.base ?? DEFAULT_CDN_BASE_URL).replace(/\/+$/, "");
|
|
134
|
+
const normalized = path.replace(/^\/+/, "");
|
|
135
|
+
return appendTransform(`${base}/${normalized}`, opts);
|
|
136
|
+
}
|
|
137
|
+
function isCimplifyAsset(src, base) {
|
|
138
|
+
if (!src) return false;
|
|
139
|
+
if (!ABSOLUTE_URL_RE.test(src)) return true;
|
|
140
|
+
if (MOCK_PASSTHROUGH_RE.test(src)) return true;
|
|
141
|
+
const resolvedBase = (base ?? DEFAULT_CDN_BASE_URL).replace(/\/+$/, "");
|
|
142
|
+
if (resolvedBase && src.startsWith(resolvedBase)) return true;
|
|
143
|
+
return CIMPLIFY_CDN_HOSTS.some((host) => src.startsWith(`https://${host}/`));
|
|
144
|
+
}
|
|
145
|
+
function appendTransform(url, t) {
|
|
146
|
+
const params = new URLSearchParams();
|
|
147
|
+
if (t.w != null) params.set("w", String(t.w));
|
|
148
|
+
if (t.h != null) params.set("h", String(t.h));
|
|
149
|
+
if (t.quality != null) params.set("quality", String(t.quality));
|
|
150
|
+
if (t.format != null) params.set("format", t.format);
|
|
151
|
+
const query = params.toString();
|
|
152
|
+
if (!query) return url;
|
|
153
|
+
return `${url}${url.includes("?") ? "&" : "?"}${query}`;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
export { CIMPLIFY_CDN_HOSTS, DEFAULT_CDN_BASE_URL, DURATION_UNIT, INPUT_FIELD_TYPE, PRODUCT_TYPE, RENDER_HINT, allGalleryImages, assetUrl, getVariantDisplayName, isCimplifyAsset, resolveGallery };
|