feeef 0.5.32 → 0.5.34-dev
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/build/index.js +98 -44
- package/build/index.js.map +1 -1
- package/build/src/core/entities/store.d.ts +2 -0
- package/build/src/feeef/services/cart.d.ts +43 -14
- package/package.json +1 -1
package/build/index.js
CHANGED
|
@@ -379,8 +379,8 @@ var NotifiableService = class {
|
|
|
379
379
|
|
|
380
380
|
// src/feeef/services/cart.ts
|
|
381
381
|
var CartService = class extends NotifiableService {
|
|
382
|
-
items =
|
|
383
|
-
//
|
|
382
|
+
items = [];
|
|
383
|
+
// Array to support multiple items with same product but different variants
|
|
384
384
|
shippingMethod = null;
|
|
385
385
|
shippingAddress = {
|
|
386
386
|
name: null,
|
|
@@ -394,14 +394,42 @@ var CartService = class extends NotifiableService {
|
|
|
394
394
|
cachedSubtotal = null;
|
|
395
395
|
// Cache for subtotal to avoid redundant calculations
|
|
396
396
|
currentItem = null;
|
|
397
|
+
/**
|
|
398
|
+
* Generates a unique key for a cart item based on product ID, variant path, offer code, and addons
|
|
399
|
+
* @param item - The cart item to generate a key for
|
|
400
|
+
* @returns A unique string key
|
|
401
|
+
*/
|
|
402
|
+
getItemKey(item) {
|
|
403
|
+
const addonKeys = item.addons ? Object.keys(item.addons).sort().join("|") : "";
|
|
404
|
+
return `${item.product.id}:${item.variantPath || ""}:${item.offer?.code || ""}:${addonKeys}`;
|
|
405
|
+
}
|
|
406
|
+
/**
|
|
407
|
+
* Finds an item in the cart that matches the given item's key
|
|
408
|
+
* @param item - The item to find
|
|
409
|
+
* @returns The matching cart item or undefined
|
|
410
|
+
*/
|
|
411
|
+
findItem(item) {
|
|
412
|
+
const targetKey = this.getItemKey(item);
|
|
413
|
+
return this.items.find((cartItem) => this.getItemKey(cartItem) === targetKey);
|
|
414
|
+
}
|
|
415
|
+
/**
|
|
416
|
+
* Finds the index of an item in the cart that matches the given item's key
|
|
417
|
+
* @param item - The item to find
|
|
418
|
+
* @returns The index of the matching cart item or -1 if not found
|
|
419
|
+
*/
|
|
420
|
+
findItemIndex(item) {
|
|
421
|
+
const targetKey = this.getItemKey(item);
|
|
422
|
+
return this.items.findIndex((cartItem) => this.getItemKey(cartItem) === targetKey);
|
|
423
|
+
}
|
|
397
424
|
/**
|
|
398
425
|
* Sets the current item to be managed in the cart.
|
|
399
426
|
* @param item - The item to be set as current.
|
|
400
427
|
*/
|
|
401
428
|
setCurrentItem(item, notify = true) {
|
|
402
429
|
this.currentItem = item;
|
|
403
|
-
|
|
404
|
-
|
|
430
|
+
const existingItemIndex = this.findItemIndex(this.currentItem);
|
|
431
|
+
if (existingItemIndex !== -1) {
|
|
432
|
+
this.items[existingItemIndex] = this.currentItem;
|
|
405
433
|
}
|
|
406
434
|
this.cachedSubtotal = null;
|
|
407
435
|
if (notify) {
|
|
@@ -424,18 +452,19 @@ var CartService = class extends NotifiableService {
|
|
|
424
452
|
return quantity;
|
|
425
453
|
}
|
|
426
454
|
/**
|
|
427
|
-
* Update item by
|
|
428
|
-
* @param
|
|
429
|
-
* @param
|
|
455
|
+
* Update item by unique key (product ID + variant + offer + addons).
|
|
456
|
+
* @param item - The item to identify the cart item to update.
|
|
457
|
+
* @param updates - Partial item data to update.
|
|
430
458
|
*/
|
|
431
|
-
updateItem(
|
|
432
|
-
const
|
|
433
|
-
if (
|
|
434
|
-
const
|
|
459
|
+
updateItem(item, updates, notify = true) {
|
|
460
|
+
const index = this.findItemIndex(item);
|
|
461
|
+
if (index !== -1) {
|
|
462
|
+
const currentItem = this.items[index];
|
|
463
|
+
const newItem = { ...currentItem, ...updates };
|
|
435
464
|
if (newItem.offer) {
|
|
436
465
|
newItem.quantity = this.clampQuantityToOfferLimits(newItem.offer, newItem.quantity);
|
|
437
466
|
}
|
|
438
|
-
this.items
|
|
467
|
+
this.items[index] = newItem;
|
|
439
468
|
this.cachedSubtotal = null;
|
|
440
469
|
if (notify) {
|
|
441
470
|
this.notify();
|
|
@@ -444,13 +473,14 @@ var CartService = class extends NotifiableService {
|
|
|
444
473
|
}
|
|
445
474
|
/**
|
|
446
475
|
* Update current item.
|
|
447
|
-
* @param
|
|
476
|
+
* @param updates - a partial item to update.
|
|
448
477
|
*/
|
|
449
|
-
updateCurrentItem(
|
|
478
|
+
updateCurrentItem(updates, notify = true) {
|
|
450
479
|
if (!this.currentItem) return;
|
|
451
|
-
this.currentItem = { ...this.currentItem, ...
|
|
452
|
-
|
|
453
|
-
|
|
480
|
+
this.currentItem = { ...this.currentItem, ...updates };
|
|
481
|
+
const existingItemIndex = this.findItemIndex(this.currentItem);
|
|
482
|
+
if (existingItemIndex !== -1) {
|
|
483
|
+
this.items[existingItemIndex] = this.currentItem;
|
|
454
484
|
}
|
|
455
485
|
this.cachedSubtotal = null;
|
|
456
486
|
if (notify) {
|
|
@@ -492,7 +522,7 @@ var CartService = class extends NotifiableService {
|
|
|
492
522
|
* @returns True if the current item is in the cart, false otherwise.
|
|
493
523
|
*/
|
|
494
524
|
isCurrentItemInCart() {
|
|
495
|
-
return this.currentItem ? this.
|
|
525
|
+
return this.currentItem ? this.findItem(this.currentItem) !== void 0 : false;
|
|
496
526
|
}
|
|
497
527
|
/**
|
|
498
528
|
* Adds the current item to the cart if it's not already present.
|
|
@@ -507,7 +537,7 @@ var CartService = class extends NotifiableService {
|
|
|
507
537
|
*/
|
|
508
538
|
removeCurrentItemFromCart() {
|
|
509
539
|
if (this.currentItem) {
|
|
510
|
-
this.remove(this.currentItem
|
|
540
|
+
this.remove(this.currentItem);
|
|
511
541
|
}
|
|
512
542
|
}
|
|
513
543
|
/**
|
|
@@ -521,29 +551,51 @@ var CartService = class extends NotifiableService {
|
|
|
521
551
|
* @param item - The cart item to add.
|
|
522
552
|
*/
|
|
523
553
|
add(item) {
|
|
524
|
-
const existingItem = this.
|
|
554
|
+
const existingItem = this.findItem(item);
|
|
525
555
|
if (existingItem) {
|
|
526
556
|
existingItem.quantity += item.quantity;
|
|
527
557
|
} else {
|
|
528
|
-
this.items.
|
|
558
|
+
this.items.push({ ...item });
|
|
529
559
|
}
|
|
530
560
|
this.cachedSubtotal = null;
|
|
531
561
|
this.notifyIfChanged();
|
|
532
562
|
}
|
|
533
563
|
/**
|
|
534
|
-
* Checks if an item exists in the cart by product ID.
|
|
535
|
-
* @param
|
|
564
|
+
* Checks if an item exists in the cart by matching product ID, variant, offer, and addons.
|
|
565
|
+
* @param item - The item to check for.
|
|
536
566
|
* @returns True if the item exists in the cart, false otherwise.
|
|
537
567
|
*/
|
|
538
|
-
has(
|
|
539
|
-
return this.
|
|
568
|
+
has(item) {
|
|
569
|
+
return this.findItem(item) !== void 0;
|
|
570
|
+
}
|
|
571
|
+
/**
|
|
572
|
+
* Checks if any item with the given product ID exists in the cart.
|
|
573
|
+
* @param productId - The product ID to check for.
|
|
574
|
+
* @returns True if any item with the product ID exists, false otherwise.
|
|
575
|
+
*/
|
|
576
|
+
hasProduct(productId) {
|
|
577
|
+
return this.items.some((item) => item.product.id === productId);
|
|
578
|
+
}
|
|
579
|
+
/**
|
|
580
|
+
* Removes an item from the cart by matching the item's unique key.
|
|
581
|
+
* @param item - The item to remove.
|
|
582
|
+
*/
|
|
583
|
+
remove(item) {
|
|
584
|
+
const index = this.findItemIndex(item);
|
|
585
|
+
if (index !== -1) {
|
|
586
|
+
this.items.splice(index, 1);
|
|
587
|
+
this.cachedSubtotal = null;
|
|
588
|
+
this.notifyIfChanged();
|
|
589
|
+
}
|
|
540
590
|
}
|
|
541
591
|
/**
|
|
542
|
-
* Removes
|
|
543
|
-
* @param
|
|
592
|
+
* Removes all items with the given product ID from the cart.
|
|
593
|
+
* @param productId - The product ID to remove.
|
|
544
594
|
*/
|
|
545
|
-
|
|
546
|
-
|
|
595
|
+
removeByProductId(productId) {
|
|
596
|
+
const initialLength = this.items.length;
|
|
597
|
+
this.items = this.items.filter((item) => item.product.id !== productId);
|
|
598
|
+
if (this.items.length !== initialLength) {
|
|
547
599
|
this.cachedSubtotal = null;
|
|
548
600
|
this.notifyIfChanged();
|
|
549
601
|
}
|
|
@@ -552,8 +604,8 @@ var CartService = class extends NotifiableService {
|
|
|
552
604
|
* Clears all items from the cart.
|
|
553
605
|
*/
|
|
554
606
|
clear(notify = true) {
|
|
555
|
-
if (this.items.
|
|
556
|
-
this.items
|
|
607
|
+
if (this.items.length > 0) {
|
|
608
|
+
this.items = [];
|
|
557
609
|
this.cachedSubtotal = null;
|
|
558
610
|
if (notify) {
|
|
559
611
|
this.notify();
|
|
@@ -567,11 +619,11 @@ var CartService = class extends NotifiableService {
|
|
|
567
619
|
*/
|
|
568
620
|
getSubtotal(withCurrentItem = true) {
|
|
569
621
|
if (this.cachedSubtotal === null) {
|
|
570
|
-
this.cachedSubtotal =
|
|
622
|
+
this.cachedSubtotal = this.items.reduce((sum, item) => {
|
|
571
623
|
return sum + this.getItemTotal(item);
|
|
572
624
|
}, 0);
|
|
573
625
|
}
|
|
574
|
-
if (withCurrentItem && this.currentItem && !this.has(this.currentItem
|
|
626
|
+
if (withCurrentItem && this.currentItem && !this.has(this.currentItem)) {
|
|
575
627
|
return this.cachedSubtotal + this.getItemTotal(this.currentItem);
|
|
576
628
|
}
|
|
577
629
|
return this.cachedSubtotal;
|
|
@@ -627,17 +679,17 @@ var CartService = class extends NotifiableService {
|
|
|
627
679
|
}
|
|
628
680
|
/**
|
|
629
681
|
* Updates the offer for a specific cart item
|
|
630
|
-
* @param
|
|
682
|
+
* @param item - The item to update
|
|
631
683
|
* @param offer - The offer to apply, or undefined to remove the offer
|
|
632
684
|
*/
|
|
633
|
-
updateItemOffer(
|
|
634
|
-
const
|
|
635
|
-
if (!
|
|
636
|
-
const updatedItem = { ...
|
|
685
|
+
updateItemOffer(item, offer) {
|
|
686
|
+
const existingItem = this.findItem(item);
|
|
687
|
+
if (!existingItem) return;
|
|
688
|
+
const updatedItem = { ...existingItem, offer };
|
|
637
689
|
if (offer) {
|
|
638
|
-
updatedItem.quantity = this.clampQuantityToOfferLimits(offer,
|
|
690
|
+
updatedItem.quantity = this.clampQuantityToOfferLimits(offer, existingItem.quantity);
|
|
639
691
|
}
|
|
640
|
-
this.updateItem(
|
|
692
|
+
this.updateItem(item, updatedItem);
|
|
641
693
|
this.cachedSubtotal = null;
|
|
642
694
|
this.notifyIfChanged();
|
|
643
695
|
}
|
|
@@ -747,7 +799,7 @@ var CartService = class extends NotifiableService {
|
|
|
747
799
|
* @returns The shipping price or 0 if not applicable.
|
|
748
800
|
*/
|
|
749
801
|
getShippingPrice() {
|
|
750
|
-
for (const item of this.items
|
|
802
|
+
for (const item of this.items) {
|
|
751
803
|
if (item.offer?.freeShipping) return 0;
|
|
752
804
|
}
|
|
753
805
|
if (!this.shippingMethod) return 0;
|
|
@@ -804,14 +856,14 @@ var CartService = class extends NotifiableService {
|
|
|
804
856
|
* @returns An array of cart items.
|
|
805
857
|
*/
|
|
806
858
|
getAll() {
|
|
807
|
-
return
|
|
859
|
+
return [...this.items];
|
|
808
860
|
}
|
|
809
861
|
/**
|
|
810
862
|
* Checks if the cart is empty.
|
|
811
863
|
* @returns True if the cart is empty, otherwise false.
|
|
812
864
|
*/
|
|
813
865
|
isEmpty() {
|
|
814
|
-
return this.items.
|
|
866
|
+
return this.items.length === 0;
|
|
815
867
|
}
|
|
816
868
|
/**
|
|
817
869
|
* Notifies listeners if the cart state has meaningfully changed.
|
|
@@ -897,7 +949,9 @@ var generatePublicStoreIntegrationMetaPixel = (metaPixel) => {
|
|
|
897
949
|
pixels: metaPixel.pixels.map((pixel) => ({
|
|
898
950
|
id: pixel.id
|
|
899
951
|
})),
|
|
900
|
-
active: metaPixel.active
|
|
952
|
+
active: metaPixel.active,
|
|
953
|
+
objective: metaPixel.objective,
|
|
954
|
+
draftObjective: metaPixel.draftObjective
|
|
901
955
|
};
|
|
902
956
|
};
|
|
903
957
|
var generatePublicStoreIntegrationTiktokPixel = (tiktokPixel) => {
|
package/build/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/feeef/feeef.ts","../src/feeef/repositories/repository.ts","../src/feeef/repositories/orders.ts","../src/feeef/repositories/products.ts","../src/feeef/repositories/stores.ts","../src/feeef/repositories/users.ts","../src/feeef/repositories/deposits.ts","../src/core/entities/order.ts","../src/core/entities/shipping_method.ts","../src/feeef/services/service.ts","../src/feeef/services/cart.ts","../src/core/entities/store.ts","../src/core/entities/product.ts","../src/core/embadded/contact.ts","../src/utils.ts"],"sourcesContent":["import axios, { AxiosInstance } from 'axios'\n// import { buildMemoryStorage, buildWebStorage, setupCache } from 'axios-cache-interceptor'\nimport { OrderRepository } from './repositories/orders.js'\nimport { ProductRepository } from './repositories/products.js'\nimport { StoreRepository } from './repositories/stores.js'\nimport { UserRepository } from './repositories/users.js'\nimport { DepositRepository } from './repositories/deposits.js'\nimport { CartService } from './services/cart.js'\n\n/**\n * Configuration options for the FeeeF module.\n */\nexport interface FeeeFConfig {\n /**\n * The API key to be used for authentication.\n */\n apiKey: string\n\n /**\n * An optional Axios instance to be used for making HTTP requests.\n */\n client?: AxiosInstance\n\n /**\n * Specifies whether caching should be enabled or disabled.\n * If set to a number, it represents the maximum number of seconds to cache the responses.\n * If set to `false`, caching will be disabled (5s).\n * cannot be less than 5 seconds\n */\n cache?: false | number\n\n /**\n * The base URL for the API.\n */\n baseURL?: string\n}\n\n/**\n * Represents the FeeeF class.\n */\nexport class FeeeF {\n /**\n * The API key used for authentication.\n */\n apiKey: string\n\n /**\n * The Axios instance used for making HTTP requests.\n */\n client: AxiosInstance\n\n /**\n * The repository for managing stores.\n */\n stores: StoreRepository\n\n /**\n * The repository for managing products.\n */\n products: ProductRepository\n\n /**\n * The repository for managing users.\n */\n users: UserRepository\n\n /**\n * The repository for managing orders.\n */\n orders: OrderRepository\n\n /**\n * The repository for managing deposits.\n */\n deposits: DepositRepository\n\n /**\n * The cart service for managing the cart.\n */\n cart: CartService\n\n /**\n * Constructs a new instance of the FeeeF class.\n * @param {FeeeFConfig} config - The configuration object.\n * @param {string} config.apiKey - The API key used for authentication.\n * @param {AxiosInstance} config.client - The Axios instance used for making HTTP requests.\n * @param {boolean | number} config.cache - The caching configuration. Set to `false` to disable caching, or provide a number to set the cache TTL in milliseconds.\n */\n //\n constructor({ apiKey, client, cache, baseURL = 'http://localhost:3333/api/v1' }: FeeeFConfig) {\n console.log('feeef super cache', cache)\n this.apiKey = apiKey\n // get th \"cache\" search param\n // const urlParams = new URLSearchParams(window.location.search)\n // const cacheParam = urlParams.get('cache')\n // if is 0 or false, disable cache\n // if (cacheParam == '0') {\n this.client = client || axios\n // } else {\n // this.client = setupCache(client || axios, {\n // ttl: cache === false ? 5 : Math.max(cache!, 5) || 1 * 60 * 1000, // 1 minute by default\n // // for persistent cache use buildWebStorage\n // storage: buildWebStorage(localStorage, 'ff:'),\n // })\n // }\n // set base url\n this.client.defaults.baseURL = baseURL\n this.stores = new StoreRepository(this.client)\n this.products = new ProductRepository(this.client)\n this.users = new UserRepository(this.client)\n this.orders = new OrderRepository(this.client)\n this.deposits = new DepositRepository(this.client)\n\n // cart\n this.cart = new CartService()\n }\n}\n","import { AxiosInstance } from 'axios'\n\n/**\n * Represents a generic model repository.\n * @template T - The type of the model.\n * @template C - The type of the create options.\n * @template U - The type of the update options.\n */\nexport abstract class ModelRepository<T, C, U> {\n resource: string\n // client\n client: AxiosInstance\n\n /**\n * Constructs a new instance of the ModelRepository class.\n * @param resource - The resource name.\n * @param client - The Axios instance used for making HTTP requests.\n */\n constructor(resource: string, client: AxiosInstance) {\n this.resource = resource\n this.client = client\n }\n\n /**\n * Finds a model by its ID or other criteria.\n * @param options - The options for finding the model.\n * @returns A promise that resolves to the found model.\n */\n async find(options: ModelFindOptions): Promise<T> {\n const { id, by, params } = options\n const res = await this.client.get(`/${this.resource}/${id}`, {\n params: {\n by: by || 'id',\n ...params,\n },\n })\n return res.data\n }\n\n /**\n * Lists models with optional pagination and filtering.\n * @param options - The options for listing the models.\n * @returns A promise that resolves to a list of models.\n */\n async list(options?: ModelListOptions): Promise<ListResponse<T>> {\n const { page, offset, limit, params } = options || {}\n const res = await this.client.get(`/${this.resource}`, {\n params: { page, offset, limit, ...params },\n })\n // if res.data is an array then create ListResponse\n if (Array.isArray(res.data)) {\n return {\n data: res.data,\n }\n } else {\n return {\n data: res.data.data,\n total: res.data.meta.total,\n page: res.data.meta.currentPage,\n limit: res.data.meta.perPage,\n }\n }\n }\n\n /**\n * Creates a new model.\n * @param options - The options for creating the model.\n * @returns A promise that resolves to the created model.\n */\n async create(options: ModelCreateOptions<C>): Promise<T> {\n const { data, params } = options\n const res = await this.client.post(`/${this.resource}`, data, { params })\n return res.data\n }\n\n /**\n * Updates an existing model.\n * @param options - The options for updating the model.\n * @returns A promise that resolves to the updated model.\n */\n async update(options: ModelUpdateOptions<U>): Promise<T> {\n const { id, data, params } = options\n const res = await this.client.put(`/${this.resource}/${id}`, data, {\n params,\n })\n return res.data\n }\n\n /**\n * Deletes a model by its ID or other criteria.\n * @param options - The options for deleting the model.\n * @returns A promise that resolves when the model is deleted.\n */\n async delete(options: ModelFindOptions): Promise<void> {\n const { id, by, params } = options\n await this.client.delete(`/${this.resource}/${id}`, {\n params: {\n by: by || 'id',\n ...params,\n },\n })\n }\n}\n\n/**\n * Represents a list response containing an array of data of type T.\n */\nexport interface ListResponse<T> {\n data: T[]\n total?: number\n page?: number\n limit?: number\n}\n\n/**\n * Represents the options for making a request.\n */\ninterface RequestOptions {\n params?: Record<string, any>\n}\n\nexport interface ModelFindOptions extends RequestOptions {\n /**\n * The ID of the model to find or the value to find by.\n */\n id: string\n /**\n * The field to find by.\n * @default \"id\" - The ID field.\n */\n by?: string\n}\n\n/**\n * Options for listing models.\n */\nexport interface ModelListOptions extends RequestOptions {\n /**\n * The page number to retrieve.\n */\n page?: number\n\n /**\n * The offset from the beginning of the list.\n */\n offset?: number\n\n /**\n * The maximum number of models to retrieve per page.\n */\n limit?: number\n}\n\n/**\n * Represents the options for creating a model.\n * @template T - The type of data being created.\n */\nexport interface ModelCreateOptions<T> extends RequestOptions {\n data: T\n}\n\n/**\n * Represents the options for updating a model.\n * @template T - The type of the data being updated.\n */\nexport interface ModelUpdateOptions<T> extends RequestOptions {\n /**\n * The ID of the model to update.\n */\n id: string\n /**\n * The data to update the model with.\n */\n data: T\n}\n","import { AxiosInstance } from 'axios'\nimport { ModelRepository } from './repository.js'\nimport { OrderEntity, OrderTrackEntity, ShippingType } from '../../core/entities/order.js'\n/**\n * Represents the options for tracking an order.\n */\nexport interface OrderModelTrackOptions {\n id: string\n params?: Record<string, any>\n}\n\nexport interface SendOrderSchema {\n id?: string // Order ID (optional)\n customerName?: string // Name of the customer (optional)\n customerNote?: string // Note from the customer (optional)\n customerPhone: string // Customer's phone number (required)\n customerEmail?: string // Customer's email address (optional)\n source?: string // the source of the order (facebook...tiktok..)\n shippingAddress?: string // Address for shipping (optional)\n shippingCity?: string // City for shipping (optional)\n shippingState?: string // State for shipping (optional)\n shippingType: ShippingType // Shipping type (required)\n shippingMethodId?: string // ID of the shipping method (optional)\n paymentMethodId?: string // ID of the payment method (optional)\n items: GuestOrderItemSchema[] // Array of order items, must have at least one item\n coupon?: string // Applied coupon code (optional)\n status: 'pending' | 'draft' // Order status (required)\n storeId: string // ID of the store (required)\n metadata?: any // Additional metadata (optional)\n}\n\n// Assuming GuestOrderItemSchema was defined elsewhere, define it here as well if needed.\nexport interface GuestOrderItemSchema {\n productId: string\n offerCode?: string\n variantPath?: string\n quantity: number\n addons?: Record<string, number>\n}\n\n/**\n * Represents a repository for managing orders.\n */\nexport class OrderRepository extends ModelRepository<OrderEntity, any, any> {\n /**\n * Constructs a new OrderRepository instance.\n * @param client - The AxiosInstance used for making HTTP requests.\n */\n constructor(client: AxiosInstance) {\n super('orders', client)\n }\n\n /**\n * Sends an order from an anonymous user.\n * @param data - The data representing the order to be sent.\n * @returns A Promise that resolves to the sent OrderEntity.\n */\n async send(data: SendOrderSchema): Promise<OrderEntity> {\n const output = data\n const res = await this.client.post(`/${this.resource}/send`, output)\n\n // Return the sent OrderEntity\n return res.data\n }\n\n /**\n * track the order by the order id\n * it will return the order status and history\n * @param options - The options for finding the model.\n * @returns A promise that resolves to the found model.\n */\n async track(options: OrderModelTrackOptions): Promise<OrderTrackEntity> {\n const { id, params } = options\n const res = await this.client.get(`/${this.resource}/${id}/track`, {\n params: {\n ...params,\n },\n })\n return res.data\n }\n}\n","import { AxiosInstance } from 'axios'\nimport { ModelRepository } from './repository.js'\nimport { ProductEntity } from '../../core/entities/product.js'\n\n/**\n * Represents a repository for managing products.\n */\nexport class ProductRepository extends ModelRepository<ProductEntity, any, any> {\n /**\n * Creates a new instance of the ProductRepository class.\n * @param client - The AxiosInstance used for making HTTP requests.\n */\n constructor(client: AxiosInstance) {\n super('products', client)\n }\n}\n","import { AxiosInstance } from 'axios'\nimport { ModelRepository, ModelCreateOptions } from './repository.js'\nimport { StoreEntity } from '../../core/entities/store.js'\n\n/**\n * Repository for managing Store entities.\n */\nexport class StoreRepository extends ModelRepository<StoreEntity, any, any> {\n /**\n * Constructs a new StoreRepository instance.\n * @param client The AxiosInstance used for making HTTP requests.\n */\n constructor(client: AxiosInstance) {\n super('stores', client)\n }\n\n /**\n * Creates a new Store entity.\n * @param options The options for creating the Store entity.\n * @returns A Promise that resolves to the created Store entity.\n */\n async create(options: ModelCreateOptions<any>): Promise<StoreEntity> {\n const output = options.data\n return super.create({ ...options, data: output })\n }\n}\n","import { AxiosInstance } from 'axios'\nimport { ModelRepository } from './repository.js'\nimport { AuthToken, UserEntity } from '../../core/entities/user.js'\n\n/**\n * Represents the response returned by the authentication process.\n */\nexport interface AuthResponse {\n token: AuthToken\n user: UserEntity\n}\n\n/**\n * Represents a repository for managing user data.\n * Extends the ModelRepository class.\n */\nexport class UserRepository extends ModelRepository<UserEntity, any, any> {\n /**\n * Represents the authentication response.\n */\n auth: AuthResponse | null = null\n\n /**\n * Constructs a new UserRepository instance.\n * @param client - The AxiosInstance used for making HTTP requests.\n */\n constructor(client: AxiosInstance) {\n super('users', client)\n }\n\n /**\n * Signs in a user with the provided credentials.\n * @param credentials - The user credentials.\n * @returns A promise that resolves to the authentication response.\n */\n async signin(credentials: any): Promise<AuthResponse> {\n // validate the input\n const output = credentials\n const res = await this.client.post(`/${this.resource}/auth/signin`, output)\n this.auth = res.data\n return res.data\n }\n\n /**\n * Signs up a new user with the provided credentials.\n * @param credentials - The user credentials.\n * @returns A promise that resolves to the authentication response.\n */\n async signup(credentials: any): Promise<AuthResponse> {\n // validate the input\n const output = credentials\n const res = await this.client.post(`/${this.resource}/auth/signup`, output)\n this.auth = res.data\n return res.data\n }\n\n /**\n * Signs out the currently authenticated user.\n * @returns A promise that resolves when the user is signed out.\n */\n async signout(): Promise<void> {\n this.auth = null\n }\n\n /**\n * Updates the authenticated user's data.\n * @param data - The updated user data.\n * @returns A promise that resolves to the updated user entity.\n */\n async updateMe(data: any): Promise<UserEntity> {\n const output = data\n const res = await this.client.put(`/${this.resource}/auth`, output)\n return res.data\n }\n}\n","import { AxiosInstance } from 'axios'\nimport { ModelRepository } from './repository.js'\n\n/**\n * Represents a deposit entity for wallet transactions\n */\nexport interface DepositEntity {\n id: string\n externalId?: string | null\n userId: string\n amount: number\n currency: string\n paymentMethod?: string | null\n attachment?: string | null\n status: 'pending' | 'completed' | 'failed' | 'cancelled'\n note?: string | null\n metadata: Record<string, any>\n history: Array<{\n status: string\n timestamp: string\n note?: string\n }>\n createdAt: any\n updatedAt: any\n}\n\n/**\n * Input data for creating a new deposit\n */\nexport interface DepositCreateInput {\n id?: string\n externalId?: string\n amount: number\n currency?: string\n paymentMethod?: string\n attachment?: string\n note?: string\n metadata?: Record<string, any>\n}\n\n/**\n * PayPal order creation response\n */\nexport interface PayPalOrderResponse {\n id: string\n status: string\n approvalUrl?: string\n links: Array<{\n href: string\n rel: string\n method: string\n }>\n}\n\n/**\n * PayPal order capture response\n */\nexport interface PayPalCaptureResponse {\n id: string\n status: string\n captureId?: string\n amount?: number\n currency?: string\n}\n\n/**\n * Repository for managing deposit data and PayPal integration\n */\nexport class DepositRepository extends ModelRepository<DepositEntity, DepositCreateInput, any> {\n /**\n * Constructs a new DepositRepository instance\n * @param client - The AxiosInstance used for making HTTP requests\n */\n constructor(client: AxiosInstance) {\n super('deposits', client)\n }\n\n /**\n * Create a new deposit request\n * @param data - The deposit data\n * @returns Promise that resolves to the created deposit\n */\n async send(data: DepositCreateInput): Promise<DepositEntity> {\n const output = data\n const res = await this.client.post(`/${this.resource}/send`, output)\n return res.data\n }\n\n /**\n * Create a PayPal order for deposit\n * @param params - PayPal order parameters\n * @returns Promise that resolves to PayPal order details\n */\n async createPayPalOrder(params: {\n amount: number\n currency?: string\n depositId?: string\n returnUrl: string\n cancelUrl: string\n }): Promise<PayPalOrderResponse> {\n const orderData = {\n amount: params.amount,\n currency: params.currency || 'USD',\n depositId: params.depositId,\n returnUrl: params.returnUrl,\n cancelUrl: params.cancelUrl,\n }\n\n const res = await this.client.post(`/${this.resource}/paypal/create-order`, orderData)\n\n // Extract approval URL from links\n const approvalLink = res.data.links?.find((link: any) => link.rel === 'approve')\n\n return {\n id: res.data.id,\n status: res.data.status,\n approvalUrl: approvalLink?.href,\n links: res.data.links || [],\n }\n }\n\n /**\n * Capture a PayPal order after user approval\n * @param orderId - PayPal order ID\n * @returns Promise that resolves to capture details\n */\n async capturePayPalOrder(orderId: string): Promise<PayPalCaptureResponse> {\n const res = await this.client.post(`/${this.resource}/paypal/capture-order`, {\n orderId,\n })\n return res.data\n }\n\n /**\n * Get PayPal order status\n * @param orderId - PayPal order ID\n * @returns Promise that resolves to order details\n */\n async getPayPalOrderStatus(orderId: string): Promise<{\n id: string\n status: string\n amount?: number\n currency?: string\n }> {\n const res = await this.client.get(`/${this.resource}/paypal/order/${orderId}`)\n return res.data\n }\n}\n","export enum OrderStatus {\n draft = 'draft',\n pending = 'pending',\n review = 'review',\n accepted = 'accepted',\n processing = 'processing',\n completed = 'completed',\n cancelled = 'cancelled',\n}\n\n// PaymentStatus\nexport enum PaymentStatus {\n unpaid = 'unpaid',\n paid = 'paid',\n received = 'received',\n}\nexport enum DeliveryStatus {\n pending = 'pending',\n delivering = 'delivering',\n delivered = 'delivered',\n returned = 'returned',\n}\n\nexport enum ShippingType {\n // delivery to customer home\n home = 'home',\n // the customer picks up the order from the local shipping center\n pickup = 'pickup',\n // the customer picks up the order from the store\n store = 'store',\n}\n\nexport interface OrderEntity {\n id: string\n customerName?: string | null\n customerPhone: string\n customerEmail?: string | null\n customerIp?: string | null\n shippingAddress?: string | null\n shippingCity?: string | null\n shippingState?: string | null\n shippingMethodId?: string | null\n shippingType: ShippingType\n paymentMethodId?: string | null\n items: OrderItem[]\n subtotal: number\n shippingPrice: number\n total: number\n discount: number\n // @Deprecated\n coupon?: string | null\n couponId?: string | null\n couponCode?: string | null\n couponDiscount?: string | null\n storeId: string\n confirmerId: string | null\n metadata: OrderMetadata\n status: OrderStatus\n paymentStatus: PaymentStatus\n deliveryStatus: DeliveryStatus\n tags: string[] | null\n createdAt: any\n updatedAt: any\n}\nexport interface OrderItem {\n productId: string\n productName: string\n productPhotoUrl?: string | null\n variantPath?: string\n sku?: string | null\n discount?: number | null\n quantity: number\n price: number\n offerCode?: string | null\n offerName?: string | null\n addons?: Record<string, number>\n}\n\n// order track entity\nexport interface OrderTrackEntity {\n id: string\n customerName?: string | null\n items: OrderItem[]\n total: number\n createdAt: any\n storeId: string\n status: OrderStatus\n history: OrderTrackHistory[]\n}\n\n// order track history\nexport interface OrderTrackHistory {\n status: OrderStatus\n deliveryStatus: string\n paymentStatus: string\n createdAt: string\n}\n\n// order metadata history\ninterface OrderMetadataHistory {\n status: OrderStatus\n deliveryStatus: string\n paymentStatus: string\n createdAt: string\n message: string\n code: string\n userId: string\n}\n\n// order metadata\ninterface OrderMetadata {\n note?: string\n history?: OrderMetadataHistory[]\n metaPixel?: any\n customOrderTagHistories?: any[]\n [key: string]: any\n}\n\n// utils\n// order entity to order track entity\nexport const convertOrderEntityToOrderTrackEntity = (order: OrderEntity): OrderTrackEntity => {\n return {\n id: order.id,\n customerName: order.customerName,\n items: order.items,\n total: order.total,\n createdAt: order.createdAt,\n storeId: order.storeId,\n status: order.status,\n history:\n order.metadata.history?.map((history) => ({\n status: history.status,\n deliveryStatus: history.deliveryStatus,\n paymentStatus: history.paymentStatus,\n createdAt: history.createdAt,\n })) || [],\n }\n}\n","import { OrderEntity } from './order.js'\n\nexport interface ShippingMethodEntity {\n id: string\n name: string\n description: string | null\n logoUrl: string | null\n ondarkLogoUrl: string | null\n price: number\n forks: number\n sourceId: string\n storeId: string\n rates: (number | null)[][] | null\n status: ShippingMethodStatus\n policy: ShippingMethodPolicy\n verifiedAt: any\n createdAt: any\n updatedAt: any\n orders: OrderEntity[]\n source: ShippingMethodEntity | null\n}\n\nexport enum ShippingMethodStatus {\n draft = 'draft',\n published = 'published',\n archived = 'archived',\n}\n\nexport enum ShippingMethodPolicy {\n private = 'private',\n public = 'public',\n}\n","export type Listener<T extends NotifiableService> = (service: T) => void\n\nexport class NotifiableService {\n // Array of listeners (functions) to notify when changes occur\n private listeners: Set<Listener<typeof this>> = new Set()\n\n /**\n * Adds a listener that gets called when `notify` is triggered.\n * @param listener - The function to be called on notification.\n * @returns The same listener for potential chaining or removal.\n */\n addListener(listener: Listener<typeof this>): Listener<typeof this> {\n this.listeners.add(listener) // Using Set for uniqueness and faster removal\n return listener\n }\n\n /**\n * Removes a previously added listener.\n * @param listener - The function to be removed from the listeners list.\n */\n removeListener(listener: Listener<typeof this>): void {\n this.listeners.delete(listener) // Set deletion is O(1) for better performance\n }\n\n /**\n * Notifies all registered listeners, passing the service instance.\n * This allows listeners to react to changes.\n */\n notify(): void {\n // Iterating over the Set of listeners and invoking each one\n this.listeners.forEach((listener) => listener(this))\n }\n\n /**\n * Clears all listeners, removing any references to them.\n */\n clearListeners(): void {\n this.listeners.clear() // Clears the Set entirely\n }\n\n /**\n * Constructor for NotifiableService, initializes listeners as an empty Set.\n * The Set ensures unique listeners and better management.\n */\n constructor() {\n // Initialization can be skipped since listeners is already initialized as an empty Set\n }\n}\n","import { ShippingType } from '../../core/entities/order.js'\nimport { ProductEntity, ProductOffer } from '../../core/entities/product.js'\nimport {\n ShippingMethodEntity,\n ShippingMethodPolicy,\n ShippingMethodStatus,\n} from '../../core/entities/shipping_method.js'\nimport { StoreEntity } from '../../core/entities/store.js'\nimport { NotifiableService } from './service.js'\n\n/**\n * Represents an item in the cart.\n */\nexport interface CartItem {\n product: ProductEntity\n offer?: ProductOffer\n quantity: number\n variantPath?: string\n addons?: Record<string, number>\n}\n\n/**\n * Cart shipping types.\n * - `pickup`: The user will pick up the order from the closest desk.\n * - `home`: The order will be delivered to the user's home.\n * - `store`: The order will be delivered to the store.\n */\n// export type CartShippingTypes = 'pickup' | 'home' | 'store'\n\n/**\n * Interface for a shipping address.\n */\nexport interface CartShippingAddress {\n name: string | null\n phone: string | null\n city: string | null\n state: string | null\n street: string | null\n country: 'dz' | string\n type: ShippingType\n}\n\n/**\n * Manages the shopping cart and its operations.\n */\nexport class CartService extends NotifiableService {\n private items: Map<string, CartItem> = new Map() // Fast lookup of cart items\n private shippingMethod: ShippingMethodEntity | null = null\n private shippingAddress: CartShippingAddress = {\n name: null,\n phone: null,\n city: null,\n state: null,\n street: null,\n country: 'dz',\n type: ShippingType.pickup,\n }\n private cachedSubtotal: number | null = null // Cache for subtotal to avoid redundant calculations\n private currentItem: CartItem | null = null\n\n /**\n * Sets the current item to be managed in the cart.\n * @param item - The item to be set as current.\n */\n setCurrentItem(item: CartItem, notify = true): void {\n this.currentItem = item\n\n if (this.has(this.currentItem.product.id)) {\n this.items.set(this.currentItem.product.id, this.currentItem)\n }\n this.cachedSubtotal = null\n if (notify) {\n this.notify()\n }\n }\n\n /**\n * Clamps the quantity to be within the offer's min/max range\n * @param offer - The offer containing quantity constraints\n * @param quantity - The quantity to clamp\n * @returns The clamped quantity value\n */\n private clampQuantityToOfferLimits(offer: ProductOffer, quantity: number): number {\n if (offer.minQuantity !== undefined) {\n quantity = Math.max(quantity, offer.minQuantity)\n }\n if (offer.maxQuantity !== undefined) {\n quantity = Math.min(quantity, offer.maxQuantity)\n }\n return quantity\n }\n\n /**\n * Update item by id.\n * @param id - The id of the item to update.\n * @param item - a partial item to update.\n */\n updateItem(id: string, item: Partial<CartItem>, notify = true): void {\n const currentItem = this.items.get(id)\n\n if (currentItem) {\n const newItem = { ...currentItem, ...item }\n // Clamp quantity if there's an offer with constraints\n if (newItem.offer) {\n newItem.quantity = this.clampQuantityToOfferLimits(newItem.offer, newItem.quantity)\n }\n\n this.items.set(id, newItem)\n this.cachedSubtotal = null\n if (notify) {\n this.notify()\n }\n }\n }\n\n /**\n * Update current item.\n * @param item - a partial item to update.\n */\n updateCurrentItem(item: Partial<CartItem>, notify = true): void {\n if (!this.currentItem) return\n\n this.currentItem = { ...this.currentItem, ...item }\n\n if (this.has(this.currentItem.product.id)) {\n this.items.set(this.currentItem.product.id, this.currentItem)\n }\n\n this.cachedSubtotal = null\n if (notify) {\n this.notify()\n }\n }\n\n /**\n * Update shipping address.\n * @param address - a partial address to update.\n */\n updateShippingAddress(address: Partial<CartShippingAddress>, notify = true): void {\n this.shippingAddress = { ...this.shippingAddress, ...address }\n this.cachedSubtotal = null\n if (notify) {\n this.notify()\n }\n }\n\n /**\n * Update shipping method.\n * @param method - a partial shipping method to update.\n */\n updateShippingMethod(method: Partial<ShippingMethodEntity>, notify = true): void {\n if (!this.shippingMethod) return\n\n this.shippingMethod = { ...this.shippingMethod, ...method }\n this.cachedSubtotal = null\n if (notify) {\n this.notify()\n }\n }\n\n /**\n * Retrieves the current item in the cart.\n * @returns The current cart item or null if not set.\n */\n getCurrentItem(): CartItem | null {\n return this.currentItem\n }\n\n /**\n * Checks if the current item is already in the cart.\n * @returns True if the current item is in the cart, false otherwise.\n */\n isCurrentItemInCart(): boolean {\n return this.currentItem ? this.items.has(this.currentItem.product.id) : false\n }\n\n /**\n * Adds the current item to the cart if it's not already present.\n */\n addCurrentItemToCart(): void {\n if (!this.currentItem || this.isCurrentItemInCart()) return\n this.add(this.currentItem)\n this.cachedSubtotal = null\n }\n\n /**\n * Removes the current item from the cart if present.\n */\n removeCurrentItemFromCart(): void {\n if (this.currentItem) {\n this.remove(this.currentItem.product.id)\n }\n }\n\n /**\n * Toggles the current item's presence in the cart (add/remove).\n */\n toggleCurrentItemInCart(): void {\n this.isCurrentItemInCart() ? this.removeCurrentItemFromCart() : this.addCurrentItemToCart()\n }\n\n /**\n * Adds an item to the cart. If the item is already present, increments its quantity.\n * @param item - The cart item to add.\n */\n add(item: CartItem): void {\n const existingItem = this.items.get(item.product.id)\n\n if (existingItem) {\n existingItem.quantity += item.quantity\n } else {\n this.items.set(item.product.id, item)\n }\n\n this.cachedSubtotal = null // Reset subtotal cache\n this.notifyIfChanged()\n }\n\n /**\n * Checks if an item exists in the cart by product ID.\n * @param itemId - The ID of the item to check.\n * @returns True if the item exists in the cart, false otherwise.\n */\n has(itemId: string): boolean {\n return this.items.has(itemId)\n }\n\n /**\n * Removes an item from the cart by product ID.\n * @param itemId - The ID of the item to remove.\n */\n remove(itemId: string): void {\n if (this.items.delete(itemId)) {\n this.cachedSubtotal = null\n this.notifyIfChanged()\n }\n }\n\n /**\n * Clears all items from the cart.\n */\n clear(notify = true): void {\n if (this.items.size > 0) {\n this.items.clear()\n this.cachedSubtotal = null\n if (notify) {\n this.notify()\n }\n }\n }\n\n /**\n * Retrieves the subtotal of the cart.\n * @param withCurrentItem - Whether to include the current item in the subtotal.\n * @returns The subtotal amount.\n */\n getSubtotal(withCurrentItem = true): number {\n if (this.cachedSubtotal === null) {\n this.cachedSubtotal = Array.from(this.items.values()).reduce((sum, item) => {\n return sum + this.getItemTotal(item)\n }, 0)\n }\n\n if (withCurrentItem && this.currentItem && !this.has(this.currentItem.product.id)) {\n return this.cachedSubtotal + this.getItemTotal(this.currentItem)\n }\n\n return this.cachedSubtotal\n }\n\n /**\n * Calculates the total price for a cart item.\n * @param item - The cart item.\n * @returns The total price for the item.\n */\n getItemTotal(item: CartItem): number {\n const { product, variantPath, quantity, offer, addons } = item\n let price = product.price\n let discount = product.discount ?? 0\n\n // Handle variant pricing if a variant path exists\n if (variantPath) {\n const parts = variantPath.split('/')\n let currentVariant = product.variant\n\n for (const part of parts) {\n if (!currentVariant) break\n const option = currentVariant.options.find((o) => o.name === part)\n if (!option) break\n price = option.price ?? price\n discount = option.discount ?? discount\n currentVariant = option.child\n }\n }\n\n // Apply offer if present\n if (offer) {\n if (offer.price !== undefined) {\n // If offer has a fixed price, use it\n price = offer.price\n discount = 0 // Reset discount since we're using a fixed price\n }\n }\n\n // Calculate base product price with quantity\n let total = (price - discount) * quantity\n\n // Add pricing for addons if present\n if (addons && product.addons) {\n for (const [addonId, addonQuantity] of Object.entries(addons)) {\n // Find the addon in the product's addons array\n const addon = product.addons.find((a) => a.title === addonId)\n if (addon && addon.price) {\n // Add the addon price * quantity to the total\n total += addon.price * addonQuantity\n }\n }\n }\n\n return total\n }\n\n /**\n * Validates if an offer can be applied to the given quantity\n * @param offer - The offer to validate\n * @param quantity - The quantity to check\n * @returns boolean indicating if the offer is valid for the quantity\n */\n isOfferValidForQuantity(offer: ProductOffer, quantity: number): boolean {\n if (offer.minQuantity && quantity < offer.minQuantity) return false\n if (offer.maxQuantity && quantity > offer.maxQuantity) return false\n return true\n }\n\n /**\n * Updates the offer for a specific cart item\n * @param itemId - The ID of the item to update\n * @param offer - The offer to apply, or undefined to remove the offer\n */\n updateItemOffer(itemId: string, offer?: ProductOffer): void {\n const item = this.items.get(itemId)\n if (!item) return\n\n const updatedItem = { ...item, offer }\n // If applying an offer, ensure quantity is within limits\n if (offer) {\n updatedItem.quantity = this.clampQuantityToOfferLimits(offer, item.quantity)\n }\n\n this.updateItem(itemId, updatedItem)\n this.cachedSubtotal = null\n this.notifyIfChanged()\n }\n\n /**\n * Updates the offer for the current item\n * @param offer - The offer to apply, or undefined to remove the offer\n */\n updateCurrentItemOffer(offer?: ProductOffer): void {\n if (!this.currentItem) return\n\n const updatedItem = { ...this.currentItem }\n updatedItem.offer = offer\n\n // If applying an offer, ensure quantity is within limits\n if (offer) {\n updatedItem.quantity = this.clampQuantityToOfferLimits(offer, this.currentItem.quantity)\n }\n\n this.updateCurrentItem(updatedItem)\n this.cachedSubtotal = null\n this.notifyIfChanged()\n }\n\n /**\n * Sets the shipping method.\n * @param method - Either a store or a shipping method.\n */\n setShippingMethod(method: ShippingMethodEntity | StoreEntity, notify = true): void {\n const store = (method as StoreEntity)?.defaultShippingRates ? (method as StoreEntity) : null\n const shippingMethod = (method as ShippingMethodEntity)?.rates\n ? (method as ShippingMethodEntity)\n : null\n\n if (store) {\n this.shippingMethod = {\n id: store.id,\n name: store.name,\n description: store.description,\n logoUrl: store.logoUrl,\n ondarkLogoUrl: store.ondarkLogoUrl,\n price: 0,\n forks: 0,\n sourceId: store.id,\n storeId: store.id,\n rates: store.defaultShippingRates,\n status: ShippingMethodStatus.published,\n policy: ShippingMethodPolicy.public,\n verifiedAt: null,\n createdAt: null,\n updatedAt: null,\n orders: [],\n source: null,\n }\n if (notify) {\n this.notify()\n }\n } else if (shippingMethod) {\n this.shippingMethod = shippingMethod\n if (notify) {\n this.notify()\n }\n } else {\n throw new Error('Invalid shipping method')\n }\n }\n\n // getAvailableShippingTypes\n /**\n * Retrieves the available shipping types for the current shipping method.\n *\n * rates is a 2D array for example `[[10, 20, 30], [5, 10, 15]]`\n * where the first array is for `home` fees and the second is for `pickup` fees, and the third is for `store` fees\n * if the fee value is 0, then it's free shipping, and if it's null, then it's not available\n *\n * @returns An array of available shipping types.\n */\n getAvailableShippingTypes(): ShippingType[] {\n if (!this.shippingMethod?.rates) return []\n\n var state = Number.parseInt(this.shippingAddress.state!)\n var stateRates = this.shippingMethod.rates[state - 1]\n\n if (!stateRates) return []\n\n var availableTypes: ShippingType[] = []\n\n if (stateRates[0] || stateRates[0] === 0) availableTypes.push(ShippingType.pickup)\n if (stateRates[1] || stateRates[1] === 0) availableTypes.push(ShippingType.home)\n if (stateRates[2] || stateRates[2] === 0) availableTypes.push(ShippingType.store)\n\n return availableTypes\n }\n\n /**\n * Retrieves the current shipping method.\n * @returns The shipping method or null.\n */\n getShippingMethod(): ShippingMethodEntity | null {\n return this.shippingMethod\n }\n\n /**\n * Sets the shipping address for the cart.\n * @param address - The shipping address.\n */\n setShippingAddress(address: CartShippingAddress, notify = true): void {\n if (\n this.shippingAddress.city !== address.city ||\n this.shippingAddress.state !== address.state ||\n this.shippingAddress.type !== address.type\n ) {\n this.shippingAddress = address\n if (notify) {\n this.notify()\n }\n }\n }\n\n /**\n * Retrieves the current shipping address.\n * @returns The shipping address.\n */\n getShippingAddress(): CartShippingAddress {\n return this.shippingAddress\n }\n\n /**\n * Calculates the shipping price based on the address and shipping method.\n * @returns The shipping price or 0 if not applicable.\n */\n getShippingPrice(): number {\n // if at least one item have freeShipping offer return 0\n for (const item of this.items.values()) {\n if (item.offer?.freeShipping) return 0\n }\n\n // if no shipping method is set, return 0\n if (!this.shippingMethod) return 0\n\n // if no shipping address is set, return the shipping method price\n if (!this.shippingAddress.state) return this.shippingMethod.price ?? 0\n\n // avalable shipping types\n const shippings = this.getAvailableShippingTypes()\n\n const currentOne = this.getShippingPriceForType(this.shippingAddress.type)\n if (currentOne) {\n return currentOne\n }\n\n for (const type of shippings) {\n if (this.getShippingPriceForType(type) !== null) {\n return this.getShippingPriceForType(type)!\n }\n }\n\n return 0\n }\n\n /**\n * Gets the shipping price for a specific shipping type using the current shipping address state.\n * @param type - The shipping type to check (pickup, home, store)\n * @returns The shipping price for the specified type, or null if not available\n */\n getShippingPriceForType(type: ShippingType): number | null {\n if (!this.shippingMethod?.rates || !this.shippingAddress.state) return null\n\n const stateIndex = Number.parseInt(this.shippingAddress.state, 10) - 1\n const rates = this.shippingMethod.rates[stateIndex]\n\n if (!rates) return null\n\n switch (type) {\n case ShippingType.pickup:\n return rates[0]\n case ShippingType.home:\n return rates[1]\n case ShippingType.store:\n return rates[2]\n default:\n return null\n }\n }\n\n /**\n * Calculates the total cost of the cart including shipping.\n * @param withCurrentItem - Whether to include the current item in the total.\n * @returns The total cost.\n */\n getTotal(withCurrentItem = true): number {\n const subTotal = this.getSubtotal(withCurrentItem)\n const shippingPrice = this.getShippingPrice() ?? 0\n const selectedOffer = this.currentItem?.offer\n if (selectedOffer && selectedOffer.freeShipping) {\n return subTotal // If the current item has free shipping, return subtotal only\n }\n return subTotal + shippingPrice\n }\n\n /**\n * Retrieves all items in the cart.\n * @returns An array of cart items.\n */\n getAll(): CartItem[] {\n return Array.from(this.items.values())\n }\n\n /**\n * Checks if the cart is empty.\n * @returns True if the cart is empty, otherwise false.\n */\n isEmpty(): boolean {\n return this.items.size === 0\n }\n\n /**\n * Notifies listeners if the cart state has meaningfully changed.\n */\n private notifyIfChanged(): void {\n // This method could be enhanced to track and notify only meaningful changes\n this.notify()\n }\n}\n","import { EmbaddedAddress } from '../embadded/address.js'\nimport { EmbaddedCategory } from '../embadded/category.js'\nimport { EmbaddedContact } from '../embadded/contact.js'\nimport { OrderEntity } from './order.js'\nimport { MetaPixelEvent } from './product.js'\n// import { OrderEntity } from \"./order.js\";\n// import { ShippingMethodEntity } from \"./shipping_method.js\";\nimport { UserEntity } from './user.js'\nimport { DateTime } from 'luxon'\n\nexport interface StoreEntity {\n id: string\n slug: string\n banner: StoreBanner | null\n action: StoreAction | null\n domain: StoreDomain | null\n decoration: StoreDecoration | null\n name: string\n iconUrl: string | null\n logoUrl: string | null\n // deprecated\n ondarkLogoUrl: string | null\n userId: string\n categories: EmbaddedCategory[]\n title: string | null\n description: string | null\n addresses: EmbaddedAddress[]\n address: EmbaddedAddress | null\n metadata: Record<string, any>\n contacts: EmbaddedContact[]\n integrations?: StoreIntegrations | null\n publicIntegrations: PublicStoreIntegrations | null\n verifiedAt: any | null\n blockedAt: any | null\n createdAt: any\n updatedAt: any\n // products: ProductEntity[];\n user?: UserEntity\n // orders: OrderEntity[];\n // shippingMethods: ShippingMethodEntity[];\n defaultShippingRates: (number | null)[][] | null\n\n // subscription\n subscription?: any\n due?: number\n\n // StoreConfigs\n configs?: StoreConfigs\n\n // metaPixelIds\n metaPixelIds?: string[] | null\n\n // tiktokPixelIds\n tiktokPixelIds?: string[] | null\n\n // googleAnalyticsId\n googleAnalyticsId?: string | null\n\n // googleTagsId\n googleTagsId?: string | null\n\n // members\n members?: Record<string, StoreMember>\n}\n\n// function that generate public data from the integrations data\nexport const generatePublicStoreIntegrations = (\n integrations: StoreIntegrations | null | undefined\n): PublicStoreIntegrations | null => {\n if (!integrations) return null\n const { metaPixel, tiktokPixel, googleAnalytics, googleTags, orderdz, webhooks } = integrations\n return {\n metaPixel: generatePublicStoreIntegrationMetaPixel(metaPixel) || null,\n tiktokPixel: generatePublicStoreIntegrationTiktokPixel(tiktokPixel) || null,\n googleAnalytics: generatePublicStoreIntegrationGoogleAnalytics(googleAnalytics) || null,\n googleTags: generatePublicStoreIntegrationGoogleTags(googleTags) || null,\n googleSheet: null,\n orderdz: generatePublicStoreIntegrationOrderdz(orderdz) || null,\n webhooks: generatePublicStoreIntegrationWebhooks(webhooks) || null,\n }\n}\nexport const generatePublicStoreIntegrationMetaPixel = (\n metaPixel: MetaPixelIntegration | null | undefined\n): PublicMetaPixelIntegration | null | undefined => {\n if (!metaPixel) return null\n return {\n pixels: metaPixel.pixels.map((pixel) => ({\n id: pixel.id,\n })),\n active: metaPixel.active,\n }\n}\nexport const generatePublicStoreIntegrationTiktokPixel = (\n tiktokPixel: TiktokPixelIntegration | null | undefined\n): PublicTiktokPixelIntegration | null | undefined => {\n if (!tiktokPixel) return null\n return {\n pixels: tiktokPixel.pixels.map((pixel) => ({\n id: pixel.id,\n })),\n active: tiktokPixel.active,\n }\n}\nexport const generatePublicStoreIntegrationGoogleAnalytics = (\n googleAnalytics: GoogleAnalyticsIntegration | null | undefined\n): PublicGoogleAnalyticsIntegration | null | undefined => {\n if (!googleAnalytics) return null\n return {\n id: googleAnalytics.id,\n active: googleAnalytics.active,\n }\n}\nexport const generatePublicStoreIntegrationGoogleSheet = (\n googleSheet: GoogleSheetsIntegration | null | undefined\n): PublicGoogleSheetsIntegration | null | undefined => {\n if (!googleSheet) return null\n return null\n}\nexport const generatePublicStoreIntegrationGoogleTags = (\n googleTags: GoogleTagsIntegration | null | undefined\n): PublicGoogleTagsIntegration | null | undefined => {\n if (!googleTags) return null\n const { id, active } = googleTags\n return {\n id,\n active,\n }\n}\n\n/**\n * Generates public OrderDZ integration data from private integration data.\n * Only exposes the URL and active status, keeping the token private for security.\n */\nexport const generatePublicStoreIntegrationOrderdz = (\n orderdz: OrderdzIntegration | null | undefined\n): PublicOrderdzIntegration | null | undefined => {\n if (!orderdz) return null\n return {\n url: orderdz.url,\n active: orderdz.active,\n }\n}\n\n/**\n * Generates public webhooks integration data from private integration data.\n * Only exposes non-sensitive information, keeping secrets private for security.\n */\nexport const generatePublicStoreIntegrationWebhooks = (\n webhooks: WebhooksIntegration | null | undefined\n): PublicWebhooksIntegration | null | undefined => {\n if (!webhooks) return null\n\n const activeWebhooks = webhooks.webhooks.filter((webhook) => webhook.active)\n\n return {\n webhookCount: webhooks.webhooks.length,\n activeWebhookCount: activeWebhooks.length,\n active: webhooks.active,\n webhookUrls: activeWebhooks.map((webhook) => webhook.url),\n }\n}\n\n/**\n * Public interface for OrderDZ integration.\n * Contains only non-sensitive information that can be safely exposed to clients.\n */\nexport interface PublicOrderdzIntegration {\n url: string\n active: boolean\n}\n\n/**\n * Public interface for webhooks integration.\n * Contains only non-sensitive information that can be safely exposed to clients.\n */\nexport interface PublicWebhooksIntegration {\n /** Total number of configured webhooks */\n webhookCount: number\n /** Number of active webhooks */\n activeWebhookCount: number\n /** Whether the integration is active */\n active: boolean\n /** List of active webhook URLs (without secrets) */\n webhookUrls: string[]\n}\n\nexport interface PublicMetaPixelIntegration {\n pixels: { id: string }[]\n active: boolean\n}\nexport interface PublicTiktokPixelIntegration {\n pixels: { id: string }[]\n active: boolean\n}\nexport interface PublicGoogleAnalyticsIntegration {\n id: string\n active: boolean\n}\nexport interface PublicGoogleSheetsIntegration {\n id: string\n active: boolean\n}\nexport interface PublicGoogleTagsIntegration {\n id: string\n active: boolean\n}\n\nexport interface PublicStoreIntegrations {\n metaPixel: PublicMetaPixelIntegration | null\n tiktokPixel: PublicTiktokPixelIntegration | null\n googleAnalytics: PublicGoogleAnalyticsIntegration | null\n googleSheet: PublicGoogleSheetsIntegration | null\n googleTags: PublicGoogleTagsIntegration | null\n orderdz: PublicOrderdzIntegration | null\n webhooks: PublicWebhooksIntegration | null\n}\n\nexport enum StoreMemberRole {\n editor = 'editor',\n viewer = 'viewer',\n confermer = 'confermer',\n}\n\nexport interface StoreMember {\n name: string\n userId: string\n role: StoreMemberRole\n acceptedAt: any | null\n expiredAt: any | null\n createdAt: any\n active: boolean\n metadata: Record<string, any>\n}\n\nexport interface StoreConfigs {\n currencies: StoreCurrencyConfig[]\n defaultCurrency: number\n}\n\nexport interface StoreCurrencyConfig {\n code: string\n symbol: string\n precision: number\n rate: number\n}\n\nexport interface StoreDomain {\n name: string\n verifiedAt: any | null\n metadata: Record<string, any>\n}\nexport interface StoreBanner {\n title: string\n url?: string | null\n enabled: boolean\n metadata: Record<string, any>\n}\n\nexport interface StoreDecoration {\n // primary\n primary: number\n onPrimary?: number\n // on dark mode\n primaryDark?: number\n onPrimaryDark?: number\n // secondary\n secondary?: number\n onSecondary?: number\n // on dark mode\n secondaryDark?: number\n onSecondaryDark?: number\n\n useLogoDarkFilter?: boolean\n\n showStoreLogoInHeader?: boolean\n logoFullHeight?: boolean\n showStoreNameInHeader?: boolean\n metadata?: Record<string, any>\n [key: string]: any\n}\n\nexport interface StoreAction {\n label: string\n url: string\n type: StoreActionType\n}\n\nexport enum StoreActionType {\n link = 'link',\n whatsapp = 'whatsapp',\n telegram = 'telegram',\n phone = 'phone',\n}\nexport interface MetaPixel {\n name?: string\n id: string\n key?: string\n}\n// tiktok pixel\nexport interface TiktokPixel {\n id: string\n key?: string\n}\n// meta pixel integration\nexport interface MetaPixelIntegration {\n id: string\n pixels: MetaPixel[]\n objective?: MetaPixelEvent | null\n draftObjective?: MetaPixelEvent | null\n active: boolean\n metadata: Record<string, any>\n}\n// tiktok pixel integration\nexport interface TiktokPixelIntegration {\n id: string\n pixels: TiktokPixel[]\n active: boolean\n metadata: Record<string, any>\n}\n\nexport interface GoogleAnalyticsIntegration {\n id: string\n active: boolean\n metadata: Record<string, any>\n}\n\n// export enum GoogleSheetsColumnType {\n// string = 'string',\n// number = 'number',\n// boolean = 'boolean',\n// date = 'date',\n// }\n\nexport interface GoogleSheetsColumn<T> {\n // it can be path in json field for exmple metadata.customData\n field: keyof OrderEntity | string | 'skus' | 'quantities' | 'itemsNames'\n name: string\n enabled: boolean\n defaultValue?: T\n // type:\n}\nexport interface GoogleSheetsIntegration {\n id: string\n name: string\n active: boolean\n oauth2?: Record<string, any>\n metadata: Record<string, any>\n simple?: boolean\n columns?: GoogleSheetsColumn<any>[]\n}\nexport interface GoogleTagsIntegration {\n id: string\n active: boolean\n metadata: Record<string, any>\n}\n\n/**\n * OrderDZ integration configuration for order confirmation service.\n * This integration allows automatic order confirmation via OrderDZ API.\n */\nexport interface OrderdzIntegration {\n /** Unique identifier for this integration instance */\n id: string\n /** API endpoint URL for OrderDZ service (e.g., \"https://orderdz.com/api/v1/feeef/order\") */\n url: string\n /** Authentication token for OrderDZ API */\n token: string\n /** Whether this integration is currently active */\n active: boolean\n /** Additional metadata for the integration */\n metadata: Record<string, any>\n}\n\n/**\n * Webhook event types for order lifecycle\n */\nexport enum WebhookEvent {\n ORDER_CREATED = 'orderCreated',\n ORDER_UPDATED = 'orderUpdated',\n ORDER_DELETED = 'orderDeleted',\n}\n\n/**\n * Individual webhook configuration\n */\nexport interface WebhookConfig {\n /** Unique identifier for this webhook */\n id: string\n /** Human-readable name for this webhook */\n name: string\n /** Target URL where webhook events will be sent */\n url: string\n /** Events this webhook is subscribed to */\n events: WebhookEvent[]\n /** Optional secret key for HMAC signature verification */\n secret?: string\n /** Whether this webhook is currently active */\n active: boolean\n /** Additional HTTP headers to send with webhook requests */\n headers?: Record<string, string>\n /** Additional metadata for this webhook */\n metadata: Record<string, any>\n}\n\n/**\n * Webhooks integration configuration for real-time order notifications\n */\nexport interface WebhooksIntegration {\n /** List of configured webhooks */\n webhooks: WebhookConfig[]\n /** Whether the webhooks integration is active */\n active: boolean\n /** Additional metadata for the integration */\n metadata: Record<string, any>\n}\n\nexport interface StoreIntegrations {\n [key: string]: any\n metadata?: Record<string, any>\n\n // @Default('default') String id,\n // @Default([]) List<MetaPixel> pixels,\n // @Default(true) bool active,\n // @Default({}) Map<String, dynamic> metadata,\n metaPixel?: MetaPixelIntegration\n tiktokPixel?: TiktokPixelIntegration\n googleAnalytics?: GoogleAnalyticsIntegration\n googleSheet?: GoogleSheetsIntegration\n googleTags?: GoogleTagsIntegration\n orderdz?: OrderdzIntegration\n webhooks?: WebhooksIntegration\n\n sms?: any\n telegram?: any\n yalidine?: any\n maystroDelivery?: any\n echotrak?: any\n procolis?: any\n noest?: any\n}\n\nexport enum StoreSubscriptionStatus {\n active = 'active',\n inactive = 'inactive',\n}\n\nexport enum StoreSubscriptionType {\n free = 'free',\n premium = 'premium',\n vip = 'vip',\n custom = 'custom',\n}\n\nexport interface StoreSubscription {\n type: StoreSubscriptionType\n name: string\n status: StoreSubscriptionStatus\n startedAt: DateTime\n expiresAt: DateTime | null\n quota: number\n consumed: number\n remaining: number\n metadata: Record<string, any>\n}\n","import { EmbaddedCategory } from '../embadded/category.js'\nimport { ShippingMethodEntity } from './shipping_method.js'\nimport { GoogleSheetsColumn, StoreEntity } from './store.js'\n\nexport interface ProductEntity {\n id: string\n\n slug: string\n\n decoration: ProductDecoration | null\n\n name: string | null\n\n photoUrl: string | null\n\n media: string[]\n\n storeId: string\n\n shippingMethodId?: string | null\n\n category?: EmbaddedCategory | null\n\n title: string | null\n\n description: string | null\n\n body: string | null\n\n // sku\n sku: string | null\n\n price: number\n\n cost: number | null\n\n discount: number | null\n\n stock: number | null\n\n sold: number\n\n views: number\n\n likes: number\n\n dislikes: number\n\n variant?: ProductVariant | null\n\n offers?: ProductOffer[] | null\n\n metadata: Record<string, any>\n\n status: ProductStatus\n\n type: ProductType\n\n verifiedAt: any | null\n\n blockedAt: any | null\n\n createdAt: any\n\n updatedAt: any\n\n addons?: ProductAddon[] | null\n\n // integrations configs\n integrationsData?: IntegrationsData | null\n publicIntegrationsData?: IntegrationsData | null\n\n // relations\n store?: StoreEntity | null\n shippingMethod?: ShippingMethodEntity | null\n}\n\n// function that generate public data from the integrations data\nexport function generatePublicIntegrationsData(data: IntegrationsData | null | null): any {\n if (!data) return data\n const { metaPixelData, tiktokPixelData, googleAnalyticsData, googleTagsData } = data\n return {\n metaPixelData: generatePublicIntegrationsDataMetaPixel(metaPixelData),\n tiktokPixelData: generatePublicIntegrationsDataTiktokPixel(tiktokPixelData),\n googleAnalyticsData: generatePublicIntegrationsDataGoogleAnalytics(googleAnalyticsData),\n googleTagsData: generatePublicIntegrationsDataGoogleTag(googleTagsData),\n }\n}\n// function that generate public data from the meta pixel data\nexport function generatePublicIntegrationsDataMetaPixel(\n data: MetaPixelData | null | undefined\n): PublicMetaPixelData | null | undefined {\n if (!data) return data\n const { ids, objective, draftObjective } = data\n return {\n ids: ids,\n objective,\n draftObjective,\n }\n}\n// function that generate public data from the tiktok pixel data\nexport function generatePublicIntegrationsDataTiktokPixel(\n data: TiktokPixelData | null | undefined\n): PubllicTiktokPixelData | null | undefined {\n if (!data) return data\n // const { ids, objective, draftObjective } = data\n return {}\n}\n// function that generate public data from the google analytics data\nexport function generatePublicIntegrationsDataGoogleAnalytics(\n data: GoogleAnalyticsData | null | undefined\n): PublicGoogleAnalyticsData | null | undefined {\n if (!data) return data\n return {}\n}\n// function that generate public data from the google tag data\nexport function generatePublicIntegrationsDataGoogleTag(\n data: GoogleTagData | null | undefined\n): PublicGoogleTagData | null | undefined {\n if (!data) return data\n return {}\n}\n// function that generate public data from the google sheets data\nexport function generatePublicIntegrationsDataGoogleSheets(\n data: GoogleSheetsData | null | undefined\n): PublicGoogleSheetsData | null | undefined {\n if (!data) return data\n return {}\n}\n\nexport interface IntegrationsData {\n metaPixelData?: MetaPixelData | null\n tiktokPixelData?: TiktokPixelData | null\n googleAnalyticsData?: GoogleAnalyticsData | null\n googleTagsData?: GoogleTagData | null\n googleSheetsData?: GoogleSheetsData | null\n}\n\nexport enum MetaPixelEvent {\n none = 'none',\n lead = 'Lead',\n purchase = 'Purchase',\n viewContent = 'ViewContent',\n addToCart = 'AddToCart',\n initiateCheckout = 'InitiateCheckout',\n}\nexport interface MetaPixelData {\n // active meta pixel ids\n ids: string[] | null\n // main objective\n objective: MetaPixelEvent | null\n // draft objective\n draftObjective: MetaPixelEvent | null\n}\n\nexport enum TiktokPixelEvent {}\nexport interface TiktokPixelData {\n // active tiktok pixel ids\n ids: string[] | null\n // main objective\n objective: TiktokPixelEvent | null\n // draft objective\n draftObjective: TiktokPixelEvent | null\n}\nexport interface GoogleAnalyticsData {}\nexport interface GoogleTagData {}\nexport interface GoogleSheetsData {\n enabled: boolean\n // use cant use both sheetId and sheetName\n sheetId: string | null\n // if sheetId is null, use sheetName\n // if sheetName not exists in the spreadsheet, create it\n sheetName: string | null\n spreadsheetId: string | null\n // the next row to insert data\n nextRow: number | null\n // columns to insert data\n columns: GoogleSheetsColumn<any>[] | null\n}\n\n// public meta pixel data\nexport interface PublicMetaPixelData {\n ids: string[] | null\n objective: MetaPixelEvent | null\n draftObjective: MetaPixelEvent | null\n}\n// public tiktok pixel data\nexport interface PubllicTiktokPixelData {}\n// public google analytics data\nexport interface PublicGoogleAnalyticsData {}\n// public google tag data\nexport interface PublicGoogleTagData {}\n// public google sheets data\nexport interface PublicGoogleSheetsData {}\n\nexport interface ProductAddon {\n photoUrl?: string\n title: string\n subtitle?: string\n stock?: number\n price?: number\n min?: number\n max?: number\n}\n\nexport enum ProductStatus {\n draft = 'draft',\n published = 'published',\n archived = 'archived',\n deleted = 'deleted',\n}\n\nexport interface ProductDecoration {\n metadata: Record<string, any>\n}\n\nexport interface ProductVariant {\n name: string\n view?: ProductVariantView\n options: ProductVariantOption[]\n required?: boolean\n}\n\nexport enum ProductVariantView {\n list = 'list',\n chips = 'chips',\n dropdown = 'dropdown',\n}\n\nexport interface ProductVariantOption {\n name: string\n sku?: string | null\n price?: number | null\n discount?: number | null\n stock?: number | null\n sold?: number | null\n type?: VariantOptionType\n child?: ProductVariant | null\n mediaIndex?: number | null\n hint?: string | null\n value?: any\n mediaId?: string | null\n hidden?: boolean\n}\n\nexport enum VariantOptionType {\n color = 'color',\n image = 'image',\n text = 'text',\n}\n\nexport enum ProductType {\n physical = 'physical',\n digital = 'digital',\n service = 'service',\n}\n\nexport interface ProductOffer {\n code: string\n title: string\n subtitle?: string\n price?: number\n minQuantity?: number\n maxQuantity?: number\n freeShipping?: boolean\n}\n","export enum EmbaddedContactType {\n phone = 'phone',\n email = 'email',\n facebook = 'facebook',\n twitter = 'twitter',\n instagram = 'instagram',\n linkedin = 'linkedin',\n website = 'website',\n whatsapp = 'whatsapp',\n telegram = 'telegram',\n signal = 'signal',\n viber = 'viber',\n skype = 'skype',\n zoom = 'zoom',\n other = 'other',\n}\n\n// EmbaddedContactType is not enum but can only be: \"phone\" | \"email\" | \"facebook\" | \"twitter\" | \"instagram\" | \"linkedin\" | \"website\" | \"whatsapp\" | \"telegram\" | \"signal\" | \"viber\" | \"skype\" | \"zoom\" | \"other\n\nexport interface EmbaddedContact {\n type: EmbaddedContactType\n value: string\n name?: string\n metadata?: Record<string, any>\n}\n","/**\n * Converts a Dart color (0xffXXXXXX) to a CSS-compatible number (0xXXXXXXFF).\n *\n * @param dartColor - The Dart color represented as a 32-bit integer (0xffXXXXXX).\n * @returns A number representing the color in CSS format (0xXXXXXXFF).\n */\nexport const convertDartColorToCssNumber = (dartColor: number): number => {\n const alpha = (dartColor >> 24) & 0xff // Extract alpha (high 8 bits)\n const rgb = dartColor & 0xffffff // Extract RGB (low 24 bits)\n\n // Return color as 0xXXXXXXFF (CSS format: RGB + alpha)\n return (rgb << 8) | alpha\n}\n\n/**\n * Converts a CSS color (0xXXXXXXFF) to HSL format.\n *\n * @param cssColor - The CSS color represented as a 32-bit integer (0xXXXXXXFF).\n * @returns An object with HSL values {h, s, l}.\n */\nexport const cssColorToHslString = (cssColor: number): string => {\n const r = ((cssColor >> 24) & 0xff) / 255 // Extract red channel\n const g = ((cssColor >> 16) & 0xff) / 255 // Extract green channel\n const b = ((cssColor >> 8) & 0xff) / 255 // Extract blue channel\n\n const max = Math.max(r, g, b)\n const min = Math.min(r, g, b)\n let h = 0\n let s = 0\n let l = (max + min) / 2\n\n if (max !== min) {\n const d = max - min\n s = l > 0.5 ? d / (2 - max - min) : d / (max + min)\n switch (max) {\n case r:\n h = (g - b) / d + (g < b ? 6 : 0)\n break\n case g:\n h = (b - r) / d + 2\n break\n case b:\n h = (r - g) / d + 4\n break\n }\n h /= 6\n }\n\n return `${Math.round(h * 360)}, ${Math.round(s * 100)}%, ${Math.round(l * 100)}%`\n}\n\n/**\n * Trims and attempts to fix the phone number by:\n * - Removing all non-numeric characters\n * - Ensuring it starts with a '0'\n * @param phone - The input phone number string\n * @returns The cleaned phone number\n */\nexport function tryFixPhoneNumber(phone: string): string {\n phone = phone.trim() // Remove leading/trailing spaces\n // Remove all non-numeric characters\n phone = phone.replace(/\\D/g, '')\n // Ensure the phone number starts with '0'\n if (!phone.startsWith('0')) {\n phone = '0' + phone\n }\n return phone\n}\n\n/**\n * Validates the phone number based on specific rules:\n * - Cannot be empty or just \"0\"\n * - Must start with '05', '06', '07', or '02'\n * - Must be 10 digits for mobile numbers (05, 06, 07)\n * - Must be 9 digits for landline numbers (02)\n * @param phone - The input phone number string\n * @returns Error message if validation fails, otherwise null\n */\nexport function validatePhoneNumber(phone: string): string | null {\n // Helper function to handle length overflow/underflow messages\n const getLengthError = (requiredLength: number, actualLength: number): string => {\n const difference = actualLength - requiredLength\n if (difference > 0) {\n return `عدد الأرقام زائد عن ${requiredLength} رقماً بـ ${difference}`\n } else {\n const missingDigits = -difference\n if (missingDigits === 1) return 'ينقصك رقم واحد'\n if (missingDigits === 2) return 'ينقصك رقمان'\n return `ينقصك ${missingDigits} أرقام`\n }\n }\n\n if (phone === '0') {\n return 'اكمل رقم الهاتف'\n }\n\n // Check if phone number is empty\n if (!phone) {\n return 'رقم الهاتف لا يمكن أن يكون فارغاً.'\n }\n\n // Check if phone number contains only digits\n if (!/^\\d+$/.test(phone)) {\n return 'رقم الهاتف يجب أن يحتوي فقط على أرقام.'\n }\n\n // Ensure the phone starts with valid prefixes\n if (!/^(05|06|07|02)/.test(phone)) {\n return 'يجب أن يبدأ بـ 05, 06, 07, أو 02'\n }\n\n const length = phone.length\n\n // Validate mobile numbers (05, 06, 07 should be 10 digits)\n if (/^(05|06|07)/.test(phone)) {\n if (length !== 10) {\n return getLengthError(10, length)\n }\n }\n\n // Validate landline numbers (02 should be 9 digits)\n else if (phone.startsWith('02')) {\n if (length !== 9) {\n return getLengthError(9, length)\n }\n }\n\n // If all checks pass, return null (no errors)\n return null\n}\n"],"mappings":";AAAA,OAAO,WAA8B;;;ACQ9B,IAAe,kBAAf,MAAwC;AAAA,EAC7C;AAAA;AAAA,EAEA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,YAAY,UAAkB,QAAuB;AACnD,SAAK,WAAW;AAChB,SAAK,SAAS;AAAA,EAChB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,MAAM,KAAK,SAAuC;AAChD,UAAM,EAAE,IAAI,IAAI,OAAO,IAAI;AAC3B,UAAM,MAAM,MAAM,KAAK,OAAO,IAAI,IAAI,KAAK,QAAQ,IAAI,EAAE,IAAI;AAAA,MAC3D,QAAQ;AAAA,QACN,IAAI,MAAM;AAAA,QACV,GAAG;AAAA,MACL;AAAA,IACF,CAAC;AACD,WAAO,IAAI;AAAA,EACb;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,MAAM,KAAK,SAAsD;AAC/D,UAAM,EAAE,MAAM,QAAQ,OAA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B,UAAQ,MAAM,QAAQ,OAAO,EAAE;AAE/B,MAAI,CAAC,MAAM,WAAW,GAAG,GAAG;AAC1B,YAAQ,MAAM;AAAA,EAChB;AACA,SAAO;AACT;AAWO,SAAS,oBAAoB,OAA8B;AAEhE,QAAM,iBAAiB,CAAC,gBAAwB,iBAAiC;AAC/E,UAAM,aAAa,eAAe;AAClC,QAAI,aAAa,GAAG;AAClB,aAAO,uGAAuB,cAAc,gDAAa,UAAU;AAAA,IACrE,OAAO;AACL,YAAM,gBAAgB,CAAC;AACvB,UAAI,kBAAkB,EAAG,QAAO;AAChC,UAAI,kBAAkB,EAAG,QAAO;AAChC,aAAO,kCAAS,aAAa;AAAA,IAC/B;AAAA,EACF;AAEA,MAAI,UAAU,KAAK;AACjB,WAAO;AAAA,EACT;AAGA,MAAI,CAAC,OAAO;AACV,WAAO;AAAA,EACT;AAGA,MAAI,CAAC,QAAQ,KAAK,KAAK,GAAG;AACxB,WAAO;AAAA,EACT;AAGA,MAAI,CAAC,iBAAiB,KAAK,KAAK,GAAG;AACjC,WAAO;AAAA,EACT;AAEA,QAAM,SAAS,MAAM;AAGrB,MAAI,cAAc,KAAK,KAAK,GAAG;AAC7B,QAAI,WAAW,IAAI;AACjB,aAAO,eAAe,IAAI,MAAM;AAAA,IAClC;AAAA,EACF,WAGS,MAAM,WAAW,IAAI,GAAG;AAC/B,QAAI,WAAW,GAAG;AAChB,aAAO,eAAe,GAAG,MAAM;AAAA,IACjC;AAAA,EACF;AAGA,SAAO;AACT;","names":["OrderStatus","PaymentStatus","DeliveryStatus","ShippingType","ShippingMethodStatus","ShippingMethodPolicy","StoreMemberRole","StoreActionType","WebhookEvent","StoreSubscriptionStatus","StoreSubscriptionType","MetaPixelEvent","TiktokPixelEvent","ProductStatus","ProductVariantView","VariantOptionType","ProductType","EmbaddedContactType"]}
|
|
1
|
+
{"version":3,"sources":["../src/feeef/feeef.ts","../src/feeef/repositories/repository.ts","../src/feeef/repositories/orders.ts","../src/feeef/repositories/products.ts","../src/feeef/repositories/stores.ts","../src/feeef/repositories/users.ts","../src/feeef/repositories/deposits.ts","../src/core/entities/order.ts","../src/core/entities/shipping_method.ts","../src/feeef/services/service.ts","../src/feeef/services/cart.ts","../src/core/entities/store.ts","../src/core/entities/product.ts","../src/core/embadded/contact.ts","../src/utils.ts"],"sourcesContent":["import axios, { AxiosInstance } from 'axios'\n// import { buildMemoryStorage, buildWebStorage, setupCache } from 'axios-cache-interceptor'\nimport { OrderRepository } from './repositories/orders.js'\nimport { ProductRepository } from './repositories/products.js'\nimport { StoreRepository } from './repositories/stores.js'\nimport { UserRepository } from './repositories/users.js'\nimport { DepositRepository } from './repositories/deposits.js'\nimport { CartService } from './services/cart.js'\n\n/**\n * Configuration options for the FeeeF module.\n */\nexport interface FeeeFConfig {\n /**\n * The API key to be used for authentication.\n */\n apiKey: string\n\n /**\n * An optional Axios instance to be used for making HTTP requests.\n */\n client?: AxiosInstance\n\n /**\n * Specifies whether caching should be enabled or disabled.\n * If set to a number, it represents the maximum number of seconds to cache the responses.\n * If set to `false`, caching will be disabled (5s).\n * cannot be less than 5 seconds\n */\n cache?: false | number\n\n /**\n * The base URL for the API.\n */\n baseURL?: string\n}\n\n/**\n * Represents the FeeeF class.\n */\nexport class FeeeF {\n /**\n * The API key used for authentication.\n */\n apiKey: string\n\n /**\n * The Axios instance used for making HTTP requests.\n */\n client: AxiosInstance\n\n /**\n * The repository for managing stores.\n */\n stores: StoreRepository\n\n /**\n * The repository for managing products.\n */\n products: ProductRepository\n\n /**\n * The repository for managing users.\n */\n users: UserRepository\n\n /**\n * The repository for managing orders.\n */\n orders: OrderRepository\n\n /**\n * The repository for managing deposits.\n */\n deposits: DepositRepository\n\n /**\n * The cart service for managing the cart.\n */\n cart: CartService\n\n /**\n * Constructs a new instance of the FeeeF class.\n * @param {FeeeFConfig} config - The configuration object.\n * @param {string} config.apiKey - The API key used for authentication.\n * @param {AxiosInstance} config.client - The Axios instance used for making HTTP requests.\n * @param {boolean | number} config.cache - The caching configuration. Set to `false` to disable caching, or provide a number to set the cache TTL in milliseconds.\n */\n //\n constructor({ apiKey, client, cache, baseURL = 'http://localhost:3333/api/v1' }: FeeeFConfig) {\n console.log('feeef super cache', cache)\n this.apiKey = apiKey\n // get th \"cache\" search param\n // const urlParams = new URLSearchParams(window.location.search)\n // const cacheParam = urlParams.get('cache')\n // if is 0 or false, disable cache\n // if (cacheParam == '0') {\n this.client = client || axios\n // } else {\n // this.client = setupCache(client || axios, {\n // ttl: cache === false ? 5 : Math.max(cache!, 5) || 1 * 60 * 1000, // 1 minute by default\n // // for persistent cache use buildWebStorage\n // storage: buildWebStorage(localStorage, 'ff:'),\n // })\n // }\n // set base url\n this.client.defaults.baseURL = baseURL\n this.stores = new StoreRepository(this.client)\n this.products = new ProductRepository(this.client)\n this.users = new UserRepository(this.client)\n this.orders = new OrderRepository(this.client)\n this.deposits = new DepositRepository(this.client)\n\n // cart\n this.cart = new CartService()\n }\n}\n","import { AxiosInstance } from 'axios'\n\n/**\n * Represents a generic model repository.\n * @template T - The type of the model.\n * @template C - The type of the create options.\n * @template U - The type of the update options.\n */\nexport abstract class ModelRepository<T, C, U> {\n resource: string\n // client\n client: AxiosInstance\n\n /**\n * Constructs a new instance of the ModelRepository class.\n * @param resource - The resource name.\n * @param client - The Axios instance used for making HTTP requests.\n */\n constructor(resource: string, client: AxiosInstance) {\n this.resource = resource\n this.client = client\n }\n\n /**\n * Finds a model by its ID or other criteria.\n * @param options - The options for finding the model.\n * @returns A promise that resolves to the found model.\n */\n async find(options: ModelFindOptions): Promise<T> {\n const { id, by, params } = options\n const res = await this.client.get(`/${this.resource}/${id}`, {\n params: {\n by: by || 'id',\n ...params,\n },\n })\n return res.data\n }\n\n /**\n * Lists models with optional pagination and filtering.\n * @param options - The options for listing the models.\n * @returns A promise that resolves to a list of models.\n */\n async list(options?: ModelListOptions): Promise<ListResponse<T>> {\n const { page, offset, limit, params } = options || {}\n const res = await this.client.get(`/${this.resource}`, {\n params: { page, offset, limit, ...params },\n })\n // if res.data is an array then create ListResponse\n if (Array.isArray(res.data)) {\n return {\n data: res.data,\n }\n } else {\n return {\n data: res.data.data,\n total: res.data.meta.total,\n page: res.data.meta.currentPage,\n limit: res.data.meta.perPage,\n }\n }\n }\n\n /**\n * Creates a new model.\n * @param options - The options for creating the model.\n * @returns A promise that resolves to the created model.\n */\n async create(options: ModelCreateOptions<C>): Promise<T> {\n const { data, params } = options\n const res = await this.client.post(`/${this.resource}`, data, { params })\n return res.data\n }\n\n /**\n * Updates an existing model.\n * @param options - The options for updating the model.\n * @returns A promise that resolves to the updated model.\n */\n async update(options: ModelUpdateOptions<U>): Promise<T> {\n const { id, data, params } = options\n const res = await this.client.put(`/${this.resource}/${id}`, data, {\n params,\n })\n return res.data\n }\n\n /**\n * Deletes a model by its ID or other criteria.\n * @param options - The options for deleting the model.\n * @returns A promise that resolves when the model is deleted.\n */\n async delete(options: ModelFindOptions): Promise<void> {\n const { id, by, params } = options\n await this.client.delete(`/${this.resource}/${id}`, {\n params: {\n by: by || 'id',\n ...params,\n },\n })\n }\n}\n\n/**\n * Represents a list response containing an array of data of type T.\n */\nexport interface ListResponse<T> {\n data: T[]\n total?: number\n page?: number\n limit?: number\n}\n\n/**\n * Represents the options for making a request.\n */\ninterface RequestOptions {\n params?: Record<string, any>\n}\n\nexport interface ModelFindOptions extends RequestOptions {\n /**\n * The ID of the model to find or the value to find by.\n */\n id: string\n /**\n * The field to find by.\n * @default \"id\" - The ID field.\n */\n by?: string\n}\n\n/**\n * Options for listing models.\n */\nexport interface ModelListOptions extends RequestOptions {\n /**\n * The page number to retrieve.\n */\n page?: number\n\n /**\n * The offset from the beginning of the list.\n */\n offset?: number\n\n /**\n * The maximum number of models to retrieve per page.\n */\n limit?: number\n}\n\n/**\n * Represents the options for creating a model.\n * @template T - The type of data being created.\n */\nexport interface ModelCreateOptions<T> extends RequestOptions {\n data: T\n}\n\n/**\n * Represents the options for updating a model.\n * @template T - The type of the data being updated.\n */\nexport interface ModelUpdateOptions<T> extends RequestOptions {\n /**\n * The ID of the model to update.\n */\n id: string\n /**\n * The data to update the model with.\n */\n data: T\n}\n","import { AxiosInstance } from 'axios'\nimport { ModelRepository } from './repository.js'\nimport { OrderEntity, OrderTrackEntity, ShippingType } from '../../core/entities/order.js'\n/**\n * Represents the options for tracking an order.\n */\nexport interface OrderModelTrackOptions {\n id: string\n params?: Record<string, any>\n}\n\nexport interface SendOrderSchema {\n id?: string // Order ID (optional)\n customerName?: string // Name of the customer (optional)\n customerNote?: string // Note from the customer (optional)\n customerPhone: string // Customer's phone number (required)\n customerEmail?: string // Customer's email address (optional)\n source?: string // the source of the order (facebook...tiktok..)\n shippingAddress?: string // Address for shipping (optional)\n shippingCity?: string // City for shipping (optional)\n shippingState?: string // State for shipping (optional)\n shippingType: ShippingType // Shipping type (required)\n shippingMethodId?: string // ID of the shipping method (optional)\n paymentMethodId?: string // ID of the payment method (optional)\n items: GuestOrderItemSchema[] // Array of order items, must have at least one item\n coupon?: string // Applied coupon code (optional)\n status: 'pending' | 'draft' // Order status (required)\n storeId: string // ID of the store (required)\n metadata?: any // Additional metadata (optional)\n}\n\n// Assuming GuestOrderItemSchema was defined elsewhere, define it here as well if needed.\nexport interface GuestOrderItemSchema {\n productId: string\n offerCode?: string\n variantPath?: string\n quantity: number\n addons?: Record<string, number>\n}\n\n/**\n * Represents a repository for managing orders.\n */\nexport class OrderRepository extends ModelRepository<OrderEntity, any, any> {\n /**\n * Constructs a new OrderRepository instance.\n * @param client - The AxiosInstance used for making HTTP requests.\n */\n constructor(client: AxiosInstance) {\n super('orders', client)\n }\n\n /**\n * Sends an order from an anonymous user.\n * @param data - The data representing the order to be sent.\n * @returns A Promise that resolves to the sent OrderEntity.\n */\n async send(data: SendOrderSchema): Promise<OrderEntity> {\n const output = data\n const res = await this.client.post(`/${this.resource}/send`, output)\n\n // Return the sent OrderEntity\n return res.data\n }\n\n /**\n * track the order by the order id\n * it will return the order status and history\n * @param options - The options for finding the model.\n * @returns A promise that resolves to the found model.\n */\n async track(options: OrderModelTrackOptions): Promise<OrderTrackEntity> {\n const { id, params } = options\n const res = await this.client.get(`/${this.resource}/${id}/track`, {\n params: {\n ...params,\n },\n })\n return res.data\n }\n}\n","import { AxiosInstance } from 'axios'\nimport { ModelRepository } from './repository.js'\nimport { ProductEntity } from '../../core/entities/product.js'\n\n/**\n * Represents a repository for managing products.\n */\nexport class ProductRepository extends ModelRepository<ProductEntity, any, any> {\n /**\n * Creates a new instance of the ProductRepository class.\n * @param client - The AxiosInstance used for making HTTP requests.\n */\n constructor(client: AxiosInstance) {\n super('products', client)\n }\n}\n","import { AxiosInstance } from 'axios'\nimport { ModelRepository, ModelCreateOptions } from './repository.js'\nimport { StoreEntity } from '../../core/entities/store.js'\n\n/**\n * Repository for managing Store entities.\n */\nexport class StoreRepository extends ModelRepository<StoreEntity, any, any> {\n /**\n * Constructs a new StoreRepository instance.\n * @param client The AxiosInstance used for making HTTP requests.\n */\n constructor(client: AxiosInstance) {\n super('stores', client)\n }\n\n /**\n * Creates a new Store entity.\n * @param options The options for creating the Store entity.\n * @returns A Promise that resolves to the created Store entity.\n */\n async create(options: ModelCreateOptions<any>): Promise<StoreEntity> {\n const output = options.data\n return super.create({ ...options, data: output })\n }\n}\n","import { AxiosInstance } from 'axios'\nimport { ModelRepository } from './repository.js'\nimport { AuthToken, UserEntity } from '../../core/entities/user.js'\n\n/**\n * Represents the response returned by the authentication process.\n */\nexport interface AuthResponse {\n token: AuthToken\n user: UserEntity\n}\n\n/**\n * Represents a repository for managing user data.\n * Extends the ModelRepository class.\n */\nexport class UserRepository extends ModelRepository<UserEntity, any, any> {\n /**\n * Represents the authentication response.\n */\n auth: AuthResponse | null = null\n\n /**\n * Constructs a new UserRepository instance.\n * @param client - The AxiosInstance used for making HTTP requests.\n */\n constructor(client: AxiosInstance) {\n super('users', client)\n }\n\n /**\n * Signs in a user with the provided credentials.\n * @param credentials - The user credentials.\n * @returns A promise that resolves to the authentication response.\n */\n async signin(credentials: any): Promise<AuthResponse> {\n // validate the input\n const output = credentials\n const res = await this.client.post(`/${this.resource}/auth/signin`, output)\n this.auth = res.data\n return res.data\n }\n\n /**\n * Signs up a new user with the provided credentials.\n * @param credentials - The user credentials.\n * @returns A promise that resolves to the authentication response.\n */\n async signup(credentials: any): Promise<AuthResponse> {\n // validate the input\n const output = credentials\n const res = await this.client.post(`/${this.resource}/auth/signup`, output)\n this.auth = res.data\n return res.data\n }\n\n /**\n * Signs out the currently authenticated user.\n * @returns A promise that resolves when the user is signed out.\n */\n async signout(): Promise<void> {\n this.auth = null\n }\n\n /**\n * Updates the authenticated user's data.\n * @param data - The updated user data.\n * @returns A promise that resolves to the updated user entity.\n */\n async updateMe(data: any): Promise<UserEntity> {\n const output = data\n const res = await this.client.put(`/${this.resource}/auth`, output)\n return res.data\n }\n}\n","import { AxiosInstance } from 'axios'\nimport { ModelRepository } from './repository.js'\n\n/**\n * Represents a deposit entity for wallet transactions\n */\nexport interface DepositEntity {\n id: string\n externalId?: string | null\n userId: string\n amount: number\n currency: string\n paymentMethod?: string | null\n attachment?: string | null\n status: 'pending' | 'completed' | 'failed' | 'cancelled'\n note?: string | null\n metadata: Record<string, any>\n history: Array<{\n status: string\n timestamp: string\n note?: string\n }>\n createdAt: any\n updatedAt: any\n}\n\n/**\n * Input data for creating a new deposit\n */\nexport interface DepositCreateInput {\n id?: string\n externalId?: string\n amount: number\n currency?: string\n paymentMethod?: string\n attachment?: string\n note?: string\n metadata?: Record<string, any>\n}\n\n/**\n * PayPal order creation response\n */\nexport interface PayPalOrderResponse {\n id: string\n status: string\n approvalUrl?: string\n links: Array<{\n href: string\n rel: string\n method: string\n }>\n}\n\n/**\n * PayPal order capture response\n */\nexport interface PayPalCaptureResponse {\n id: string\n status: string\n captureId?: string\n amount?: number\n currency?: string\n}\n\n/**\n * Repository for managing deposit data and PayPal integration\n */\nexport class DepositRepository extends ModelRepository<DepositEntity, DepositCreateInput, any> {\n /**\n * Constructs a new DepositRepository instance\n * @param client - The AxiosInstance used for making HTTP requests\n */\n constructor(client: AxiosInstance) {\n super('deposits', client)\n }\n\n /**\n * Create a new deposit request\n * @param data - The deposit data\n * @returns Promise that resolves to the created deposit\n */\n async send(data: DepositCreateInput): Promise<DepositEntity> {\n const output = data\n const res = await this.client.post(`/${this.resource}/send`, output)\n return res.data\n }\n\n /**\n * Create a PayPal order for deposit\n * @param params - PayPal order parameters\n * @returns Promise that resolves to PayPal order details\n */\n async createPayPalOrder(params: {\n amount: number\n currency?: string\n depositId?: string\n returnUrl: string\n cancelUrl: string\n }): Promise<PayPalOrderResponse> {\n const orderData = {\n amount: params.amount,\n currency: params.currency || 'USD',\n depositId: params.depositId,\n returnUrl: params.returnUrl,\n cancelUrl: params.cancelUrl,\n }\n\n const res = await this.client.post(`/${this.resource}/paypal/create-order`, orderData)\n\n // Extract approval URL from links\n const approvalLink = res.data.links?.find((link: any) => link.rel === 'approve')\n\n return {\n id: res.data.id,\n status: res.data.status,\n approvalUrl: approvalLink?.href,\n links: res.data.links || [],\n }\n }\n\n /**\n * Capture a PayPal order after user approval\n * @param orderId - PayPal order ID\n * @returns Promise that resolves to capture details\n */\n async capturePayPalOrder(orderId: string): Promise<PayPalCaptureResponse> {\n const res = await this.client.post(`/${this.resource}/paypal/capture-order`, {\n orderId,\n })\n return res.data\n }\n\n /**\n * Get PayPal order status\n * @param orderId - PayPal order ID\n * @returns Promise that resolves to order details\n */\n async getPayPalOrderStatus(orderId: string): Promise<{\n id: string\n status: string\n amount?: number\n currency?: string\n }> {\n const res = await this.client.get(`/${this.resource}/paypal/order/${orderId}`)\n return res.data\n }\n}\n","export enum OrderStatus {\n draft = 'draft',\n pending = 'pending',\n review = 'review',\n accepted = 'accepted',\n processing = 'processing',\n completed = 'completed',\n cancelled = 'cancelled',\n}\n\n// PaymentStatus\nexport enum PaymentStatus {\n unpaid = 'unpaid',\n paid = 'paid',\n received = 'received',\n}\nexport enum DeliveryStatus {\n pending = 'pending',\n delivering = 'delivering',\n delivered = 'delivered',\n returned = 'returned',\n}\n\nexport enum ShippingType {\n // delivery to customer home\n home = 'home',\n // the customer picks up the order from the local shipping center\n pickup = 'pickup',\n // the customer picks up the order from the store\n store = 'store',\n}\n\nexport interface OrderEntity {\n id: string\n customerName?: string | null\n customerPhone: string\n customerEmail?: string | null\n customerIp?: string | null\n shippingAddress?: string | null\n shippingCity?: string | null\n shippingState?: string | null\n shippingMethodId?: string | null\n shippingType: ShippingType\n paymentMethodId?: string | null\n items: OrderItem[]\n subtotal: number\n shippingPrice: number\n total: number\n discount: number\n // @Deprecated\n coupon?: string | null\n couponId?: string | null\n couponCode?: string | null\n couponDiscount?: string | null\n storeId: string\n confirmerId: string | null\n metadata: OrderMetadata\n status: OrderStatus\n paymentStatus: PaymentStatus\n deliveryStatus: DeliveryStatus\n tags: string[] | null\n createdAt: any\n updatedAt: any\n}\nexport interface OrderItem {\n productId: string\n productName: string\n productPhotoUrl?: string | null\n variantPath?: string\n sku?: string | null\n discount?: number | null\n quantity: number\n price: number\n offerCode?: string | null\n offerName?: string | null\n addons?: Record<string, number>\n}\n\n// order track entity\nexport interface OrderTrackEntity {\n id: string\n customerName?: string | null\n items: OrderItem[]\n total: number\n createdAt: any\n storeId: string\n status: OrderStatus\n history: OrderTrackHistory[]\n}\n\n// order track history\nexport interface OrderTrackHistory {\n status: OrderStatus\n deliveryStatus: string\n paymentStatus: string\n createdAt: string\n}\n\n// order metadata history\ninterface OrderMetadataHistory {\n status: OrderStatus\n deliveryStatus: string\n paymentStatus: string\n createdAt: string\n message: string\n code: string\n userId: string\n}\n\n// order metadata\ninterface OrderMetadata {\n note?: string\n history?: OrderMetadataHistory[]\n metaPixel?: any\n customOrderTagHistories?: any[]\n [key: string]: any\n}\n\n// utils\n// order entity to order track entity\nexport const convertOrderEntityToOrderTrackEntity = (order: OrderEntity): OrderTrackEntity => {\n return {\n id: order.id,\n customerName: order.customerName,\n items: order.items,\n total: order.total,\n createdAt: order.createdAt,\n storeId: order.storeId,\n status: order.status,\n history:\n order.metadata.history?.map((history) => ({\n status: history.status,\n deliveryStatus: history.deliveryStatus,\n paymentStatus: history.paymentStatus,\n createdAt: history.createdAt,\n })) || [],\n }\n}\n","import { OrderEntity } from './order.js'\n\nexport interface ShippingMethodEntity {\n id: string\n name: string\n description: string | null\n logoUrl: string | null\n ondarkLogoUrl: string | null\n price: number\n forks: number\n sourceId: string\n storeId: string\n rates: (number | null)[][] | null\n status: ShippingMethodStatus\n policy: ShippingMethodPolicy\n verifiedAt: any\n createdAt: any\n updatedAt: any\n orders: OrderEntity[]\n source: ShippingMethodEntity | null\n}\n\nexport enum ShippingMethodStatus {\n draft = 'draft',\n published = 'published',\n archived = 'archived',\n}\n\nexport enum ShippingMethodPolicy {\n private = 'private',\n public = 'public',\n}\n","export type Listener<T extends NotifiableService> = (service: T) => void\n\nexport class NotifiableService {\n // Array of listeners (functions) to notify when changes occur\n private listeners: Set<Listener<typeof this>> = new Set()\n\n /**\n * Adds a listener that gets called when `notify` is triggered.\n * @param listener - The function to be called on notification.\n * @returns The same listener for potential chaining or removal.\n */\n addListener(listener: Listener<typeof this>): Listener<typeof this> {\n this.listeners.add(listener) // Using Set for uniqueness and faster removal\n return listener\n }\n\n /**\n * Removes a previously added listener.\n * @param listener - The function to be removed from the listeners list.\n */\n removeListener(listener: Listener<typeof this>): void {\n this.listeners.delete(listener) // Set deletion is O(1) for better performance\n }\n\n /**\n * Notifies all registered listeners, passing the service instance.\n * This allows listeners to react to changes.\n */\n notify(): void {\n // Iterating over the Set of listeners and invoking each one\n this.listeners.forEach((listener) => listener(this))\n }\n\n /**\n * Clears all listeners, removing any references to them.\n */\n clearListeners(): void {\n this.listeners.clear() // Clears the Set entirely\n }\n\n /**\n * Constructor for NotifiableService, initializes listeners as an empty Set.\n * The Set ensures unique listeners and better management.\n */\n constructor() {\n // Initialization can be skipped since listeners is already initialized as an empty Set\n }\n}\n","import { ShippingType } from '../../core/entities/order.js'\nimport { ProductEntity, ProductOffer } from '../../core/entities/product.js'\nimport {\n ShippingMethodEntity,\n ShippingMethodPolicy,\n ShippingMethodStatus,\n} from '../../core/entities/shipping_method.js'\nimport { StoreEntity } from '../../core/entities/store.js'\nimport { NotifiableService } from './service.js'\n\n/**\n * Represents an item in the cart.\n */\nexport interface CartItem {\n product: ProductEntity\n offer?: ProductOffer\n quantity: number\n variantPath?: string\n addons?: Record<string, number>\n}\n\n/**\n * Cart shipping types.\n * - `pickup`: The user will pick up the order from the closest desk.\n * - `home`: The order will be delivered to the user's home.\n * - `store`: The order will be delivered to the store.\n */\n// export type CartShippingTypes = 'pickup' | 'home' | 'store'\n\n/**\n * Interface for a shipping address.\n */\nexport interface CartShippingAddress {\n name: string | null\n phone: string | null\n city: string | null\n state: string | null\n street: string | null\n country: 'dz' | string\n type: ShippingType\n}\n\n/**\n * Manages the shopping cart and its operations.\n */\nexport class CartService extends NotifiableService {\n private items: CartItem[] = [] // Array to support multiple items with same product but different variants\n private shippingMethod: ShippingMethodEntity | null = null\n private shippingAddress: CartShippingAddress = {\n name: null,\n phone: null,\n city: null,\n state: null,\n street: null,\n country: 'dz',\n type: ShippingType.pickup,\n }\n private cachedSubtotal: number | null = null // Cache for subtotal to avoid redundant calculations\n private currentItem: CartItem | null = null\n\n /**\n * Generates a unique key for a cart item based on product ID, variant path, offer code, and addons\n * @param item - The cart item to generate a key for\n * @returns A unique string key\n */\n private getItemKey(item: CartItem): string {\n const addonKeys = item.addons ? Object.keys(item.addons).sort().join('|') : ''\n return `${item.product.id}:${item.variantPath || ''}:${item.offer?.code || ''}:${addonKeys}`\n }\n\n /**\n * Finds an item in the cart that matches the given item's key\n * @param item - The item to find\n * @returns The matching cart item or undefined\n */\n private findItem(item: CartItem): CartItem | undefined {\n const targetKey = this.getItemKey(item)\n return this.items.find((cartItem) => this.getItemKey(cartItem) === targetKey)\n }\n\n /**\n * Finds the index of an item in the cart that matches the given item's key\n * @param item - The item to find\n * @returns The index of the matching cart item or -1 if not found\n */\n private findItemIndex(item: CartItem): number {\n const targetKey = this.getItemKey(item)\n return this.items.findIndex((cartItem) => this.getItemKey(cartItem) === targetKey)\n }\n\n /**\n * Sets the current item to be managed in the cart.\n * @param item - The item to be set as current.\n */\n setCurrentItem(item: CartItem, notify = true): void {\n this.currentItem = item\n\n const existingItemIndex = this.findItemIndex(this.currentItem)\n if (existingItemIndex !== -1) {\n this.items[existingItemIndex] = this.currentItem\n }\n this.cachedSubtotal = null\n if (notify) {\n this.notify()\n }\n }\n\n /**\n * Clamps the quantity to be within the offer's min/max range\n * @param offer - The offer containing quantity constraints\n * @param quantity - The quantity to clamp\n * @returns The clamped quantity value\n */\n private clampQuantityToOfferLimits(offer: ProductOffer, quantity: number): number {\n if (offer.minQuantity !== undefined) {\n quantity = Math.max(quantity, offer.minQuantity)\n }\n if (offer.maxQuantity !== undefined) {\n quantity = Math.min(quantity, offer.maxQuantity)\n }\n return quantity\n }\n\n /**\n * Update item by unique key (product ID + variant + offer + addons).\n * @param item - The item to identify the cart item to update.\n * @param updates - Partial item data to update.\n */\n updateItem(item: CartItem, updates: Partial<CartItem>, notify = true): void {\n const index = this.findItemIndex(item)\n\n if (index !== -1) {\n const currentItem = this.items[index]\n const newItem = { ...currentItem, ...updates }\n\n // Clamp quantity if there's an offer with constraints\n if (newItem.offer) {\n newItem.quantity = this.clampQuantityToOfferLimits(newItem.offer, newItem.quantity)\n }\n\n this.items[index] = newItem\n this.cachedSubtotal = null\n if (notify) {\n this.notify()\n }\n }\n }\n\n /**\n * Update current item.\n * @param updates - a partial item to update.\n */\n updateCurrentItem(updates: Partial<CartItem>, notify = true): void {\n if (!this.currentItem) return\n\n this.currentItem = { ...this.currentItem, ...updates }\n\n const existingItemIndex = this.findItemIndex(this.currentItem)\n if (existingItemIndex !== -1) {\n this.items[existingItemIndex] = this.currentItem\n }\n\n this.cachedSubtotal = null\n if (notify) {\n this.notify()\n }\n }\n\n /**\n * Update shipping address.\n * @param address - a partial address to update.\n */\n updateShippingAddress(address: Partial<CartShippingAddress>, notify = true): void {\n this.shippingAddress = { ...this.shippingAddress, ...address }\n this.cachedSubtotal = null\n if (notify) {\n this.notify()\n }\n }\n\n /**\n * Update shipping method.\n * @param method - a partial shipping method to update.\n */\n updateShippingMethod(method: Partial<ShippingMethodEntity>, notify = true): void {\n if (!this.shippingMethod) return\n\n this.shippingMethod = { ...this.shippingMethod, ...method }\n this.cachedSubtotal = null\n if (notify) {\n this.notify()\n }\n }\n\n /**\n * Retrieves the current item in the cart.\n * @returns The current cart item or null if not set.\n */\n getCurrentItem(): CartItem | null {\n return this.currentItem\n }\n\n /**\n * Checks if the current item is already in the cart.\n * @returns True if the current item is in the cart, false otherwise.\n */\n isCurrentItemInCart(): boolean {\n return this.currentItem ? this.findItem(this.currentItem) !== undefined : false\n }\n\n /**\n * Adds the current item to the cart if it's not already present.\n */\n addCurrentItemToCart(): void {\n if (!this.currentItem || this.isCurrentItemInCart()) return\n this.add(this.currentItem)\n this.cachedSubtotal = null\n }\n\n /**\n * Removes the current item from the cart if present.\n */\n removeCurrentItemFromCart(): void {\n if (this.currentItem) {\n this.remove(this.currentItem)\n }\n }\n\n /**\n * Toggles the current item's presence in the cart (add/remove).\n */\n toggleCurrentItemInCart(): void {\n this.isCurrentItemInCart() ? this.removeCurrentItemFromCart() : this.addCurrentItemToCart()\n }\n\n /**\n * Adds an item to the cart. If the item is already present, increments its quantity.\n * @param item - The cart item to add.\n */\n add(item: CartItem): void {\n const existingItem = this.findItem(item)\n\n if (existingItem) {\n existingItem.quantity += item.quantity\n } else {\n this.items.push({ ...item })\n }\n\n this.cachedSubtotal = null // Reset subtotal cache\n this.notifyIfChanged()\n }\n\n /**\n * Checks if an item exists in the cart by matching product ID, variant, offer, and addons.\n * @param item - The item to check for.\n * @returns True if the item exists in the cart, false otherwise.\n */\n has(item: CartItem): boolean {\n return this.findItem(item) !== undefined\n }\n\n /**\n * Checks if any item with the given product ID exists in the cart.\n * @param productId - The product ID to check for.\n * @returns True if any item with the product ID exists, false otherwise.\n */\n hasProduct(productId: string): boolean {\n return this.items.some((item) => item.product.id === productId)\n }\n\n /**\n * Removes an item from the cart by matching the item's unique key.\n * @param item - The item to remove.\n */\n remove(item: CartItem): void {\n const index = this.findItemIndex(item)\n if (index !== -1) {\n this.items.splice(index, 1)\n this.cachedSubtotal = null\n this.notifyIfChanged()\n }\n }\n\n /**\n * Removes all items with the given product ID from the cart.\n * @param productId - The product ID to remove.\n */\n removeByProductId(productId: string): void {\n const initialLength = this.items.length\n this.items = this.items.filter((item) => item.product.id !== productId)\n\n if (this.items.length !== initialLength) {\n this.cachedSubtotal = null\n this.notifyIfChanged()\n }\n }\n\n /**\n * Clears all items from the cart.\n */\n clear(notify = true): void {\n if (this.items.length > 0) {\n this.items = []\n this.cachedSubtotal = null\n if (notify) {\n this.notify()\n }\n }\n }\n\n /**\n * Retrieves the subtotal of the cart.\n * @param withCurrentItem - Whether to include the current item in the subtotal.\n * @returns The subtotal amount.\n */\n getSubtotal(withCurrentItem = true): number {\n if (this.cachedSubtotal === null) {\n this.cachedSubtotal = this.items.reduce((sum, item) => {\n return sum + this.getItemTotal(item)\n }, 0)\n }\n\n if (withCurrentItem && this.currentItem && !this.has(this.currentItem)) {\n return this.cachedSubtotal + this.getItemTotal(this.currentItem)\n }\n\n return this.cachedSubtotal\n }\n\n /**\n * Calculates the total price for a cart item.\n * @param item - The cart item.\n * @returns The total price for the item.\n */\n getItemTotal(item: CartItem): number {\n const { product, variantPath, quantity, offer, addons } = item\n let price = product.price\n let discount = product.discount ?? 0\n\n // Handle variant pricing if a variant path exists\n if (variantPath) {\n const parts = variantPath.split('/')\n let currentVariant = product.variant\n\n for (const part of parts) {\n if (!currentVariant) break\n const option = currentVariant.options.find((o) => o.name === part)\n if (!option) break\n price = option.price ?? price\n discount = option.discount ?? discount\n currentVariant = option.child\n }\n }\n\n // Apply offer if present\n if (offer) {\n if (offer.price !== undefined) {\n // If offer has a fixed price, use it\n price = offer.price\n discount = 0 // Reset discount since we're using a fixed price\n }\n }\n\n // Calculate base product price with quantity\n let total = (price - discount) * quantity\n\n // Add pricing for addons if present\n if (addons && product.addons) {\n for (const [addonId, addonQuantity] of Object.entries(addons)) {\n // Find the addon in the product's addons array\n const addon = product.addons.find((a) => a.title === addonId)\n if (addon && addon.price) {\n // Add the addon price * quantity to the total\n total += addon.price * addonQuantity\n }\n }\n }\n\n return total\n }\n\n /**\n * Validates if an offer can be applied to the given quantity\n * @param offer - The offer to validate\n * @param quantity - The quantity to check\n * @returns boolean indicating if the offer is valid for the quantity\n */\n isOfferValidForQuantity(offer: ProductOffer, quantity: number): boolean {\n if (offer.minQuantity && quantity < offer.minQuantity) return false\n if (offer.maxQuantity && quantity > offer.maxQuantity) return false\n return true\n }\n\n /**\n * Updates the offer for a specific cart item\n * @param item - The item to update\n * @param offer - The offer to apply, or undefined to remove the offer\n */\n updateItemOffer(item: CartItem, offer?: ProductOffer): void {\n const existingItem = this.findItem(item)\n if (!existingItem) return\n\n const updatedItem = { ...existingItem, offer }\n // If applying an offer, ensure quantity is within limits\n if (offer) {\n updatedItem.quantity = this.clampQuantityToOfferLimits(offer, existingItem.quantity)\n }\n\n this.updateItem(item, updatedItem)\n this.cachedSubtotal = null\n this.notifyIfChanged()\n }\n\n /**\n * Updates the offer for the current item\n * @param offer - The offer to apply, or undefined to remove the offer\n */\n updateCurrentItemOffer(offer?: ProductOffer): void {\n if (!this.currentItem) return\n\n const updatedItem = { ...this.currentItem }\n updatedItem.offer = offer\n\n // If applying an offer, ensure quantity is within limits\n if (offer) {\n updatedItem.quantity = this.clampQuantityToOfferLimits(offer, this.currentItem.quantity)\n }\n\n this.updateCurrentItem(updatedItem)\n this.cachedSubtotal = null\n this.notifyIfChanged()\n }\n\n /**\n * Sets the shipping method.\n * @param method - Either a store or a shipping method.\n */\n setShippingMethod(method: ShippingMethodEntity | StoreEntity, notify = true): void {\n const store = (method as StoreEntity)?.defaultShippingRates ? (method as StoreEntity) : null\n const shippingMethod = (method as ShippingMethodEntity)?.rates\n ? (method as ShippingMethodEntity)\n : null\n\n if (store) {\n this.shippingMethod = {\n id: store.id,\n name: store.name,\n description: store.description,\n logoUrl: store.logoUrl,\n ondarkLogoUrl: store.ondarkLogoUrl,\n price: 0,\n forks: 0,\n sourceId: store.id,\n storeId: store.id,\n rates: store.defaultShippingRates,\n status: ShippingMethodStatus.published,\n policy: ShippingMethodPolicy.public,\n verifiedAt: null,\n createdAt: null,\n updatedAt: null,\n orders: [],\n source: null,\n }\n if (notify) {\n this.notify()\n }\n } else if (shippingMethod) {\n this.shippingMethod = shippingMethod\n if (notify) {\n this.notify()\n }\n } else {\n throw new Error('Invalid shipping method')\n }\n }\n\n // getAvailableShippingTypes\n /**\n * Retrieves the available shipping types for the current shipping method.\n *\n * rates is a 2D array for example `[[10, 20, 30], [5, 10, 15]]`\n * where the first array is for `home` fees and the second is for `pickup` fees, and the third is for `store` fees\n * if the fee value is 0, then it's free shipping, and if it's null, then it's not available\n *\n * @returns An array of available shipping types.\n */\n getAvailableShippingTypes(): ShippingType[] {\n if (!this.shippingMethod?.rates) return []\n\n var state = Number.parseInt(this.shippingAddress.state!)\n var stateRates = this.shippingMethod.rates[state - 1]\n\n if (!stateRates) return []\n\n var availableTypes: ShippingType[] = []\n\n if (stateRates[0] || stateRates[0] === 0) availableTypes.push(ShippingType.pickup)\n if (stateRates[1] || stateRates[1] === 0) availableTypes.push(ShippingType.home)\n if (stateRates[2] || stateRates[2] === 0) availableTypes.push(ShippingType.store)\n\n return availableTypes\n }\n\n /**\n * Retrieves the current shipping method.\n * @returns The shipping method or null.\n */\n getShippingMethod(): ShippingMethodEntity | null {\n return this.shippingMethod\n }\n\n /**\n * Sets the shipping address for the cart.\n * @param address - The shipping address.\n */\n setShippingAddress(address: CartShippingAddress, notify = true): void {\n if (\n this.shippingAddress.city !== address.city ||\n this.shippingAddress.state !== address.state ||\n this.shippingAddress.type !== address.type\n ) {\n this.shippingAddress = address\n if (notify) {\n this.notify()\n }\n }\n }\n\n /**\n * Retrieves the current shipping address.\n * @returns The shipping address.\n */\n getShippingAddress(): CartShippingAddress {\n return this.shippingAddress\n }\n\n /**\n * Calculates the shipping price based on the address and shipping method.\n * @returns The shipping price or 0 if not applicable.\n */\n getShippingPrice(): number {\n // if at least one item have freeShipping offer return 0\n for (const item of this.items) {\n if (item.offer?.freeShipping) return 0\n }\n\n // if no shipping method is set, return 0\n if (!this.shippingMethod) return 0\n\n // if no shipping address is set, return the shipping method price\n if (!this.shippingAddress.state) return this.shippingMethod.price ?? 0\n\n // avalable shipping types\n const shippings = this.getAvailableShippingTypes()\n\n const currentOne = this.getShippingPriceForType(this.shippingAddress.type)\n if (currentOne) {\n return currentOne\n }\n\n for (const type of shippings) {\n if (this.getShippingPriceForType(type) !== null) {\n return this.getShippingPriceForType(type)!\n }\n }\n\n return 0\n }\n\n /**\n * Gets the shipping price for a specific shipping type using the current shipping address state.\n * @param type - The shipping type to check (pickup, home, store)\n * @returns The shipping price for the specified type, or null if not available\n */\n getShippingPriceForType(type: ShippingType): number | null {\n if (!this.shippingMethod?.rates || !this.shippingAddress.state) return null\n\n const stateIndex = Number.parseInt(this.shippingAddress.state, 10) - 1\n const rates = this.shippingMethod.rates[stateIndex]\n\n if (!rates) return null\n\n switch (type) {\n case ShippingType.pickup:\n return rates[0]\n case ShippingType.home:\n return rates[1]\n case ShippingType.store:\n return rates[2]\n default:\n return null\n }\n }\n\n /**\n * Calculates the total cost of the cart including shipping.\n * @param withCurrentItem - Whether to include the current item in the total.\n * @returns The total cost.\n */\n getTotal(withCurrentItem = true): number {\n const subTotal = this.getSubtotal(withCurrentItem)\n const shippingPrice = this.getShippingPrice() ?? 0\n const selectedOffer = this.currentItem?.offer\n if (selectedOffer && selectedOffer.freeShipping) {\n return subTotal // If the current item has free shipping, return subtotal only\n }\n return subTotal + shippingPrice\n }\n\n /**\n * Retrieves all items in the cart.\n * @returns An array of cart items.\n */\n getAll(): CartItem[] {\n return [...this.items] // Return a copy to prevent external modification\n }\n\n /**\n * Checks if the cart is empty.\n * @returns True if the cart is empty, otherwise false.\n */\n isEmpty(): boolean {\n return this.items.length === 0\n }\n\n /**\n * Notifies listeners if the cart state has meaningfully changed.\n */\n private notifyIfChanged(): void {\n // This method could be enhanced to track and notify only meaningful changes\n this.notify()\n }\n}\n","import { EmbaddedAddress } from '../embadded/address.js'\nimport { EmbaddedCategory } from '../embadded/category.js'\nimport { EmbaddedContact } from '../embadded/contact.js'\nimport { OrderEntity } from './order.js'\nimport { MetaPixelEvent } from './product.js'\n// import { OrderEntity } from \"./order.js\";\n// import { ShippingMethodEntity } from \"./shipping_method.js\";\nimport { UserEntity } from './user.js'\nimport { DateTime } from 'luxon'\n\nexport interface StoreEntity {\n id: string\n slug: string\n banner: StoreBanner | null\n action: StoreAction | null\n domain: StoreDomain | null\n decoration: StoreDecoration | null\n name: string\n iconUrl: string | null\n logoUrl: string | null\n // deprecated\n ondarkLogoUrl: string | null\n userId: string\n categories: EmbaddedCategory[]\n title: string | null\n description: string | null\n addresses: EmbaddedAddress[]\n address: EmbaddedAddress | null\n metadata: Record<string, any>\n contacts: EmbaddedContact[]\n integrations?: StoreIntegrations | null\n publicIntegrations: PublicStoreIntegrations | null\n verifiedAt: any | null\n blockedAt: any | null\n createdAt: any\n updatedAt: any\n // products: ProductEntity[];\n user?: UserEntity\n // orders: OrderEntity[];\n // shippingMethods: ShippingMethodEntity[];\n defaultShippingRates: (number | null)[][] | null\n\n // subscription\n subscription?: any\n due?: number\n\n // StoreConfigs\n configs?: StoreConfigs\n\n // metaPixelIds\n metaPixelIds?: string[] | null\n\n // tiktokPixelIds\n tiktokPixelIds?: string[] | null\n\n // googleAnalyticsId\n googleAnalyticsId?: string | null\n\n // googleTagsId\n googleTagsId?: string | null\n\n // members\n members?: Record<string, StoreMember>\n}\n\n// function that generate public data from the integrations data\nexport const generatePublicStoreIntegrations = (\n integrations: StoreIntegrations | null | undefined\n): PublicStoreIntegrations | null => {\n if (!integrations) return null\n const { metaPixel, tiktokPixel, googleAnalytics, googleTags, orderdz, webhooks } = integrations\n return {\n metaPixel: generatePublicStoreIntegrationMetaPixel(metaPixel) || null,\n tiktokPixel: generatePublicStoreIntegrationTiktokPixel(tiktokPixel) || null,\n googleAnalytics: generatePublicStoreIntegrationGoogleAnalytics(googleAnalytics) || null,\n googleTags: generatePublicStoreIntegrationGoogleTags(googleTags) || null,\n googleSheet: null,\n orderdz: generatePublicStoreIntegrationOrderdz(orderdz) || null,\n webhooks: generatePublicStoreIntegrationWebhooks(webhooks) || null,\n }\n}\nexport const generatePublicStoreIntegrationMetaPixel = (\n metaPixel: MetaPixelIntegration | null | undefined\n): PublicMetaPixelIntegration | null | undefined => {\n if (!metaPixel) return null\n return {\n pixels: metaPixel.pixels.map((pixel) => ({\n id: pixel.id,\n })),\n active: metaPixel.active,\n objective: metaPixel.objective,\n draftObjective: metaPixel.draftObjective,\n }\n}\nexport const generatePublicStoreIntegrationTiktokPixel = (\n tiktokPixel: TiktokPixelIntegration | null | undefined\n): PublicTiktokPixelIntegration | null | undefined => {\n if (!tiktokPixel) return null\n return {\n pixels: tiktokPixel.pixels.map((pixel) => ({\n id: pixel.id,\n })),\n active: tiktokPixel.active,\n }\n}\nexport const generatePublicStoreIntegrationGoogleAnalytics = (\n googleAnalytics: GoogleAnalyticsIntegration | null | undefined\n): PublicGoogleAnalyticsIntegration | null | undefined => {\n if (!googleAnalytics) return null\n return {\n id: googleAnalytics.id,\n active: googleAnalytics.active,\n }\n}\nexport const generatePublicStoreIntegrationGoogleSheet = (\n googleSheet: GoogleSheetsIntegration | null | undefined\n): PublicGoogleSheetsIntegration | null | undefined => {\n if (!googleSheet) return null\n return null\n}\nexport const generatePublicStoreIntegrationGoogleTags = (\n googleTags: GoogleTagsIntegration | null | undefined\n): PublicGoogleTagsIntegration | null | undefined => {\n if (!googleTags) return null\n const { id, active } = googleTags\n return {\n id,\n active,\n }\n}\n\n/**\n * Generates public OrderDZ integration data from private integration data.\n * Only exposes the URL and active status, keeping the token private for security.\n */\nexport const generatePublicStoreIntegrationOrderdz = (\n orderdz: OrderdzIntegration | null | undefined\n): PublicOrderdzIntegration | null | undefined => {\n if (!orderdz) return null\n return {\n url: orderdz.url,\n active: orderdz.active,\n }\n}\n\n/**\n * Generates public webhooks integration data from private integration data.\n * Only exposes non-sensitive information, keeping secrets private for security.\n */\nexport const generatePublicStoreIntegrationWebhooks = (\n webhooks: WebhooksIntegration | null | undefined\n): PublicWebhooksIntegration | null | undefined => {\n if (!webhooks) return null\n\n const activeWebhooks = webhooks.webhooks.filter((webhook) => webhook.active)\n\n return {\n webhookCount: webhooks.webhooks.length,\n activeWebhookCount: activeWebhooks.length,\n active: webhooks.active,\n webhookUrls: activeWebhooks.map((webhook) => webhook.url),\n }\n}\n\n/**\n * Public interface for OrderDZ integration.\n * Contains only non-sensitive information that can be safely exposed to clients.\n */\nexport interface PublicOrderdzIntegration {\n url: string\n active: boolean\n}\n\n/**\n * Public interface for webhooks integration.\n * Contains only non-sensitive information that can be safely exposed to clients.\n */\nexport interface PublicWebhooksIntegration {\n /** Total number of configured webhooks */\n webhookCount: number\n /** Number of active webhooks */\n activeWebhookCount: number\n /** Whether the integration is active */\n active: boolean\n /** List of active webhook URLs (without secrets) */\n webhookUrls: string[]\n}\n\nexport interface PublicMetaPixelIntegration {\n pixels: { id: string }[]\n active: boolean\n objective?: MetaPixelEvent | null\n draftObjective?: MetaPixelEvent | null\n}\nexport interface PublicTiktokPixelIntegration {\n pixels: { id: string }[]\n active: boolean\n}\nexport interface PublicGoogleAnalyticsIntegration {\n id: string\n active: boolean\n}\nexport interface PublicGoogleSheetsIntegration {\n id: string\n active: boolean\n}\nexport interface PublicGoogleTagsIntegration {\n id: string\n active: boolean\n}\n\nexport interface PublicStoreIntegrations {\n metaPixel: PublicMetaPixelIntegration | null\n tiktokPixel: PublicTiktokPixelIntegration | null\n googleAnalytics: PublicGoogleAnalyticsIntegration | null\n googleSheet: PublicGoogleSheetsIntegration | null\n googleTags: PublicGoogleTagsIntegration | null\n orderdz: PublicOrderdzIntegration | null\n webhooks: PublicWebhooksIntegration | null\n}\n\nexport enum StoreMemberRole {\n editor = 'editor',\n viewer = 'viewer',\n confermer = 'confermer',\n}\n\nexport interface StoreMember {\n name: string\n userId: string\n role: StoreMemberRole\n acceptedAt: any | null\n expiredAt: any | null\n createdAt: any\n active: boolean\n metadata: Record<string, any>\n}\n\nexport interface StoreConfigs {\n currencies: StoreCurrencyConfig[]\n defaultCurrency: number\n}\n\nexport interface StoreCurrencyConfig {\n code: string\n symbol: string\n precision: number\n rate: number\n}\n\nexport interface StoreDomain {\n name: string\n verifiedAt: any | null\n metadata: Record<string, any>\n}\nexport interface StoreBanner {\n title: string\n url?: string | null\n enabled: boolean\n metadata: Record<string, any>\n}\n\nexport interface StoreDecoration {\n // primary\n primary: number\n onPrimary?: number\n // on dark mode\n primaryDark?: number\n onPrimaryDark?: number\n // secondary\n secondary?: number\n onSecondary?: number\n // on dark mode\n secondaryDark?: number\n onSecondaryDark?: number\n\n useLogoDarkFilter?: boolean\n\n showStoreLogoInHeader?: boolean\n logoFullHeight?: boolean\n showStoreNameInHeader?: boolean\n metadata?: Record<string, any>\n [key: string]: any\n}\n\nexport interface StoreAction {\n label: string\n url: string\n type: StoreActionType\n}\n\nexport enum StoreActionType {\n link = 'link',\n whatsapp = 'whatsapp',\n telegram = 'telegram',\n phone = 'phone',\n}\nexport interface MetaPixel {\n name?: string\n id: string\n key?: string\n}\n// tiktok pixel\nexport interface TiktokPixel {\n id: string\n key?: string\n}\n// meta pixel integration\nexport interface MetaPixelIntegration {\n id: string\n pixels: MetaPixel[]\n objective?: MetaPixelEvent | null\n draftObjective?: MetaPixelEvent | null\n active: boolean\n metadata: Record<string, any>\n}\n// tiktok pixel integration\nexport interface TiktokPixelIntegration {\n id: string\n pixels: TiktokPixel[]\n active: boolean\n metadata: Record<string, any>\n}\n\nexport interface GoogleAnalyticsIntegration {\n id: string\n active: boolean\n metadata: Record<string, any>\n}\n\n// export enum GoogleSheetsColumnType {\n// string = 'string',\n// number = 'number',\n// boolean = 'boolean',\n// date = 'date',\n// }\n\nexport interface GoogleSheetsColumn<T> {\n // it can be path in json field for exmple metadata.customData\n field: keyof OrderEntity | string | 'skus' | 'quantities' | 'itemsNames'\n name: string\n enabled: boolean\n defaultValue?: T\n // type:\n}\nexport interface GoogleSheetsIntegration {\n id: string\n name: string\n active: boolean\n oauth2?: Record<string, any>\n metadata: Record<string, any>\n simple?: boolean\n columns?: GoogleSheetsColumn<any>[]\n}\nexport interface GoogleTagsIntegration {\n id: string\n active: boolean\n metadata: Record<string, any>\n}\n\n/**\n * OrderDZ integration configuration for order confirmation service.\n * This integration allows automatic order confirmation via OrderDZ API.\n */\nexport interface OrderdzIntegration {\n /** Unique identifier for this integration instance */\n id: string\n /** API endpoint URL for OrderDZ service (e.g., \"https://orderdz.com/api/v1/feeef/order\") */\n url: string\n /** Authentication token for OrderDZ API */\n token: string\n /** Whether this integration is currently active */\n active: boolean\n /** Additional metadata for the integration */\n metadata: Record<string, any>\n}\n\n/**\n * Webhook event types for order lifecycle\n */\nexport enum WebhookEvent {\n ORDER_CREATED = 'orderCreated',\n ORDER_UPDATED = 'orderUpdated',\n ORDER_DELETED = 'orderDeleted',\n}\n\n/**\n * Individual webhook configuration\n */\nexport interface WebhookConfig {\n /** Unique identifier for this webhook */\n id: string\n /** Human-readable name for this webhook */\n name: string\n /** Target URL where webhook events will be sent */\n url: string\n /** Events this webhook is subscribed to */\n events: WebhookEvent[]\n /** Optional secret key for HMAC signature verification */\n secret?: string\n /** Whether this webhook is currently active */\n active: boolean\n /** Additional HTTP headers to send with webhook requests */\n headers?: Record<string, string>\n /** Additional metadata for this webhook */\n metadata: Record<string, any>\n}\n\n/**\n * Webhooks integration configuration for real-time order notifications\n */\nexport interface WebhooksIntegration {\n /** List of configured webhooks */\n webhooks: WebhookConfig[]\n /** Whether the webhooks integration is active */\n active: boolean\n /** Additional metadata for the integration */\n metadata: Record<string, any>\n}\n\nexport interface StoreIntegrations {\n [key: string]: any\n metadata?: Record<string, any>\n\n // @Default('default') String id,\n // @Default([]) List<MetaPixel> pixels,\n // @Default(true) bool active,\n // @Default({}) Map<String, dynamic> metadata,\n metaPixel?: MetaPixelIntegration\n tiktokPixel?: TiktokPixelIntegration\n googleAnalytics?: GoogleAnalyticsIntegration\n googleSheet?: GoogleSheetsIntegration\n googleTags?: GoogleTagsIntegration\n orderdz?: OrderdzIntegration\n webhooks?: WebhooksIntegration\n\n sms?: any\n telegram?: any\n yalidine?: any\n maystroDelivery?: any\n echotrak?: any\n procolis?: any\n noest?: any\n}\n\nexport enum StoreSubscriptionStatus {\n active = 'active',\n inactive = 'inactive',\n}\n\nexport enum StoreSubscriptionType {\n free = 'free',\n premium = 'premium',\n vip = 'vip',\n custom = 'custom',\n}\n\nexport interface StoreSubscription {\n type: StoreSubscriptionType\n name: string\n status: StoreSubscriptionStatus\n startedAt: DateTime\n expiresAt: DateTime | null\n quota: number\n consumed: number\n remaining: number\n metadata: Record<string, any>\n}\n","import { EmbaddedCategory } from '../embadded/category.js'\nimport { ShippingMethodEntity } from './shipping_method.js'\nimport { GoogleSheetsColumn, StoreEntity } from './store.js'\n\nexport interface ProductEntity {\n id: string\n\n slug: string\n\n decoration: ProductDecoration | null\n\n name: string | null\n\n photoUrl: string | null\n\n media: string[]\n\n storeId: string\n\n shippingMethodId?: string | null\n\n category?: EmbaddedCategory | null\n\n title: string | null\n\n description: string | null\n\n body: string | null\n\n // sku\n sku: string | null\n\n price: number\n\n cost: number | null\n\n discount: number | null\n\n stock: number | null\n\n sold: number\n\n views: number\n\n likes: number\n\n dislikes: number\n\n variant?: ProductVariant | null\n\n offers?: ProductOffer[] | null\n\n metadata: Record<string, any>\n\n status: ProductStatus\n\n type: ProductType\n\n verifiedAt: any | null\n\n blockedAt: any | null\n\n createdAt: any\n\n updatedAt: any\n\n addons?: ProductAddon[] | null\n\n // integrations configs\n integrationsData?: IntegrationsData | null\n publicIntegrationsData?: IntegrationsData | null\n\n // relations\n store?: StoreEntity | null\n shippingMethod?: ShippingMethodEntity | null\n}\n\n// function that generate public data from the integrations data\nexport function generatePublicIntegrationsData(data: IntegrationsData | null | null): any {\n if (!data) return data\n const { metaPixelData, tiktokPixelData, googleAnalyticsData, googleTagsData } = data\n return {\n metaPixelData: generatePublicIntegrationsDataMetaPixel(metaPixelData),\n tiktokPixelData: generatePublicIntegrationsDataTiktokPixel(tiktokPixelData),\n googleAnalyticsData: generatePublicIntegrationsDataGoogleAnalytics(googleAnalyticsData),\n googleTagsData: generatePublicIntegrationsDataGoogleTag(googleTagsData),\n }\n}\n// function that generate public data from the meta pixel data\nexport function generatePublicIntegrationsDataMetaPixel(\n data: MetaPixelData | null | undefined\n): PublicMetaPixelData | null | undefined {\n if (!data) return data\n const { ids, objective, draftObjective } = data\n return {\n ids: ids,\n objective,\n draftObjective,\n }\n}\n// function that generate public data from the tiktok pixel data\nexport function generatePublicIntegrationsDataTiktokPixel(\n data: TiktokPixelData | null | undefined\n): PubllicTiktokPixelData | null | undefined {\n if (!data) return data\n // const { ids, objective, draftObjective } = data\n return {}\n}\n// function that generate public data from the google analytics data\nexport function generatePublicIntegrationsDataGoogleAnalytics(\n data: GoogleAnalyticsData | null | undefined\n): PublicGoogleAnalyticsData | null | undefined {\n if (!data) return data\n return {}\n}\n// function that generate public data from the google tag data\nexport function generatePublicIntegrationsDataGoogleTag(\n data: GoogleTagData | null | undefined\n): PublicGoogleTagData | null | undefined {\n if (!data) return data\n return {}\n}\n// function that generate public data from the google sheets data\nexport function generatePublicIntegrationsDataGoogleSheets(\n data: GoogleSheetsData | null | undefined\n): PublicGoogleSheetsData | null | undefined {\n if (!data) return data\n return {}\n}\n\nexport interface IntegrationsData {\n metaPixelData?: MetaPixelData | null\n tiktokPixelData?: TiktokPixelData | null\n googleAnalyticsData?: GoogleAnalyticsData | null\n googleTagsData?: GoogleTagData | null\n googleSheetsData?: GoogleSheetsData | null\n}\n\nexport enum MetaPixelEvent {\n none = 'none',\n lead = 'Lead',\n purchase = 'Purchase',\n viewContent = 'ViewContent',\n addToCart = 'AddToCart',\n initiateCheckout = 'InitiateCheckout',\n}\nexport interface MetaPixelData {\n // active meta pixel ids\n ids: string[] | null\n // main objective\n objective: MetaPixelEvent | null\n // draft objective\n draftObjective: MetaPixelEvent | null\n}\n\nexport enum TiktokPixelEvent {}\nexport interface TiktokPixelData {\n // active tiktok pixel ids\n ids: string[] | null\n // main objective\n objective: TiktokPixelEvent | null\n // draft objective\n draftObjective: TiktokPixelEvent | null\n}\nexport interface GoogleAnalyticsData {}\nexport interface GoogleTagData {}\nexport interface GoogleSheetsData {\n enabled: boolean\n // use cant use both sheetId and sheetName\n sheetId: string | null\n // if sheetId is null, use sheetName\n // if sheetName not exists in the spreadsheet, create it\n sheetName: string | null\n spreadsheetId: string | null\n // the next row to insert data\n nextRow: number | null\n // columns to insert data\n columns: GoogleSheetsColumn<any>[] | null\n}\n\n// public meta pixel data\nexport interface PublicMetaPixelData {\n ids: string[] | null\n objective: MetaPixelEvent | null\n draftObjective: MetaPixelEvent | null\n}\n// public tiktok pixel data\nexport interface PubllicTiktokPixelData {}\n// public google analytics data\nexport interface PublicGoogleAnalyticsData {}\n// public google tag data\nexport interface PublicGoogleTagData {}\n// public google sheets data\nexport interface PublicGoogleSheetsData {}\n\nexport interface ProductAddon {\n photoUrl?: string\n title: string\n subtitle?: string\n stock?: number\n price?: number\n min?: number\n max?: number\n}\n\nexport enum ProductStatus {\n draft = 'draft',\n published = 'published',\n archived = 'archived',\n deleted = 'deleted',\n}\n\nexport interface ProductDecoration {\n metadata: Record<string, any>\n}\n\nexport interface ProductVariant {\n name: string\n view?: ProductVariantView\n options: ProductVariantOption[]\n required?: boolean\n}\n\nexport enum ProductVariantView {\n list = 'list',\n chips = 'chips',\n dropdown = 'dropdown',\n}\n\nexport interface ProductVariantOption {\n name: string\n sku?: string | null\n price?: number | null\n discount?: number | null\n stock?: number | null\n sold?: number | null\n type?: VariantOptionType\n child?: ProductVariant | null\n mediaIndex?: number | null\n hint?: string | null\n value?: any\n mediaId?: string | null\n hidden?: boolean\n}\n\nexport enum VariantOptionType {\n color = 'color',\n image = 'image',\n text = 'text',\n}\n\nexport enum ProductType {\n physical = 'physical',\n digital = 'digital',\n service = 'service',\n}\n\nexport interface ProductOffer {\n code: string\n title: string\n subtitle?: string\n price?: number\n minQuantity?: number\n maxQuantity?: number\n freeShipping?: boolean\n}\n","export enum EmbaddedContactType {\n phone = 'phone',\n email = 'email',\n facebook = 'facebook',\n twitter = 'twitter',\n instagram = 'instagram',\n linkedin = 'linkedin',\n website = 'website',\n whatsapp = 'whatsapp',\n telegram = 'telegram',\n signal = 'signal',\n viber = 'viber',\n skype = 'skype',\n zoom = 'zoom',\n other = 'other',\n}\n\n// EmbaddedContactType is not enum but can only be: \"phone\" | \"email\" | \"facebook\" | \"twitter\" | \"instagram\" | \"linkedin\" | \"website\" | \"whatsapp\" | \"telegram\" | \"signal\" | \"viber\" | \"skype\" | \"zoom\" | \"other\n\nexport interface EmbaddedContact {\n type: EmbaddedContactType\n value: string\n name?: string\n metadata?: Record<string, any>\n}\n","/**\n * Converts a Dart color (0xffXXXXXX) to a CSS-compatible number (0xXXXXXXFF).\n *\n * @param dartColor - The Dart color represented as a 32-bit integer (0xffXXXXXX).\n * @returns A number representing the color in CSS format (0xXXXXXXFF).\n */\nexport const convertDartColorToCssNumber = (dartColor: number): number => {\n const alpha = (dartColor >> 24) & 0xff // Extract alpha (high 8 bits)\n const rgb = dartColor & 0xffffff // Extract RGB (low 24 bits)\n\n // Return color as 0xXXXXXXFF (CSS format: RGB + alpha)\n return (rgb << 8) | alpha\n}\n\n/**\n * Converts a CSS color (0xXXXXXXFF) to HSL format.\n *\n * @param cssColor - The CSS color represented as a 32-bit integer (0xXXXXXXFF).\n * @returns An object with HSL values {h, s, l}.\n */\nexport const cssColorToHslString = (cssColor: number): string => {\n const r = ((cssColor >> 24) & 0xff) / 255 // Extract red channel\n const g = ((cssColor >> 16) & 0xff) / 255 // Extract green channel\n const b = ((cssColor >> 8) & 0xff) / 255 // Extract blue channel\n\n const max = Math.max(r, g, b)\n const min = Math.min(r, g, b)\n let h = 0\n let s = 0\n let l = (max + min) / 2\n\n if (max !== min) {\n const d = max - min\n s = l > 0.5 ? d / (2 - max - min) : d / (max + min)\n switch (max) {\n case r:\n h = (g - b) / d + (g < b ? 6 : 0)\n break\n case g:\n h = (b - r) / d + 2\n break\n case b:\n h = (r - g) / d + 4\n break\n }\n h /= 6\n }\n\n return `${Math.round(h * 360)}, ${Math.round(s * 100)}%, ${Math.round(l * 100)}%`\n}\n\n/**\n * Trims and attempts to fix the phone number by:\n * - Removing all non-numeric characters\n * - Ensuring it starts with a '0'\n * @param phone - The input phone number string\n * @returns The cleaned phone number\n */\nexport function tryFixPhoneNumber(phone: string): string {\n phone = phone.trim() // Remove leading/trailing spaces\n // Remove all non-numeric characters\n phone = phone.replace(/\\D/g, '')\n // Ensure the phone number starts with '0'\n if (!phone.startsWith('0')) {\n phone = '0' + phone\n }\n return phone\n}\n\n/**\n * Validates the phone number based on specific rules:\n * - Cannot be empty or just \"0\"\n * - Must start with '05', '06', '07', or '02'\n * - Must be 10 digits for mobile numbers (05, 06, 07)\n * - Must be 9 digits for landline numbers (02)\n * @param phone - The input phone number string\n * @returns Error message if validation fails, otherwise null\n */\nexport function validatePhoneNumber(phone: string): string | null {\n // Helper function to handle length overflow/underflow messages\n const getLengthError = (requiredLength: number, actualLength: number): string => {\n const difference = actualLength - requiredLength\n if (difference > 0) {\n return `عدد الأرقام زائد عن ${requiredLength} رقماً بـ ${difference}`\n } else {\n const missingDigits = -difference\n if (missingDigits === 1) return 'ينقصك رقم واحد'\n if (missingDigits === 2) return 'ينقصك رقمان'\n return `ينقصك ${missingDigits} أرقام`\n }\n }\n\n if (phone === '0') {\n return 'اكمل رقم الهاتف'\n }\n\n // Check if phone number is empty\n if (!phone) {\n return 'رقم الهاتف لا يمكن أن يكون فارغاً.'\n }\n\n // Check if phone number contains only digits\n if (!/^\\d+$/.test(phone)) {\n return 'رقم الهاتف يجب أن يحتوي فقط على أرقام.'\n }\n\n // Ensure the phone starts with valid prefixes\n if (!/^(05|06|07|02)/.test(phone)) {\n return 'يجب أن يبدأ بـ 05, 06, 07, أو 02'\n }\n\n const length = phone.length\n\n // Validate mobile numbers (05, 06, 07 should be 10 digits)\n if (/^(05|06|07)/.test(phone)) {\n if (length !== 10) {\n return getLengthError(10, length)\n }\n }\n\n // Validate landline numbers (02 should be 9 digits)\n else if (phone.startsWith('02')) {\n if (length !== 9) {\n return getLengthError(9, length)\n }\n }\n\n // If all checks pass, return null (no errors)\n return null\n}\n"],"mappings":";AAAA,OAAO,WAA8B;;;ACQ9B,IAAe,kBAAf,MAAwC;AAAA,EAC7C;AAAA;AAAA,EAEA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,YAAY,UAAkB,QAAuB;AACnD,SAAK,WAAW;AAChB,SAAK,SAAS;AAAA,EAChB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,MAAM,KAAK,SAAuC;AAChD,UAAM,EAAE,IAAI,IAAI,OAAO,IAAI;AAC3B,UAAM,MAAM,MAAM,KAAK,OAAO,IAAI,IAAI,KAAK,QAAQ,IAAI,EAAE,IAAI;AAAA,MAC3D,QAAQ;AAAA,QACN,IAAI,MAAM;AAAA,QACV,GAAG;AAAA,MACL;AAAA,IACF,CAAC;AACD,WAAO,IAAI;AAAA,EACb;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,MAAM,KAAK,SAAsD;AAC/D,UAAM,EAAE,MAAM,QAAQ,OAAO,OAAO,IAAI,WAAW,CAAC;AACpD,UAAM,MAAM,MAAM,KAAK,OAAO,IAAI,IAAI,KAAK,QAAQ,IAAI;AAAA,MACrD,QAAQ,EAAE,MAAM,QAAQ,OAAO,GAAG,OAAO;AAAA,IAC3C,CAAC;AAED,QAAI,MAAM,QAAQ,IAAI,IAAI,GAAG;AAC3B,aAAO;AAAA,QACL,MAAM,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MAAI,UAAU,KAAK;AACjB,WAAO;AAAA,EACT;AAGA,MAAI,CAAC,OAAO;AACV,WAAO;AAAA,EACT;AAGA,MAAI,CAAC,QAAQ,KAAK,KAAK,GAAG;AACxB,WAAO;AAAA,EACT;AAGA,MAAI,CAAC,iBAAiB,KAAK,KAAK,GAAG;AACjC,WAAO;AAAA,EACT;AAEA,QAAM,SAAS,MAAM;AAGrB,MAAI,cAAc,KAAK,KAAK,GAAG;AAC7B,QAAI,WAAW,IAAI;AACjB,aAAO,eAAe,IAAI,MAAM;AAAA,IAClC;AAAA,EACF,WAGS,MAAM,WAAW,IAAI,GAAG;AAC/B,QAAI,WAAW,GAAG;AAChB,aAAO,eAAe,GAAG,MAAM;AAAA,IACjC;AAAA,EACF;AAGA,SAAO;AACT;","names":["OrderStatus","PaymentStatus","DeliveryStatus","ShippingType","ShippingMethodStatus","ShippingMethodPolicy","StoreMemberRole","StoreActionType","WebhookEvent","StoreSubscriptionStatus","StoreSubscriptionType","MetaPixelEvent","TiktokPixelEvent","ProductStatus","ProductVariantView","VariantOptionType","ProductType","EmbaddedContactType"]}
|
|
@@ -40,6 +40,24 @@ export declare class CartService extends NotifiableService {
|
|
|
40
40
|
private shippingAddress;
|
|
41
41
|
private cachedSubtotal;
|
|
42
42
|
private currentItem;
|
|
43
|
+
/**
|
|
44
|
+
* Generates a unique key for a cart item based on product ID, variant path, offer code, and addons
|
|
45
|
+
* @param item - The cart item to generate a key for
|
|
46
|
+
* @returns A unique string key
|
|
47
|
+
*/
|
|
48
|
+
private getItemKey;
|
|
49
|
+
/**
|
|
50
|
+
* Finds an item in the cart that matches the given item's key
|
|
51
|
+
* @param item - The item to find
|
|
52
|
+
* @returns The matching cart item or undefined
|
|
53
|
+
*/
|
|
54
|
+
private findItem;
|
|
55
|
+
/**
|
|
56
|
+
* Finds the index of an item in the cart that matches the given item's key
|
|
57
|
+
* @param item - The item to find
|
|
58
|
+
* @returns The index of the matching cart item or -1 if not found
|
|
59
|
+
*/
|
|
60
|
+
private findItemIndex;
|
|
43
61
|
/**
|
|
44
62
|
* Sets the current item to be managed in the cart.
|
|
45
63
|
* @param item - The item to be set as current.
|
|
@@ -53,16 +71,16 @@ export declare class CartService extends NotifiableService {
|
|
|
53
71
|
*/
|
|
54
72
|
private clampQuantityToOfferLimits;
|
|
55
73
|
/**
|
|
56
|
-
* Update item by
|
|
57
|
-
* @param
|
|
58
|
-
* @param
|
|
74
|
+
* Update item by unique key (product ID + variant + offer + addons).
|
|
75
|
+
* @param item - The item to identify the cart item to update.
|
|
76
|
+
* @param updates - Partial item data to update.
|
|
59
77
|
*/
|
|
60
|
-
updateItem(
|
|
78
|
+
updateItem(item: CartItem, updates: Partial<CartItem>, notify?: boolean): void;
|
|
61
79
|
/**
|
|
62
80
|
* Update current item.
|
|
63
|
-
* @param
|
|
81
|
+
* @param updates - a partial item to update.
|
|
64
82
|
*/
|
|
65
|
-
updateCurrentItem(
|
|
83
|
+
updateCurrentItem(updates: Partial<CartItem>, notify?: boolean): void;
|
|
66
84
|
/**
|
|
67
85
|
* Update shipping address.
|
|
68
86
|
* @param address - a partial address to update.
|
|
@@ -101,16 +119,27 @@ export declare class CartService extends NotifiableService {
|
|
|
101
119
|
*/
|
|
102
120
|
add(item: CartItem): void;
|
|
103
121
|
/**
|
|
104
|
-
* Checks if an item exists in the cart by product ID.
|
|
105
|
-
* @param
|
|
122
|
+
* Checks if an item exists in the cart by matching product ID, variant, offer, and addons.
|
|
123
|
+
* @param item - The item to check for.
|
|
106
124
|
* @returns True if the item exists in the cart, false otherwise.
|
|
107
125
|
*/
|
|
108
|
-
has(
|
|
126
|
+
has(item: CartItem): boolean;
|
|
127
|
+
/**
|
|
128
|
+
* Checks if any item with the given product ID exists in the cart.
|
|
129
|
+
* @param productId - The product ID to check for.
|
|
130
|
+
* @returns True if any item with the product ID exists, false otherwise.
|
|
131
|
+
*/
|
|
132
|
+
hasProduct(productId: string): boolean;
|
|
133
|
+
/**
|
|
134
|
+
* Removes an item from the cart by matching the item's unique key.
|
|
135
|
+
* @param item - The item to remove.
|
|
136
|
+
*/
|
|
137
|
+
remove(item: CartItem): void;
|
|
109
138
|
/**
|
|
110
|
-
* Removes
|
|
111
|
-
* @param
|
|
139
|
+
* Removes all items with the given product ID from the cart.
|
|
140
|
+
* @param productId - The product ID to remove.
|
|
112
141
|
*/
|
|
113
|
-
|
|
142
|
+
removeByProductId(productId: string): void;
|
|
114
143
|
/**
|
|
115
144
|
* Clears all items from the cart.
|
|
116
145
|
*/
|
|
@@ -136,10 +165,10 @@ export declare class CartService extends NotifiableService {
|
|
|
136
165
|
isOfferValidForQuantity(offer: ProductOffer, quantity: number): boolean;
|
|
137
166
|
/**
|
|
138
167
|
* Updates the offer for a specific cart item
|
|
139
|
-
* @param
|
|
168
|
+
* @param item - The item to update
|
|
140
169
|
* @param offer - The offer to apply, or undefined to remove the offer
|
|
141
170
|
*/
|
|
142
|
-
updateItemOffer(
|
|
171
|
+
updateItemOffer(item: CartItem, offer?: ProductOffer): void;
|
|
143
172
|
/**
|
|
144
173
|
* Updates the offer for the current item
|
|
145
174
|
* @param offer - The offer to apply, or undefined to remove the offer
|