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7BC,MAAOR,IAGX,K,+lBCtOA,MAAM4D,EAAU,CAAEC,QAAS,GAAIC,YAAa,IAwCpC,CACI,MAAMC,EAAa,sEACnBH,EAAQE,YAAYC,GAAcC,EAAQ,KAxCxBD,CAAAA,IAClBH,EAAQE,YAAYC,IACpBH,EAAQE,YAAYC,GAAYE,SAChCL,EAAQE,YAAYC,GAAYE,QAAQC,WACxCN,EAAQE,YAAYC,GAAYE,QAAQC,UAAUR,GAClDE,EAAQE,YAAYF,EAAQE,YAAYC,GAAYE,QAAQC,UAAUR,IAAME,EAAQE,YAAYC,GAEhGI,OAAOC,KAAKR,EAAQE,YAAYC,IAAe,IAAIM,SAAQC,IACnDV,EAAQE,YAAYC,GAAYO,IAChCV,EAAQE,YAAYC,GAAYO,GAAYJ,WAC5CN,EAAQE,YAAYC,GAAYO,GAAYJ,UAAUK,SACtDX,EAAQE,YAAYF,EAAQE,YAAYC,GAAYO,GAAYJ,UAAUR,IAAME,EAAQE,YAAYC,GAAYO,QA8BxHE,CAAiBT,GAIzBU,OAAOC,aAAeD,OAAOC,cAAgB,GAC7CD,OAAOC,aAAab,QAAOc,EAAAA,EAAA,GACpBF,OAAOC,aAAab,SAAW,IAC/BD,EAAQC,SAGXY,OAAOC,aAAaE,mBAAqB,GACzCH,OAAOC,aAAaE,mBAA8B,UAACD,EAAA,GAC5Cf,EAAQE,c,mBCvDvBe,EAAOC,QAAUC,O,oBCAjBF,EAAOC,QAAUE,W","sources":["webpack://jansen-adventureworks/./src/actions/get-product-availabilities-for-selected-variant-copy.action.ts?e41c","webpack://jansen-adventureworks/./lib/__local__/module-registration.js?8a42","webpack://jansen-adventureworks/external var \"React\"?0d3b","webpack://jansen-adventureworks/external var \"ReactDOM\"?853b"],"sourcesContent":["/*!\r\n * Copyright (c) Microsoft Corporation.\r\n * All rights reserved. See LICENSE in the project root for license information.\r\n */\r\n\r\nimport {\r\n ArrayExtensions,\r\n createInventoryAvailabilitySearchCriteria,\r\n DeliveryMode,\r\n getSelectedProductIdFromActionInput,\r\n getSelectedVariant,\r\n IProductInventoryInformation,\r\n mapAggregatedProductInventoryInformation,\r\n SelectedVariantInput\r\n} from '@msdyn365-commerce-modules/retail-actions';\r\nimport {\r\n CacheType,\r\n createObservableDataAction,\r\n IAction,\r\n IActionContext,\r\n IActionInput,\r\n IAny,\r\n ICreateActionContext,\r\n IGeneric\r\n} from '@msdyn365-commerce/core';\r\nimport {\r\n ProductAvailableQuantity,\r\n ProductsDataActions,\r\n ProductType,\r\n ProductWarehouseInventoryAvailability,\r\n ReleasedProductType,\r\n SimpleProduct\r\n} from '@msdyn365-commerce/retail-proxy';\r\n\r\nexport enum Availability {\r\n outOfStock = 'Out of stock',\r\n available = 'Available',\r\n outOfStockClass = 'out-of-stock',\r\n availableClass = 'available',\r\n loading = 'loading',\r\n loadingClass = 'loading'\r\n}\r\n\r\n/**\r\n * Input class for the getProductAvailabilitiesForSelectedVariant Data Action.\r\n */\r\nexport class ProductAvailabilitiesForSelectedVariantInput implements IActionInput {\r\n public productId: number;\r\n\r\n public channelId: number;\r\n\r\n public selectedProduct: SimpleProduct | undefined;\r\n\r\n public constructor(productId: number | string, channelId: number, selectedProduct?: SimpleProduct) {\r\n this.productId = typeof productId === 'string' ? +productId : productId;\r\n this.channelId = channelId;\r\n this.selectedProduct = selectedProduct;\r\n }\r\n\r\n /**\r\n * GetCacheKey.\r\n * @returns - Returns string.\r\n */\r\n public getCacheKey = (): string => 'ProductAvailabilitiesForSelectedVariant';\r\n\r\n /**\r\n * GetCacheObjectType.\r\n * @returns - Cache Object Type string.\r\n */\r\n public getCacheObjectType = (): string => 'ProductAvailabilities';\r\n\r\n /**\r\n * DataCacheType.\r\n * @returns - CacheType string.\r\n */\r\n public dataCacheType = (): CacheType => 'none';\r\n}\r\n\r\n/**\r\n * CreateInput method for the getProductAvailabilitiesForSelectedVariant data action.\r\n * @param inputData - The input data passed to the createInput method.\r\n * @returns - ProductAvailabilitiesForSelectedVariant or error.\r\n */\r\nexport const createProductAvailabilitiesForSelectedVariantInput = (\r\n inputData: ICreateActionContext>\r\n): ProductAvailabilitiesForSelectedVariantInput => {\r\n const productId = getSelectedProductIdFromActionInput(inputData);\r\n\r\n if (productId) {\r\n return new ProductAvailabilitiesForSelectedVariantInput(+productId, +inputData.requestContext.apiSettings.channelId);\r\n }\r\n throw new Error('Unable to create ProductAvailabilitiesForSelectedVariantInput, no productId found on module config or query');\r\n};\r\n\r\n/**\r\n * The action method for the getProductAvailabilitiesForSelectedVariant data action.\r\n * @param input - ProductAvailabilitiesForSelectedVariant.\r\n * @param ctx - Action Context.\r\n * @returns - Product inventory information.\r\n */\r\nexport async function getProductAvailabilitiesForSelectedVariantAction(\r\n input: ProductAvailabilitiesForSelectedVariantInput,\r\n ctx: IActionContext\r\n): Promise {\r\n const productInventoryInformation: IProductInventoryInformation[] = [];\r\n try {\r\n let productResult: SimpleProduct | null = input.selectedProduct ?? null;\r\n\r\n if (!productResult) {\r\n const selectedVariantInput = new SelectedVariantInput(\r\n input.productId,\r\n input.channelId,\r\n undefined,\r\n undefined,\r\n ctx.requestContext\r\n );\r\n\r\n productResult = await getSelectedVariant(selectedVariantInput, ctx);\r\n }\r\n\r\n // Don't get availability if it is service item && enableStockCheck is disbaled.\r\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access -- Reading config.\r\n if (\r\n ctx.requestContext.app.config.enableStockCheck &&\r\n productResult &&\r\n productResult.ItemTypeValue !== ReleasedProductType.Service &&\r\n productResult.ProductTypeValue !== ProductType.Master\r\n ) {\r\n const shippingSearchCriteria = createInventoryAvailabilitySearchCriteria(\r\n ctx,\r\n [productResult.RecordId],\r\n true,\r\n undefined,\r\n undefined,\r\n DeliveryMode.shipping\r\n );\r\n const pickupSearchCriteria = createInventoryAvailabilitySearchCriteria(\r\n ctx,\r\n [input.productId],\r\n false,\r\n true,\r\n undefined,\r\n DeliveryMode.pickup\r\n );\r\n const shippingAvailability = await ProductsDataActions.getEstimatedAvailabilityAsync(\r\n { callerContext: ctx },\r\n shippingSearchCriteria\r\n );\r\n if (shippingAvailability.ProductWarehouseInventoryAvailabilities) {\r\n const shippingInventory = mapAggregatedProductInventoryInformation(ctx, shippingAvailability);\r\n if (ArrayExtensions.hasElements(shippingInventory)) {\r\n shippingInventory[0].deliveryType = DeliveryMode.shipping;\r\n productInventoryInformation.push(shippingInventory[0]);\r\n }\r\n }\r\n const pickupAvailability = await ProductsDataActions.getEstimatedAvailabilityAsync(\r\n { callerContext: ctx },\r\n pickupSearchCriteria\r\n );\r\n if (pickupAvailability.ProductWarehouseInventoryAvailabilities) {\r\n const pickupInventory = mapAggregatedProductInventoryInformation(ctx, pickupAvailability);\r\n if (ArrayExtensions.hasElements(pickupInventory)) {\r\n pickupInventory[0].deliveryType = DeliveryMode.pickup;\r\n productInventoryInformation.push(pickupInventory[0]);\r\n }\r\n }\r\n return productInventoryInformation;\r\n } else if (\r\n productResult &&\r\n productResult.ItemTypeValue !== ReleasedProductType.Service &&\r\n productResult.ProductTypeValue !== ProductType.Master\r\n ) {\r\n const shippingSearchCriteria = createInventoryAvailabilitySearchCriteria(\r\n ctx,\r\n [productResult.RecordId],\r\n true,\r\n undefined,\r\n undefined,\r\n DeliveryMode.shipping\r\n );\r\n const shippingAvailability = await ProductsDataActions.getEstimatedAvailabilityAsync(\r\n { callerContext: ctx },\r\n shippingSearchCriteria\r\n );\r\n if (\r\n shippingAvailability.ProductWarehouseInventoryAvailabilities &&\r\n shippingAvailability.AggregatedProductInventoryAvailabilities\r\n ) {\r\n return shippingAvailability.AggregatedProductInventoryAvailabilities[0];\r\n }\r\n }\r\n return undefined;\r\n } catch (error) {\r\n // eslint-disable-next-line @typescript-eslint/no-unsafe-argument -- cann't assign type to the error variable.\r\n // ctx.telemetry.exception(error);\r\n ctx.telemetry.debug('[getPriceForSelectedVariantAction]Error executing action');\r\n return undefined;\r\n }\r\n}\r\n\r\n/**\r\n * The function that maps a ProductWareHouse object into a ProductAvailabilityQuantity.\r\n * @param productsWarehouseInventory - Product warehouse inventory.\r\n * @returns Product Available quantity.\r\n */\r\nexport function mergeProductWarehouseToProductAvailabities(\r\n productsWarehouseInventory: ProductWarehouseInventoryAvailability[]\r\n): ProductAvailableQuantity[] {\r\n const productAvailable: ProductAvailableQuantity[] = [];\r\n if (ArrayExtensions.hasElements(productsWarehouseInventory)) {\r\n for (const product of productsWarehouseInventory) {\r\n if (product.TotalAvailable !== undefined && product.ProductId !== undefined) {\r\n productAvailable.push({ ProductId: product.ProductId, AvailableQuantity: product.TotalAvailable });\r\n }\r\n }\r\n }\r\n return productAvailable;\r\n}\r\n\r\n/**\r\n * The complete getProductAvailabilitiesForSelectedVariant data action\r\n * Get the currently selected variant via the getSelectedVariant data action, and\r\n * then gets the availabilities for the variant via the getProductAvailabilities RetailServer API.\r\n */\r\nexport const getProductAvailabilitiesForSelectedVariantActionDataAction = createObservableDataAction({\r\n id: '@msdyn365-commerce-modules/retail-actions/get-product-availabilities-for-selected-variant',\r\n action: >getProductAvailabilitiesForSelectedVariantAction,\r\n input: createProductAvailabilitiesForSelectedVariantInput\r\n});\r\n\r\nexport default getProductAvailabilitiesForSelectedVariantActionDataAction;\r\n","const binding = { modules: {}, dataActions: {} };\n\n const registerActionId = (actionPath) => {\n if (binding.dataActions[actionPath] &&\n binding.dataActions[actionPath].default &&\n binding.dataActions[actionPath].default.prototype &&\n binding.dataActions[actionPath].default.prototype.id) {\n binding.dataActions[binding.dataActions[actionPath].default.prototype.id] = binding.dataActions[actionPath];\n } else {\n Object.keys(binding.dataActions[actionPath] || {}).forEach(exportName => {\n if (binding.dataActions[actionPath][exportName] &&\n binding.dataActions[actionPath][exportName].prototype &&\n binding.dataActions[actionPath][exportName].prototype.Action) {\n binding.dataActions[binding.dataActions[actionPath][exportName].prototype.id] = binding.dataActions[actionPath][exportName];\n }\n })\n }\n };\n\n const registerSanitizedActionPath = (sanitizedActionPath, dataAction) => {\n if (process.env.NODE_ENV === 'development') {\n if (!dataAction.default) {\n throw new Error('Data action path does not have a default export');\n }\n if (!(dataAction.default.prototype.id && binding.dataActions[dataAction.default.prototype.id]) || !binding.dataActions[sanitizedActionPath]) {\n binding.dataActions[sanitizedActionPath] = dataAction;\n }\n } else {\n binding.dataActions[sanitizedActionPath] = dataAction;\n if (!binding.dataActions[sanitizedActionPath].default) {\n throw new Error('Data action path ' + sanitizedActionPath + ' does not have a default export');\n }\n binding.dataActions[sanitizedActionPath].default.prototype.RegistrationId = sanitizedActionPath;\n if (binding.dataActions[sanitizedActionPath].default.prototype.id) {\n binding.dataActions[binding.dataActions[sanitizedActionPath].default.prototype.id] = sanitizedActionPath;\n }\n }\n };\n \n\n { \n const actionPath = 'actions/get-product-availabilities-for-selected-variant-copy.action';\n binding.dataActions[actionPath] = require('partner/actions/get-product-availabilities-for-selected-variant-copy.action');\n registerActionId(actionPath);\n }\n\n \n window.__bindings__ = window.__bindings__ || {};\n window.__bindings__.modules = {\n ...window.__bindings__.modules || {},\n ...binding.modules\n };\n \n window.__bindings__.packageDataActions = {};\n window.__bindings__.packageDataActions['__local__'] = {\n ...binding.dataActions\n };","module.exports = React;","module.exports = ReactDOM;"],"names":["Availability","ProductAvailabilitiesForSelectedVariantInput","constructor","productId","channelId","selectedProduct","getCacheKey","getCacheObjectType","dataCacheType","this","createProductAvailabilitiesForSelectedVariantInput","inputData","getSelectedProductIdFromActionInput","requestContext","apiSettings","Error","async","getProductAvailabilitiesForSelectedVariantAction","input","ctx","productInventoryInformation","_input$selectedProduc","productResult","selectedVariantInput","SelectedVariantInput","undefined","getSelectedVariant","app","config","enableStockCheck","ItemTypeValue","ReleasedProductType","Service","ProductTypeValue","ProductType","Master","shippingSearchCriteria","createInventoryAvailabilitySearchCriteria","RecordId","DeliveryMode","shipping","pickupSearchCriteria","pickup","shippingAvailability","ProductsDataActions","callerContext","ProductWarehouseInventoryAvailabilities","shippingInventory","mapAggregatedProductInventoryInformation","ArrayExtensions","hasElements","deliveryType","push","pickupAvailability","pickupInventory","AggregatedProductInventoryAvailabilities","error","telemetry","debug","mergeProductWarehouseToProductAvailabities","productsWarehouseInventory","productAvailable","product","TotalAvailable","ProductId","AvailableQuantity","getProductAvailabilitiesForSelectedVariantActionDataAction","createObservableDataAction","id","action","binding","modules","dataActions","actionPath","require","default","prototype","Object","keys","forEach","exportName","Action","registerActionId","window","__bindings__","_objectSpread","packageDataActions","module","exports","React","ReactDOM"],"sourceRoot":""}