@cimplify/sdk 0.6.12 → 0.7.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +20 -3
- package/dist/advanced.d.mts +1 -1
- package/dist/advanced.d.ts +1 -1
- package/dist/advanced.js +54 -21
- package/dist/advanced.mjs +54 -21
- package/dist/{client-2Rmdqutj.d.ts → client-C082Zp8J.d.ts} +16 -4
- package/dist/{client-BIbWQK7v.d.mts → client-CSH0xyto.d.mts} +16 -4
- package/dist/{index-DAztg_LQ.d.ts → index-B_JHO-ER.d.ts} +0 -6
- package/dist/{index-Dqaywky7.d.mts → index-mrKi_VbR.d.mts} +0 -6
- package/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +54 -21
- package/dist/index.mjs +54 -21
- package/dist/react.d.mts +5 -2
- package/dist/react.d.ts +5 -2
- package/dist/react.js +79 -24
- package/dist/react.mjs +79 -24
- package/dist/utils.d.mts +1 -1
- package/dist/utils.d.ts +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -20,7 +20,14 @@ import { createCimplifyClient } from "@cimplify/sdk";
|
|
|
20
20
|
const cimplify = createCimplifyClient();
|
|
21
21
|
|
|
22
22
|
// Fetch products
|
|
23
|
-
const
|
|
23
|
+
const productsResult = await cimplify.catalogue.getProducts();
|
|
24
|
+
if (!productsResult.ok) throw productsResult.error;
|
|
25
|
+
const products = productsResult.value.items;
|
|
26
|
+
|
|
27
|
+
// Fetch full catalogue envelope (products + categories + add-ons)
|
|
28
|
+
const catalogueResult = await cimplify.catalogue.getCatalogue();
|
|
29
|
+
if (!catalogueResult.ok) throw catalogueResult.error;
|
|
30
|
+
const { categories, add_ons } = catalogueResult.value;
|
|
24
31
|
|
|
25
32
|
// Add to cart
|
|
26
33
|
await cimplify.cart.addItem({ item_id: "product-id", quantity: 1 });
|
|
@@ -40,8 +47,18 @@ const cart = await cimplify.cart.get();
|
|
|
40
47
|
|
|
41
48
|
```typescript
|
|
42
49
|
// Products
|
|
43
|
-
|
|
44
|
-
const
|
|
50
|
+
// getProducts() is list-focused (items + pagination/truncation metadata)
|
|
51
|
+
const productsResult = await cimplify.catalogue.getProducts();
|
|
52
|
+
const featuredResult = await cimplify.catalogue.getProducts({ featured: true, limit: 10 });
|
|
53
|
+
if (!productsResult.ok || !featuredResult.ok) throw new Error("Failed to fetch products");
|
|
54
|
+
const products = productsResult.value.items;
|
|
55
|
+
const featured = featuredResult.value.items;
|
|
56
|
+
|
|
57
|
+
// Full catalogue envelope when you need categories/add-ons alongside products
|
|
58
|
+
const catalogueResult = await cimplify.catalogue.getCatalogue();
|
|
59
|
+
if (!catalogueResult.ok) throw catalogueResult.error;
|
|
60
|
+
const { categories, add_ons } = catalogueResult.value;
|
|
61
|
+
|
|
45
62
|
const product = await cimplify.catalogue.getProduct("product-id");
|
|
46
63
|
const product = await cimplify.catalogue.getProductBySlug("my-product");
|
|
47
64
|
|
package/dist/advanced.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { A as AuthService, B as BusinessService, i as CartOperations, b as CatalogueQueries, j as CheckoutOperations, j as CheckoutService, v as CimplifyElement, u as CimplifyElements, x as ELEMENT_TYPES, E as EVENT_TYPES, H as ElementEventType, z as ElementOptions, D as ElementType, y as ElementsOptions, F as FetchQuoteInput, r as FxService, G as GetProductsOptions, I as InventoryService, L as LinkService, q as LiteService, M as MESSAGE_TYPES, O as OrderQueries, P as PriceQuote, d as QuoteBundleSelectionInput, Q as QuoteCompositeSelectionInput, f as QuoteDynamicBuckets, e as QuoteStatus, g as QuoteUiMessage, R as RefreshQuoteInput, h as RefreshQuoteResult, p as SchedulingService, S as SearchOptions, w as createElements, k as generateIdempotencyKey } from './client-
|
|
1
|
+
export { A as AuthService, B as BusinessService, i as CartOperations, b as CatalogueQueries, j as CheckoutOperations, j as CheckoutService, v as CimplifyElement, u as CimplifyElements, x as ELEMENT_TYPES, E as EVENT_TYPES, H as ElementEventType, z as ElementOptions, D as ElementType, y as ElementsOptions, F as FetchQuoteInput, r as FxService, G as GetProductsOptions, I as InventoryService, L as LinkService, q as LiteService, M as MESSAGE_TYPES, O as OrderQueries, P as PriceQuote, d as QuoteBundleSelectionInput, Q as QuoteCompositeSelectionInput, f as QuoteDynamicBuckets, e as QuoteStatus, g as QuoteUiMessage, R as RefreshQuoteInput, h as RefreshQuoteResult, p as SchedulingService, S as SearchOptions, w as createElements, k as generateIdempotencyKey } from './client-CSH0xyto.mjs';
|
|
2
2
|
import './payment-CLIWNMaP.mjs';
|
|
3
3
|
|
|
4
4
|
type Operator = "==" | "!=" | ">" | "<" | ">=" | "<=" | "contains" | "startsWith";
|
package/dist/advanced.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { A as AuthService, B as BusinessService, i as CartOperations, b as CatalogueQueries, j as CheckoutOperations, j as CheckoutService, v as CimplifyElement, u as CimplifyElements, x as ELEMENT_TYPES, E as EVENT_TYPES, H as ElementEventType, z as ElementOptions, D as ElementType, y as ElementsOptions, F as FetchQuoteInput, r as FxService, G as GetProductsOptions, I as InventoryService, L as LinkService, q as LiteService, M as MESSAGE_TYPES, O as OrderQueries, P as PriceQuote, d as QuoteBundleSelectionInput, Q as QuoteCompositeSelectionInput, f as QuoteDynamicBuckets, e as QuoteStatus, g as QuoteUiMessage, R as RefreshQuoteInput, h as RefreshQuoteResult, p as SchedulingService, S as SearchOptions, w as createElements, k as generateIdempotencyKey } from './client-
|
|
1
|
+
export { A as AuthService, B as BusinessService, i as CartOperations, b as CatalogueQueries, j as CheckoutOperations, j as CheckoutService, v as CimplifyElement, u as CimplifyElements, x as ELEMENT_TYPES, E as EVENT_TYPES, H as ElementEventType, z as ElementOptions, D as ElementType, y as ElementsOptions, F as FetchQuoteInput, r as FxService, G as GetProductsOptions, I as InventoryService, L as LinkService, q as LiteService, M as MESSAGE_TYPES, O as OrderQueries, P as PriceQuote, d as QuoteBundleSelectionInput, Q as QuoteCompositeSelectionInput, f as QuoteDynamicBuckets, e as QuoteStatus, g as QuoteUiMessage, R as RefreshQuoteInput, h as RefreshQuoteResult, p as SchedulingService, S as SearchOptions, w as createElements, k as generateIdempotencyKey } from './client-C082Zp8J.js';
|
|
2
2
|
import './payment-CLIWNMaP.js';
|
|
3
3
|
|
|
4
4
|
type Operator = "==" | "!=" | ">" | "<" | ">=" | "<=" | "contains" | "startsWith";
|
package/dist/advanced.js
CHANGED
|
@@ -233,6 +233,22 @@ function readFinalPrice(value) {
|
|
|
233
233
|
}
|
|
234
234
|
return void 0;
|
|
235
235
|
}
|
|
236
|
+
function normalizeAddOnPayload(addOn) {
|
|
237
|
+
if (!isRecord(addOn)) return addOn;
|
|
238
|
+
const normalizedAddOn = { ...addOn };
|
|
239
|
+
const options = normalizedAddOn["options"];
|
|
240
|
+
if (!Array.isArray(options)) return normalizedAddOn;
|
|
241
|
+
normalizedAddOn["options"] = options.map((option) => {
|
|
242
|
+
if (!isRecord(option)) return option;
|
|
243
|
+
const normalizedOption = { ...option };
|
|
244
|
+
const optionPrice = normalizedOption["default_price"];
|
|
245
|
+
if (optionPrice === void 0 || optionPrice === null || optionPrice === "") {
|
|
246
|
+
normalizedOption["default_price"] = readFinalPrice(normalizedOption["default_price_info"]) || readFinalPrice(normalizedOption["price_info"]) || "0";
|
|
247
|
+
}
|
|
248
|
+
return normalizedOption;
|
|
249
|
+
});
|
|
250
|
+
return normalizedAddOn;
|
|
251
|
+
}
|
|
236
252
|
function normalizeCatalogueProductPayload(product) {
|
|
237
253
|
const normalized = { ...product };
|
|
238
254
|
const defaultPrice = normalized["default_price"];
|
|
@@ -254,22 +270,7 @@ function normalizeCatalogueProductPayload(product) {
|
|
|
254
270
|
}
|
|
255
271
|
const addOns = normalized["add_ons"];
|
|
256
272
|
if (Array.isArray(addOns)) {
|
|
257
|
-
normalized["add_ons"] = addOns.map((addOn) =>
|
|
258
|
-
if (!isRecord(addOn)) return addOn;
|
|
259
|
-
const normalizedAddOn = { ...addOn };
|
|
260
|
-
const options = normalizedAddOn["options"];
|
|
261
|
-
if (!Array.isArray(options)) return normalizedAddOn;
|
|
262
|
-
normalizedAddOn["options"] = options.map((option) => {
|
|
263
|
-
if (!isRecord(option)) return option;
|
|
264
|
-
const normalizedOption = { ...option };
|
|
265
|
-
const optionPrice = normalizedOption["default_price"];
|
|
266
|
-
if (optionPrice === void 0 || optionPrice === null || optionPrice === "") {
|
|
267
|
-
normalizedOption["default_price"] = readFinalPrice(normalizedOption["default_price_info"]) || readFinalPrice(normalizedOption["price_info"]) || "0";
|
|
268
|
-
}
|
|
269
|
-
return normalizedOption;
|
|
270
|
-
});
|
|
271
|
-
return normalizedAddOn;
|
|
272
|
-
});
|
|
273
|
+
normalized["add_ons"] = addOns.map((addOn) => normalizeAddOnPayload(addOn));
|
|
273
274
|
}
|
|
274
275
|
return normalized;
|
|
275
276
|
}
|
|
@@ -342,16 +343,48 @@ function normalizeCatalogueResult(payload) {
|
|
|
342
343
|
pagination: normalizePagination(payload.pagination)
|
|
343
344
|
};
|
|
344
345
|
}
|
|
346
|
+
function normalizeCatalogueSnapshot(payload) {
|
|
347
|
+
if (Array.isArray(payload)) {
|
|
348
|
+
return {
|
|
349
|
+
categories: [],
|
|
350
|
+
products: payload.map((product) => normalizeCatalogueProductPayload(product)),
|
|
351
|
+
add_ons: [],
|
|
352
|
+
is_complete: true
|
|
353
|
+
};
|
|
354
|
+
}
|
|
355
|
+
if (!isRecord(payload)) {
|
|
356
|
+
return {
|
|
357
|
+
categories: [],
|
|
358
|
+
products: [],
|
|
359
|
+
add_ons: [],
|
|
360
|
+
is_complete: true
|
|
361
|
+
};
|
|
362
|
+
}
|
|
363
|
+
const rawProducts = Array.isArray(payload.products) ? payload.products : Array.isArray(payload.items) ? payload.items : [];
|
|
364
|
+
const rawCategories = Array.isArray(payload.categories) ? payload.categories : [];
|
|
365
|
+
const rawAddOns = Array.isArray(payload.add_ons) ? payload.add_ons : [];
|
|
366
|
+
return {
|
|
367
|
+
categories: rawCategories,
|
|
368
|
+
products: rawProducts.map((product) => normalizeCatalogueProductPayload(product)),
|
|
369
|
+
add_ons: rawAddOns.map((addOn) => normalizeAddOnPayload(addOn)),
|
|
370
|
+
is_complete: typeof payload.is_complete === "boolean" ? payload.is_complete : true,
|
|
371
|
+
total_available: toFiniteNumber(payload.total_available),
|
|
372
|
+
pagination: normalizePagination(payload.pagination)
|
|
373
|
+
};
|
|
374
|
+
}
|
|
345
375
|
var CatalogueQueries = class {
|
|
346
376
|
constructor(client) {
|
|
347
377
|
this.client = client;
|
|
348
378
|
}
|
|
349
|
-
async
|
|
350
|
-
const result = await
|
|
379
|
+
async getCatalogue() {
|
|
380
|
+
const result = await safeWithFallback(
|
|
381
|
+
() => this.client.get("/api/v1/catalogue"),
|
|
382
|
+
() => this.client.query("catalogue")
|
|
383
|
+
);
|
|
351
384
|
if (!result.ok) return result;
|
|
352
|
-
return ok(result.value
|
|
385
|
+
return ok(normalizeCatalogueSnapshot(result.value));
|
|
353
386
|
}
|
|
354
|
-
async
|
|
387
|
+
async getProducts(options) {
|
|
355
388
|
let query2 = "products";
|
|
356
389
|
const filters = [];
|
|
357
390
|
if (options?.category) {
|
|
@@ -734,7 +767,7 @@ var CatalogueQueries = class {
|
|
|
734
767
|
limit: options?.limit ?? 20
|
|
735
768
|
});
|
|
736
769
|
if (!result.ok) return result;
|
|
737
|
-
return ok(result.value);
|
|
770
|
+
return ok(result.value.items);
|
|
738
771
|
}
|
|
739
772
|
async searchProducts(query2, options) {
|
|
740
773
|
return this.search(query2, options);
|
package/dist/advanced.mjs
CHANGED
|
@@ -231,6 +231,22 @@ function readFinalPrice(value) {
|
|
|
231
231
|
}
|
|
232
232
|
return void 0;
|
|
233
233
|
}
|
|
234
|
+
function normalizeAddOnPayload(addOn) {
|
|
235
|
+
if (!isRecord(addOn)) return addOn;
|
|
236
|
+
const normalizedAddOn = { ...addOn };
|
|
237
|
+
const options = normalizedAddOn["options"];
|
|
238
|
+
if (!Array.isArray(options)) return normalizedAddOn;
|
|
239
|
+
normalizedAddOn["options"] = options.map((option) => {
|
|
240
|
+
if (!isRecord(option)) return option;
|
|
241
|
+
const normalizedOption = { ...option };
|
|
242
|
+
const optionPrice = normalizedOption["default_price"];
|
|
243
|
+
if (optionPrice === void 0 || optionPrice === null || optionPrice === "") {
|
|
244
|
+
normalizedOption["default_price"] = readFinalPrice(normalizedOption["default_price_info"]) || readFinalPrice(normalizedOption["price_info"]) || "0";
|
|
245
|
+
}
|
|
246
|
+
return normalizedOption;
|
|
247
|
+
});
|
|
248
|
+
return normalizedAddOn;
|
|
249
|
+
}
|
|
234
250
|
function normalizeCatalogueProductPayload(product) {
|
|
235
251
|
const normalized = { ...product };
|
|
236
252
|
const defaultPrice = normalized["default_price"];
|
|
@@ -252,22 +268,7 @@ function normalizeCatalogueProductPayload(product) {
|
|
|
252
268
|
}
|
|
253
269
|
const addOns = normalized["add_ons"];
|
|
254
270
|
if (Array.isArray(addOns)) {
|
|
255
|
-
normalized["add_ons"] = addOns.map((addOn) =>
|
|
256
|
-
if (!isRecord(addOn)) return addOn;
|
|
257
|
-
const normalizedAddOn = { ...addOn };
|
|
258
|
-
const options = normalizedAddOn["options"];
|
|
259
|
-
if (!Array.isArray(options)) return normalizedAddOn;
|
|
260
|
-
normalizedAddOn["options"] = options.map((option) => {
|
|
261
|
-
if (!isRecord(option)) return option;
|
|
262
|
-
const normalizedOption = { ...option };
|
|
263
|
-
const optionPrice = normalizedOption["default_price"];
|
|
264
|
-
if (optionPrice === void 0 || optionPrice === null || optionPrice === "") {
|
|
265
|
-
normalizedOption["default_price"] = readFinalPrice(normalizedOption["default_price_info"]) || readFinalPrice(normalizedOption["price_info"]) || "0";
|
|
266
|
-
}
|
|
267
|
-
return normalizedOption;
|
|
268
|
-
});
|
|
269
|
-
return normalizedAddOn;
|
|
270
|
-
});
|
|
271
|
+
normalized["add_ons"] = addOns.map((addOn) => normalizeAddOnPayload(addOn));
|
|
271
272
|
}
|
|
272
273
|
return normalized;
|
|
273
274
|
}
|
|
@@ -340,16 +341,48 @@ function normalizeCatalogueResult(payload) {
|
|
|
340
341
|
pagination: normalizePagination(payload.pagination)
|
|
341
342
|
};
|
|
342
343
|
}
|
|
344
|
+
function normalizeCatalogueSnapshot(payload) {
|
|
345
|
+
if (Array.isArray(payload)) {
|
|
346
|
+
return {
|
|
347
|
+
categories: [],
|
|
348
|
+
products: payload.map((product) => normalizeCatalogueProductPayload(product)),
|
|
349
|
+
add_ons: [],
|
|
350
|
+
is_complete: true
|
|
351
|
+
};
|
|
352
|
+
}
|
|
353
|
+
if (!isRecord(payload)) {
|
|
354
|
+
return {
|
|
355
|
+
categories: [],
|
|
356
|
+
products: [],
|
|
357
|
+
add_ons: [],
|
|
358
|
+
is_complete: true
|
|
359
|
+
};
|
|
360
|
+
}
|
|
361
|
+
const rawProducts = Array.isArray(payload.products) ? payload.products : Array.isArray(payload.items) ? payload.items : [];
|
|
362
|
+
const rawCategories = Array.isArray(payload.categories) ? payload.categories : [];
|
|
363
|
+
const rawAddOns = Array.isArray(payload.add_ons) ? payload.add_ons : [];
|
|
364
|
+
return {
|
|
365
|
+
categories: rawCategories,
|
|
366
|
+
products: rawProducts.map((product) => normalizeCatalogueProductPayload(product)),
|
|
367
|
+
add_ons: rawAddOns.map((addOn) => normalizeAddOnPayload(addOn)),
|
|
368
|
+
is_complete: typeof payload.is_complete === "boolean" ? payload.is_complete : true,
|
|
369
|
+
total_available: toFiniteNumber(payload.total_available),
|
|
370
|
+
pagination: normalizePagination(payload.pagination)
|
|
371
|
+
};
|
|
372
|
+
}
|
|
343
373
|
var CatalogueQueries = class {
|
|
344
374
|
constructor(client) {
|
|
345
375
|
this.client = client;
|
|
346
376
|
}
|
|
347
|
-
async
|
|
348
|
-
const result = await
|
|
377
|
+
async getCatalogue() {
|
|
378
|
+
const result = await safeWithFallback(
|
|
379
|
+
() => this.client.get("/api/v1/catalogue"),
|
|
380
|
+
() => this.client.query("catalogue")
|
|
381
|
+
);
|
|
349
382
|
if (!result.ok) return result;
|
|
350
|
-
return ok(result.value
|
|
383
|
+
return ok(normalizeCatalogueSnapshot(result.value));
|
|
351
384
|
}
|
|
352
|
-
async
|
|
385
|
+
async getProducts(options) {
|
|
353
386
|
let query2 = "products";
|
|
354
387
|
const filters = [];
|
|
355
388
|
if (options?.category) {
|
|
@@ -732,7 +765,7 @@ var CatalogueQueries = class {
|
|
|
732
765
|
limit: options?.limit ?? 20
|
|
733
766
|
});
|
|
734
767
|
if (!result.ok) return result;
|
|
735
|
-
return ok(result.value);
|
|
768
|
+
return ok(result.value.items);
|
|
736
769
|
}
|
|
737
770
|
async searchProducts(query2, options) {
|
|
738
771
|
return this.search(query2, options);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { K as Category, q as Product, F as AddOnWithOptions, d as Pagination, h as CimplifyError, r as ProductWithDetails, s as ProductVariant, u as VariantAxis, z as VariantAxisSelection, B as AddOn, N as Collection, T as Bundle, X as BundleWithDetails, a2 as Composite, a3 as CompositeWithDetails, a7 as ComponentSelectionInput, a8 as CompositePriceResult, an as ChosenPrice, aS as UICart, aD as Cart, aE as CartItem, aW as CartSummary, aU as AddToCartInput, aV as UpdateCartItemInput, ar as DiscountDetails, M as Money, C as CurrencyCode, aC as LineConfiguration, a_ as AuthorizationType, b0 as PaymentMethod, b2 as InitializePaymentResult, b6 as SubmitAuthorizationInput, b4 as PaymentStatusResponse } from './payment-CLIWNMaP.js';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Observability hooks for monitoring SDK behavior.
|
|
@@ -104,6 +104,18 @@ interface CatalogueResult<T> {
|
|
|
104
104
|
/** Pagination metadata when listing is paginated. */
|
|
105
105
|
pagination?: Pagination;
|
|
106
106
|
}
|
|
107
|
+
/** Full catalogue envelope (products + categories + add-ons + metadata). */
|
|
108
|
+
interface CatalogueSnapshot {
|
|
109
|
+
categories: Category[];
|
|
110
|
+
products: Product[];
|
|
111
|
+
add_ons: AddOnWithOptions[];
|
|
112
|
+
/** true when the full catalogue is returned; false when truncated by server cap. */
|
|
113
|
+
is_complete: boolean;
|
|
114
|
+
/** Total available products before truncation (present when truncated). */
|
|
115
|
+
total_available?: number;
|
|
116
|
+
/** Pagination metadata when listing is paginated. */
|
|
117
|
+
pagination?: Pagination;
|
|
118
|
+
}
|
|
107
119
|
|
|
108
120
|
/**
|
|
109
121
|
* A Result type that makes errors explicit in the type system.
|
|
@@ -349,8 +361,8 @@ interface RefreshQuoteResult {
|
|
|
349
361
|
declare class CatalogueQueries {
|
|
350
362
|
private client;
|
|
351
363
|
constructor(client: CimplifyClient);
|
|
352
|
-
|
|
353
|
-
|
|
364
|
+
getCatalogue(): Promise<Result<CatalogueSnapshot, CimplifyError>>;
|
|
365
|
+
getProducts(options?: GetProductsOptions): Promise<Result<CatalogueResult<Product>, CimplifyError>>;
|
|
354
366
|
getProduct(id: string): Promise<Result<ProductWithDetails, CimplifyError>>;
|
|
355
367
|
getProductBySlug(slug: string): Promise<Result<ProductWithDetails, CimplifyError>>;
|
|
356
368
|
getVariants(productId: string): Promise<Result<ProductVariant[], CimplifyError>>;
|
|
@@ -2370,4 +2382,4 @@ declare class CimplifyClient {
|
|
|
2370
2382
|
}
|
|
2371
2383
|
declare function createCimplifyClient(config?: CimplifyConfig): CimplifyClient;
|
|
2372
2384
|
|
|
2373
|
-
export { type ProcessAndResolveOptions as $, AuthService as A, BusinessService as B, CimplifyClient as C, type ElementType as D, EVENT_TYPES as E, type FetchQuoteInput as F, type GetProductsOptions as G, type ElementEventType as H, InventoryService as I, type CheckoutMode as J, type KitchenOrderItem as K, LinkService as L, MESSAGE_TYPES as M, type CheckoutOrderType as N, OrderQueries as O, type PriceQuote as P, type QuoteCompositeSelectionInput as Q, type RefreshQuoteInput as R, type SearchOptions as S, type TableInfo as T, type UpdateProfileInput as U, type CheckoutPaymentMethod as V, type CheckoutStep as W, type CheckoutFormData as X, type CheckoutResult as Y, type ProcessCheckoutOptions as Z, type ProcessCheckoutResult as _, type CimplifyConfig as a, type
|
|
2385
|
+
export { type ProcessAndResolveOptions as $, AuthService as A, BusinessService as B, CimplifyClient as C, type ElementType as D, EVENT_TYPES as E, type FetchQuoteInput as F, type GetProductsOptions as G, type ElementEventType as H, InventoryService as I, type CheckoutMode as J, type KitchenOrderItem as K, LinkService as L, MESSAGE_TYPES as M, type CheckoutOrderType as N, OrderQueries as O, type PriceQuote as P, type QuoteCompositeSelectionInput as Q, type RefreshQuoteInput as R, type SearchOptions as S, type TableInfo as T, type UpdateProfileInput as U, type CheckoutPaymentMethod as V, type CheckoutStep as W, type CheckoutFormData as X, type CheckoutResult as Y, type ProcessCheckoutOptions as Z, type ProcessCheckoutResult as _, type CimplifyConfig as a, type OrderGroupDetails as a$, type CheckoutStatus as a0, type CheckoutStatusContext as a1, type AbortablePromise as a2, type MobileMoneyProvider as a3, type DeviceType as a4, type ContactType as a5, CHECKOUT_MODE as a6, ORDER_TYPE as a7, PAYMENT_METHOD as a8, CHECKOUT_STEP as a9, toNullable as aA, fromPromise as aB, tryCatch as aC, combine as aD, combineObject as aE, type CatalogueResult as aF, type CatalogueSnapshot as aG, type OrderStatus as aH, type PaymentState as aI, type OrderChannel as aJ, type LineType as aK, type OrderLineState as aL, type OrderLineStatus as aM, type FulfillmentType as aN, type FulfillmentStatus as aO, type FulfillmentLink as aP, type OrderFulfillmentSummary as aQ, type FeeBearerType as aR, type AmountToPay as aS, type LineItem as aT, type Order as aU, type OrderHistory as aV, type OrderGroupPaymentState as aW, type OrderGroup as aX, type OrderGroupPayment as aY, type OrderSplitDetail as aZ, type OrderGroupPaymentSummary as a_, PAYMENT_STATE as aa, PICKUP_TIME_TYPE as ab, MOBILE_MONEY_PROVIDER as ac, AUTHORIZATION_TYPE as ad, DEVICE_TYPE as ae, CONTACT_TYPE as af, LINK_QUERY as ag, LINK_MUTATION as ah, AUTH_MUTATION as ai, CHECKOUT_MUTATION as aj, PAYMENT_MUTATION as ak, ORDER_MUTATION as al, DEFAULT_CURRENCY as am, DEFAULT_COUNTRY as an, type Result as ao, type Ok as ap, type Err as aq, ok as ar, err as as, isOk as at, isErr as au, mapResult as av, mapError as aw, flatMap as ax, getOrElse as ay, unwrap as az, CatalogueQueries as b, type CancelBookingInput as b$, type OrderPaymentEvent as b0, type OrderFilter as b1, type CheckoutInput as b2, type UpdateOrderStatusInput as b3, type CancelOrderInput as b4, type RefundOrderInput as b5, type ServiceStatus as b6, type StaffRole as b7, type ReminderMethod as b8, type CustomerServicePreferences as b9, type BusinessWithLocations as bA, type LocationWithDetails as bB, type BusinessSettings as bC, type BusinessHours as bD, type CategoryInfo as bE, type ServiceAvailabilityRule as bF, type ServiceAvailabilityException as bG, type StaffAvailabilityRule as bH, type StaffAvailabilityException as bI, type ResourceAvailabilityRule as bJ, type ResourceAvailabilityException as bK, type StaffBookingProfile as bL, type ServiceStaffRequirement as bM, type BookingRequirementOverride as bN, type ResourceType as bO, type Service as bP, type ServiceWithStaff as bQ, type Staff as bR, type TimeSlot as bS, type AvailableSlot as bT, type DayAvailability as bU, type BookingStatus as bV, type Booking as bW, type BookingWithDetails as bX, type GetAvailableSlotsInput as bY, type CheckSlotAvailabilityInput as bZ, type RescheduleBookingInput as b_, type BufferTimes as ba, type ReminderSettings as bb, type CancellationPolicy as bc, type ServiceNotes as bd, type PricingOverrides as be, type SchedulingMetadata as bf, type StaffAssignment as bg, type ResourceAssignment as bh, type SchedulingResult as bi, type DepositResult as bj, type ServiceScheduleRequest as bk, type StaffScheduleItem as bl, type LocationAppointment as bm, type BusinessType as bn, type BusinessPreferences as bo, type Business as bp, type LocationTaxBehavior as bq, type LocationTaxOverrides as br, type Location as bs, type TimeRange as bt, type TimeRanges as bu, type LocationTimeProfile as bv, type Table as bw, type Room as bx, type ServiceCharge as by, type StorefrontBootstrap as bz, createCimplifyClient as c, type ServiceAvailabilityParams as c0, type ServiceAvailabilityResult as c1, type StockOwnershipType as c2, type StockStatus as c3, type Stock as c4, type StockLevel as c5, type ProductStock as c6, type VariantStock as c7, type LocationStock as c8, type AvailabilityCheck as c9, type MobileMoneyDetails as cA, type CheckoutCustomerInfo as cB, type FxQuoteRequest as cC, type FxQuote as cD, type FxRateResponse as cE, type RequestContext as cF, type RequestStartEvent as cG, type RequestSuccessEvent as cH, type RequestErrorEvent as cI, type RetryEvent as cJ, type SessionChangeEvent as cK, type ObservabilityHooks as cL, type ElementAppearance as cM, type AddressInfo as cN, type PaymentMethodInfo as cO, type AuthenticatedCustomer as cP, type ElementsCustomerInfo as cQ, type AuthenticatedData as cR, type ElementsCheckoutData as cS, type ElementsCheckoutResult as cT, type ParentToIframeMessage as cU, type IframeToParentMessage as cV, type ElementEventHandler as cW, type AvailabilityResult as ca, type InventorySummary as cb, type Customer as cc, type CustomerAddress as cd, type CustomerMobileMoney as ce, type CustomerLinkPreferences as cf, type LinkData as cg, type CreateAddressInput as ch, type UpdateAddressInput as ci, type CreateMobileMoneyInput as cj, type EnrollmentData as ck, type AddressData as cl, type MobileMoneyData as cm, type EnrollAndLinkOrderInput as cn, type LinkStatusResult as co, type LinkEnrollResult as cp, type EnrollAndLinkOrderResult as cq, type LinkSession as cr, type RevokeSessionResult as cs, type RevokeAllSessionsResult as ct, type RequestOtpInput as cu, type VerifyOtpInput as cv, type AuthResponse as cw, type PickupTimeType as cx, type PickupTime as cy, type CheckoutAddressInfo as cz, type QuoteBundleSelectionInput as d, type QuoteStatus as e, type QuoteDynamicBuckets as f, type QuoteUiMessage as g, type RefreshQuoteResult as h, CartOperations as i, CheckoutService as j, generateIdempotencyKey as k, type GetOrdersOptions as l, type AuthStatus as m, type OtpResult as n, type ChangePasswordInput as o, SchedulingService as p, LiteService as q, FxService as r, type LiteBootstrap as s, type KitchenOrderResult as t, CimplifyElements as u, CimplifyElement as v, createElements as w, ELEMENT_TYPES as x, type ElementsOptions as y, type ElementOptions as z };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { K as Category, q as Product, F as AddOnWithOptions, d as Pagination, h as CimplifyError, r as ProductWithDetails, s as ProductVariant, u as VariantAxis, z as VariantAxisSelection, B as AddOn, N as Collection, T as Bundle, X as BundleWithDetails, a2 as Composite, a3 as CompositeWithDetails, a7 as ComponentSelectionInput, a8 as CompositePriceResult, an as ChosenPrice, aS as UICart, aD as Cart, aE as CartItem, aW as CartSummary, aU as AddToCartInput, aV as UpdateCartItemInput, ar as DiscountDetails, M as Money, C as CurrencyCode, aC as LineConfiguration, a_ as AuthorizationType, b0 as PaymentMethod, b2 as InitializePaymentResult, b6 as SubmitAuthorizationInput, b4 as PaymentStatusResponse } from './payment-CLIWNMaP.mjs';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Observability hooks for monitoring SDK behavior.
|
|
@@ -104,6 +104,18 @@ interface CatalogueResult<T> {
|
|
|
104
104
|
/** Pagination metadata when listing is paginated. */
|
|
105
105
|
pagination?: Pagination;
|
|
106
106
|
}
|
|
107
|
+
/** Full catalogue envelope (products + categories + add-ons + metadata). */
|
|
108
|
+
interface CatalogueSnapshot {
|
|
109
|
+
categories: Category[];
|
|
110
|
+
products: Product[];
|
|
111
|
+
add_ons: AddOnWithOptions[];
|
|
112
|
+
/** true when the full catalogue is returned; false when truncated by server cap. */
|
|
113
|
+
is_complete: boolean;
|
|
114
|
+
/** Total available products before truncation (present when truncated). */
|
|
115
|
+
total_available?: number;
|
|
116
|
+
/** Pagination metadata when listing is paginated. */
|
|
117
|
+
pagination?: Pagination;
|
|
118
|
+
}
|
|
107
119
|
|
|
108
120
|
/**
|
|
109
121
|
* A Result type that makes errors explicit in the type system.
|
|
@@ -349,8 +361,8 @@ interface RefreshQuoteResult {
|
|
|
349
361
|
declare class CatalogueQueries {
|
|
350
362
|
private client;
|
|
351
363
|
constructor(client: CimplifyClient);
|
|
352
|
-
|
|
353
|
-
|
|
364
|
+
getCatalogue(): Promise<Result<CatalogueSnapshot, CimplifyError>>;
|
|
365
|
+
getProducts(options?: GetProductsOptions): Promise<Result<CatalogueResult<Product>, CimplifyError>>;
|
|
354
366
|
getProduct(id: string): Promise<Result<ProductWithDetails, CimplifyError>>;
|
|
355
367
|
getProductBySlug(slug: string): Promise<Result<ProductWithDetails, CimplifyError>>;
|
|
356
368
|
getVariants(productId: string): Promise<Result<ProductVariant[], CimplifyError>>;
|
|
@@ -2370,4 +2382,4 @@ declare class CimplifyClient {
|
|
|
2370
2382
|
}
|
|
2371
2383
|
declare function createCimplifyClient(config?: CimplifyConfig): CimplifyClient;
|
|
2372
2384
|
|
|
2373
|
-
export { type ProcessAndResolveOptions as $, AuthService as A, BusinessService as B, CimplifyClient as C, type ElementType as D, EVENT_TYPES as E, type FetchQuoteInput as F, type GetProductsOptions as G, type ElementEventType as H, InventoryService as I, type CheckoutMode as J, type KitchenOrderItem as K, LinkService as L, MESSAGE_TYPES as M, type CheckoutOrderType as N, OrderQueries as O, type PriceQuote as P, type QuoteCompositeSelectionInput as Q, type RefreshQuoteInput as R, type SearchOptions as S, type TableInfo as T, type UpdateProfileInput as U, type CheckoutPaymentMethod as V, type CheckoutStep as W, type CheckoutFormData as X, type CheckoutResult as Y, type ProcessCheckoutOptions as Z, type ProcessCheckoutResult as _, type CimplifyConfig as a, type
|
|
2385
|
+
export { type ProcessAndResolveOptions as $, AuthService as A, BusinessService as B, CimplifyClient as C, type ElementType as D, EVENT_TYPES as E, type FetchQuoteInput as F, type GetProductsOptions as G, type ElementEventType as H, InventoryService as I, type CheckoutMode as J, type KitchenOrderItem as K, LinkService as L, MESSAGE_TYPES as M, type CheckoutOrderType as N, OrderQueries as O, type PriceQuote as P, type QuoteCompositeSelectionInput as Q, type RefreshQuoteInput as R, type SearchOptions as S, type TableInfo as T, type UpdateProfileInput as U, type CheckoutPaymentMethod as V, type CheckoutStep as W, type CheckoutFormData as X, type CheckoutResult as Y, type ProcessCheckoutOptions as Z, type ProcessCheckoutResult as _, type CimplifyConfig as a, type OrderGroupDetails as a$, type CheckoutStatus as a0, type CheckoutStatusContext as a1, type AbortablePromise as a2, type MobileMoneyProvider as a3, type DeviceType as a4, type ContactType as a5, CHECKOUT_MODE as a6, ORDER_TYPE as a7, PAYMENT_METHOD as a8, CHECKOUT_STEP as a9, toNullable as aA, fromPromise as aB, tryCatch as aC, combine as aD, combineObject as aE, type CatalogueResult as aF, type CatalogueSnapshot as aG, type OrderStatus as aH, type PaymentState as aI, type OrderChannel as aJ, type LineType as aK, type OrderLineState as aL, type OrderLineStatus as aM, type FulfillmentType as aN, type FulfillmentStatus as aO, type FulfillmentLink as aP, type OrderFulfillmentSummary as aQ, type FeeBearerType as aR, type AmountToPay as aS, type LineItem as aT, type Order as aU, type OrderHistory as aV, type OrderGroupPaymentState as aW, type OrderGroup as aX, type OrderGroupPayment as aY, type OrderSplitDetail as aZ, type OrderGroupPaymentSummary as a_, PAYMENT_STATE as aa, PICKUP_TIME_TYPE as ab, MOBILE_MONEY_PROVIDER as ac, AUTHORIZATION_TYPE as ad, DEVICE_TYPE as ae, CONTACT_TYPE as af, LINK_QUERY as ag, LINK_MUTATION as ah, AUTH_MUTATION as ai, CHECKOUT_MUTATION as aj, PAYMENT_MUTATION as ak, ORDER_MUTATION as al, DEFAULT_CURRENCY as am, DEFAULT_COUNTRY as an, type Result as ao, type Ok as ap, type Err as aq, ok as ar, err as as, isOk as at, isErr as au, mapResult as av, mapError as aw, flatMap as ax, getOrElse as ay, unwrap as az, CatalogueQueries as b, type CancelBookingInput as b$, type OrderPaymentEvent as b0, type OrderFilter as b1, type CheckoutInput as b2, type UpdateOrderStatusInput as b3, type CancelOrderInput as b4, type RefundOrderInput as b5, type ServiceStatus as b6, type StaffRole as b7, type ReminderMethod as b8, type CustomerServicePreferences as b9, type BusinessWithLocations as bA, type LocationWithDetails as bB, type BusinessSettings as bC, type BusinessHours as bD, type CategoryInfo as bE, type ServiceAvailabilityRule as bF, type ServiceAvailabilityException as bG, type StaffAvailabilityRule as bH, type StaffAvailabilityException as bI, type ResourceAvailabilityRule as bJ, type ResourceAvailabilityException as bK, type StaffBookingProfile as bL, type ServiceStaffRequirement as bM, type BookingRequirementOverride as bN, type ResourceType as bO, type Service as bP, type ServiceWithStaff as bQ, type Staff as bR, type TimeSlot as bS, type AvailableSlot as bT, type DayAvailability as bU, type BookingStatus as bV, type Booking as bW, type BookingWithDetails as bX, type GetAvailableSlotsInput as bY, type CheckSlotAvailabilityInput as bZ, type RescheduleBookingInput as b_, type BufferTimes as ba, type ReminderSettings as bb, type CancellationPolicy as bc, type ServiceNotes as bd, type PricingOverrides as be, type SchedulingMetadata as bf, type StaffAssignment as bg, type ResourceAssignment as bh, type SchedulingResult as bi, type DepositResult as bj, type ServiceScheduleRequest as bk, type StaffScheduleItem as bl, type LocationAppointment as bm, type BusinessType as bn, type BusinessPreferences as bo, type Business as bp, type LocationTaxBehavior as bq, type LocationTaxOverrides as br, type Location as bs, type TimeRange as bt, type TimeRanges as bu, type LocationTimeProfile as bv, type Table as bw, type Room as bx, type ServiceCharge as by, type StorefrontBootstrap as bz, createCimplifyClient as c, type ServiceAvailabilityParams as c0, type ServiceAvailabilityResult as c1, type StockOwnershipType as c2, type StockStatus as c3, type Stock as c4, type StockLevel as c5, type ProductStock as c6, type VariantStock as c7, type LocationStock as c8, type AvailabilityCheck as c9, type MobileMoneyDetails as cA, type CheckoutCustomerInfo as cB, type FxQuoteRequest as cC, type FxQuote as cD, type FxRateResponse as cE, type RequestContext as cF, type RequestStartEvent as cG, type RequestSuccessEvent as cH, type RequestErrorEvent as cI, type RetryEvent as cJ, type SessionChangeEvent as cK, type ObservabilityHooks as cL, type ElementAppearance as cM, type AddressInfo as cN, type PaymentMethodInfo as cO, type AuthenticatedCustomer as cP, type ElementsCustomerInfo as cQ, type AuthenticatedData as cR, type ElementsCheckoutData as cS, type ElementsCheckoutResult as cT, type ParentToIframeMessage as cU, type IframeToParentMessage as cV, type ElementEventHandler as cW, type AvailabilityResult as ca, type InventorySummary as cb, type Customer as cc, type CustomerAddress as cd, type CustomerMobileMoney as ce, type CustomerLinkPreferences as cf, type LinkData as cg, type CreateAddressInput as ch, type UpdateAddressInput as ci, type CreateMobileMoneyInput as cj, type EnrollmentData as ck, type AddressData as cl, type MobileMoneyData as cm, type EnrollAndLinkOrderInput as cn, type LinkStatusResult as co, type LinkEnrollResult as cp, type EnrollAndLinkOrderResult as cq, type LinkSession as cr, type RevokeSessionResult as cs, type RevokeAllSessionsResult as ct, type RequestOtpInput as cu, type VerifyOtpInput as cv, type AuthResponse as cw, type PickupTimeType as cx, type PickupTime as cy, type CheckoutAddressInfo as cz, type QuoteBundleSelectionInput as d, type QuoteStatus as e, type QuoteDynamicBuckets as f, type QuoteUiMessage as g, type RefreshQuoteResult as h, CartOperations as i, CheckoutService as j, generateIdempotencyKey as k, type GetOrdersOptions as l, type AuthStatus as m, type OtpResult as n, type ChangePasswordInput as o, SchedulingService as p, LiteService as q, FxService as r, type LiteBootstrap as s, type KitchenOrderResult as t, CimplifyElements as u, CimplifyElement as v, createElements as w, ELEMENT_TYPES as x, type ElementsOptions as y, type ElementOptions as z };
|
|
@@ -8,23 +8,17 @@ import { an as ChosenPrice, C as CurrencyCode, ak as TaxPathComponent, al as Pri
|
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
10
|
* Individual tax component (e.g., VAT, NHIL, GETFund)
|
|
11
|
-
*/
|
|
12
|
-
/**
|
|
13
11
|
* @deprecated Use `TaxPathComponent` from `types/cart` instead.
|
|
14
12
|
*/
|
|
15
13
|
type TaxComponent = TaxPathComponent;
|
|
16
14
|
/**
|
|
17
15
|
* Complete tax information from a pricing response
|
|
18
|
-
*/
|
|
19
|
-
/**
|
|
20
16
|
* @deprecated Use `PricePathTaxInfo` from `types/cart` instead.
|
|
21
17
|
*/
|
|
22
18
|
type TaxInfo = PricePathTaxInfo;
|
|
23
19
|
/**
|
|
24
20
|
* Price information in snake_case format (as returned from backend)
|
|
25
21
|
* Used by components that work with raw API responses
|
|
26
|
-
*/
|
|
27
|
-
/**
|
|
28
22
|
* @deprecated Use `ChosenPrice` from `types/cart` instead.
|
|
29
23
|
*/
|
|
30
24
|
type PriceInfo = ChosenPrice;
|
|
@@ -8,23 +8,17 @@ import { an as ChosenPrice, C as CurrencyCode, ak as TaxPathComponent, al as Pri
|
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
10
|
* Individual tax component (e.g., VAT, NHIL, GETFund)
|
|
11
|
-
*/
|
|
12
|
-
/**
|
|
13
11
|
* @deprecated Use `TaxPathComponent` from `types/cart` instead.
|
|
14
12
|
*/
|
|
15
13
|
type TaxComponent = TaxPathComponent;
|
|
16
14
|
/**
|
|
17
15
|
* Complete tax information from a pricing response
|
|
18
|
-
*/
|
|
19
|
-
/**
|
|
20
16
|
* @deprecated Use `PricePathTaxInfo` from `types/cart` instead.
|
|
21
17
|
*/
|
|
22
18
|
type TaxInfo = PricePathTaxInfo;
|
|
23
19
|
/**
|
|
24
20
|
* Price information in snake_case format (as returned from backend)
|
|
25
21
|
* Used by components that work with raw API responses
|
|
26
|
-
*/
|
|
27
|
-
/**
|
|
28
22
|
* @deprecated Use `ChosenPrice` from `types/cart` instead.
|
|
29
23
|
*/
|
|
30
24
|
type PriceInfo = ChosenPrice;
|
package/dist/index.d.mts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
export { ad as AUTHORIZATION_TYPE, ai as AUTH_MUTATION, a2 as AbortablePromise,
|
|
1
|
+
export { ad as AUTHORIZATION_TYPE, ai as AUTH_MUTATION, a2 as AbortablePromise, cl as AddressData, cN as AddressInfo, aS as AmountToPay, cw as AuthResponse, A as AuthService, m as AuthStatus, cP as AuthenticatedCustomer, cR as AuthenticatedData, c9 as AvailabilityCheck, ca as AvailabilityResult, bT as AvailableSlot, bW as Booking, bN as BookingRequirementOverride, bV as BookingStatus, bX as BookingWithDetails, ba as BufferTimes, bp as Business, bD as BusinessHours, bo as BusinessPreferences, B as BusinessService, bC as BusinessSettings, bn as BusinessType, bA as BusinessWithLocations, a6 as CHECKOUT_MODE, aj as CHECKOUT_MUTATION, a9 as CHECKOUT_STEP, af as CONTACT_TYPE, b$ as CancelBookingInput, b4 as CancelOrderInput, bc as CancellationPolicy, i as CartOperations, b as CatalogueQueries, aF as CatalogueResult, aG as CatalogueSnapshot, bE as CategoryInfo, o as ChangePasswordInput, bZ as CheckSlotAvailabilityInput, cz as CheckoutAddressInfo, cB as CheckoutCustomerInfo, X as CheckoutFormData, b2 as CheckoutInput, J as CheckoutMode, j as CheckoutOperations, N as CheckoutOrderType, V as CheckoutPaymentMethod, Y as CheckoutResult, j as CheckoutService, a0 as CheckoutStatus, a1 as CheckoutStatusContext, W as CheckoutStep, C as CimplifyClient, a as CimplifyConfig, v as CimplifyElement, u as CimplifyElements, a5 as ContactType, ch as CreateAddressInput, cj as CreateMobileMoneyInput, cc as Customer, cd as CustomerAddress, cf as CustomerLinkPreferences, ce as CustomerMobileMoney, b9 as CustomerServicePreferences, an as DEFAULT_COUNTRY, am as DEFAULT_CURRENCY, ae as DEVICE_TYPE, bU as DayAvailability, bj as DepositResult, a4 as DeviceType, x as ELEMENT_TYPES, E as EVENT_TYPES, cM as ElementAppearance, cW as ElementEventHandler, H as ElementEventType, z as ElementOptions, D as ElementType, cS as ElementsCheckoutData, cT as ElementsCheckoutResult, cQ as ElementsCustomerInfo, y as ElementsOptions, cn as EnrollAndLinkOrderInput, cq as EnrollAndLinkOrderResult, ck as EnrollmentData, aq as Err, aR as FeeBearerType, F as FetchQuoteInput, aP as FulfillmentLink, aO as FulfillmentStatus, aN as FulfillmentType, cD as FxQuote, cC as FxQuoteRequest, cE as FxRateResponse, r as FxService, bY as GetAvailableSlotsInput, l as GetOrdersOptions, G as GetProductsOptions, cV as IframeToParentMessage, I as InventoryService, cb as InventorySummary, K as KitchenOrderItem, t as KitchenOrderResult, ah as LINK_MUTATION, ag as LINK_QUERY, aT as LineItem, aK as LineType, cg as LinkData, cp as LinkEnrollResult, L as LinkService, cr as LinkSession, co as LinkStatusResult, s as LiteBootstrap, q as LiteService, bs as Location, bm as LocationAppointment, c8 as LocationStock, bq as LocationTaxBehavior, br as LocationTaxOverrides, bv as LocationTimeProfile, bB as LocationWithDetails, M as MESSAGE_TYPES, ac as MOBILE_MONEY_PROVIDER, cm as MobileMoneyData, cA as MobileMoneyDetails, a3 as MobileMoneyProvider, al as ORDER_MUTATION, a7 as ORDER_TYPE, cL as ObservabilityHooks, ap as Ok, aU as Order, aJ as OrderChannel, b1 as OrderFilter, aQ as OrderFulfillmentSummary, aX as OrderGroup, a$ as OrderGroupDetails, aY as OrderGroupPayment, aW as OrderGroupPaymentState, a_ as OrderGroupPaymentSummary, aV as OrderHistory, aL as OrderLineState, aM as OrderLineStatus, b0 as OrderPaymentEvent, O as OrderQueries, aZ as OrderSplitDetail, aH as OrderStatus, n as OtpResult, a8 as PAYMENT_METHOD, ak as PAYMENT_MUTATION, aa as PAYMENT_STATE, ab as PICKUP_TIME_TYPE, cU as ParentToIframeMessage, cO as PaymentMethodInfo, aI as PaymentState, cy as PickupTime, cx as PickupTimeType, P as PriceQuote, be as PricingOverrides, $ as ProcessAndResolveOptions, Z as ProcessCheckoutOptions, _ as ProcessCheckoutResult, c6 as ProductStock, d as QuoteBundleSelectionInput, Q as QuoteCompositeSelectionInput, f as QuoteDynamicBuckets, e as QuoteStatus, g as QuoteUiMessage, R as RefreshQuoteInput, h as RefreshQuoteResult, b5 as RefundOrderInput, b8 as ReminderMethod, bb as ReminderSettings, cF as RequestContext, cI as RequestErrorEvent, cu as RequestOtpInput, cG as RequestStartEvent, cH as RequestSuccessEvent, b_ as RescheduleBookingInput, bh as ResourceAssignment, bK as ResourceAvailabilityException, bJ as ResourceAvailabilityRule, bO as ResourceType, ao as Result, cJ as RetryEvent, ct as RevokeAllSessionsResult, cs as RevokeSessionResult, bx as Room, bf as SchedulingMetadata, bi as SchedulingResult, p as SchedulingService, S as SearchOptions, bP as Service, bG as ServiceAvailabilityException, c0 as ServiceAvailabilityParams, c1 as ServiceAvailabilityResult, bF as ServiceAvailabilityRule, by as ServiceCharge, bd as ServiceNotes, bk as ServiceScheduleRequest, bM as ServiceStaffRequirement, b6 as ServiceStatus, bQ as ServiceWithStaff, cK as SessionChangeEvent, bR as Staff, bg as StaffAssignment, bI as StaffAvailabilityException, bH as StaffAvailabilityRule, bL as StaffBookingProfile, b7 as StaffRole, bl as StaffScheduleItem, c4 as Stock, c5 as StockLevel, c2 as StockOwnershipType, c3 as StockStatus, bz as StorefrontBootstrap, bw as Table, T as TableInfo, bt as TimeRange, bu as TimeRanges, bS as TimeSlot, ci as UpdateAddressInput, b3 as UpdateOrderStatusInput, U as UpdateProfileInput, c7 as VariantStock, cv as VerifyOtpInput, aD as combine, aE as combineObject, c as createCimplifyClient, w as createElements, as as err, ax as flatMap, aB as fromPromise, k as generateIdempotencyKey, ay as getOrElse, au as isErr, at as isOk, aw as mapError, av as mapResult, ar as ok, aA as toNullable, aC as tryCatch, az as unwrap } from './client-CSH0xyto.mjs';
|
|
2
2
|
export { QueryBuilder, query } from './advanced.mjs';
|
|
3
3
|
import { A as ApiError } from './payment-CLIWNMaP.mjs';
|
|
4
4
|
export { B as AddOn, at as AddOnDetails, aP as AddOnGroupDetails, G as AddOnOption, aO as AddOnOptionDetails, H as AddOnOptionPrice, F as AddOnWithOptions, aU as AddToCartInput, ai as AdjustmentType, ap as AppliedDiscount, a_ as AuthorizationType, ao as BenefitType, T as Bundle, Y as BundleComponentData, _ as BundleComponentInfo, R as BundlePriceType, W as BundleProduct, ay as BundleSelectionData, aw as BundleSelectionInput, ax as BundleStoredSelection, U as BundleSummary, X as BundleWithDetails, aD as Cart, au as CartAddOn, ag as CartChannel, aE as CartItem, aR as CartItemDetails, af as CartStatus, aW as CartSummary, aF as CartTotals, K as Category, L as CategorySummary, an as ChosenPrice, h as CimplifyError, N as Collection, Q as CollectionProduct, O as CollectionSummary, a4 as ComponentGroup, a5 as ComponentGroupWithComponents, a9 as ComponentPriceBreakdown, a7 as ComponentSelectionInput, a1 as ComponentSourceType, a2 as Composite, a6 as CompositeComponent, aA as CompositePriceBreakdown, a8 as CompositePriceResult, $ as CompositePricingMode, aB as CompositeSelectionData, a7 as CompositeSelectionInput, az as CompositeStoredSelection, a3 as CompositeWithDetails, b as Currency, C as CurrencyCode, p as DepositType, D as DigitalProductType, aq as DiscountBreakdown, ar as DiscountDetails, aI as DisplayAddOn, aJ as DisplayAddOnOption, aG as DisplayCart, aH as DisplayCartItem, g as ERROR_HINTS, E as ErrorCode, e as ErrorCodeType, f as ErrorHint, a0 as GroupPricingBehavior, b2 as InitializePaymentResult, I as InventoryType, aC as LineConfiguration, ac as LocationProductPrice, M as Money, d as Pagination, P as PaginationParams, b1 as Payment, b5 as PaymentErrorDetails, b0 as PaymentMethod, aZ as PaymentMethodType, a$ as PaymentProcessingState, aY as PaymentProvider, b3 as PaymentResponse, aX as PaymentStatus, b4 as PaymentStatusResponse, ab as Price, aj as PriceAdjustment, am as PriceDecisionPath, aa as PriceEntryType, al as PricePathTaxInfo, ah as PriceSource, q as Product, J as ProductAddOn, ad as ProductAvailability, o as ProductRenderHint, ae as ProductTimeProfile, n as ProductType, s as ProductVariant, x as ProductVariantValue, r as ProductWithDetails, S as SalesChannel, as as SelectedAddOnOption, b6 as SubmitAuthorizationInput, ak as TaxPathComponent, aS as UICart, aK as UICartBusiness, aM as UICartCustomer, aL as UICartLocation, aN as UICartPricing, aT as UICartResponse, aV as UpdateCartItemInput, u as VariantAxis, z as VariantAxisSelection, w as VariantAxisValue, v as VariantAxisWithValues, av as VariantDetails, aQ as VariantDetailsDTO, t as VariantDisplayAttribute, y as VariantLocationAvailability, V as VariantStrategy, Z as ZERO, c as currencyCode, k as enrichError, j as getErrorHint, i as isCimplifyError, l as isRetryableError, m as money, a as moneyFromNumber } from './payment-CLIWNMaP.mjs';
|
|
5
|
-
export { C as CURRENCY_SYMBOLS, B as FormatCompactOptions, F as FormatPriceOptions, M as MOBILE_MONEY_PROVIDERS, P as PriceInfo, A as ProductWithPrice, T as TaxComponent, z as TaxInfo, s as categorizePaymentError, y as detectMobileMoneyProvider, c as formatMoney, d as formatNumberCompact, f as formatPrice, a as formatPriceAdjustment, b as formatPriceCompact, j as formatPriceWithTax, e as formatProductPrice, m as getBasePrice, k as getCurrencySymbol, o as getDiscountPercentage, l as getDisplayPrice, q as getMarkupPercentage, r as getProductCurrency, g as getTaxAmount, h as hasTaxInfo, n as isOnSale, v as isPaymentStatusFailure, w as isPaymentStatusRequiresAction, x as isPaymentStatusSuccess, i as isTaxInclusive, t as normalizePaymentResponse, u as normalizeStatusResponse, p as parsePrice } from './index-
|
|
5
|
+
export { C as CURRENCY_SYMBOLS, B as FormatCompactOptions, F as FormatPriceOptions, M as MOBILE_MONEY_PROVIDERS, P as PriceInfo, A as ProductWithPrice, T as TaxComponent, z as TaxInfo, s as categorizePaymentError, y as detectMobileMoneyProvider, c as formatMoney, d as formatNumberCompact, f as formatPrice, a as formatPriceAdjustment, b as formatPriceCompact, j as formatPriceWithTax, e as formatProductPrice, m as getBasePrice, k as getCurrencySymbol, o as getDiscountPercentage, l as getDisplayPrice, q as getMarkupPercentage, r as getProductCurrency, g as getTaxAmount, h as hasTaxInfo, n as isOnSale, v as isPaymentStatusFailure, w as isPaymentStatusRequiresAction, x as isPaymentStatusSuccess, i as isTaxInclusive, t as normalizePaymentResponse, u as normalizeStatusResponse, p as parsePrice } from './index-mrKi_VbR.mjs';
|
|
6
6
|
export { c as AdConfig, e as AdContextValue, d as AdCreative, a as AdPosition, A as AdSlot, b as AdTheme } from './ads-t3FBTU8p.mjs';
|
|
7
7
|
|
|
8
8
|
/** Context sent with every request to scope operations to a specific location/branch */
|
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
export { ad as AUTHORIZATION_TYPE, ai as AUTH_MUTATION, a2 as AbortablePromise,
|
|
1
|
+
export { ad as AUTHORIZATION_TYPE, ai as AUTH_MUTATION, a2 as AbortablePromise, cl as AddressData, cN as AddressInfo, aS as AmountToPay, cw as AuthResponse, A as AuthService, m as AuthStatus, cP as AuthenticatedCustomer, cR as AuthenticatedData, c9 as AvailabilityCheck, ca as AvailabilityResult, bT as AvailableSlot, bW as Booking, bN as BookingRequirementOverride, bV as BookingStatus, bX as BookingWithDetails, ba as BufferTimes, bp as Business, bD as BusinessHours, bo as BusinessPreferences, B as BusinessService, bC as BusinessSettings, bn as BusinessType, bA as BusinessWithLocations, a6 as CHECKOUT_MODE, aj as CHECKOUT_MUTATION, a9 as CHECKOUT_STEP, af as CONTACT_TYPE, b$ as CancelBookingInput, b4 as CancelOrderInput, bc as CancellationPolicy, i as CartOperations, b as CatalogueQueries, aF as CatalogueResult, aG as CatalogueSnapshot, bE as CategoryInfo, o as ChangePasswordInput, bZ as CheckSlotAvailabilityInput, cz as CheckoutAddressInfo, cB as CheckoutCustomerInfo, X as CheckoutFormData, b2 as CheckoutInput, J as CheckoutMode, j as CheckoutOperations, N as CheckoutOrderType, V as CheckoutPaymentMethod, Y as CheckoutResult, j as CheckoutService, a0 as CheckoutStatus, a1 as CheckoutStatusContext, W as CheckoutStep, C as CimplifyClient, a as CimplifyConfig, v as CimplifyElement, u as CimplifyElements, a5 as ContactType, ch as CreateAddressInput, cj as CreateMobileMoneyInput, cc as Customer, cd as CustomerAddress, cf as CustomerLinkPreferences, ce as CustomerMobileMoney, b9 as CustomerServicePreferences, an as DEFAULT_COUNTRY, am as DEFAULT_CURRENCY, ae as DEVICE_TYPE, bU as DayAvailability, bj as DepositResult, a4 as DeviceType, x as ELEMENT_TYPES, E as EVENT_TYPES, cM as ElementAppearance, cW as ElementEventHandler, H as ElementEventType, z as ElementOptions, D as ElementType, cS as ElementsCheckoutData, cT as ElementsCheckoutResult, cQ as ElementsCustomerInfo, y as ElementsOptions, cn as EnrollAndLinkOrderInput, cq as EnrollAndLinkOrderResult, ck as EnrollmentData, aq as Err, aR as FeeBearerType, F as FetchQuoteInput, aP as FulfillmentLink, aO as FulfillmentStatus, aN as FulfillmentType, cD as FxQuote, cC as FxQuoteRequest, cE as FxRateResponse, r as FxService, bY as GetAvailableSlotsInput, l as GetOrdersOptions, G as GetProductsOptions, cV as IframeToParentMessage, I as InventoryService, cb as InventorySummary, K as KitchenOrderItem, t as KitchenOrderResult, ah as LINK_MUTATION, ag as LINK_QUERY, aT as LineItem, aK as LineType, cg as LinkData, cp as LinkEnrollResult, L as LinkService, cr as LinkSession, co as LinkStatusResult, s as LiteBootstrap, q as LiteService, bs as Location, bm as LocationAppointment, c8 as LocationStock, bq as LocationTaxBehavior, br as LocationTaxOverrides, bv as LocationTimeProfile, bB as LocationWithDetails, M as MESSAGE_TYPES, ac as MOBILE_MONEY_PROVIDER, cm as MobileMoneyData, cA as MobileMoneyDetails, a3 as MobileMoneyProvider, al as ORDER_MUTATION, a7 as ORDER_TYPE, cL as ObservabilityHooks, ap as Ok, aU as Order, aJ as OrderChannel, b1 as OrderFilter, aQ as OrderFulfillmentSummary, aX as OrderGroup, a$ as OrderGroupDetails, aY as OrderGroupPayment, aW as OrderGroupPaymentState, a_ as OrderGroupPaymentSummary, aV as OrderHistory, aL as OrderLineState, aM as OrderLineStatus, b0 as OrderPaymentEvent, O as OrderQueries, aZ as OrderSplitDetail, aH as OrderStatus, n as OtpResult, a8 as PAYMENT_METHOD, ak as PAYMENT_MUTATION, aa as PAYMENT_STATE, ab as PICKUP_TIME_TYPE, cU as ParentToIframeMessage, cO as PaymentMethodInfo, aI as PaymentState, cy as PickupTime, cx as PickupTimeType, P as PriceQuote, be as PricingOverrides, $ as ProcessAndResolveOptions, Z as ProcessCheckoutOptions, _ as ProcessCheckoutResult, c6 as ProductStock, d as QuoteBundleSelectionInput, Q as QuoteCompositeSelectionInput, f as QuoteDynamicBuckets, e as QuoteStatus, g as QuoteUiMessage, R as RefreshQuoteInput, h as RefreshQuoteResult, b5 as RefundOrderInput, b8 as ReminderMethod, bb as ReminderSettings, cF as RequestContext, cI as RequestErrorEvent, cu as RequestOtpInput, cG as RequestStartEvent, cH as RequestSuccessEvent, b_ as RescheduleBookingInput, bh as ResourceAssignment, bK as ResourceAvailabilityException, bJ as ResourceAvailabilityRule, bO as ResourceType, ao as Result, cJ as RetryEvent, ct as RevokeAllSessionsResult, cs as RevokeSessionResult, bx as Room, bf as SchedulingMetadata, bi as SchedulingResult, p as SchedulingService, S as SearchOptions, bP as Service, bG as ServiceAvailabilityException, c0 as ServiceAvailabilityParams, c1 as ServiceAvailabilityResult, bF as ServiceAvailabilityRule, by as ServiceCharge, bd as ServiceNotes, bk as ServiceScheduleRequest, bM as ServiceStaffRequirement, b6 as ServiceStatus, bQ as ServiceWithStaff, cK as SessionChangeEvent, bR as Staff, bg as StaffAssignment, bI as StaffAvailabilityException, bH as StaffAvailabilityRule, bL as StaffBookingProfile, b7 as StaffRole, bl as StaffScheduleItem, c4 as Stock, c5 as StockLevel, c2 as StockOwnershipType, c3 as StockStatus, bz as StorefrontBootstrap, bw as Table, T as TableInfo, bt as TimeRange, bu as TimeRanges, bS as TimeSlot, ci as UpdateAddressInput, b3 as UpdateOrderStatusInput, U as UpdateProfileInput, c7 as VariantStock, cv as VerifyOtpInput, aD as combine, aE as combineObject, c as createCimplifyClient, w as createElements, as as err, ax as flatMap, aB as fromPromise, k as generateIdempotencyKey, ay as getOrElse, au as isErr, at as isOk, aw as mapError, av as mapResult, ar as ok, aA as toNullable, aC as tryCatch, az as unwrap } from './client-C082Zp8J.js';
|
|
2
2
|
export { QueryBuilder, query } from './advanced.js';
|
|
3
3
|
import { A as ApiError } from './payment-CLIWNMaP.js';
|
|
4
4
|
export { B as AddOn, at as AddOnDetails, aP as AddOnGroupDetails, G as AddOnOption, aO as AddOnOptionDetails, H as AddOnOptionPrice, F as AddOnWithOptions, aU as AddToCartInput, ai as AdjustmentType, ap as AppliedDiscount, a_ as AuthorizationType, ao as BenefitType, T as Bundle, Y as BundleComponentData, _ as BundleComponentInfo, R as BundlePriceType, W as BundleProduct, ay as BundleSelectionData, aw as BundleSelectionInput, ax as BundleStoredSelection, U as BundleSummary, X as BundleWithDetails, aD as Cart, au as CartAddOn, ag as CartChannel, aE as CartItem, aR as CartItemDetails, af as CartStatus, aW as CartSummary, aF as CartTotals, K as Category, L as CategorySummary, an as ChosenPrice, h as CimplifyError, N as Collection, Q as CollectionProduct, O as CollectionSummary, a4 as ComponentGroup, a5 as ComponentGroupWithComponents, a9 as ComponentPriceBreakdown, a7 as ComponentSelectionInput, a1 as ComponentSourceType, a2 as Composite, a6 as CompositeComponent, aA as CompositePriceBreakdown, a8 as CompositePriceResult, $ as CompositePricingMode, aB as CompositeSelectionData, a7 as CompositeSelectionInput, az as CompositeStoredSelection, a3 as CompositeWithDetails, b as Currency, C as CurrencyCode, p as DepositType, D as DigitalProductType, aq as DiscountBreakdown, ar as DiscountDetails, aI as DisplayAddOn, aJ as DisplayAddOnOption, aG as DisplayCart, aH as DisplayCartItem, g as ERROR_HINTS, E as ErrorCode, e as ErrorCodeType, f as ErrorHint, a0 as GroupPricingBehavior, b2 as InitializePaymentResult, I as InventoryType, aC as LineConfiguration, ac as LocationProductPrice, M as Money, d as Pagination, P as PaginationParams, b1 as Payment, b5 as PaymentErrorDetails, b0 as PaymentMethod, aZ as PaymentMethodType, a$ as PaymentProcessingState, aY as PaymentProvider, b3 as PaymentResponse, aX as PaymentStatus, b4 as PaymentStatusResponse, ab as Price, aj as PriceAdjustment, am as PriceDecisionPath, aa as PriceEntryType, al as PricePathTaxInfo, ah as PriceSource, q as Product, J as ProductAddOn, ad as ProductAvailability, o as ProductRenderHint, ae as ProductTimeProfile, n as ProductType, s as ProductVariant, x as ProductVariantValue, r as ProductWithDetails, S as SalesChannel, as as SelectedAddOnOption, b6 as SubmitAuthorizationInput, ak as TaxPathComponent, aS as UICart, aK as UICartBusiness, aM as UICartCustomer, aL as UICartLocation, aN as UICartPricing, aT as UICartResponse, aV as UpdateCartItemInput, u as VariantAxis, z as VariantAxisSelection, w as VariantAxisValue, v as VariantAxisWithValues, av as VariantDetails, aQ as VariantDetailsDTO, t as VariantDisplayAttribute, y as VariantLocationAvailability, V as VariantStrategy, Z as ZERO, c as currencyCode, k as enrichError, j as getErrorHint, i as isCimplifyError, l as isRetryableError, m as money, a as moneyFromNumber } from './payment-CLIWNMaP.js';
|
|
5
|
-
export { C as CURRENCY_SYMBOLS, B as FormatCompactOptions, F as FormatPriceOptions, M as MOBILE_MONEY_PROVIDERS, P as PriceInfo, A as ProductWithPrice, T as TaxComponent, z as TaxInfo, s as categorizePaymentError, y as detectMobileMoneyProvider, c as formatMoney, d as formatNumberCompact, f as formatPrice, a as formatPriceAdjustment, b as formatPriceCompact, j as formatPriceWithTax, e as formatProductPrice, m as getBasePrice, k as getCurrencySymbol, o as getDiscountPercentage, l as getDisplayPrice, q as getMarkupPercentage, r as getProductCurrency, g as getTaxAmount, h as hasTaxInfo, n as isOnSale, v as isPaymentStatusFailure, w as isPaymentStatusRequiresAction, x as isPaymentStatusSuccess, i as isTaxInclusive, t as normalizePaymentResponse, u as normalizeStatusResponse, p as parsePrice } from './index-
|
|
5
|
+
export { C as CURRENCY_SYMBOLS, B as FormatCompactOptions, F as FormatPriceOptions, M as MOBILE_MONEY_PROVIDERS, P as PriceInfo, A as ProductWithPrice, T as TaxComponent, z as TaxInfo, s as categorizePaymentError, y as detectMobileMoneyProvider, c as formatMoney, d as formatNumberCompact, f as formatPrice, a as formatPriceAdjustment, b as formatPriceCompact, j as formatPriceWithTax, e as formatProductPrice, m as getBasePrice, k as getCurrencySymbol, o as getDiscountPercentage, l as getDisplayPrice, q as getMarkupPercentage, r as getProductCurrency, g as getTaxAmount, h as hasTaxInfo, n as isOnSale, v as isPaymentStatusFailure, w as isPaymentStatusRequiresAction, x as isPaymentStatusSuccess, i as isTaxInclusive, t as normalizePaymentResponse, u as normalizeStatusResponse, p as parsePrice } from './index-B_JHO-ER.js';
|
|
6
6
|
export { c as AdConfig, e as AdContextValue, d as AdCreative, a as AdPosition, A as AdSlot, b as AdTheme } from './ads-t3FBTU8p.js';
|
|
7
7
|
|
|
8
8
|
/** Context sent with every request to scope operations to a specific location/branch */
|
package/dist/index.js
CHANGED
|
@@ -349,6 +349,22 @@ function readFinalPrice(value) {
|
|
|
349
349
|
}
|
|
350
350
|
return void 0;
|
|
351
351
|
}
|
|
352
|
+
function normalizeAddOnPayload(addOn) {
|
|
353
|
+
if (!isRecord(addOn)) return addOn;
|
|
354
|
+
const normalizedAddOn = { ...addOn };
|
|
355
|
+
const options = normalizedAddOn["options"];
|
|
356
|
+
if (!Array.isArray(options)) return normalizedAddOn;
|
|
357
|
+
normalizedAddOn["options"] = options.map((option) => {
|
|
358
|
+
if (!isRecord(option)) return option;
|
|
359
|
+
const normalizedOption = { ...option };
|
|
360
|
+
const optionPrice = normalizedOption["default_price"];
|
|
361
|
+
if (optionPrice === void 0 || optionPrice === null || optionPrice === "") {
|
|
362
|
+
normalizedOption["default_price"] = readFinalPrice(normalizedOption["default_price_info"]) || readFinalPrice(normalizedOption["price_info"]) || "0";
|
|
363
|
+
}
|
|
364
|
+
return normalizedOption;
|
|
365
|
+
});
|
|
366
|
+
return normalizedAddOn;
|
|
367
|
+
}
|
|
352
368
|
function normalizeCatalogueProductPayload(product) {
|
|
353
369
|
const normalized = { ...product };
|
|
354
370
|
const defaultPrice = normalized["default_price"];
|
|
@@ -370,22 +386,7 @@ function normalizeCatalogueProductPayload(product) {
|
|
|
370
386
|
}
|
|
371
387
|
const addOns = normalized["add_ons"];
|
|
372
388
|
if (Array.isArray(addOns)) {
|
|
373
|
-
normalized["add_ons"] = addOns.map((addOn) =>
|
|
374
|
-
if (!isRecord(addOn)) return addOn;
|
|
375
|
-
const normalizedAddOn = { ...addOn };
|
|
376
|
-
const options = normalizedAddOn["options"];
|
|
377
|
-
if (!Array.isArray(options)) return normalizedAddOn;
|
|
378
|
-
normalizedAddOn["options"] = options.map((option) => {
|
|
379
|
-
if (!isRecord(option)) return option;
|
|
380
|
-
const normalizedOption = { ...option };
|
|
381
|
-
const optionPrice = normalizedOption["default_price"];
|
|
382
|
-
if (optionPrice === void 0 || optionPrice === null || optionPrice === "") {
|
|
383
|
-
normalizedOption["default_price"] = readFinalPrice(normalizedOption["default_price_info"]) || readFinalPrice(normalizedOption["price_info"]) || "0";
|
|
384
|
-
}
|
|
385
|
-
return normalizedOption;
|
|
386
|
-
});
|
|
387
|
-
return normalizedAddOn;
|
|
388
|
-
});
|
|
389
|
+
normalized["add_ons"] = addOns.map((addOn) => normalizeAddOnPayload(addOn));
|
|
389
390
|
}
|
|
390
391
|
return normalized;
|
|
391
392
|
}
|
|
@@ -458,16 +459,48 @@ function normalizeCatalogueResult(payload) {
|
|
|
458
459
|
pagination: normalizePagination(payload.pagination)
|
|
459
460
|
};
|
|
460
461
|
}
|
|
462
|
+
function normalizeCatalogueSnapshot(payload) {
|
|
463
|
+
if (Array.isArray(payload)) {
|
|
464
|
+
return {
|
|
465
|
+
categories: [],
|
|
466
|
+
products: payload.map((product) => normalizeCatalogueProductPayload(product)),
|
|
467
|
+
add_ons: [],
|
|
468
|
+
is_complete: true
|
|
469
|
+
};
|
|
470
|
+
}
|
|
471
|
+
if (!isRecord(payload)) {
|
|
472
|
+
return {
|
|
473
|
+
categories: [],
|
|
474
|
+
products: [],
|
|
475
|
+
add_ons: [],
|
|
476
|
+
is_complete: true
|
|
477
|
+
};
|
|
478
|
+
}
|
|
479
|
+
const rawProducts = Array.isArray(payload.products) ? payload.products : Array.isArray(payload.items) ? payload.items : [];
|
|
480
|
+
const rawCategories = Array.isArray(payload.categories) ? payload.categories : [];
|
|
481
|
+
const rawAddOns = Array.isArray(payload.add_ons) ? payload.add_ons : [];
|
|
482
|
+
return {
|
|
483
|
+
categories: rawCategories,
|
|
484
|
+
products: rawProducts.map((product) => normalizeCatalogueProductPayload(product)),
|
|
485
|
+
add_ons: rawAddOns.map((addOn) => normalizeAddOnPayload(addOn)),
|
|
486
|
+
is_complete: typeof payload.is_complete === "boolean" ? payload.is_complete : true,
|
|
487
|
+
total_available: toFiniteNumber(payload.total_available),
|
|
488
|
+
pagination: normalizePagination(payload.pagination)
|
|
489
|
+
};
|
|
490
|
+
}
|
|
461
491
|
var CatalogueQueries = class {
|
|
462
492
|
constructor(client) {
|
|
463
493
|
this.client = client;
|
|
464
494
|
}
|
|
465
|
-
async
|
|
466
|
-
const result = await
|
|
495
|
+
async getCatalogue() {
|
|
496
|
+
const result = await safeWithFallback(
|
|
497
|
+
() => this.client.get("/api/v1/catalogue"),
|
|
498
|
+
() => this.client.query("catalogue")
|
|
499
|
+
);
|
|
467
500
|
if (!result.ok) return result;
|
|
468
|
-
return ok(result.value
|
|
501
|
+
return ok(normalizeCatalogueSnapshot(result.value));
|
|
469
502
|
}
|
|
470
|
-
async
|
|
503
|
+
async getProducts(options) {
|
|
471
504
|
let query2 = "products";
|
|
472
505
|
const filters = [];
|
|
473
506
|
if (options?.category) {
|
|
@@ -850,7 +883,7 @@ var CatalogueQueries = class {
|
|
|
850
883
|
limit: options?.limit ?? 20
|
|
851
884
|
});
|
|
852
885
|
if (!result.ok) return result;
|
|
853
|
-
return ok(result.value);
|
|
886
|
+
return ok(result.value.items);
|
|
854
887
|
}
|
|
855
888
|
async searchProducts(query2, options) {
|
|
856
889
|
return this.search(query2, options);
|
package/dist/index.mjs
CHANGED
|
@@ -347,6 +347,22 @@ function readFinalPrice(value) {
|
|
|
347
347
|
}
|
|
348
348
|
return void 0;
|
|
349
349
|
}
|
|
350
|
+
function normalizeAddOnPayload(addOn) {
|
|
351
|
+
if (!isRecord(addOn)) return addOn;
|
|
352
|
+
const normalizedAddOn = { ...addOn };
|
|
353
|
+
const options = normalizedAddOn["options"];
|
|
354
|
+
if (!Array.isArray(options)) return normalizedAddOn;
|
|
355
|
+
normalizedAddOn["options"] = options.map((option) => {
|
|
356
|
+
if (!isRecord(option)) return option;
|
|
357
|
+
const normalizedOption = { ...option };
|
|
358
|
+
const optionPrice = normalizedOption["default_price"];
|
|
359
|
+
if (optionPrice === void 0 || optionPrice === null || optionPrice === "") {
|
|
360
|
+
normalizedOption["default_price"] = readFinalPrice(normalizedOption["default_price_info"]) || readFinalPrice(normalizedOption["price_info"]) || "0";
|
|
361
|
+
}
|
|
362
|
+
return normalizedOption;
|
|
363
|
+
});
|
|
364
|
+
return normalizedAddOn;
|
|
365
|
+
}
|
|
350
366
|
function normalizeCatalogueProductPayload(product) {
|
|
351
367
|
const normalized = { ...product };
|
|
352
368
|
const defaultPrice = normalized["default_price"];
|
|
@@ -368,22 +384,7 @@ function normalizeCatalogueProductPayload(product) {
|
|
|
368
384
|
}
|
|
369
385
|
const addOns = normalized["add_ons"];
|
|
370
386
|
if (Array.isArray(addOns)) {
|
|
371
|
-
normalized["add_ons"] = addOns.map((addOn) =>
|
|
372
|
-
if (!isRecord(addOn)) return addOn;
|
|
373
|
-
const normalizedAddOn = { ...addOn };
|
|
374
|
-
const options = normalizedAddOn["options"];
|
|
375
|
-
if (!Array.isArray(options)) return normalizedAddOn;
|
|
376
|
-
normalizedAddOn["options"] = options.map((option) => {
|
|
377
|
-
if (!isRecord(option)) return option;
|
|
378
|
-
const normalizedOption = { ...option };
|
|
379
|
-
const optionPrice = normalizedOption["default_price"];
|
|
380
|
-
if (optionPrice === void 0 || optionPrice === null || optionPrice === "") {
|
|
381
|
-
normalizedOption["default_price"] = readFinalPrice(normalizedOption["default_price_info"]) || readFinalPrice(normalizedOption["price_info"]) || "0";
|
|
382
|
-
}
|
|
383
|
-
return normalizedOption;
|
|
384
|
-
});
|
|
385
|
-
return normalizedAddOn;
|
|
386
|
-
});
|
|
387
|
+
normalized["add_ons"] = addOns.map((addOn) => normalizeAddOnPayload(addOn));
|
|
387
388
|
}
|
|
388
389
|
return normalized;
|
|
389
390
|
}
|
|
@@ -456,16 +457,48 @@ function normalizeCatalogueResult(payload) {
|
|
|
456
457
|
pagination: normalizePagination(payload.pagination)
|
|
457
458
|
};
|
|
458
459
|
}
|
|
460
|
+
function normalizeCatalogueSnapshot(payload) {
|
|
461
|
+
if (Array.isArray(payload)) {
|
|
462
|
+
return {
|
|
463
|
+
categories: [],
|
|
464
|
+
products: payload.map((product) => normalizeCatalogueProductPayload(product)),
|
|
465
|
+
add_ons: [],
|
|
466
|
+
is_complete: true
|
|
467
|
+
};
|
|
468
|
+
}
|
|
469
|
+
if (!isRecord(payload)) {
|
|
470
|
+
return {
|
|
471
|
+
categories: [],
|
|
472
|
+
products: [],
|
|
473
|
+
add_ons: [],
|
|
474
|
+
is_complete: true
|
|
475
|
+
};
|
|
476
|
+
}
|
|
477
|
+
const rawProducts = Array.isArray(payload.products) ? payload.products : Array.isArray(payload.items) ? payload.items : [];
|
|
478
|
+
const rawCategories = Array.isArray(payload.categories) ? payload.categories : [];
|
|
479
|
+
const rawAddOns = Array.isArray(payload.add_ons) ? payload.add_ons : [];
|
|
480
|
+
return {
|
|
481
|
+
categories: rawCategories,
|
|
482
|
+
products: rawProducts.map((product) => normalizeCatalogueProductPayload(product)),
|
|
483
|
+
add_ons: rawAddOns.map((addOn) => normalizeAddOnPayload(addOn)),
|
|
484
|
+
is_complete: typeof payload.is_complete === "boolean" ? payload.is_complete : true,
|
|
485
|
+
total_available: toFiniteNumber(payload.total_available),
|
|
486
|
+
pagination: normalizePagination(payload.pagination)
|
|
487
|
+
};
|
|
488
|
+
}
|
|
459
489
|
var CatalogueQueries = class {
|
|
460
490
|
constructor(client) {
|
|
461
491
|
this.client = client;
|
|
462
492
|
}
|
|
463
|
-
async
|
|
464
|
-
const result = await
|
|
493
|
+
async getCatalogue() {
|
|
494
|
+
const result = await safeWithFallback(
|
|
495
|
+
() => this.client.get("/api/v1/catalogue"),
|
|
496
|
+
() => this.client.query("catalogue")
|
|
497
|
+
);
|
|
465
498
|
if (!result.ok) return result;
|
|
466
|
-
return ok(result.value
|
|
499
|
+
return ok(normalizeCatalogueSnapshot(result.value));
|
|
467
500
|
}
|
|
468
|
-
async
|
|
501
|
+
async getProducts(options) {
|
|
469
502
|
let query2 = "products";
|
|
470
503
|
const filters = [];
|
|
471
504
|
if (options?.category) {
|
|
@@ -848,7 +881,7 @@ var CatalogueQueries = class {
|
|
|
848
881
|
limit: options?.limit ?? 20
|
|
849
882
|
});
|
|
850
883
|
if (!result.ok) return result;
|
|
851
|
-
return ok(result.value);
|
|
884
|
+
return ok(result.value.items);
|
|
852
885
|
}
|
|
853
886
|
async searchProducts(query2, options) {
|
|
854
887
|
return this.search(query2, options);
|
package/dist/react.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { C as CimplifyClient, _ as ProcessCheckoutResult, a0 as CheckoutStatus, a1 as CheckoutStatusContext,
|
|
1
|
+
import { C as CimplifyClient, _ as ProcessCheckoutResult, a0 as CheckoutStatus, a1 as CheckoutStatusContext, bs as Location, bp as Business, aU as Order, d as QuoteBundleSelectionInput, Q as QuoteCompositeSelectionInput, P as PriceQuote, g as QuoteUiMessage, u as CimplifyElements, y as ElementsOptions, cR as AuthenticatedData, cN as AddressInfo, cO as PaymentMethodInfo, cT as ElementsCheckoutResult, Z as ProcessCheckoutOptions } from './client-CSH0xyto.mjs';
|
|
2
2
|
import React, { ReactNode } from 'react';
|
|
3
|
-
import { q as Product, h as CimplifyError, r as ProductWithDetails, K as Category, aw as BundleSelectionInput, a7 as ComponentSelectionInput, N as Collection, X as BundleWithDetails, a3 as CompositeWithDetails, a8 as CompositePriceResult, C as CurrencyCode } from './payment-CLIWNMaP.mjs';
|
|
3
|
+
import { q as Product, d as Pagination, h as CimplifyError, r as ProductWithDetails, K as Category, aw as BundleSelectionInput, a7 as ComponentSelectionInput, N as Collection, X as BundleWithDetails, a3 as CompositeWithDetails, a8 as CompositePriceResult, C as CurrencyCode } from './payment-CLIWNMaP.mjs';
|
|
4
4
|
import { A as AdSlot, a as AdPosition, e as AdContextValue } from './ads-t3FBTU8p.mjs';
|
|
5
5
|
export { c as AdConfig } from './ads-t3FBTU8p.mjs';
|
|
6
6
|
|
|
@@ -107,6 +107,9 @@ interface UseProductsOptions {
|
|
|
107
107
|
}
|
|
108
108
|
interface UseProductsResult {
|
|
109
109
|
products: Product[];
|
|
110
|
+
is_complete: boolean;
|
|
111
|
+
total_available?: number;
|
|
112
|
+
pagination?: Pagination;
|
|
110
113
|
isLoading: boolean;
|
|
111
114
|
error: CimplifyError | null;
|
|
112
115
|
refetch: () => Promise<void>;
|
package/dist/react.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { C as CimplifyClient, _ as ProcessCheckoutResult, a0 as CheckoutStatus, a1 as CheckoutStatusContext,
|
|
1
|
+
import { C as CimplifyClient, _ as ProcessCheckoutResult, a0 as CheckoutStatus, a1 as CheckoutStatusContext, bs as Location, bp as Business, aU as Order, d as QuoteBundleSelectionInput, Q as QuoteCompositeSelectionInput, P as PriceQuote, g as QuoteUiMessage, u as CimplifyElements, y as ElementsOptions, cR as AuthenticatedData, cN as AddressInfo, cO as PaymentMethodInfo, cT as ElementsCheckoutResult, Z as ProcessCheckoutOptions } from './client-C082Zp8J.js';
|
|
2
2
|
import React, { ReactNode } from 'react';
|
|
3
|
-
import { q as Product, h as CimplifyError, r as ProductWithDetails, K as Category, aw as BundleSelectionInput, a7 as ComponentSelectionInput, N as Collection, X as BundleWithDetails, a3 as CompositeWithDetails, a8 as CompositePriceResult, C as CurrencyCode } from './payment-CLIWNMaP.js';
|
|
3
|
+
import { q as Product, d as Pagination, h as CimplifyError, r as ProductWithDetails, K as Category, aw as BundleSelectionInput, a7 as ComponentSelectionInput, N as Collection, X as BundleWithDetails, a3 as CompositeWithDetails, a8 as CompositePriceResult, C as CurrencyCode } from './payment-CLIWNMaP.js';
|
|
4
4
|
import { A as AdSlot, a as AdPosition, e as AdContextValue } from './ads-t3FBTU8p.js';
|
|
5
5
|
export { c as AdConfig } from './ads-t3FBTU8p.js';
|
|
6
6
|
|
|
@@ -107,6 +107,9 @@ interface UseProductsOptions {
|
|
|
107
107
|
}
|
|
108
108
|
interface UseProductsResult {
|
|
109
109
|
products: Product[];
|
|
110
|
+
is_complete: boolean;
|
|
111
|
+
total_available?: number;
|
|
112
|
+
pagination?: Pagination;
|
|
110
113
|
isLoading: boolean;
|
|
111
114
|
error: CimplifyError | null;
|
|
112
115
|
refetch: () => Promise<void>;
|
package/dist/react.js
CHANGED
|
@@ -885,6 +885,22 @@ function readFinalPrice(value) {
|
|
|
885
885
|
}
|
|
886
886
|
return void 0;
|
|
887
887
|
}
|
|
888
|
+
function normalizeAddOnPayload(addOn) {
|
|
889
|
+
if (!isRecord(addOn)) return addOn;
|
|
890
|
+
const normalizedAddOn = { ...addOn };
|
|
891
|
+
const options = normalizedAddOn["options"];
|
|
892
|
+
if (!Array.isArray(options)) return normalizedAddOn;
|
|
893
|
+
normalizedAddOn["options"] = options.map((option) => {
|
|
894
|
+
if (!isRecord(option)) return option;
|
|
895
|
+
const normalizedOption = { ...option };
|
|
896
|
+
const optionPrice = normalizedOption["default_price"];
|
|
897
|
+
if (optionPrice === void 0 || optionPrice === null || optionPrice === "") {
|
|
898
|
+
normalizedOption["default_price"] = readFinalPrice(normalizedOption["default_price_info"]) || readFinalPrice(normalizedOption["price_info"]) || "0";
|
|
899
|
+
}
|
|
900
|
+
return normalizedOption;
|
|
901
|
+
});
|
|
902
|
+
return normalizedAddOn;
|
|
903
|
+
}
|
|
888
904
|
function normalizeCatalogueProductPayload(product) {
|
|
889
905
|
const normalized = { ...product };
|
|
890
906
|
const defaultPrice = normalized["default_price"];
|
|
@@ -906,22 +922,7 @@ function normalizeCatalogueProductPayload(product) {
|
|
|
906
922
|
}
|
|
907
923
|
const addOns = normalized["add_ons"];
|
|
908
924
|
if (Array.isArray(addOns)) {
|
|
909
|
-
normalized["add_ons"] = addOns.map((addOn) =>
|
|
910
|
-
if (!isRecord(addOn)) return addOn;
|
|
911
|
-
const normalizedAddOn = { ...addOn };
|
|
912
|
-
const options = normalizedAddOn["options"];
|
|
913
|
-
if (!Array.isArray(options)) return normalizedAddOn;
|
|
914
|
-
normalizedAddOn["options"] = options.map((option) => {
|
|
915
|
-
if (!isRecord(option)) return option;
|
|
916
|
-
const normalizedOption = { ...option };
|
|
917
|
-
const optionPrice = normalizedOption["default_price"];
|
|
918
|
-
if (optionPrice === void 0 || optionPrice === null || optionPrice === "") {
|
|
919
|
-
normalizedOption["default_price"] = readFinalPrice(normalizedOption["default_price_info"]) || readFinalPrice(normalizedOption["price_info"]) || "0";
|
|
920
|
-
}
|
|
921
|
-
return normalizedOption;
|
|
922
|
-
});
|
|
923
|
-
return normalizedAddOn;
|
|
924
|
-
});
|
|
925
|
+
normalized["add_ons"] = addOns.map((addOn) => normalizeAddOnPayload(addOn));
|
|
925
926
|
}
|
|
926
927
|
return normalized;
|
|
927
928
|
}
|
|
@@ -994,16 +995,48 @@ function normalizeCatalogueResult(payload) {
|
|
|
994
995
|
pagination: normalizePagination(payload.pagination)
|
|
995
996
|
};
|
|
996
997
|
}
|
|
998
|
+
function normalizeCatalogueSnapshot(payload) {
|
|
999
|
+
if (Array.isArray(payload)) {
|
|
1000
|
+
return {
|
|
1001
|
+
categories: [],
|
|
1002
|
+
products: payload.map((product) => normalizeCatalogueProductPayload(product)),
|
|
1003
|
+
add_ons: [],
|
|
1004
|
+
is_complete: true
|
|
1005
|
+
};
|
|
1006
|
+
}
|
|
1007
|
+
if (!isRecord(payload)) {
|
|
1008
|
+
return {
|
|
1009
|
+
categories: [],
|
|
1010
|
+
products: [],
|
|
1011
|
+
add_ons: [],
|
|
1012
|
+
is_complete: true
|
|
1013
|
+
};
|
|
1014
|
+
}
|
|
1015
|
+
const rawProducts = Array.isArray(payload.products) ? payload.products : Array.isArray(payload.items) ? payload.items : [];
|
|
1016
|
+
const rawCategories = Array.isArray(payload.categories) ? payload.categories : [];
|
|
1017
|
+
const rawAddOns = Array.isArray(payload.add_ons) ? payload.add_ons : [];
|
|
1018
|
+
return {
|
|
1019
|
+
categories: rawCategories,
|
|
1020
|
+
products: rawProducts.map((product) => normalizeCatalogueProductPayload(product)),
|
|
1021
|
+
add_ons: rawAddOns.map((addOn) => normalizeAddOnPayload(addOn)),
|
|
1022
|
+
is_complete: typeof payload.is_complete === "boolean" ? payload.is_complete : true,
|
|
1023
|
+
total_available: toFiniteNumber(payload.total_available),
|
|
1024
|
+
pagination: normalizePagination(payload.pagination)
|
|
1025
|
+
};
|
|
1026
|
+
}
|
|
997
1027
|
var CatalogueQueries = class {
|
|
998
1028
|
constructor(client) {
|
|
999
1029
|
this.client = client;
|
|
1000
1030
|
}
|
|
1001
|
-
async
|
|
1002
|
-
const result = await
|
|
1031
|
+
async getCatalogue() {
|
|
1032
|
+
const result = await safeWithFallback(
|
|
1033
|
+
() => this.client.get("/api/v1/catalogue"),
|
|
1034
|
+
() => this.client.query("catalogue")
|
|
1035
|
+
);
|
|
1003
1036
|
if (!result.ok) return result;
|
|
1004
|
-
return ok(result.value
|
|
1037
|
+
return ok(normalizeCatalogueSnapshot(result.value));
|
|
1005
1038
|
}
|
|
1006
|
-
async
|
|
1039
|
+
async getProducts(options) {
|
|
1007
1040
|
let query = "products";
|
|
1008
1041
|
const filters = [];
|
|
1009
1042
|
if (options?.category) {
|
|
@@ -1386,7 +1419,7 @@ var CatalogueQueries = class {
|
|
|
1386
1419
|
limit: options?.limit ?? 20
|
|
1387
1420
|
});
|
|
1388
1421
|
if (!result.ok) return result;
|
|
1389
|
-
return ok(result.value);
|
|
1422
|
+
return ok(result.value.items);
|
|
1390
1423
|
}
|
|
1391
1424
|
async searchProducts(query, options) {
|
|
1392
1425
|
return this.search(query, options);
|
|
@@ -4582,6 +4615,9 @@ function useProducts(options = {}) {
|
|
|
4582
4615
|
);
|
|
4583
4616
|
const cached = productsCache.get(cacheKey);
|
|
4584
4617
|
const [products, setProducts] = react.useState(cached?.products ?? []);
|
|
4618
|
+
const [isComplete, setIsComplete] = react.useState(cached?.is_complete ?? true);
|
|
4619
|
+
const [totalAvailable, setTotalAvailable] = react.useState(cached?.total_available);
|
|
4620
|
+
const [pagination, setPagination] = react.useState(cached?.pagination);
|
|
4585
4621
|
const [isLoading, setIsLoading] = react.useState(enabled && !cached);
|
|
4586
4622
|
const [error, setError] = react.useState(null);
|
|
4587
4623
|
react.useEffect(() => {
|
|
@@ -4603,6 +4639,9 @@ function useProducts(options = {}) {
|
|
|
4603
4639
|
const cacheEntry = productsCache.get(cacheKey);
|
|
4604
4640
|
if (cacheEntry) {
|
|
4605
4641
|
setProducts(cacheEntry.products);
|
|
4642
|
+
setIsComplete(cacheEntry.is_complete);
|
|
4643
|
+
setTotalAvailable(cacheEntry.total_available);
|
|
4644
|
+
setPagination(cacheEntry.pagination);
|
|
4606
4645
|
setIsLoading(false);
|
|
4607
4646
|
return;
|
|
4608
4647
|
}
|
|
@@ -4626,9 +4665,17 @@ function useProducts(options = {}) {
|
|
|
4626
4665
|
);
|
|
4627
4666
|
}
|
|
4628
4667
|
const value = await promise;
|
|
4629
|
-
productsCache.set(cacheKey, {
|
|
4668
|
+
productsCache.set(cacheKey, {
|
|
4669
|
+
products: value.items,
|
|
4670
|
+
is_complete: value.is_complete,
|
|
4671
|
+
total_available: value.total_available,
|
|
4672
|
+
pagination: value.pagination
|
|
4673
|
+
});
|
|
4630
4674
|
if (nextRequestId === requestIdRef.current) {
|
|
4631
|
-
setProducts(value);
|
|
4675
|
+
setProducts(value.items);
|
|
4676
|
+
setIsComplete(value.is_complete);
|
|
4677
|
+
setTotalAvailable(value.total_available);
|
|
4678
|
+
setPagination(value.pagination);
|
|
4632
4679
|
setError(null);
|
|
4633
4680
|
}
|
|
4634
4681
|
} catch (loadError) {
|
|
@@ -4650,7 +4697,15 @@ function useProducts(options = {}) {
|
|
|
4650
4697
|
productsCache.delete(cacheKey);
|
|
4651
4698
|
await load(true);
|
|
4652
4699
|
}, [cacheKey, load]);
|
|
4653
|
-
return {
|
|
4700
|
+
return {
|
|
4701
|
+
products,
|
|
4702
|
+
is_complete: isComplete,
|
|
4703
|
+
total_available: totalAvailable,
|
|
4704
|
+
pagination,
|
|
4705
|
+
isLoading,
|
|
4706
|
+
error,
|
|
4707
|
+
refetch
|
|
4708
|
+
};
|
|
4654
4709
|
}
|
|
4655
4710
|
var productCache = /* @__PURE__ */ new Map();
|
|
4656
4711
|
var productInflight = /* @__PURE__ */ new Map();
|
package/dist/react.mjs
CHANGED
|
@@ -883,6 +883,22 @@ function readFinalPrice(value) {
|
|
|
883
883
|
}
|
|
884
884
|
return void 0;
|
|
885
885
|
}
|
|
886
|
+
function normalizeAddOnPayload(addOn) {
|
|
887
|
+
if (!isRecord(addOn)) return addOn;
|
|
888
|
+
const normalizedAddOn = { ...addOn };
|
|
889
|
+
const options = normalizedAddOn["options"];
|
|
890
|
+
if (!Array.isArray(options)) return normalizedAddOn;
|
|
891
|
+
normalizedAddOn["options"] = options.map((option) => {
|
|
892
|
+
if (!isRecord(option)) return option;
|
|
893
|
+
const normalizedOption = { ...option };
|
|
894
|
+
const optionPrice = normalizedOption["default_price"];
|
|
895
|
+
if (optionPrice === void 0 || optionPrice === null || optionPrice === "") {
|
|
896
|
+
normalizedOption["default_price"] = readFinalPrice(normalizedOption["default_price_info"]) || readFinalPrice(normalizedOption["price_info"]) || "0";
|
|
897
|
+
}
|
|
898
|
+
return normalizedOption;
|
|
899
|
+
});
|
|
900
|
+
return normalizedAddOn;
|
|
901
|
+
}
|
|
886
902
|
function normalizeCatalogueProductPayload(product) {
|
|
887
903
|
const normalized = { ...product };
|
|
888
904
|
const defaultPrice = normalized["default_price"];
|
|
@@ -904,22 +920,7 @@ function normalizeCatalogueProductPayload(product) {
|
|
|
904
920
|
}
|
|
905
921
|
const addOns = normalized["add_ons"];
|
|
906
922
|
if (Array.isArray(addOns)) {
|
|
907
|
-
normalized["add_ons"] = addOns.map((addOn) =>
|
|
908
|
-
if (!isRecord(addOn)) return addOn;
|
|
909
|
-
const normalizedAddOn = { ...addOn };
|
|
910
|
-
const options = normalizedAddOn["options"];
|
|
911
|
-
if (!Array.isArray(options)) return normalizedAddOn;
|
|
912
|
-
normalizedAddOn["options"] = options.map((option) => {
|
|
913
|
-
if (!isRecord(option)) return option;
|
|
914
|
-
const normalizedOption = { ...option };
|
|
915
|
-
const optionPrice = normalizedOption["default_price"];
|
|
916
|
-
if (optionPrice === void 0 || optionPrice === null || optionPrice === "") {
|
|
917
|
-
normalizedOption["default_price"] = readFinalPrice(normalizedOption["default_price_info"]) || readFinalPrice(normalizedOption["price_info"]) || "0";
|
|
918
|
-
}
|
|
919
|
-
return normalizedOption;
|
|
920
|
-
});
|
|
921
|
-
return normalizedAddOn;
|
|
922
|
-
});
|
|
923
|
+
normalized["add_ons"] = addOns.map((addOn) => normalizeAddOnPayload(addOn));
|
|
923
924
|
}
|
|
924
925
|
return normalized;
|
|
925
926
|
}
|
|
@@ -992,16 +993,48 @@ function normalizeCatalogueResult(payload) {
|
|
|
992
993
|
pagination: normalizePagination(payload.pagination)
|
|
993
994
|
};
|
|
994
995
|
}
|
|
996
|
+
function normalizeCatalogueSnapshot(payload) {
|
|
997
|
+
if (Array.isArray(payload)) {
|
|
998
|
+
return {
|
|
999
|
+
categories: [],
|
|
1000
|
+
products: payload.map((product) => normalizeCatalogueProductPayload(product)),
|
|
1001
|
+
add_ons: [],
|
|
1002
|
+
is_complete: true
|
|
1003
|
+
};
|
|
1004
|
+
}
|
|
1005
|
+
if (!isRecord(payload)) {
|
|
1006
|
+
return {
|
|
1007
|
+
categories: [],
|
|
1008
|
+
products: [],
|
|
1009
|
+
add_ons: [],
|
|
1010
|
+
is_complete: true
|
|
1011
|
+
};
|
|
1012
|
+
}
|
|
1013
|
+
const rawProducts = Array.isArray(payload.products) ? payload.products : Array.isArray(payload.items) ? payload.items : [];
|
|
1014
|
+
const rawCategories = Array.isArray(payload.categories) ? payload.categories : [];
|
|
1015
|
+
const rawAddOns = Array.isArray(payload.add_ons) ? payload.add_ons : [];
|
|
1016
|
+
return {
|
|
1017
|
+
categories: rawCategories,
|
|
1018
|
+
products: rawProducts.map((product) => normalizeCatalogueProductPayload(product)),
|
|
1019
|
+
add_ons: rawAddOns.map((addOn) => normalizeAddOnPayload(addOn)),
|
|
1020
|
+
is_complete: typeof payload.is_complete === "boolean" ? payload.is_complete : true,
|
|
1021
|
+
total_available: toFiniteNumber(payload.total_available),
|
|
1022
|
+
pagination: normalizePagination(payload.pagination)
|
|
1023
|
+
};
|
|
1024
|
+
}
|
|
995
1025
|
var CatalogueQueries = class {
|
|
996
1026
|
constructor(client) {
|
|
997
1027
|
this.client = client;
|
|
998
1028
|
}
|
|
999
|
-
async
|
|
1000
|
-
const result = await
|
|
1029
|
+
async getCatalogue() {
|
|
1030
|
+
const result = await safeWithFallback(
|
|
1031
|
+
() => this.client.get("/api/v1/catalogue"),
|
|
1032
|
+
() => this.client.query("catalogue")
|
|
1033
|
+
);
|
|
1001
1034
|
if (!result.ok) return result;
|
|
1002
|
-
return ok(result.value
|
|
1035
|
+
return ok(normalizeCatalogueSnapshot(result.value));
|
|
1003
1036
|
}
|
|
1004
|
-
async
|
|
1037
|
+
async getProducts(options) {
|
|
1005
1038
|
let query = "products";
|
|
1006
1039
|
const filters = [];
|
|
1007
1040
|
if (options?.category) {
|
|
@@ -1384,7 +1417,7 @@ var CatalogueQueries = class {
|
|
|
1384
1417
|
limit: options?.limit ?? 20
|
|
1385
1418
|
});
|
|
1386
1419
|
if (!result.ok) return result;
|
|
1387
|
-
return ok(result.value);
|
|
1420
|
+
return ok(result.value.items);
|
|
1388
1421
|
}
|
|
1389
1422
|
async searchProducts(query, options) {
|
|
1390
1423
|
return this.search(query, options);
|
|
@@ -4580,6 +4613,9 @@ function useProducts(options = {}) {
|
|
|
4580
4613
|
);
|
|
4581
4614
|
const cached = productsCache.get(cacheKey);
|
|
4582
4615
|
const [products, setProducts] = useState(cached?.products ?? []);
|
|
4616
|
+
const [isComplete, setIsComplete] = useState(cached?.is_complete ?? true);
|
|
4617
|
+
const [totalAvailable, setTotalAvailable] = useState(cached?.total_available);
|
|
4618
|
+
const [pagination, setPagination] = useState(cached?.pagination);
|
|
4583
4619
|
const [isLoading, setIsLoading] = useState(enabled && !cached);
|
|
4584
4620
|
const [error, setError] = useState(null);
|
|
4585
4621
|
useEffect(() => {
|
|
@@ -4601,6 +4637,9 @@ function useProducts(options = {}) {
|
|
|
4601
4637
|
const cacheEntry = productsCache.get(cacheKey);
|
|
4602
4638
|
if (cacheEntry) {
|
|
4603
4639
|
setProducts(cacheEntry.products);
|
|
4640
|
+
setIsComplete(cacheEntry.is_complete);
|
|
4641
|
+
setTotalAvailable(cacheEntry.total_available);
|
|
4642
|
+
setPagination(cacheEntry.pagination);
|
|
4604
4643
|
setIsLoading(false);
|
|
4605
4644
|
return;
|
|
4606
4645
|
}
|
|
@@ -4624,9 +4663,17 @@ function useProducts(options = {}) {
|
|
|
4624
4663
|
);
|
|
4625
4664
|
}
|
|
4626
4665
|
const value = await promise;
|
|
4627
|
-
productsCache.set(cacheKey, {
|
|
4666
|
+
productsCache.set(cacheKey, {
|
|
4667
|
+
products: value.items,
|
|
4668
|
+
is_complete: value.is_complete,
|
|
4669
|
+
total_available: value.total_available,
|
|
4670
|
+
pagination: value.pagination
|
|
4671
|
+
});
|
|
4628
4672
|
if (nextRequestId === requestIdRef.current) {
|
|
4629
|
-
setProducts(value);
|
|
4673
|
+
setProducts(value.items);
|
|
4674
|
+
setIsComplete(value.is_complete);
|
|
4675
|
+
setTotalAvailable(value.total_available);
|
|
4676
|
+
setPagination(value.pagination);
|
|
4630
4677
|
setError(null);
|
|
4631
4678
|
}
|
|
4632
4679
|
} catch (loadError) {
|
|
@@ -4648,7 +4695,15 @@ function useProducts(options = {}) {
|
|
|
4648
4695
|
productsCache.delete(cacheKey);
|
|
4649
4696
|
await load(true);
|
|
4650
4697
|
}, [cacheKey, load]);
|
|
4651
|
-
return {
|
|
4698
|
+
return {
|
|
4699
|
+
products,
|
|
4700
|
+
is_complete: isComplete,
|
|
4701
|
+
total_available: totalAvailable,
|
|
4702
|
+
pagination,
|
|
4703
|
+
isLoading,
|
|
4704
|
+
error,
|
|
4705
|
+
refetch
|
|
4706
|
+
};
|
|
4652
4707
|
}
|
|
4653
4708
|
var productCache = /* @__PURE__ */ new Map();
|
|
4654
4709
|
var productInflight = /* @__PURE__ */ new Map();
|
package/dist/utils.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { C as CURRENCY_SYMBOLS, M as MOBILE_MONEY_PROVIDERS, s as categorizePaymentError, y as detectMobileMoneyProvider, c as formatMoney, d as formatNumberCompact, f as formatPrice, a as formatPriceAdjustment, b as formatPriceCompact, j as formatPriceWithTax, e as formatProductPrice, m as getBasePrice, k as getCurrencySymbol, o as getDiscountPercentage, l as getDisplayPrice, q as getMarkupPercentage, r as getProductCurrency, g as getTaxAmount, h as hasTaxInfo, n as isOnSale, v as isPaymentStatusFailure, w as isPaymentStatusRequiresAction, x as isPaymentStatusSuccess, i as isTaxInclusive, t as normalizePaymentResponse, u as normalizeStatusResponse, p as parsePrice } from './index-
|
|
1
|
+
export { C as CURRENCY_SYMBOLS, M as MOBILE_MONEY_PROVIDERS, s as categorizePaymentError, y as detectMobileMoneyProvider, c as formatMoney, d as formatNumberCompact, f as formatPrice, a as formatPriceAdjustment, b as formatPriceCompact, j as formatPriceWithTax, e as formatProductPrice, m as getBasePrice, k as getCurrencySymbol, o as getDiscountPercentage, l as getDisplayPrice, q as getMarkupPercentage, r as getProductCurrency, g as getTaxAmount, h as hasTaxInfo, n as isOnSale, v as isPaymentStatusFailure, w as isPaymentStatusRequiresAction, x as isPaymentStatusSuccess, i as isTaxInclusive, t as normalizePaymentResponse, u as normalizeStatusResponse, p as parsePrice } from './index-mrKi_VbR.mjs';
|
|
2
2
|
import './payment-CLIWNMaP.mjs';
|
package/dist/utils.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { C as CURRENCY_SYMBOLS, M as MOBILE_MONEY_PROVIDERS, s as categorizePaymentError, y as detectMobileMoneyProvider, c as formatMoney, d as formatNumberCompact, f as formatPrice, a as formatPriceAdjustment, b as formatPriceCompact, j as formatPriceWithTax, e as formatProductPrice, m as getBasePrice, k as getCurrencySymbol, o as getDiscountPercentage, l as getDisplayPrice, q as getMarkupPercentage, r as getProductCurrency, g as getTaxAmount, h as hasTaxInfo, n as isOnSale, v as isPaymentStatusFailure, w as isPaymentStatusRequiresAction, x as isPaymentStatusSuccess, i as isTaxInclusive, t as normalizePaymentResponse, u as normalizeStatusResponse, p as parsePrice } from './index-
|
|
1
|
+
export { C as CURRENCY_SYMBOLS, M as MOBILE_MONEY_PROVIDERS, s as categorizePaymentError, y as detectMobileMoneyProvider, c as formatMoney, d as formatNumberCompact, f as formatPrice, a as formatPriceAdjustment, b as formatPriceCompact, j as formatPriceWithTax, e as formatProductPrice, m as getBasePrice, k as getCurrencySymbol, o as getDiscountPercentage, l as getDisplayPrice, q as getMarkupPercentage, r as getProductCurrency, g as getTaxAmount, h as hasTaxInfo, n as isOnSale, v as isPaymentStatusFailure, w as isPaymentStatusRequiresAction, x as isPaymentStatusSuccess, i as isTaxInclusive, t as normalizePaymentResponse, u as normalizeStatusResponse, p as parsePrice } from './index-B_JHO-ER.js';
|
|
2
2
|
import './payment-CLIWNMaP.js';
|