{"version":3,"sources":["../src/collections.ts"],"sourcesContent":["import { filter, isNonNullish } from \"remeda\";\nimport type { StoreInfo } from \"./store\";\nimport type {\n  Collection,\n  CurrencyCode,\n  Product,\n  ShopifyCollection,\n} from \"./types\";\nimport { formatPrice } from \"./utils/func\";\nimport { rateLimitedFetch } from \"./utils/rate-limit\";\n\n/**\n * Interface for collection operations\n */\nexport interface CollectionOperations {\n  /**\n   * Fetches all collections from the store across all pages.\n   */\n  all(): Promise<Collection[]>;\n\n  /**\n   * Fetches collections with pagination support.\n   *\n   * @param options - Pagination options\n   * @param options.page - Page number (default: 1)\n   * @param options.limit - Number of collections per page (default: 10, max: 250)\n   *\n   * @returns {Promise<Collection[] | null>} Array of collections for the page or null if error occurs\n   */\n  paginated(options?: {\n    page?: number;\n    limit?: number;\n  }): Promise<Collection[] | null>;\n\n  /**\n   * Finds a specific collection by its handle.\n   */\n  find(collectionHandle: string): Promise<Collection | null>;\n\n  /**\n   * Fetches collections that are showcased/featured on the store's homepage.\n   */\n  showcased(): Promise<Collection[]>;\n\n  /**\n   * Product-related methods for fetching products from specific collections.\n   */\n  products: {\n    /**\n     * Fetches products from a specific collection with pagination support.\n     */\n    paginated(\n      collectionHandle: string,\n      options?: { page?: number; limit?: number; currency?: CurrencyCode }\n    ): Promise<Product[] | null>;\n\n    /**\n     * Fetches all products from a specific collection.\n     */\n    all(\n      collectionHandle: string,\n      options?: { currency?: CurrencyCode }\n    ): Promise<Product[] | null>;\n    /**\n     * Fetches all product slugs from a specific collection.\n     */\n    slugs(collectionHandle: string): Promise<string[] | null>;\n  };\n}\n\n/**\n * Creates collection operations for a store instance\n */\nexport function createCollectionOperations(\n  baseUrl: string,\n  storeDomain: string,\n  fetchCollections: (\n    page: number,\n    limit: number\n  ) => Promise<Collection[] | null>,\n  collectionsDto: (collections: ShopifyCollection[]) => Collection[],\n  fetchPaginatedProductsFromCollection: (\n    collectionHandle: string,\n    options?: { page?: number; limit?: number }\n  ) => Promise<Product[] | null>,\n  getStoreInfo: () => Promise<StoreInfo>,\n  findCollection: (handle: string) => Promise<Collection | null>\n): CollectionOperations {\n  // Use shared formatter from utils\n\n  function applyCurrencyOverride(\n    product: Product,\n    currency: CurrencyCode\n  ): Product {\n    const priceMin = product.priceMin ?? product.price ?? 0;\n    const priceMax = product.priceMax ?? product.price ?? 0;\n    const compareAtMin =\n      product.compareAtPriceMin ?? product.compareAtPrice ?? 0;\n    return {\n      ...product,\n      currency,\n      localizedPricing: {\n        currency,\n        priceFormatted: formatPrice(priceMin, currency),\n        priceMinFormatted: formatPrice(priceMin, currency),\n        priceMaxFormatted: formatPrice(priceMax, currency),\n        compareAtPriceFormatted: formatPrice(compareAtMin, currency),\n      },\n    };\n  }\n\n  function maybeOverrideProductsCurrency(\n    products: Product[] | null,\n    currency?: CurrencyCode\n  ): Product[] | null {\n    if (!products || !currency) return products;\n    return products.map((p) => applyCurrencyOverride(p, currency));\n  }\n\n  return {\n    /**\n     * Fetches collections with pagination support.\n     *\n     * @param options - Pagination options\n     * @param options.page - Page number (default: 1)\n     * @param options.limit - Number of collections per page (default: 10, max: 250)\n     *\n     * @returns {Promise<Collection[] | null>} Collections for the requested page, or null on error\n     */\n    paginated: async (options?: {\n      page?: number;\n      limit?: number;\n    }): Promise<Collection[] | null> => {\n      const page = options?.page ?? 1;\n      const limit = options?.limit ?? 10;\n\n      if (page < 1 || limit < 1 || limit > 250) {\n        throw new Error(\n          \"Invalid pagination parameters: page must be >= 1, limit must be between 1 and 250\"\n        );\n      }\n\n      try {\n        const collections = await fetchCollections(page, limit);\n        return collections ?? null;\n      } catch (error) {\n        console.error(\n          \"Failed to fetch paginated collections:\",\n          storeDomain,\n          error\n        );\n        return null;\n      }\n    },\n    /**\n     * Fetches all collections from the store across all pages.\n     *\n     * @returns {Promise<Collection[]>} Array of all collections\n     *\n     * @throws {Error} When there's a network error or API failure\n     *\n     * @example\n     * ```typescript\n     * const shop = new ShopClient('https://exampleshop.com');\n     * const allCollections = await shop.collections.all();\n     *\n     * console.log(`Found ${allCollections.length} collections`);\n     * allCollections.forEach(collection => {\n     *   console.log(collection.title, collection.handle);\n     * });\n     * ```\n     */\n    all: async (): Promise<Collection[]> => {\n      const limit = 250;\n      const allCollections: Collection[] = [];\n\n      async function fetchAll() {\n        let currentPage = 1;\n\n        while (true) {\n          const collections = await fetchCollections(currentPage, limit);\n\n          if (\n            !collections ||\n            collections.length === 0 ||\n            collections.length < limit\n          ) {\n            if (!collections) {\n              console.warn(\n                \"fetchCollections returned null, treating as empty array.\"\n              );\n              break;\n            }\n            if (collections && collections.length > 0) {\n              allCollections.push(...collections);\n            }\n            break;\n          }\n\n          allCollections.push(...collections);\n          currentPage++;\n        }\n        return allCollections;\n      }\n\n      try {\n        const collections = await fetchAll();\n        return collections || [];\n      } catch (error) {\n        console.error(\"Failed to fetch all collections:\", storeDomain, error);\n        throw error;\n      }\n    },\n\n    /**\n     * Finds a specific collection by its handle.\n     *\n     * @param collectionHandle - The collection handle (URL slug) to search for\n     *\n     * @returns {Promise<Collection | null>} The collection if found, null if not found\n     *\n     * @throws {Error} When the handle is invalid or there's a network error\n     *\n     * @example\n     * ```typescript\n     * const shop = new ShopClient('https://example.myshopify.com');\n     * const collection = await shop.collections.find('summer-collection');\n     * if (collection) {\n     *   console.log(collection.title); // \"Summer Collection\"\n     * }\n     * ```\n     */\n    find: async (collectionHandle: string): Promise<Collection | null> => {\n      // Validate collection handle\n      if (!collectionHandle || typeof collectionHandle !== \"string\") {\n        throw new Error(\"Collection handle is required and must be a string\");\n      }\n\n      // Sanitize handle - remove potentially dangerous characters\n      const sanitizedHandle = collectionHandle\n        .trim()\n        .replace(/[^a-zA-Z0-9\\-_]/g, \"\");\n      if (!sanitizedHandle) {\n        throw new Error(\"Invalid collection handle format\");\n      }\n\n      // Check handle length (reasonable limits)\n      if (sanitizedHandle.length > 255) {\n        throw new Error(\"Collection handle is too long\");\n      }\n\n      try {\n        const url = `${baseUrl}collections/${encodeURIComponent(sanitizedHandle)}.json`;\n        const response = await rateLimitedFetch(url);\n\n        if (!response.ok) {\n          if (response.status === 404) {\n            return null;\n          }\n          throw new Error(`HTTP error! status: ${response.status}`);\n        }\n\n        const result = (await response.json()) as {\n          collection: ShopifyCollection;\n        };\n\n        let collectionImage = result.collection.image;\n        if (!collectionImage) {\n          const collectionProduct = (\n            await fetchPaginatedProductsFromCollection(\n              result.collection.handle,\n              {\n                limit: 1,\n                page: 1,\n              }\n            )\n          )?.at(0);\n          const collectionProductImage = collectionProduct?.images?.[0];\n          if (collectionProduct && collectionProductImage) {\n            collectionImage = {\n              id: collectionProductImage.id,\n              src: collectionProductImage.src,\n              alt: collectionProductImage.alt || collectionProduct.title,\n              created_at:\n                collectionProductImage.createdAt || new Date().toISOString(),\n            };\n          }\n        }\n\n        const collectionData = collectionsDto([\n          {\n            ...result.collection,\n            image: collectionImage,\n          },\n        ]);\n        return collectionData[0] || null;\n      } catch (error) {\n        if (error instanceof Error) {\n          console.error(\n            `Error fetching collection ${sanitizedHandle}:`,\n            baseUrl,\n            error.message\n          );\n        }\n        throw error;\n      }\n    },\n\n    /**\n     * Fetches collections that are showcased/featured on the store's homepage.\n     *\n     * @returns {Promise<Collection[]>} Array of showcased collections found on the homepage\n     *\n     * @throws {Error} When there's a network error or API failure\n     *\n     * @example\n     * ```typescript\n     * const shop = new ShopClient('https://exampleshop.com');\n     * const showcasedCollections = await shop.collections.showcased();\n     *\n     * console.log(`Found ${showcasedCollections.length} showcased collections`);\n     * showcasedCollections.forEach(collection => {\n     *   console.log(`Featured: ${collection.title} - ${collection.productsCount} products`);\n     * });\n     * ```\n     */\n    showcased: async () => {\n      const storeInfo = await getStoreInfo();\n      const collections = await Promise.all(\n        storeInfo.showcase.collections.map((collectionHandle: string) =>\n          findCollection(collectionHandle)\n        )\n      );\n      return filter(collections, isNonNullish);\n    },\n\n    products: {\n      /**\n       * Fetches products from a specific collection with pagination support.\n       *\n       * @param collectionHandle - The collection handle to fetch products from\n       * @param options - Pagination options\n       * @param options.page - Page number (default: 1)\n       * @param options.limit - Number of products per page (default: 250, max: 250)\n       *\n       * @returns {Promise<Product[] | null>} Array of products from the collection or null if error occurs\n       *\n       * @throws {Error} When the collection handle is invalid or there's a network error\n       *\n       * @example\n       * ```typescript\n       * const shop = new ShopClient('https://example.myshopify.com');\n       *\n       * // Get first page of products from a collection\n       * const products = await shop.collections.products.paginated('summer-collection');\n       *\n       * // Get second page with custom limit\n       * const moreProducts = await shop.collections.products.paginated(\n       *   'summer-collection',\n       *   { page: 2, limit: 50 }\n       * );\n       * ```\n       */\n      paginated: async (\n        collectionHandle: string,\n        options?: { page?: number; limit?: number; currency?: CurrencyCode }\n      ) => {\n        // Validate collection handle\n        if (!collectionHandle || typeof collectionHandle !== \"string\") {\n          throw new Error(\"Collection handle is required and must be a string\");\n        }\n        // Sanitize handle - remove potentially dangerous characters\n        const sanitizedHandle = collectionHandle\n          .trim()\n          .replace(/[^a-zA-Z0-9\\-_]/g, \"\");\n\n        if (!sanitizedHandle) {\n          throw new Error(\"Invalid collection handle format\");\n        }\n\n        if (sanitizedHandle.length > 255) {\n          // Check handle length (reasonable limits)\n          throw new Error(\"Collection handle is too long\");\n        }\n\n        // Validate pagination options\n        const page = options?.page ?? 1;\n        const limit = options?.limit ?? 250;\n\n        if (page < 1 || limit < 1 || limit > 250) {\n          throw new Error(\n            \"Invalid pagination parameters: page must be >= 1, limit must be between 1 and 250\"\n          );\n        }\n\n        const products = await fetchPaginatedProductsFromCollection(\n          sanitizedHandle,\n          { page, limit }\n        );\n        return maybeOverrideProductsCurrency(products, options?.currency);\n      },\n\n      /**\n       * Fetches all products from a specific collection.\n       *\n       * @param collectionHandle - The collection handle to fetch products from\n       *\n       * @returns {Promise<Product[] | null>} Array of all products from the collection or null if error occurs\n       *\n       * @throws {Error} When the collection handle is invalid or there's a network error\n       *\n       * @example\n       * ```typescript\n       * const shop = new ShopClient('https://exampleshop.com');\n       * const allProducts = await shop.collections.products.all('summer-collection');\n       *\n       * if (allProducts) {\n       *   console.log(`Found ${allProducts.length} products in the collection`);\n       *   allProducts.forEach(product => {\n       *     console.log(`${product.title} - $${product.price}`);\n       *   });\n       * }\n       * ```\n       */\n      all: async (\n        collectionHandle: string,\n        options?: { currency?: CurrencyCode }\n      ): Promise<Product[] | null> => {\n        // Validate collection handle\n        if (!collectionHandle || typeof collectionHandle !== \"string\") {\n          throw new Error(\"Collection handle is required and must be a string\");\n        }\n\n        // Sanitize handle - remove potentially dangerous characters\n        const sanitizedHandle = collectionHandle\n          .trim()\n          .replace(/[^a-zA-Z0-9\\-_]/g, \"\");\n        if (!sanitizedHandle) {\n          throw new Error(\"Invalid collection handle format\");\n        }\n\n        // Check handle length (reasonable limits)\n        if (sanitizedHandle.length > 255) {\n          throw new Error(\"Collection handle is too long\");\n        }\n\n        try {\n          const limit = 250;\n          const allProducts: Product[] = [];\n\n          let currentPage = 1;\n\n          while (true) {\n            const products = await fetchPaginatedProductsFromCollection(\n              sanitizedHandle,\n              {\n                page: currentPage,\n                limit,\n              }\n            );\n\n            if (!products || products.length === 0 || products.length < limit) {\n              if (products && products.length > 0) {\n                allProducts.push(...products);\n              }\n              break;\n            }\n\n            allProducts.push(...products);\n            currentPage++;\n          }\n\n          return maybeOverrideProductsCurrency(allProducts, options?.currency);\n        } catch (error) {\n          console.error(\n            `Error fetching all products for collection ${sanitizedHandle}:`,\n            baseUrl,\n            error\n          );\n          return null;\n        }\n      },\n\n      /**\n       * Fetches all product slugs from a specific collection.\n       *\n       * @param collectionHandle - The collection handle to fetch product slugs from\n       *\n       * @returns {Promise<string[] | null>} Array of product slugs from the collection or null if error occurs\n       *\n       * @throws {Error} When the collection handle is invalid or there's a network error\n       *\n       * @example\n       * ```typescript\n       * const shop = new ShopClient('https://exampleshop.com');\n       * const productSlugs = await shop.collections.products.slugs('summer-collection');\n       * console.log(productSlugs);\n       * ```\n       */\n      slugs: async (collectionHandle: string): Promise<string[] | null> => {\n        // Validate collection handle\n        if (!collectionHandle || typeof collectionHandle !== \"string\") {\n          throw new Error(\"Collection handle is required and must be a string\");\n        }\n\n        // Sanitize handle - remove potentially dangerous characters\n        const sanitizedHandle = collectionHandle\n          .trim()\n          .replace(/[^a-zA-Z0-9\\-_]/g, \"\");\n        if (!sanitizedHandle) {\n          throw new Error(\"Invalid collection handle format\");\n        }\n\n        // Check handle length (reasonable limits)\n        if (sanitizedHandle.length > 255) {\n          throw new Error(\"Collection handle is too long\");\n        }\n\n        try {\n          const limit = 250;\n          const slugs: string[] = [];\n\n          let currentPage = 1;\n\n          while (true) {\n            const products = await fetchPaginatedProductsFromCollection(\n              sanitizedHandle,\n              {\n                page: currentPage,\n                limit,\n              }\n            );\n\n            if (!products || products.length === 0 || products.length < limit) {\n              if (products && products.length > 0) {\n                slugs.push(...products.map((p) => p.slug));\n              }\n              break;\n            }\n\n            slugs.push(...products.map((p) => p.slug));\n            currentPage++;\n          }\n\n          return slugs;\n        } catch (error) {\n          console.error(\n            `Error fetching product slugs for collection ${sanitizedHandle}:`,\n            baseUrl,\n            error\n          );\n          return null;\n        }\n      },\n    },\n  };\n}\n"],"mappings":";;;;;;;;AAAA,SAAS,QAAQ,oBAAoB;AAyE9B,SAAS,2BACd,SACA,aACA,kBAIA,gBACA,sCAIA,cACA,gBACsB;AAGtB,WAAS,sBACP,SACA,UACS;AA7Fb;AA8FI,UAAM,YAAW,mBAAQ,aAAR,YAAoB,QAAQ,UAA5B,YAAqC;AACtD,UAAM,YAAW,mBAAQ,aAAR,YAAoB,QAAQ,UAA5B,YAAqC;AACtD,UAAM,gBACJ,mBAAQ,sBAAR,YAA6B,QAAQ,mBAArC,YAAuD;AACzD,WAAO;AAAA,MACL,GAAG;AAAA,MACH;AAAA,MACA,kBAAkB;AAAA,QAChB;AAAA,QACA,gBAAgB,YAAY,UAAU,QAAQ;AAAA,QAC9C,mBAAmB,YAAY,UAAU,QAAQ;AAAA,QACjD,mBAAmB,YAAY,UAAU,QAAQ;AAAA,QACjD,yBAAyB,YAAY,cAAc,QAAQ;AAAA,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