feeef 0.5.20 → 0.5.21
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.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/feeef/feeef.ts","../src/feeef/repositories/repository.ts","../src/feeef/repositories/orders.ts","../src/feeef/repositories/products.ts","../src/feeef/repositories/stores.ts","../src/feeef/repositories/users.ts","../src/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 { 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 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\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 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","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 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 coupon?: string | null\n storeId: string\n metadata: OrderMetadata\n status: OrderStatus\n paymentStatus: PaymentStatus\n deliveryStatus: DeliveryStatus\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'\n type: ShippingType\n}\n\n/**\n * Manages the shopping cart and its operations.\n */\nexport class CartService extends NotifiableService {\n private items: Map<string, CartItem> = new Map() // Fast lookup of cart items\n private shippingMethod: ShippingMethodEntity | null = null\n private shippingAddress: CartShippingAddress = {\n name: null,\n phone: null,\n city: null,\n state: null,\n street: null,\n country: 'dz',\n type: ShippingType.pickup,\n }\n private cachedSubtotal: number | null = null // Cache for subtotal to avoid redundant calculations\n private currentItem: CartItem | null = null\n\n /**\n * Sets the current item to be managed in the cart.\n * @param item - The item to be set as current.\n */\n setCurrentItem(item: CartItem, notify = true): void {\n this.currentItem = item\n\n if (this.has(this.currentItem.product.id)) {\n this.items.set(this.currentItem.product.id, this.currentItem)\n }\n this.cachedSubtotal = null\n if (notify) {\n this.notify()\n }\n }\n\n /**\n * Clamps the quantity to be within the offer's min/max range\n * @param offer - The offer containing quantity constraints\n * @param quantity - The quantity to clamp\n * @returns The clamped quantity value\n */\n private clampQuantityToOfferLimits(offer: ProductOffer, quantity: number): number {\n if (offer.minQuantity !== undefined) {\n quantity = Math.max(quantity, offer.minQuantity)\n }\n if (offer.maxQuantity !== undefined) {\n quantity = Math.min(quantity, offer.maxQuantity)\n }\n return quantity\n }\n\n /**\n * Update item by id.\n * @param id - The id of the item to update.\n * @param item - a partial item to update.\n */\n updateItem(id: string, item: Partial<CartItem>, notify = true): void {\n const currentItem = this.items.get(id)\n\n if (currentItem) {\n const newItem = { ...currentItem, ...item }\n // Clamp quantity if there's an offer with constraints\n if (newItem.offer) {\n newItem.quantity = this.clampQuantityToOfferLimits(newItem.offer, newItem.quantity)\n }\n\n this.items.set(id, newItem)\n this.cachedSubtotal = null\n if (notify) {\n this.notify()\n }\n }\n }\n\n /**\n * Update current item.\n * @param item - a partial item to update.\n */\n updateCurrentItem(item: Partial<CartItem>, notify = true): void {\n if (!this.currentItem) return\n\n this.currentItem = { ...this.currentItem, ...item }\n\n if (this.has(this.currentItem.product.id)) {\n this.items.set(this.currentItem.product.id, this.currentItem)\n }\n\n this.cachedSubtotal = null\n if (notify) {\n this.notify()\n }\n }\n\n /**\n * Update shipping address.\n * @param address - a partial address to update.\n */\n updateShippingAddress(address: Partial<CartShippingAddress>, notify = true): void {\n this.shippingAddress = { ...this.shippingAddress, ...address }\n this.cachedSubtotal = null\n if (notify) {\n this.notify()\n }\n }\n\n /**\n * Update shipping method.\n * @param method - a partial shipping method to update.\n */\n updateShippingMethod(method: Partial<ShippingMethodEntity>, notify = true): void {\n if (!this.shippingMethod) return\n\n this.shippingMethod = { ...this.shippingMethod, ...method }\n this.cachedSubtotal = null\n if (notify) {\n this.notify()\n }\n }\n\n /**\n * Retrieves the current item in the cart.\n * @returns The current cart item or null if not set.\n */\n getCurrentItem(): CartItem | null {\n return this.currentItem\n }\n\n /**\n * Checks if the current item is already in the cart.\n * @returns True if the current item is in the cart, false otherwise.\n */\n isCurrentItemInCart(): boolean {\n return this.currentItem ? this.items.has(this.currentItem.product.id) : false\n }\n\n /**\n * Adds the current item to the cart if it's not already present.\n */\n addCurrentItemToCart(): void {\n if (!this.currentItem || this.isCurrentItemInCart()) return\n this.add(this.currentItem)\n this.cachedSubtotal = null\n }\n\n /**\n * Removes the current item from the cart if present.\n */\n removeCurrentItemFromCart(): void {\n if (this.currentItem) {\n this.remove(this.currentItem.product.id)\n }\n }\n\n /**\n * Toggles the current item's presence in the cart (add/remove).\n */\n toggleCurrentItemInCart(): void {\n this.isCurrentItemInCart() ? this.removeCurrentItemFromCart() : this.addCurrentItemToCart()\n }\n\n /**\n * Adds an item to the cart. If the item is already present, increments its quantity.\n * @param item - The cart item to add.\n */\n add(item: CartItem): void {\n const existingItem = this.items.get(item.product.id)\n\n if (existingItem) {\n existingItem.quantity += item.quantity\n } else {\n this.items.set(item.product.id, item)\n }\n\n this.cachedSubtotal = null // Reset subtotal cache\n this.notifyIfChanged()\n }\n\n /**\n * Checks if an item exists in the cart by product ID.\n * @param itemId - The ID of the item to check.\n * @returns True if the item exists in the cart, false otherwise.\n */\n has(itemId: string): boolean {\n return this.items.has(itemId)\n }\n\n /**\n * Removes an item from the cart by product ID.\n * @param itemId - The ID of the item to remove.\n */\n remove(itemId: string): void {\n if (this.items.delete(itemId)) {\n this.cachedSubtotal = null\n this.notifyIfChanged()\n }\n }\n\n /**\n * Clears all items from the cart.\n */\n clear(notify = true): void {\n if (this.items.size > 0) {\n this.items.clear()\n this.cachedSubtotal = null\n if (notify) {\n this.notify()\n }\n }\n }\n\n /**\n * Retrieves the subtotal of the cart.\n * @param withCurrentItem - Whether to include the current item in the subtotal.\n * @returns The subtotal amount.\n */\n getSubtotal(withCurrentItem = true): number {\n if (this.cachedSubtotal === null) {\n this.cachedSubtotal = Array.from(this.items.values()).reduce((sum, item) => {\n return sum + this.getItemTotal(item)\n }, 0)\n }\n\n if (withCurrentItem && this.currentItem && !this.has(this.currentItem.product.id)) {\n return this.cachedSubtotal + this.getItemTotal(this.currentItem)\n }\n\n return this.cachedSubtotal\n }\n\n /**\n * Calculates the total price for a cart item.\n * @param item - The cart item.\n * @returns The total price for the item.\n */\n getItemTotal(item: CartItem): number {\n const { product, variantPath, quantity, offer, addons } = item\n let price = product.price\n let discount = product.discount ?? 0\n\n // Handle variant pricing if a variant path exists\n if (variantPath) {\n const parts = variantPath.split('/')\n let currentVariant = product.variant\n\n for (const part of parts) {\n if (!currentVariant) break\n const option = currentVariant.options.find((o) => o.name === part)\n if (!option) break\n price = option.price ?? price\n discount = option.discount ?? discount\n currentVariant = option.child\n }\n }\n\n // Apply offer if present\n if (offer) {\n if (offer.price !== undefined) {\n // If offer has a fixed price, use it\n price = offer.price\n discount = 0 // Reset discount since we're using a fixed price\n }\n }\n\n // Calculate base product price with quantity\n let total = (price - discount) * quantity\n\n // Add pricing for addons if present\n if (addons && product.addons) {\n for (const [addonId, addonQuantity] of Object.entries(addons)) {\n // Find the addon in the product's addons array\n const addon = product.addons.find((a) => a.title === addonId)\n if (addon && addon.price) {\n // Add the addon price * quantity to the total\n total += addon.price * addonQuantity\n }\n }\n }\n\n return total\n }\n\n /**\n * Validates if an offer can be applied to the given quantity\n * @param offer - The offer to validate\n * @param quantity - The quantity to check\n * @returns boolean indicating if the offer is valid for the quantity\n */\n isOfferValidForQuantity(offer: ProductOffer, quantity: number): boolean {\n if (offer.minQuantity && quantity < offer.minQuantity) return false\n if (offer.maxQuantity && quantity > offer.maxQuantity) return false\n return true\n }\n\n /**\n * Updates the offer for a specific cart item\n * @param itemId - The ID of the item to update\n * @param offer - The offer to apply, or undefined to remove the offer\n */\n updateItemOffer(itemId: string, offer?: ProductOffer): void {\n const item = this.items.get(itemId)\n if (!item) return\n\n const updatedItem = { ...item, offer }\n // If applying an offer, ensure quantity is within limits\n if (offer) {\n updatedItem.quantity = this.clampQuantityToOfferLimits(offer, item.quantity)\n }\n\n this.updateItem(itemId, updatedItem)\n this.cachedSubtotal = null\n this.notifyIfChanged()\n }\n\n /**\n * Updates the offer for the current item\n * @param offer - The offer to apply, or undefined to remove the offer\n */\n updateCurrentItemOffer(offer?: ProductOffer): void {\n if (!this.currentItem) return\n\n const updatedItem = { ...this.currentItem }\n updatedItem.offer = offer\n\n // If applying an offer, ensure quantity is within limits\n if (offer) {\n updatedItem.quantity = this.clampQuantityToOfferLimits(offer, this.currentItem.quantity)\n }\n\n this.updateCurrentItem(updatedItem)\n this.cachedSubtotal = null\n this.notifyIfChanged()\n }\n\n /**\n * Sets the shipping method.\n * @param method - Either a store or a shipping method.\n */\n setShippingMethod(method: ShippingMethodEntity | StoreEntity, notify = true): void {\n const store = (method as StoreEntity)?.defaultShippingRates ? (method as StoreEntity) : null\n const shippingMethod = (method as ShippingMethodEntity)?.rates\n ? (method as ShippingMethodEntity)\n : null\n\n if (store) {\n this.shippingMethod = {\n id: store.id,\n name: store.name,\n description: store.description,\n logoUrl: store.logoUrl,\n ondarkLogoUrl: store.ondarkLogoUrl,\n price: 0,\n forks: 0,\n sourceId: store.id,\n storeId: store.id,\n rates: store.defaultShippingRates,\n status: ShippingMethodStatus.published,\n policy: ShippingMethodPolicy.public,\n verifiedAt: null,\n createdAt: null,\n updatedAt: null,\n orders: [],\n source: null,\n }\n if (notify) {\n this.notify()\n }\n } else if (shippingMethod) {\n this.shippingMethod = shippingMethod\n if (notify) {\n this.notify()\n }\n } else {\n throw new Error('Invalid shipping method')\n }\n }\n\n // getAvailableShippingTypes\n /**\n * Retrieves the available shipping types for the current shipping method.\n *\n * rates is a 2D array for example `[[10, 20, 30], [5, 10, 15]]`\n * where the first array is for `home` fees and the second is for `pickup` fees, and the third is for `store` fees\n * if the fee value is 0, then it's free shipping, and if it's null, then it's not available\n *\n * @returns An array of available shipping types.\n */\n getAvailableShippingTypes(): ShippingType[] {\n if (!this.shippingMethod?.rates) return []\n\n var state = Number.parseInt(this.shippingAddress.state!)\n var stateRates = this.shippingMethod.rates[state - 1]\n\n if (!stateRates) return []\n\n var availableTypes: ShippingType[] = []\n\n if (stateRates[0] || stateRates[0] === 0) availableTypes.push(ShippingType.pickup)\n if (stateRates[1] || stateRates[1] === 0) availableTypes.push(ShippingType.home)\n if (stateRates[2] || stateRates[2] === 0) availableTypes.push(ShippingType.store)\n\n return availableTypes\n }\n\n /**\n * Retrieves the current shipping method.\n * @returns The shipping method or null.\n */\n getShippingMethod(): ShippingMethodEntity | null {\n return this.shippingMethod\n }\n\n /**\n * Sets the shipping address for the cart.\n * @param address - The shipping address.\n */\n setShippingAddress(address: CartShippingAddress, notify = true): void {\n if (\n this.shippingAddress.city !== address.city ||\n this.shippingAddress.state !== address.state ||\n this.shippingAddress.type !== address.type\n ) {\n this.shippingAddress = address\n if (notify) {\n this.notify()\n }\n }\n }\n\n /**\n * Retrieves the current shipping address.\n * @returns The shipping address.\n */\n getShippingAddress(): CartShippingAddress {\n return this.shippingAddress\n }\n\n /**\n * Calculates the shipping price based on the address and shipping method.\n * @returns The shipping price or 0 if not applicable.\n */\n getShippingPrice(): number {\n // if at least one item have freeShipping offer return 0\n for (const item of this.items.values()) {\n if (item.offer?.freeShipping) return 0\n }\n\n // if no shipping method is set, return 0\n if (!this.shippingMethod) return 0\n\n // if no shipping address is set, return the shipping method price\n if (!this.shippingAddress.state) return this.shippingMethod.price ?? 0\n\n // avalable shipping types\n const shippings = this.getAvailableShippingTypes()\n\n const currentOne = this.getShippingPriceForType(this.shippingAddress.type)\n if (currentOne) {\n return currentOne\n }\n\n for (const type of shippings) {\n if (this.getShippingPriceForType(type) !== null) {\n return this.getShippingPriceForType(type)!\n }\n }\n\n return 0\n }\n\n /**\n * Gets the shipping price for a specific shipping type using the current shipping address state.\n * @param type - The shipping type to check (pickup, home, store)\n * @returns The shipping price for the specified type, or null if not available\n */\n getShippingPriceForType(type: ShippingType): number | null {\n if (!this.shippingMethod?.rates || !this.shippingAddress.state) return null\n\n const stateIndex = Number.parseInt(this.shippingAddress.state, 10) - 1\n const rates = this.shippingMethod.rates[stateIndex]\n\n if (!rates) return null\n\n switch (type) {\n case ShippingType.pickup:\n return rates[0]\n case ShippingType.home:\n return rates[1]\n case ShippingType.store:\n return rates[2]\n default:\n return null\n }\n }\n\n /**\n * Calculates the total cost of the cart including shipping.\n * @param withCurrentItem - Whether to include the current item in the total.\n * @returns The total cost.\n */\n getTotal(withCurrentItem = true): number {\n const subTotal = this.getSubtotal(withCurrentItem)\n const shippingPrice = this.getShippingPrice() ?? 0\n const selectedOffer = this.currentItem?.offer\n if (selectedOffer && selectedOffer.freeShipping) {\n return subTotal // If the current item has free shipping, return subtotal only\n }\n return subTotal + shippingPrice\n }\n\n /**\n * Retrieves all items in the cart.\n * @returns An array of cart items.\n */\n getAll(): CartItem[] {\n return Array.from(this.items.values())\n }\n\n /**\n * Checks if the cart is empty.\n * @returns True if the cart is empty, otherwise false.\n */\n isEmpty(): boolean {\n return this.items.size === 0\n }\n\n /**\n * Notifies listeners if the cart state has meaningfully changed.\n */\n private notifyIfChanged(): void {\n // This method could be enhanced to track and notify only meaningful changes\n this.notify()\n }\n}\n","import { EmbaddedAddress } from '../embadded/address.js'\nimport { EmbaddedCategory } from '../embadded/category.js'\nimport { EmbaddedContact } from '../embadded/contact.js'\nimport { OrderEntity } from './order.js'\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\n publicIntegrations: PublicStoreIntegrations\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 } = 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 }\n}\nexport const generatePublicStoreIntegrationMetaPixel = (\n metaPixel: MetaPixelIntegration | null | undefined\n): PublicMetaPixelIntegration | null | undefined => {\n if (!metaPixel) return null\n return {\n pixels: metaPixel.pixels.map((pixel) => ({\n id: pixel.id,\n })),\n active: metaPixel.active,\n }\n}\nexport const generatePublicStoreIntegrationTiktokPixel = (\n tiktokPixel: TiktokPixelIntegration | null | undefined\n): PublicTiktokPixelIntegration | null | undefined => {\n if (!tiktokPixel) return null\n return {\n pixels: tiktokPixel.pixels.map((pixel) => ({\n id: pixel.id,\n })),\n active: tiktokPixel.active,\n }\n}\nexport const generatePublicStoreIntegrationGoogleAnalytics = (\n googleAnalytics: GoogleAnalyticsIntegration | null | undefined\n): PublicGoogleAnalyticsIntegration | null | undefined => {\n if (!googleAnalytics) return null\n return {\n id: googleAnalytics.id,\n active: googleAnalytics.active,\n }\n}\nexport const generatePublicStoreIntegrationGoogleSheet = (\n googleSheet: GoogleSheetsIntegration | null | undefined\n): PublicGoogleSheetsIntegration | null | undefined => {\n if (!googleSheet) return null\n return null\n}\nexport const generatePublicStoreIntegrationGoogleTags = (\n googleTags: GoogleTagsIntegration | null | undefined\n): PublicGoogleTagsIntegration | null | undefined => {\n if (!googleTags) return null\n const { id, active } = googleTags\n return {\n id,\n active,\n }\n}\nexport interface PublicMetaPixelIntegration {\n pixels: { id: string }[]\n active: boolean\n}\nexport interface PublicTiktokPixelIntegration {\n pixels: { id: string }[]\n active: boolean\n}\nexport interface PublicGoogleAnalyticsIntegration {\n id: string\n active: boolean\n}\nexport interface PublicGoogleSheetsIntegration {\n id: string\n active: boolean\n}\nexport interface PublicGoogleTagsIntegration {\n id: string\n active: boolean\n}\nexport interface PublicStoreIntegrations {\n metaPixel: PublicMetaPixelIntegration | null\n tiktokPixel: PublicTiktokPixelIntegration | null\n googleAnalytics: PublicGoogleAnalyticsIntegration | null\n googleSheet: PublicGoogleSheetsIntegration | null\n googleTags: PublicGoogleTagsIntegration | 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 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\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\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 { 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\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 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}\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}\n\nexport enum VariantOptionType {\n color = 'color',\n image = 'image',\n text = 'text',\n}\n\nexport enum ProductType {\n physical = 'physical',\n digital = 'digital',\n service = 'service',\n}\n\nexport interface ProductOffer {\n code: string\n title: string\n subtitle?: string\n price?: number\n minQuantity?: number\n maxQuantity?: number\n freeShipping?: boolean\n}\n","export enum EmbaddedContactType {\n phone = 'phone',\n email = 'email',\n facebook = 'facebook',\n twitter = 'twitter',\n instagram = 'instagram',\n linkedin = 'linkedin',\n website = 'website',\n whatsapp = 'whatsapp',\n telegram = 'telegram',\n signal = 'signal',\n viber = 'viber',\n skype = 'skype',\n zoom = 'zoom',\n other = 'other',\n}\n\n// EmbaddedContactType is not enum but can only be: \"phone\" | \"email\" | \"facebook\" | \"twitter\" | \"instagram\" | \"linkedin\" | \"website\" | \"whatsapp\" | \"telegram\" | \"signal\" | \"viber\" | \"skype\" | \"zoom\" | \"other\n\nexport interface EmbaddedContact {\n type: EmbaddedContactType\n value: string\n name?: string\n metadata?: Record<string, any>\n}\n","/**\n * Converts a Dart color (0xffXXXXXX) to a CSS-compatible number (0xXXXXXXFF).\n *\n * @param dartColor - The Dart color represented as a 32-bit integer (0xffXXXXXX).\n * @returns A number representing the color in CSS format (0xXXXXXXFF).\n */\nexport const convertDartColorToCssNumber = (dartColor: number): number => {\n const alpha = (dartColor >> 24) & 0xff // Extract alpha (high 8 bits)\n const rgb = dartColor & 0xffffff // Extract RGB (low 24 bits)\n\n // Return color as 0xXXXXXXFF (CSS format: RGB + alpha)\n return (rgb << 8) | alpha\n}\n\n/**\n * Converts a CSS color (0xXXXXXXFF) to HSL format.\n *\n * @param cssColor - The CSS color represented as a 32-bit integer (0xXXXXXXFF).\n * @returns An object with HSL values {h, s, l}.\n */\nexport const cssColorToHslString = (cssColor: number): string => {\n const r = ((cssColor >> 24) & 0xff) / 255 // Extract red channel\n const g = ((cssColor >> 16) & 0xff) / 255 // Extract green channel\n const b = ((cssColor >> 8) & 0xff) / 255 // Extract blue channel\n\n const max = Math.max(r, g, b)\n const min = Math.min(r, g, b)\n let h = 0\n let s = 0\n let l = (max + min) / 2\n\n if (max !== min) {\n const d = max - min\n s = l > 0.5 ? d / (2 - max - min) : d / (max + min)\n switch (max) {\n case r:\n h = (g - b) / d + (g < b ? 6 : 0)\n break\n case g:\n h = (b - r) / d + 2\n break\n case b:\n h = (r - g) / d + 4\n break\n }\n h /= 6\n }\n\n return `${Math.round(h * 360)}, ${Math.round(s * 100)}%, ${Math.round(l * 100)}%`\n}\n\n/**\n * Trims and attempts to fix the phone number by:\n * - Removing all non-numeric characters\n * - Ensuring it starts with a '0'\n * @param phone - The input phone number string\n * @returns The cleaned phone number\n */\nexport function tryFixPhoneNumber(phone: string): string {\n phone = phone.trim() // Remove leading/trailing spaces\n // Remove all non-numeric characters\n phone = phone.replace(/\\D/g, '')\n // Ensure the phone number starts with '0'\n if (!phone.startsWith('0')) {\n phone = '0' + phone\n }\n return phone\n}\n\n/**\n * Validates the phone number based on specific rules:\n * - Cannot be empty or just \"0\"\n * - Must start with '05', '06', '07', or '02'\n * - Must be 10 digits for mobile numbers (05, 06, 07)\n * - Must be 9 digits for landline numbers (02)\n * @param phone - The input phone number string\n * @returns Error message if validation fails, otherwise null\n */\nexport function validatePhoneNumber(phone: string): string | null {\n // Helper function to handle length overflow/underflow messages\n const getLengthError = (requiredLength: number, actualLength: number): string => {\n const difference = actualLength - requiredLength\n if (difference > 0) {\n return `عدد الأرقام زائد عن ${requiredLength} رقماً بـ ${difference}`\n } else {\n const missingDigits = -difference\n if (missingDigits === 1) return 'ينقصك رقم واحد'\n if (missingDigits === 2) return 'ينقصك رقمان'\n return `ينقصك ${missingDigits} أرقام`\n }\n }\n\n if (phone === '0') {\n return 'اكمل رقم الهاتف'\n }\n\n // Check if phone number is empty\n if (!phone) {\n return 'رقم الهاتف لا يمكن أن يكون فارغاً.'\n }\n\n // Check if phone number contains only digits\n if (!/^\\d+$/.test(phone)) {\n return 'رقم الهاتف يجب أن يحتوي فقط على أرقام.'\n }\n\n // Ensure the phone starts with valid prefixes\n if (!/^(05|06|07|02)/.test(phone)) {\n return 'يجب أن يبدأ بـ 05, 06, 07, أو 02'\n }\n\n const length = phone.length\n\n // Validate mobile numbers (05, 06, 07 should be 10 digits)\n if (/^(05|06|07)/.test(phone)) {\n if (length !== 10) {\n return getLengthError(10, length)\n }\n }\n\n // Validate landline numbers (02 should be 9 digits)\n else if (phone.startsWith('02')) {\n if (length !== 9) {\n return getLengthError(9, length)\n }\n }\n\n // If all checks pass, return null (no errors)\n return null\n}\n"],"mappings":";AAAA,OAAO,WAA8B;;;ACQ9B,IAAe,kBAAf,MAAwC;AAAA,EAC7C;AAAA;AAAA,EAEA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,YAAY,UAAkB,QAAuB;AACnD,SAAK,WAAW;AAChB,SAAK,SAAS;AAAA,EAChB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,MAAM,KAAK,SAAuC;AAChD,UAAM,EAAE,IAAI,IAAI,OAAO,IAAI;AAC3B,UAAM,MAAM,MAAM,KAAK,OAAO,IAAI,IAAI,KAAK,QAAQ,IAAI,EAAE,IAAI;AAAA,MAC3D,QAAQ;AAAA,QACN,IAAI,MAAM;AAAA,QACV,GAAG;AAAA,MACL;AAAA,IACF,CAAC;AACD,WAAO,IAAI;AAAA,EACb;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,MAAM,KAAK,SAAsD;AAC/D,UAAM,EAAE,MAAM,QAAQ,OAAO,OAAO,IAAI,WAAW,CAAC;AACpD,UAAM,MAAM,MAAM,KAAK,OAAO,IAAI,IAAI,KAAK,QAAQ,IAAI;AAAA,MACrD,QAAQ,EAAE,MAAM,QAAQ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e,GAAG,MAAM;AAAA,IACjC;AAAA,EACF;AAGA,SAAO;AACT;","names":["OrderStatus","PaymentStatus","DeliveryStatus","ShippingType","ShippingMethodStatus","ShippingMethodPolicy","StoreMemberRole","StoreActionType","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/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 { 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 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\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 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","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 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 coupon?: string | null\n storeId: string\n metadata: OrderMetadata\n status: OrderStatus\n paymentStatus: PaymentStatus\n deliveryStatus: DeliveryStatus\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'\n type: ShippingType\n}\n\n/**\n * Manages the shopping cart and its operations.\n */\nexport class CartService extends NotifiableService {\n private items: Map<string, CartItem> = new Map() // Fast lookup of cart items\n private shippingMethod: ShippingMethodEntity | null = null\n private shippingAddress: CartShippingAddress = {\n name: null,\n phone: null,\n city: null,\n state: null,\n street: null,\n country: 'dz',\n type: ShippingType.pickup,\n }\n private cachedSubtotal: number | null = null // Cache for subtotal to avoid redundant calculations\n private currentItem: CartItem | null = null\n\n /**\n * Sets the current item to be managed in the cart.\n * @param item - The item to be set as current.\n */\n setCurrentItem(item: CartItem, notify = true): void {\n this.currentItem = item\n\n if (this.has(this.currentItem.product.id)) {\n this.items.set(this.currentItem.product.id, this.currentItem)\n }\n this.cachedSubtotal = null\n if (notify) {\n this.notify()\n }\n }\n\n /**\n * Clamps the quantity to be within the offer's min/max range\n * @param offer - The offer containing quantity constraints\n * @param quantity - The quantity to clamp\n * @returns The clamped quantity value\n */\n private clampQuantityToOfferLimits(offer: ProductOffer, quantity: number): number {\n if (offer.minQuantity !== undefined) {\n quantity = Math.max(quantity, offer.minQuantity)\n }\n if (offer.maxQuantity !== undefined) {\n quantity = Math.min(quantity, offer.maxQuantity)\n }\n return quantity\n }\n\n /**\n * Update item by id.\n * @param id - The id of the item to update.\n * @param item - a partial item to update.\n */\n updateItem(id: string, item: Partial<CartItem>, notify = true): void {\n const currentItem = this.items.get(id)\n\n if (currentItem) {\n const newItem = { ...currentItem, ...item }\n // Clamp quantity if there's an offer with constraints\n if (newItem.offer) {\n newItem.quantity = this.clampQuantityToOfferLimits(newItem.offer, newItem.quantity)\n }\n\n this.items.set(id, newItem)\n this.cachedSubtotal = null\n if (notify) {\n this.notify()\n }\n }\n }\n\n /**\n * Update current item.\n * @param item - a partial item to update.\n */\n updateCurrentItem(item: Partial<CartItem>, notify = true): void {\n if (!this.currentItem) return\n\n this.currentItem = { ...this.currentItem, ...item }\n\n if (this.has(this.currentItem.product.id)) {\n this.items.set(this.currentItem.product.id, this.currentItem)\n }\n\n this.cachedSubtotal = null\n if (notify) {\n this.notify()\n }\n }\n\n /**\n * Update shipping address.\n * @param address - a partial address to update.\n */\n updateShippingAddress(address: Partial<CartShippingAddress>, notify = true): void {\n this.shippingAddress = { ...this.shippingAddress, ...address }\n this.cachedSubtotal = null\n if (notify) {\n this.notify()\n }\n }\n\n /**\n * Update shipping method.\n * @param method - a partial shipping method to update.\n */\n updateShippingMethod(method: Partial<ShippingMethodEntity>, notify = true): void {\n if (!this.shippingMethod) return\n\n this.shippingMethod = { ...this.shippingMethod, ...method }\n this.cachedSubtotal = null\n if (notify) {\n this.notify()\n }\n }\n\n /**\n * Retrieves the current item in the cart.\n * @returns The current cart item or null if not set.\n */\n getCurrentItem(): CartItem | null {\n return this.currentItem\n }\n\n /**\n * Checks if the current item is already in the cart.\n * @returns True if the current item is in the cart, false otherwise.\n */\n isCurrentItemInCart(): boolean {\n return this.currentItem ? this.items.has(this.currentItem.product.id) : false\n }\n\n /**\n * Adds the current item to the cart if it's not already present.\n */\n addCurrentItemToCart(): void {\n if (!this.currentItem || this.isCurrentItemInCart()) return\n this.add(this.currentItem)\n this.cachedSubtotal = null\n }\n\n /**\n * Removes the current item from the cart if present.\n */\n removeCurrentItemFromCart(): void {\n if (this.currentItem) {\n this.remove(this.currentItem.product.id)\n }\n }\n\n /**\n * Toggles the current item's presence in the cart (add/remove).\n */\n toggleCurrentItemInCart(): void {\n this.isCurrentItemInCart() ? this.removeCurrentItemFromCart() : this.addCurrentItemToCart()\n }\n\n /**\n * Adds an item to the cart. If the item is already present, increments its quantity.\n * @param item - The cart item to add.\n */\n add(item: CartItem): void {\n const existingItem = this.items.get(item.product.id)\n\n if (existingItem) {\n existingItem.quantity += item.quantity\n } else {\n this.items.set(item.product.id, item)\n }\n\n this.cachedSubtotal = null // Reset subtotal cache\n this.notifyIfChanged()\n }\n\n /**\n * Checks if an item exists in the cart by product ID.\n * @param itemId - The ID of the item to check.\n * @returns True if the item exists in the cart, false otherwise.\n */\n has(itemId: string): boolean {\n return this.items.has(itemId)\n }\n\n /**\n * Removes an item from the cart by product ID.\n * @param itemId - The ID of the item to remove.\n */\n remove(itemId: string): void {\n if (this.items.delete(itemId)) {\n this.cachedSubtotal = null\n this.notifyIfChanged()\n }\n }\n\n /**\n * Clears all items from the cart.\n */\n clear(notify = true): void {\n if (this.items.size > 0) {\n this.items.clear()\n this.cachedSubtotal = null\n if (notify) {\n this.notify()\n }\n }\n }\n\n /**\n * Retrieves the subtotal of the cart.\n * @param withCurrentItem - Whether to include the current item in the subtotal.\n * @returns The subtotal amount.\n */\n getSubtotal(withCurrentItem = true): number {\n if (this.cachedSubtotal === null) {\n this.cachedSubtotal = Array.from(this.items.values()).reduce((sum, item) => {\n return sum + this.getItemTotal(item)\n }, 0)\n }\n\n if (withCurrentItem && this.currentItem && !this.has(this.currentItem.product.id)) {\n return this.cachedSubtotal + this.getItemTotal(this.currentItem)\n }\n\n return this.cachedSubtotal\n }\n\n /**\n * Calculates the total price for a cart item.\n * @param item - The cart item.\n * @returns The total price for the item.\n */\n getItemTotal(item: CartItem): number {\n const { product, variantPath, quantity, offer, addons } = item\n let price = product.price\n let discount = product.discount ?? 0\n\n // Handle variant pricing if a variant path exists\n if (variantPath) {\n const parts = variantPath.split('/')\n let currentVariant = product.variant\n\n for (const part of parts) {\n if (!currentVariant) break\n const option = currentVariant.options.find((o) => o.name === part)\n if (!option) break\n price = option.price ?? price\n discount = option.discount ?? discount\n currentVariant = option.child\n }\n }\n\n // Apply offer if present\n if (offer) {\n if (offer.price !== undefined) {\n // If offer has a fixed price, use it\n price = offer.price\n discount = 0 // Reset discount since we're using a fixed price\n }\n }\n\n // Calculate base product price with quantity\n let total = (price - discount) * quantity\n\n // Add pricing for addons if present\n if (addons && product.addons) {\n for (const [addonId, addonQuantity] of Object.entries(addons)) {\n // Find the addon in the product's addons array\n const addon = product.addons.find((a) => a.title === addonId)\n if (addon && addon.price) {\n // Add the addon price * quantity to the total\n total += addon.price * addonQuantity\n }\n }\n }\n\n return total\n }\n\n /**\n * Validates if an offer can be applied to the given quantity\n * @param offer - The offer to validate\n * @param quantity - The quantity to check\n * @returns boolean indicating if the offer is valid for the quantity\n */\n isOfferValidForQuantity(offer: ProductOffer, quantity: number): boolean {\n if (offer.minQuantity && quantity < offer.minQuantity) return false\n if (offer.maxQuantity && quantity > offer.maxQuantity) return false\n return true\n }\n\n /**\n * Updates the offer for a specific cart item\n * @param itemId - The ID of the item to update\n * @param offer - The offer to apply, or undefined to remove the offer\n */\n updateItemOffer(itemId: string, offer?: ProductOffer): void {\n const item = this.items.get(itemId)\n if (!item) return\n\n const updatedItem = { ...item, offer }\n // If applying an offer, ensure quantity is within limits\n if (offer) {\n updatedItem.quantity = this.clampQuantityToOfferLimits(offer, item.quantity)\n }\n\n this.updateItem(itemId, updatedItem)\n this.cachedSubtotal = null\n this.notifyIfChanged()\n }\n\n /**\n * Updates the offer for the current item\n * @param offer - The offer to apply, or undefined to remove the offer\n */\n updateCurrentItemOffer(offer?: ProductOffer): void {\n if (!this.currentItem) return\n\n const updatedItem = { ...this.currentItem }\n updatedItem.offer = offer\n\n // If applying an offer, ensure quantity is within limits\n if (offer) {\n updatedItem.quantity = this.clampQuantityToOfferLimits(offer, this.currentItem.quantity)\n }\n\n this.updateCurrentItem(updatedItem)\n this.cachedSubtotal = null\n this.notifyIfChanged()\n }\n\n /**\n * Sets the shipping method.\n * @param method - Either a store or a shipping method.\n */\n setShippingMethod(method: ShippingMethodEntity | StoreEntity, notify = true): void {\n const store = (method as StoreEntity)?.defaultShippingRates ? (method as StoreEntity) : null\n const shippingMethod = (method as ShippingMethodEntity)?.rates\n ? (method as ShippingMethodEntity)\n : null\n\n if (store) {\n this.shippingMethod = {\n id: store.id,\n name: store.name,\n description: store.description,\n logoUrl: store.logoUrl,\n ondarkLogoUrl: store.ondarkLogoUrl,\n price: 0,\n forks: 0,\n sourceId: store.id,\n storeId: store.id,\n rates: store.defaultShippingRates,\n status: ShippingMethodStatus.published,\n policy: ShippingMethodPolicy.public,\n verifiedAt: null,\n createdAt: null,\n updatedAt: null,\n orders: [],\n source: null,\n }\n if (notify) {\n this.notify()\n }\n } else if (shippingMethod) {\n this.shippingMethod = shippingMethod\n if (notify) {\n this.notify()\n }\n } else {\n throw new Error('Invalid shipping method')\n }\n }\n\n // getAvailableShippingTypes\n /**\n * Retrieves the available shipping types for the current shipping method.\n *\n * rates is a 2D array for example `[[10, 20, 30], [5, 10, 15]]`\n * where the first array is for `home` fees and the second is for `pickup` fees, and the third is for `store` fees\n * if the fee value is 0, then it's free shipping, and if it's null, then it's not available\n *\n * @returns An array of available shipping types.\n */\n getAvailableShippingTypes(): ShippingType[] {\n if (!this.shippingMethod?.rates) return []\n\n var state = Number.parseInt(this.shippingAddress.state!)\n var stateRates = this.shippingMethod.rates[state - 1]\n\n if (!stateRates) return []\n\n var availableTypes: ShippingType[] = []\n\n if (stateRates[0] || stateRates[0] === 0) availableTypes.push(ShippingType.pickup)\n if (stateRates[1] || stateRates[1] === 0) availableTypes.push(ShippingType.home)\n if (stateRates[2] || stateRates[2] === 0) availableTypes.push(ShippingType.store)\n\n return availableTypes\n }\n\n /**\n * Retrieves the current shipping method.\n * @returns The shipping method or null.\n */\n getShippingMethod(): ShippingMethodEntity | null {\n return this.shippingMethod\n }\n\n /**\n * Sets the shipping address for the cart.\n * @param address - The shipping address.\n */\n setShippingAddress(address: CartShippingAddress, notify = true): void {\n if (\n this.shippingAddress.city !== address.city ||\n this.shippingAddress.state !== address.state ||\n this.shippingAddress.type !== address.type\n ) {\n this.shippingAddress = address\n if (notify) {\n this.notify()\n }\n }\n }\n\n /**\n * Retrieves the current shipping address.\n * @returns The shipping address.\n */\n getShippingAddress(): CartShippingAddress {\n return this.shippingAddress\n }\n\n /**\n * Calculates the shipping price based on the address and shipping method.\n * @returns The shipping price or 0 if not applicable.\n */\n getShippingPrice(): number {\n // if at least one item have freeShipping offer return 0\n for (const item of this.items.values()) {\n if (item.offer?.freeShipping) return 0\n }\n\n // if no shipping method is set, return 0\n if (!this.shippingMethod) return 0\n\n // if no shipping address is set, return the shipping method price\n if (!this.shippingAddress.state) return this.shippingMethod.price ?? 0\n\n // avalable shipping types\n const shippings = this.getAvailableShippingTypes()\n\n const currentOne = this.getShippingPriceForType(this.shippingAddress.type)\n if (currentOne) {\n return currentOne\n }\n\n for (const type of shippings) {\n if (this.getShippingPriceForType(type) !== null) {\n return this.getShippingPriceForType(type)!\n }\n }\n\n return 0\n }\n\n /**\n * Gets the shipping price for a specific shipping type using the current shipping address state.\n * @param type - The shipping type to check (pickup, home, store)\n * @returns The shipping price for the specified type, or null if not available\n */\n getShippingPriceForType(type: ShippingType): number | null {\n if (!this.shippingMethod?.rates || !this.shippingAddress.state) return null\n\n const stateIndex = Number.parseInt(this.shippingAddress.state, 10) - 1\n const rates = this.shippingMethod.rates[stateIndex]\n\n if (!rates) return null\n\n switch (type) {\n case ShippingType.pickup:\n return rates[0]\n case ShippingType.home:\n return rates[1]\n case ShippingType.store:\n return rates[2]\n default:\n return null\n }\n }\n\n /**\n * Calculates the total cost of the cart including shipping.\n * @param withCurrentItem - Whether to include the current item in the total.\n * @returns The total cost.\n */\n getTotal(withCurrentItem = true): number {\n const subTotal = this.getSubtotal(withCurrentItem)\n const shippingPrice = this.getShippingPrice() ?? 0\n const selectedOffer = this.currentItem?.offer\n if (selectedOffer && selectedOffer.freeShipping) {\n return subTotal // If the current item has free shipping, return subtotal only\n }\n return subTotal + shippingPrice\n }\n\n /**\n * Retrieves all items in the cart.\n * @returns An array of cart items.\n */\n getAll(): CartItem[] {\n return Array.from(this.items.values())\n }\n\n /**\n * Checks if the cart is empty.\n * @returns True if the cart is empty, otherwise false.\n */\n isEmpty(): boolean {\n return this.items.size === 0\n }\n\n /**\n * Notifies listeners if the cart state has meaningfully changed.\n */\n private notifyIfChanged(): void {\n // This method could be enhanced to track and notify only meaningful changes\n this.notify()\n }\n}\n","import { EmbaddedAddress } from '../embadded/address.js'\nimport { EmbaddedCategory } from '../embadded/category.js'\nimport { EmbaddedContact } from '../embadded/contact.js'\nimport { OrderEntity } from './order.js'\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\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 } = 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 }\n}\nexport const generatePublicStoreIntegrationMetaPixel = (\n metaPixel: MetaPixelIntegration | null | undefined\n): PublicMetaPixelIntegration | null | undefined => {\n if (!metaPixel) return null\n return {\n pixels: metaPixel.pixels.map((pixel) => ({\n id: pixel.id,\n })),\n active: metaPixel.active,\n }\n}\nexport const generatePublicStoreIntegrationTiktokPixel = (\n tiktokPixel: TiktokPixelIntegration | null | undefined\n): PublicTiktokPixelIntegration | null | undefined => {\n if (!tiktokPixel) return null\n return {\n pixels: tiktokPixel.pixels.map((pixel) => ({\n id: pixel.id,\n })),\n active: tiktokPixel.active,\n }\n}\nexport const generatePublicStoreIntegrationGoogleAnalytics = (\n googleAnalytics: GoogleAnalyticsIntegration | null | undefined\n): PublicGoogleAnalyticsIntegration | null | undefined => {\n if (!googleAnalytics) return null\n return {\n id: googleAnalytics.id,\n active: googleAnalytics.active,\n }\n}\nexport const generatePublicStoreIntegrationGoogleSheet = (\n googleSheet: GoogleSheetsIntegration | null | undefined\n): PublicGoogleSheetsIntegration | null | undefined => {\n if (!googleSheet) return null\n return null\n}\nexport const generatePublicStoreIntegrationGoogleTags = (\n googleTags: GoogleTagsIntegration | null | undefined\n): PublicGoogleTagsIntegration | null | undefined => {\n if (!googleTags) return null\n const { id, active } = googleTags\n return {\n id,\n active,\n }\n}\nexport interface PublicMetaPixelIntegration {\n pixels: { id: string }[]\n active: boolean\n}\nexport interface PublicTiktokPixelIntegration {\n pixels: { id: string }[]\n active: boolean\n}\nexport interface PublicGoogleAnalyticsIntegration {\n id: string\n active: boolean\n}\nexport interface PublicGoogleSheetsIntegration {\n id: string\n active: boolean\n}\nexport interface PublicGoogleTagsIntegration {\n id: string\n active: boolean\n}\nexport interface PublicStoreIntegrations {\n metaPixel: PublicMetaPixelIntegration | null\n tiktokPixel: PublicTiktokPixelIntegration | null\n googleAnalytics: PublicGoogleAnalyticsIntegration | null\n googleSheet: PublicGoogleSheetsIntegration | null\n googleTags: PublicGoogleTagsIntegration | 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 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\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\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 { 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\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 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}\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}\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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AAI,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","StoreSubscriptionStatus","StoreSubscriptionType","MetaPixelEvent","TiktokPixelEvent","ProductStatus","ProductVariantView","VariantOptionType","ProductType","EmbaddedContactType"]}
|
|
@@ -24,7 +24,7 @@ export interface StoreEntity {
|
|
|
24
24
|
metadata: Record<string, any>;
|
|
25
25
|
contacts: EmbaddedContact[];
|
|
26
26
|
integrations: StoreIntegrations;
|
|
27
|
-
publicIntegrations: PublicStoreIntegrations;
|
|
27
|
+
publicIntegrations: PublicStoreIntegrations | null;
|
|
28
28
|
verifiedAt: any | null;
|
|
29
29
|
blockedAt: any | null;
|
|
30
30
|
createdAt: any;
|