ChemPal Documentation - v1.6.0
    Preparing search index...

    Module utils/typeGuards/ambeed

    Functions - Typeguards

    isAmbeedProductListResponse

    Type guard to validate if a response matches the Ambeed product list API response structure. Checks for the presence and correct types of source, code, lang, value, and time fields.

    assertIsAmbeedProductListResponse

    Type assertion to ensure the given data is a valid AmbeedProductListResponse. Throws an error if the data does not match the expected structure.

    isAmbeedProductListResponseValue

    Type guard to validate if data matches the Ambeed product list response value structure. Checks for pagination fields (total, pagenum, pageindex, pagesize) and result/menu data.

    isAmbeedProductListResponseResultItem

    Type guard to validate if data matches the Ambeed product result item structure. Checks for required product fields including product ID, price list, name, molecular formula, URL, English name, and CAS number.

    isAmbeedProductListResponsePriceList

    Type guard to validate if data matches the Ambeed price list item structure. Checks for required pricing fields including amount, USD price, discount, size, VIP price, and rate.

    isAmbeedSearchResponseProduct

    Type guard to validate if data matches the Ambeed search response product structure. Uses the same schema as the product list response for validation.

    isAmbeedProductPriceResponse

    Type guard to validate if data matches the Ambeed product price API response structure. Checks the AmbeedResponseBase fields plus a value.proInfo object, which carries the shared product info every priced variant in the response is keyed against.

    assertIsAmbeedProductPriceResponse

    Type assertion to ensure the given data is a valid AmbeedProductPriceResponse. Throws an error if the data does not match the expected structure.

    isAmbeedGetSearchProductAndRecommendedProductsByCASResponse

    Type guard to validate if data matches the Ambeed "get search product and recommended products by CAS" API response structure. Checks the AmbeedResponseBase fields plus a value object containing the CAS-matched search_pro_dict and the r_pro_list array of recommendations.

    assertIsAmbeedGetSearchProductAndRecommendedProductsByCASResponse

    Type assertion to ensure the given data is a valid AmbeedGetSearchProductAndRecommendedProductsByCASResponse. Throws an error if the data does not match the expected structure.

    isAmbeedProductStockResponse

    Type guard to validate the webapi/v1/product_stock response shape — the value array of per-size stock rows (each with a size, plus per-warehouse quantities and an optional aggregate has_stock flag). An empty value array is valid (no stock data available).

    assertIsAmbeedProductStockResponse

    Type assertion that the given data is a valid AmbeedProductStockResponse. Throws if the data does not match the expected structure.

    isAmbeedGetPmsSdsByAmsResponse

    Type guard to validate the webapi/v1/getPmsSdsByAms response shape — the value.sds_list map of per-product (AM id) SDS documents keyed by SDS type.

    assertIsAmbeedGetPmsSdsByAmsResponse

    Type assertion that the given data is a valid AmbeedGetPmsSdsByAmsResponse. Throws if the data does not match the expected structure.