feeef 0.5.34-dev → 0.5.36-dev.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/build/index.js CHANGED
@@ -561,11 +561,24 @@ var CartService = class extends NotifiableService {
561
561
  this.notifyIfChanged();
562
562
  }
563
563
  /**
564
- * Checks if an item exists in the cart by matching product ID, variant, offer, and addons.
564
+ * Checks if an item exists in the cart by matching product ID and variant path.
565
+ * @param productId - The product ID to check for.
566
+ * @param variantPath - The variant path to check for.
567
+ * @returns True if the item exists in the cart, false otherwise.
568
+ */
569
+ has(productId, variantPath) {
570
+ return this.items.some((item) => {
571
+ if (item.product.id !== productId) return false;
572
+ if (variantPath !== void 0 && item.variantPath !== variantPath) return false;
573
+ return true;
574
+ });
575
+ }
576
+ /**
577
+ * Checks if an item exists in the cart by matching the item's unique key.
565
578
  * @param item - The item to check for.
566
579
  * @returns True if the item exists in the cart, false otherwise.
567
580
  */
568
- has(item) {
581
+ hasItem(item) {
569
582
  return this.findItem(item) !== void 0;
570
583
  }
571
584
  /**
@@ -592,9 +605,13 @@ var CartService = class extends NotifiableService {
592
605
  * Removes all items with the given product ID from the cart.
593
606
  * @param productId - The product ID to remove.
594
607
  */
595
- removeByProductId(productId) {
608
+ removeByProductId(productId, variantPath) {
596
609
  const initialLength = this.items.length;
597
- this.items = this.items.filter((item) => item.product.id !== productId);
610
+ this.items = this.items.filter((item) => {
611
+ if (item.product.id !== productId) return true;
612
+ if (variantPath !== void 0 && item.variantPath !== variantPath) return true;
613
+ return false;
614
+ });
598
615
  if (this.items.length !== initialLength) {
599
616
  this.cachedSubtotal = null;
600
617
  this.notifyIfChanged();
@@ -623,7 +640,7 @@ var CartService = class extends NotifiableService {
623
640
  return sum + this.getItemTotal(item);
624
641
  }, 0);
625
642
  }
626
- if (withCurrentItem && this.currentItem && !this.has(this.currentItem)) {
643
+ if (withCurrentItem && this.currentItem && !this.hasItem(this.currentItem)) {
627
644
  return this.cachedSubtotal + this.getItemTotal(this.currentItem);
628
645
  }
629
646
  return this.cachedSubtotal;
@@ -960,7 +977,9 @@ var generatePublicStoreIntegrationTiktokPixel = (tiktokPixel) => {
960
977
  pixels: tiktokPixel.pixels.map((pixel) => ({
961
978
  id: pixel.id
962
979
  })),
963
- active: tiktokPixel.active
980
+ active: tiktokPixel.active,
981
+ objective: tiktokPixel.objective,
982
+ draftObjective: tiktokPixel.draftObjective
964
983
  };
965
984
  };
966
985
  var generatePublicStoreIntegrationGoogleAnalytics = (googleAnalytics) => {
@@ -1053,7 +1072,12 @@ function generatePublicIntegrationsDataMetaPixel(data) {
1053
1072
  }
1054
1073
  function generatePublicIntegrationsDataTiktokPixel(data) {
1055
1074
  if (!data) return data;
1056
- return {};
1075
+ const { ids, objective, draftObjective } = data;
1076
+ return {
1077
+ ids,
1078
+ objective,
1079
+ draftObjective
1080
+ };
1057
1081
  }
1058
1082
  function generatePublicIntegrationsDataGoogleAnalytics(data) {
1059
1083
  if (!data) return data;
@@ -1077,6 +1101,16 @@ var MetaPixelEvent = /* @__PURE__ */ ((MetaPixelEvent2) => {
1077
1101
  return MetaPixelEvent2;
1078
1102
  })(MetaPixelEvent || {});
1079
1103
  var TiktokPixelEvent = /* @__PURE__ */ ((TiktokPixelEvent2) => {
1104
+ TiktokPixelEvent2["none"] = "none";
1105
+ TiktokPixelEvent2["viewContent"] = "ViewContent";
1106
+ TiktokPixelEvent2["addToWishlist"] = "AddToWishlist";
1107
+ TiktokPixelEvent2["search"] = "Search";
1108
+ TiktokPixelEvent2["addPaymentInfo"] = "AddPaymentInfo";
1109
+ TiktokPixelEvent2["addToCart"] = "AddToCart";
1110
+ TiktokPixelEvent2["initiateCheckout"] = "InitiateCheckout";
1111
+ TiktokPixelEvent2["placeAnOrder"] = "PlaceAnOrder";
1112
+ TiktokPixelEvent2["completeRegistration"] = "CompleteRegistration";
1113
+ TiktokPixelEvent2["purchase"] = "Purchase";
1080
1114
  return TiktokPixelEvent2;
1081
1115
  })(TiktokPixelEvent || {});
1082
1116
  var ProductStatus = /* @__PURE__ */ ((ProductStatus2) => {
@@ -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: 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,KAA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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 and variant path.\n * @param productId - The product ID to check for.\n * @param variantPath - The variant path to check for.\n * @returns True if the item exists in the cart, false otherwise.\n */\n has(productId: string, variantPath?: string): boolean {\n return this.items.some((item) => {\n if (item.product.id !== productId) return false\n if (variantPath !== undefined && item.variantPath !== variantPath) return false\n return true\n })\n }\n\n /**\n * Checks if an item exists in the cart by matching the item's unique key.\n * @param item - The item to check for.\n * @returns True if the item exists in the cart, false otherwise.\n */\n hasItem(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, variantPath?: string): void {\n const initialLength = this.items.length\n this.items = this.items.filter((item) => {\n if (item.product.id !== productId) return true\n if (variantPath !== undefined && item.variantPath !== variantPath) return true\n return false\n })\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.hasItem(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, TiktokPixelEvent } 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 objective: tiktokPixel.objective,\n draftObjective: tiktokPixel.draftObjective,\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 objective?: TiktokPixelEvent | null\n draftObjective?: TiktokPixelEvent | null\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 name?: string\n id: string\n accessToken?: 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 objective?: TiktokPixelEvent | null\n draftObjective?: TiktokPixelEvent | null\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): PublicTiktokPixelData | 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 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 {\n none = 'none',\n viewContent = 'ViewContent',\n addToWishlist = 'AddToWishlist',\n search = 'Search',\n addPaymentInfo = 'AddPaymentInfo',\n addToCart = 'AddToCart',\n initiateCheckout = 'InitiateCheckout',\n placeAnOrder = 'PlaceAnOrder',\n completeRegistration = 'CompleteRegistration',\n purchase = 'Purchase',\n}\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 PublicTiktokPixelData {\n ids: string[] | null\n objective: TiktokPixelEvent | null\n draftObjective: TiktokPixelEvent | null\n}\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;AAA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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,7 +40,7 @@ export interface ProductEntity {
40
40
  }
41
41
  export declare function generatePublicIntegrationsData(data: IntegrationsData | null | null): any;
42
42
  export declare function generatePublicIntegrationsDataMetaPixel(data: MetaPixelData | null | undefined): PublicMetaPixelData | null | undefined;
43
- export declare function generatePublicIntegrationsDataTiktokPixel(data: TiktokPixelData | null | undefined): PubllicTiktokPixelData | null | undefined;
43
+ export declare function generatePublicIntegrationsDataTiktokPixel(data: TiktokPixelData | null | undefined): PublicTiktokPixelData | null | undefined;
44
44
  export declare function generatePublicIntegrationsDataGoogleAnalytics(data: GoogleAnalyticsData | null | undefined): PublicGoogleAnalyticsData | null | undefined;
45
45
  export declare function generatePublicIntegrationsDataGoogleTag(data: GoogleTagData | null | undefined): PublicGoogleTagData | null | undefined;
46
46
  export declare function generatePublicIntegrationsDataGoogleSheets(data: GoogleSheetsData | null | undefined): PublicGoogleSheetsData | null | undefined;
@@ -65,6 +65,16 @@ export interface MetaPixelData {
65
65
  draftObjective: MetaPixelEvent | null;
66
66
  }
67
67
  export declare enum TiktokPixelEvent {
68
+ none = "none",
69
+ viewContent = "ViewContent",
70
+ addToWishlist = "AddToWishlist",
71
+ search = "Search",
72
+ addPaymentInfo = "AddPaymentInfo",
73
+ addToCart = "AddToCart",
74
+ initiateCheckout = "InitiateCheckout",
75
+ placeAnOrder = "PlaceAnOrder",
76
+ completeRegistration = "CompleteRegistration",
77
+ purchase = "Purchase"
68
78
  }
69
79
  export interface TiktokPixelData {
70
80
  ids: string[] | null;
@@ -88,7 +98,10 @@ export interface PublicMetaPixelData {
88
98
  objective: MetaPixelEvent | null;
89
99
  draftObjective: MetaPixelEvent | null;
90
100
  }
91
- export interface PubllicTiktokPixelData {
101
+ export interface PublicTiktokPixelData {
102
+ ids: string[] | null;
103
+ objective: TiktokPixelEvent | null;
104
+ draftObjective: TiktokPixelEvent | null;
92
105
  }
93
106
  export interface PublicGoogleAnalyticsData {
94
107
  }
@@ -2,7 +2,7 @@ import { EmbaddedAddress } from '../embadded/address.js';
2
2
  import { EmbaddedCategory } from '../embadded/category.js';
3
3
  import { EmbaddedContact } from '../embadded/contact.js';
4
4
  import { OrderEntity } from './order.js';
5
- import { MetaPixelEvent } from './product.js';
5
+ import { MetaPixelEvent, TiktokPixelEvent } from './product.js';
6
6
  import { UserEntity } from './user.js';
7
7
  import { DateTime } from 'luxon';
8
8
  export interface StoreEntity {
@@ -92,6 +92,8 @@ export interface PublicTiktokPixelIntegration {
92
92
  id: string;
93
93
  }[];
94
94
  active: boolean;
95
+ objective?: TiktokPixelEvent | null;
96
+ draftObjective?: TiktokPixelEvent | null;
95
97
  }
96
98
  export interface PublicGoogleAnalyticsIntegration {
97
99
  id: string;
@@ -183,8 +185,9 @@ export interface MetaPixel {
183
185
  key?: string;
184
186
  }
185
187
  export interface TiktokPixel {
188
+ name?: string;
186
189
  id: string;
187
- key?: string;
190
+ accessToken?: string;
188
191
  }
189
192
  export interface MetaPixelIntegration {
190
193
  id: string;
@@ -197,6 +200,8 @@ export interface MetaPixelIntegration {
197
200
  export interface TiktokPixelIntegration {
198
201
  id: string;
199
202
  pixels: TiktokPixel[];
203
+ objective?: TiktokPixelEvent | null;
204
+ draftObjective?: TiktokPixelEvent | null;
200
205
  active: boolean;
201
206
  metadata: Record<string, any>;
202
207
  }
@@ -119,11 +119,18 @@ export declare class CartService extends NotifiableService {
119
119
  */
120
120
  add(item: CartItem): void;
121
121
  /**
122
- * Checks if an item exists in the cart by matching product ID, variant, offer, and addons.
122
+ * Checks if an item exists in the cart by matching product ID and variant path.
123
+ * @param productId - The product ID to check for.
124
+ * @param variantPath - The variant path to check for.
125
+ * @returns True if the item exists in the cart, false otherwise.
126
+ */
127
+ has(productId: string, variantPath?: string): boolean;
128
+ /**
129
+ * Checks if an item exists in the cart by matching the item's unique key.
123
130
  * @param item - The item to check for.
124
131
  * @returns True if the item exists in the cart, false otherwise.
125
132
  */
126
- has(item: CartItem): boolean;
133
+ hasItem(item: CartItem): boolean;
127
134
  /**
128
135
  * Checks if any item with the given product ID exists in the cart.
129
136
  * @param productId - The product ID to check for.
@@ -139,7 +146,7 @@ export declare class CartService extends NotifiableService {
139
146
  * Removes all items with the given product ID from the cart.
140
147
  * @param productId - The product ID to remove.
141
148
  */
142
- removeByProductId(productId: string): void;
149
+ removeByProductId(productId: string, variantPath?: string): void;
143
150
  /**
144
151
  * Clears all items from the cart.
145
152
  */
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "feeef",
3
3
  "description": "feeef sdk for javascript",
4
- "version": "0.5.34-dev",
4
+ "version": "0.5.36-dev.1",
5
5
  "main": "build/index.js",
6
6
  "type": "module",
7
7
  "files": [