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,YAAYE,GAAqBE,QAC1C,MAAM,IAAIrB,MAAM,oBAAsBmB,EAAsB,mCAEhEJ,EAAQE,YAAYE,GAAqBE,QAAQC,UAAUC,eAAiBJ,EACxEJ,EAAQE,YAAYE,GAAqBE,QAAQC,UAAUhC,KAC3DyB,EAAQE,YAAYF,EAAQE,YAAYE,GAAqBE,QAAQC,UAAUhC,IAAM6B,IAMhGJ,EAAQC,QAAQ,sBAAwB,CACrCQ,EAAGA,IAAMC,EAAQ,KACjBC,MAAO,cACPC,GAAI,CAAC,CAACC,KAAK,oBAAsBC,KAAK,kCAAmCC,WAAY,qBAAqBC,MAAO,GAAG,CAACH,KAAK,2BAA6BC,KAAK,mCAAoCC,WAAY,SAASC,MAAO,IAC5NC,qBAAsB,CAAC,SAAS,OAAO,gBAAgB,sBACvDC,KAAK,EACLC,GAAI,YACJC,EAAG,qBACHC,EAAG,YAEHC,IAAK,uCAELC,cAAe,yCACfC,GAAI,iCAOArB,EAF4B,kCACXO,EAAQ,MAQzBP,EAF4B,mCACXO,EAAQ,MAMjCe,OAAOC,aAAeD,OAAOC,cAAgB,GAC7CD,OAAOC,aAAazB,QAAO0B,EAAAA,EAAA,GACpBF,OAAOC,aAAazB,SAAW,IAC/BD,EAAQC,SAGXwB,OAAOC,aAAaxB,YAAWyB,EAAAA,EAAA,GAC5BF,OAAOC,aAAaxB,aAAe,IACnCF,EAAQE,c,mBChFnB0B,EAAOC,QAAUC,O,oBCAjBF,EAAOC,QAAUE,W","sources":["webpack://united-malt/./src/actions/get-attributes-for-list.ts?0fb8","webpack://united-malt/./src/actions/get-localized-attributes.ts?7444","webpack://united-malt/./lib/country-malt-group/module-registration.js?8ee3","webpack://united-malt/external var \"React\"?0d3b","webpack://united-malt/external var \"ReactDOM\"?853b"],"sourcesContent":["//==============================================================================\r\n//==============================================================================\r\nimport * as Msdyn365 from '@msdyn365-commerce/core';\r\nimport { AttributeValue, ProductSearchCriteria } from '@msdyn365-commerce/retail-proxy';\r\nimport { searchByCriteriaAsync } from '@msdyn365-commerce/retail-proxy/dist/DataActions/ProductsDataActions.g';\r\n\r\n//==============================================================================\r\n// INTERFACES\r\n//==============================================================================\r\nexport interface IGetAttributesForListData {\r\n [productID: number]: AttributeValue[]\r\n}\r\n\r\ntype ProductCollection = Msdyn365.IProductList & {relationshipId: number};\r\n\r\ntype ProductCollectionConfig = {\r\n productCollection: ProductCollection\r\n};\r\n\r\n//==============================================================================\r\n// FUNCTIONS\r\n//==============================================================================\r\n\r\n//==========================================================\r\n//==========================================================\r\nexport class GetAttributesForListInput implements Msdyn365.IActionInput {\r\n public readonly productList: ProductCollection | undefined;\r\n\r\n constructor(productCollection: ProductCollection | undefined) {\r\n this.productList = productCollection;\r\n }\r\n\r\n public getCacheKey = () => `${this.productList?.relationshipId}`;\r\n public getCacheObjectType = () => 'AttributesForList';\r\n\r\n // If the cache key was unique, we could use application caching. However, it would need to include the context as well as the relation type\r\n public dataCacheType = (): Msdyn365.CacheType => 'request';\r\n}\r\n\r\n//==========================================================\r\n//==========================================================\r\nexport const createGetAttributesForListInput = (args: Msdyn365.ICreateActionContext): Msdyn365.IActionInput => {\r\n return new GetAttributesForListInput(args.config?.productCollection);\r\n};\r\n\r\n//==========================================================\r\n//==========================================================\r\nexport async function getAttributesForListAction(input: GetAttributesForListInput, ctx: Msdyn365.IActionContext): Promise {\r\n\r\n // Ensure we have a productList and product -- this won't be set yet when this is run on the server\r\n const productIDs = input.productList?.products.map(entry => entry.RecordId);\r\n if (!productIDs || !productIDs.length) {\r\n return [];\r\n }\r\n\r\n // Build a ProductSearchCriteria object\r\n const criteria: ProductSearchCriteria = {\r\n Ids: productIDs,\r\n IncludeProductsFromDescendantCategories: false,\r\n SkipVariantExpansion: true,\r\n IncludeAttributes: true, // The main point of this data action\r\n Context: {\r\n ChannelId: ctx.requestContext.channel?.RecordId,\r\n CatalogId: Msdyn365.getCatalogId(ctx.requestContext)\r\n },\r\n };\r\n\r\n // Fetch search results\r\n const searchResults = await searchByCriteriaAsync({ callerContext: ctx }, criteria);\r\n\r\n // Remap attributes into a friendlier format\r\n const attributes = searchResults.reduce(\r\n (output, entry) => {\r\n output[entry.RecordId] = entry.AttributeValues || [];\r\n return output;\r\n },\r\n {}\r\n );\r\n\r\n return attributes;\r\n}\r\n\r\n//==============================================================================\r\n//==============================================================================\r\nexport default Msdyn365.createObservableDataAction({\r\n action: >getAttributesForListAction,\r\n id: 'get-attributes-for-list', // This can be anything EXCEPT the data action path ('actions/get-attributes-for-list')\r\n input: createGetAttributesForListInput\r\n});\r\n","//==============================================================================\r\n//==============================================================================\r\nimport { CacheType, createObservableDataAction, ICommerceApiSettings, IAction, IActionContext, IActionInput, IAny, ICreateActionContext, IGeneric, getCatalogId } from '@msdyn365-commerce/core';\r\nimport { AttributeValue, ProductSearchCriteria } from '@msdyn365-commerce/retail-proxy';\r\nimport { searchByCriteriaAsync, getAttributeValuesAsync } from '@msdyn365-commerce/retail-proxy/dist/DataActions/ProductsDataActions.g';\r\nimport { getSelectedProductIdFromActionInput, buildCacheKey } from '@msdyn365-commerce-modules/retail-actions';\r\n\r\n//==========================================================\r\n//==========================================================\r\nexport class GetLocalizedAttributesInput implements IActionInput {\r\n\r\n public productId: number;\r\n\r\n public channelId: number;\r\n\r\n private apiSettings: ICommerceApiSettings;\r\n\r\n private locale: string;\r\n\r\n constructor(productId: number, channelId: number, apiSettings: ICommerceApiSettings, locale: string) {\r\n this.productId = productId;\r\n this.channelId = channelId;\r\n this.apiSettings = apiSettings;\r\n this.locale = locale;\r\n }\r\n\r\n public getCacheKey = () => buildCacheKey(`LocalAttributes-${this.productId}`, this.apiSettings, this.locale);\r\n\r\n public getCacheObjectType = () => 'LocalAttributes';\r\n\r\n public dataCacheType = (): CacheType => 'application';\r\n\r\n}\r\n\r\n//==========================================================\r\n//==========================================================\r\nexport const createGetLocalizedAttributesInput = (inputData: ICreateActionContext>): IActionInput => {\r\n\r\n const productId = getSelectedProductIdFromActionInput(inputData);\r\n if (productId) {\r\n return new GetLocalizedAttributesInput(+productId, +inputData.requestContext.apiSettings.channelId, inputData.requestContext.apiSettings, inputData.requestContext.locale);\r\n }\r\n throw new Error('No productId found on query, unable to get product attributes');\r\n\r\n};\r\n\r\n//==========================================================\r\n//==========================================================\r\nexport async function getLocalizedAttributesAction(input: GetLocalizedAttributesInput, ctx: IActionContext): Promise {\r\n\r\n const catalogId = getCatalogId(ctx.requestContext);\r\n\r\n // Build a ProductSearchCriteria object\r\n const criteria: ProductSearchCriteria = {\r\n Ids: [input.productId],\r\n IncludeProductsFromDescendantCategories: false,\r\n SkipVariantExpansion: true,\r\n IncludeAttributes: true,\r\n Context: {\r\n ChannelId: input.channelId,\r\n CatalogId: catalogId\r\n }\r\n };\r\n\r\n // Fetch search results containing attribute internal names\r\n const productSearchResult = await searchByCriteriaAsync({ callerContext: ctx }, criteria);\r\n const product = productSearchResult[0];\r\n\r\n // Reformat product search attributes for easier lookup\r\n const internalNameAttributeMap = {};\r\n product?.AttributeValues?.forEach(attr => {\r\n if (attr.RecordId) {\r\n internalNameAttributeMap[attr.RecordId] = attr.Name;\r\n }\r\n });\r\n\r\n const attributesWithFriendlyName = await getAttributeValuesAsync({ callerContext: ctx, queryResultSettings: {} }, product.RecordId, input.channelId, catalogId);\r\n\r\n // Combines product search attributes internal name with result\r\n attributesWithFriendlyName.forEach(attr => {\r\n if (attr.RecordId) {\r\n attr.KeyName = internalNameAttributeMap[attr.RecordId];\r\n }\r\n });\r\n\r\n return attributesWithFriendlyName;\r\n\r\n}\r\n\r\n//==============================================================================\r\n//==============================================================================\r\nexport default createObservableDataAction({\r\n action: >getLocalizedAttributesAction,\r\n id: 'get-localized-attributes',\r\n input: createGetLocalizedAttributesInput\r\n});\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 (binding.modules['country-malt-group'] = {\n c: () => require('base/index.js'),\n $type: 'themeModule',\n da: [{name:'productAttributes', path:'actions/get-attributes-for-list', moduleName: 'product-collection',runOn: 0},{name:'productSpecificationData', path:'actions/get-localized-attributes', moduleName: 'buybox',runOn: 0}],\n definitionExtensions: ['buybox','cart','invoices-list','product-collection'],\n iNM: true,\n ns: '__local__',\n n: 'country-malt-group',\n p: '__local__',\n \n pdp: 'src/themes/base/base.definition.json',\n \n themeSettings: 'country-malt-group.theme.settings.json',\n md: 'src/themes/country-malt-group'\n });\n \n\n {\n const sanitizedActionPath = 'actions/get-attributes-for-list';\n let dataAction = require('partner/actions/get-attributes-for-list');\n registerSanitizedActionPath(sanitizedActionPath, dataAction);\n }\n \n\n {\n const sanitizedActionPath = 'actions/get-localized-attributes';\n let dataAction = require('partner/actions/get-localized-attributes');\n registerSanitizedActionPath(sanitizedActionPath, dataAction);\n }\n \n\n \n window.__bindings__ = window.__bindings__ || {};\n window.__bindings__.modules = {\n ...window.__bindings__.modules || {},\n ...binding.modules\n };\n \n window.__bindings__.dataActions = {\n ...window.__bindings__.dataActions || {},\n ...binding.dataActions\n };","module.exports = React;","module.exports = ReactDOM;"],"names":["GetAttributesForListInput","constructor","productCollection","getCacheKey","_this$productList","this","productList","relationshipId","getCacheObjectType","dataCacheType","createGetAttributesForListInput","args","_args$config","config","async","getAttributesForListAction","input","ctx","_input$productList","_ctx$requestContext$c","productIDs","products","map","entry","RecordId","length","criteria","Ids","IncludeProductsFromDescendantCategories","SkipVariantExpansion","IncludeAttributes","Context","ChannelId","requestContext","channel","CatalogId","Msdyn365","searchByCriteriaAsync","callerContext","reduce","output","AttributeValues","action","id","GetLocalizedAttributesInput","productId","channelId","apiSettings","locale","buildCacheKey","createGetLocalizedAttributesInput","inputData","getSelectedProductIdFromActionInput","Error","getLocalizedAttributesAction","_product$AttributeVal","catalogId","getCatalogId","product","internalNameAttributeMap","forEach","attr","Name","attributesWithFriendlyName","getAttributeValuesAsync","queryResultSettings","KeyName","createObservableDataAction","binding","modules","dataActions","registerSanitizedActionPath","sanitizedActionPath","dataAction","default","prototype","RegistrationId","c","require","$type","da","name","path","moduleName","runOn","definitionExtensions","iNM","ns","n","p","pdp","themeSettings","md","window","__bindings__","_objectSpread","module","exports","React","ReactDOM"],"sourceRoot":""}